I have a php page to create an excel file and save it to a folder. I start from a page where user click on a button to start the script. My goal is to perform the following steps:
- run the script in another window (I am now using a small popup);
- when the script ends close the popup and in the main window display an alert to say that execution is ok;
- on alert close refresh the file list displayed in the main window.
I know how to do all these stuffs but one: how can i trigger any event (popup close and alert) when in the popup the script ends?
My actual code for the popup is the following:
$('#elabora').click(function(e){
e.preventDefault();
var data = $('#data_rif').val();
if (data=='') {
$("#spnmsg").fadeTo(200,0.1,function(){
$(this).removeClass().addClass('spn_error').html("Inserisci una data di riferimento per l'elaborazione").fadeTo(900,1);
});
}else{
window.open('sofferenze/trxls.php?data='+data, "popupWindow", "width=10,height=10");
//here is where I want to trigger that when trxls.php ends the alert should be displayed.
}
});
The script (beginning and end only)
<?php
header('Cache-Control: max-age=1');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_sqlite3;
PHPExcel_Settings::setCacheStorageMethod($cacheMethod);
// Create a new PHPExcel object
$ea = new PHPExcel();
...
$objWriter = PHPExcel_IOFactory::createWriter($ea, 'Excel2007');
ob_end_clean();
//$objWriter->save('php://output');
$objWriter->save('trackrecord/'.$data.'_trackrecord.xlsx"');
exit();
echo "<script>window.close();</script>";
?>