$i = 0; foreach (array_keys($_POST['inv']) as $key) { $invoice = $LMS->GetInvoiceContent(intval($key)); $invoice['type'] = $type; $i++; if ($invoice['customerid'] != $SESSION->id) { continue; } if ($i == $count) { $invoice['last'] = TRUE; } invoice_body(); } close_pdf($pdf); die; } $invoice = $LMS->GetInvoiceContent($_GET['id']); if ($invoice['customerid'] != $SESSION->id) { die; } $number = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']); if (!isset($invoice['invoice'])) { $title = trans('Invoice No. $a', $number); } else { $title = trans('Credit Note No. $a', $number); } $pdf =& init_pdf('A4', 'portrait', $title); $invoice['last'] = TRUE; $invoice['type'] = $type; invoice_body(); close_pdf($pdf);
function invoice_create_pdf_file($docid, $output) { global $pdf, $LMS, $invoice; $pdf = init_pdf('A4', 'portrait', trans('Invoices')); $invoice = $LMS->GetInvoiceContent($docid); $which = array(); if (!empty($_GET['original'])) { $which[] = trans('ORIGINAL'); } if (!empty($_GET['copy'])) { $which[] = trans('COPY'); } if (!empty($_GET['duplicate'])) { $which[] = trans('DUPLICATE'); } if (!sizeof($which)) { $tmp = explode(',', $CONFIG['invoices']['default_printpage']); foreach ($tmp as $t) { if (trim($t) == 'original') { $which[] = trans('ORIGINAL'); } elseif (trim($t) == 'copy') { $which[] = trans('COPY'); } elseif (trim($t) == 'duplicate') { $which[] = trans('DUPLICATE'); } } if (!sizeof($which)) { $which[] = ''; } } $count = sizeof($which); $i = 0; foreach ($which as $type) { $i++; if ($i == $count) { $invoice['last'] = TRUE; } if ($invoice['version'] == '2') { invoice_body_v2(); } else { invoice_body(); } } $pdf->output($output, 'F'); }
$which[] = trans('ORIGINAL'); } elseif (trim($t) == 'copy') { $which[] = trans('COPY'); } elseif (trim($t) == 'duplicate') { $which[] = trans('DUPLICATE'); } } if (!sizeof($which)) { $which[] = trans('ORIGINAL'); } } $count = sizeof($which); $i = 0; foreach ($which as $type) { $i++; if ($i == $count) { $invoice['last'] = TRUE; } $invoice['type'] = $type; invoice_body($document, $invoice); } } else { $SESSION->redirect('?m=invoicelist'); } if (!is_null($attachment_name) && isset($docnumber)) { $attachment_name = str_replace('%number', $docnumber, $attachment_name); $attachment_name = preg_replace('/[^[:alnum:]_\\.]/i', '_', $attachment_name); } else { $attachment_name = 'invoices.' . ($invoice_type == 'pdf' ? 'pdf' : 'html'); } $document->WriteToBrowser($attachment_name);