Beispiel #1
0
$invoiceData = mysqli_fetch_assoc($intRes);
if (!$invoiceData) {
    die('Could not find invoice data');
}
$strQuery = 'SELECT * FROM {prefix}company WHERE id=?';
$intRes = mysqli_param_query($strQuery, [$invoiceData['company_id']]);
$recipientData = mysqli_fetch_assoc($intRes);
if (!empty($recipientData['company_id'])) {
    $recipientData['vat_id'] = createVATID($recipientData['company_id']);
} else {
    $recipientData['vat_id'] = '';
}
$strQuery = 'SELECT * FROM {prefix}base WHERE id=?';
$intRes = mysqli_param_query($strQuery, [$invoiceData['base_id']]);
$senderData = mysqli_fetch_assoc($intRes);
if (!$senderData) {
    die('Could not find invoice sender data');
}
$senderData['vat_id'] = createVATID($senderData['company_id']);
$strQuery = 'SELECT pr.product_name, pr.product_code, pr.price_decimals, pr.barcode1, pr.barcode1_type, pr.barcode2, pr.barcode2_type, ir.description, ir.pcs, ir.price, IFNULL(ir.discount, 0) as discount, ir.row_date, ir.vat, ir.vat_included, ir.reminder_row, rt.name type ' . 'FROM {prefix}invoice_row ir ' . 'LEFT OUTER JOIN {prefix}row_type rt ON rt.id = ir.type_id ' . 'LEFT OUTER JOIN {prefix}product pr ON ir.product_id = pr.id ' . 'WHERE ir.invoice_id=? AND ir.deleted=0 ORDER BY ir.order_no, row_date, pr.product_name DESC, ir.description DESC';
$intRes = mysqli_param_query($strQuery, [$intInvoiceId]);
$invoiceRowData = [];
while ($row = mysqli_fetch_assoc($intRes)) {
    $invoiceRowData[] = $row;
}
if (sesWriteAccess()) {
    mysqli_param_query('UPDATE {prefix}invoice SET print_date=? where id=?', [date('Ymd'), $intInvoiceId]);
}
$printer = instantiateInvoicePrinter(trim($printTemplateFile));
$printer->init($intInvoiceId, $printParameters, $printOutputFileName, $senderData, $recipientData, $invoiceData, $invoiceRowData);
$printer->printInvoice();
Beispiel #2
0
 }
 // Print buttons
 $printButtons = array();
 $printButtons2 = array();
 $res = mysqli_query_check('SELECT * FROM {prefix}print_template WHERE deleted=0 and type=\'invoice\' and inactive=0 ORDER BY order_no');
 $templateCount = mysqli_num_rows($res);
 $templateFirstCol = max(floor($templateCount / 2 + 1), 3);
 $rowNum = 0;
 while ($row = mysqli_fetch_assoc($res)) {
     $templateId = $row['id'];
     $printStyle = $row['new_window'] ? 'openwindow' : 'redirect';
     if (sesWriteAccess()) {
         $printFunc = "{$invoicePrintChecks}{$invoiceNumberUpdatePrefix}save_record('invoice.php?id=_ID_&template={$templateId}&func={$strFunc}', '{$printStyle}'); {$invoiceNumberUpdateSuffix} return false;";
     } else {
         // Check if this print template is safe for read-only use
         $printer = instantiateInvoicePrinter($row['filename']);
         if (!$printer->getReadOnlySafe()) {
             continue;
         }
         if ($printStyle == 'openwindow') {
             $printFunc = "window.open('invoice.php?id=_ID_&template={$templateId}&func={$strFunc}'); return false;";
         } else {
             $printFunc = "window.location = 'invoice.php?id=_ID_&template={$templateId}&func={$strFunc}'; return false;";
         }
     }
     $arr = array('name' => "print{$templateId}", 'label' => isset($GLOBALS["loc{$row['name']}"]) ? $GLOBALS["loc{$row['name']}"] : $row['name'], 'type' => 'JSBUTTON', 'style' => $printStyle, 'listquery' => $printFunc, 'position' => 3, 'allow_null' => true);
     if (++$rowNum > $templateFirstCol) {
         $arr['position'] = 4;
         $printButtons2[] = $arr;
     } else {
         $printButtons[] = $arr;