Created
August 1, 2014 19:50
-
-
Save kylechase/7a549d098b0d21d65542 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
zile = system.file.saveFile("temp.zip") | |
myzip = zipfile.ZipFile(zile,'w') | |
invoiceId = event.source.parent.getComponent('Container').getComponent('tblInvoices').selectedInvoice | |
invoiceFile = system.file.getTempFile("pdf") | |
bytes = event.source.parent.getComponent('Report Viewer Labour').getBytesPDF() | |
system.file.writeFile(invoiceFile,bytes) | |
invoiceName = "000000" + str(invoiceId) | |
invoiceName = invoiceName[-6:] | |
invoiceName = "Invoice " + invoiceName + ".pdf" | |
myzip.write(invoiceFile,invoiceName) | |
receipts = system.db.runPrepQuery("SELECT `receipt_file_name`,`receipt_blob` FROM `expenses` WHERE invoice_id = ?",[invoiceId]) | |
i = 1 | |
for row in receipts: | |
tFile = system.file.getTempFile(".tmp") | |
system.file.writeFile(tFile,row[1]) | |
myzip.write(tFile,row[0]) | |
myzip.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment