The code is added in checkdir.php under function custom_popup($ALLVAR) .
I have added another code to write the file just below pop up script and it get executed without an issue however no pop up window. Also set both notify_on_ringing and notify_on_connect to 1 in /etc/asterisk/fop2/fop2.cfg