Example #1
0
            $invoice['last'] = TRUE;
        }
        $invoice['type'] = $type;
        $document->Draw($invoice);
        if (!isset($invoice['last'])) {
            $document->NewPage();
        }
    }
} else {
    $invoice = $LMS->GetInvoiceContent($_GET['id']);
    if ($invoice['customerid'] != $SESSION->id) {
        die;
    }
    $invoice['last'] = TRUE;
    $invoice['type'] = $type;
    $docnumber = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
    if (!isset($invoice['invoice'])) {
        $layout['pagetitle'] = trans('Invoice No. $a', $docnumber);
    } else {
        $layout['pagetitle'] = trans('Credit Note No. $a', $docnumber);
    }
    $document->Draw($invoice);
}
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.pdf';
}
$document->WriteToBrowser($attachment_name);