We have an ERP in which twice a month, all the orders in the last two weeks have to be billed. So that our clients select all those orders, press on the "generate bills" button, and a series of sequential ajax http requests are done, once per invoice, while a pop-up message informs them of the process.
First, all the invoices are sequentially generated in the DB, just as mentioned previously, and once this process is done, then it's the turn for the generation of the PDF files. This is also made with sequential ajax requests.
This is good, as long as the users keep that window untouched. It they leave that page or close it, the whole process, which might take a few minutes if there are many invoices to generate, is stopped.
It might lead to many invoices without the PDF file generated if the process is stopped in the middle. This is critical because when they send all those invoices to be printed, this action takes a lot more to get done if the PDF content must be generated on the fly and sent to the printer than if the content is read from an existing file.
I could change the process so that after one invoice is generated, the next action is to generate its file, and so on. But I wonder if there's some way to send the process to background, via system(), exec() or so, and get notified in the same web app when the process is done, regardless of the users decision to leave the billing page to do other tasks.