void InvoiceWizard::createInvoices() { PPSPerson pers; Invoice invoice; XmlPdf *pdf; QString fileName; bool reminder = (_invoiceState == INVOICE_STATE_TYPE_OUTSTANDING) || (_invoiceState == INVOICE_STATE_TYPE_REMINDER); int num = _previewModel.rowCount(); int cnt = 0; QProgressDialog bar(this); bar.setRange(0, num); bar.setCancelButtonText(tr("&Cancel")); bar.setWindowTitle(tr("Create Invoices")); bar.setWindowModality(Qt::WindowModal); bar.show(); for (qint32 i = 0; i < num; i++) { if (bar.wasCanceled()) { break; } bar.setValue(cnt++); qint32 uid = _previewModel.index(i, 0).data(Qt::DisplayRole).toInt(); if (pers.load(uid)) { if (bar.wasCanceled()) break; bar.setLabelText(tr("Create Invoice for %1 %2 (%3 of %4)").arg(pers.familyName()).arg(pers.givenName()).arg(cnt).arg(num) ); if (reminder) { invoice.loadLast(uid); invoice.setReminded(invoice.reminded() + 1); invoice.setLastReminded(QDate::currentDate()); invoice.save(); } else { invoice.create(&pers); } // Send invoice by SnailMail and not EMail if "print" is checked, the user likes to become SnailsMails or he has no EMailaddress // The "invoice" template is the one without an invoiceSlip, the "reminder" has attached one normally if (checkPrint->isChecked() || invoice.addressEmail().isEmpty() || (!noSnailMail->isChecked() && pers.isLoaded() && (pers.notify() == PPSPerson::SnailMail))) { if (fileName.isEmpty()) { fileName = getSaveFileName(); } pdf = invoice.createPdf("reminder"); pdf->print( fileName.arg(invoice.memberUid()) ); } else { pdf = invoice.createPdf("invoice"); pdf->send(invoice.addressEmail()); } } } bar.setValue(num); updatePreviewTable(); }
void InvoiceWizard::invoiceMembers() { PPSPerson pers; Invoice invoice; XmlPdf *pdf; QString fileName; QProgressDialog bar(this); int max = memberUidList->count(); bar.setRange(0, max); bar.setCancelButtonText(tr("&Cancel")); bar.setWindowTitle(tr("Create Invoices")); bar.setWindowModality(Qt::WindowModal); bar.show(); for (int i = 0; i < max; i++) { QListWidgetItem *item = memberUidList->item(i); bar.setValue(i); if (pers.load(item->text().toInt())) { if (bar.wasCanceled()) break; bar.setLabelText(tr("Create Invoice for %1 %2 (%3 of %4)").arg(pers.familyName()).arg(pers.givenName()).arg(i).arg(max) ); invoice.create(&pers); // Send invoice by SnailMail and not EMail if "print" is checked, the user likes to become SnailsMails or he has no EMailaddress // The "invoice" template is the one without an invoiceSlip, the "reminder" has attached one normally if (checkPrint->isChecked() || invoice.addressEmail().isEmpty() || (pers.isLoaded() && (pers.notify() == PPSPerson::SnailMail))) { if (fileName.isEmpty()) { fileName = getSaveFileName(); } pdf = invoice.createPdf("reminder"); pdf->print( fileName.arg(invoice.memberUid()) ); } else { pdf = invoice.createPdf("invoice"); pdf->send(invoice.addressEmail()); } } } bar.setValue(max); }