protected function printInfo() { $pdf = $this->pdf; $senderData = $this->senderData; $invoiceData = $this->invoiceData; $recipientData = $this->recipientData; // Invoice info headers $pdf->SetXY(115, 10); $pdf->SetFont('Helvetica', 'B', 12); $pdf->Cell(40, 5, $GLOBALS['locPDFOrderConfirmationHeader'], 0, 1, 'R'); $pdf->SetFont('Helvetica', '', 10); $pdf->SetXY(115, $pdf->GetY() + 5); if ($recipientData['customer_no'] != 0) { $pdf->Cell(40, 4, $GLOBALS['locPDFCustomerNumber'] . ': ', 0, 0, 'R'); $pdf->Cell(60, 4, $recipientData['customer_no'], 0, 1); } if ($recipientData['company_id']) { $pdf->SetX(115); $pdf->Cell(40, 4, $GLOBALS['locPDFClientVATID'] . ': ', 0, 0, 'R'); $pdf->Cell(60, 4, $recipientData['company_id'], 0, 1); } $pdf->SetX(115); $pdf->Cell(40, 4, $GLOBALS['locPDFOrderConfirmationNumber'] . ': ', 0, 0, 'R'); $pdf->Cell(60, 4, $invoiceData['invoice_no'], 0, 1); $pdf->SetX(115); $pdf->Cell(40, 4, $GLOBALS['locPDFOrderConfirmationDate'] . ': ', 0, 0, 'R'); $strInvoiceDate = $this->_formatDate($invoiceData['invoice_date']); $pdf->Cell(60, 4, $strInvoiceDate, 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFTermsOfPayment'] . ': ', 0, 0, 'R'); $paymentDays = round(dbDate2UnixTime($invoiceData['due_date']) / 3600 / 24 - dbDate2UnixTime($invoiceData['invoice_date']) / 3600 / 24); if ($paymentDays < 0) { // This shouldn't happen, but try to be safe... $paymentDays = getPaymentDays($invoiceData['company_id']); } $pdf->Cell(60, 5, sprintf(getTermsOfPayment($invoiceData['company_id']), $paymentDays), 0, 1); if ($invoiceData['reference']) { $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFYourReference'] . ': ', 0, 0, 'R'); $pdf->MultiCell(50, 5, $invoiceData['reference'], 0, 'L'); } if ($invoiceData['delivery_terms']) { $pdf->SetX(115); $pdf->Cell(40, 4, $GLOBALS['locPDFDeliveryTerms'] . ': ', 0, 0, 'R'); $pdf->MultiCell(50, 4, $invoiceData['delivery_terms'], 0, 'L', 0); } if ($invoiceData['delivery_method']) { $pdf->SetX(115); $pdf->Cell(40, 4, $GLOBALS['locPDFDeliveryMethod'] . ': ', 0, 0, 'R'); $pdf->MultiCell(50, 4, $invoiceData['delivery_method'], 0, 'L', 0); } if (isset($invoiceData['info']) && $invoiceData['info']) { $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFAdditionalInformation'] . ': ', 0, 0, 'R'); $pdf->MultiCell(50, 4, $invoiceData['info'], 0, 'L', 0); } }
protected function printInfo() { $pdf = $this->pdf; $senderData = $this->senderData; $invoiceData = $this->invoiceData; $recipientData = $this->recipientData; if ($this->printStyle == 'dispatch') { $locStr = 'DispatchNote'; } elseif ($this->printStyle == 'receipt') { $locStr = 'Receipt'; } else { $locStr = 'Invoice'; } // Invoice info headers $pdf->SetXY(115, 10); $pdf->SetFont('Helvetica', 'B', 12); if ($this->printStyle == 'dispatch') { $pdf->Cell(40, 5, $GLOBALS['locPDFDispatchNoteHeader'], 0, 1, 'R'); } elseif ($this->printStyle == 'receipt') { $pdf->Cell(40, 5, $GLOBALS['locPDFReceiptHeader'], 0, 1, 'R'); } elseif ($invoiceData['state_id'] == 5) { $pdf->Cell(40, 5, $GLOBALS['locPDFFirstReminderHeader'], 0, 1, 'R'); } elseif ($invoiceData['state_id'] == 6) { $pdf->Cell(40, 5, $GLOBALS['locPDFSecondReminderHeader'], 0, 1, 'R'); } else { $pdf->Cell(40, 5, $GLOBALS['locPDFInvoiceHeader'], 0, 1, 'R'); } $pdf->SetFont('Helvetica', '', 10); $pdf->SetXY(115, $pdf->GetY() + 5); if ($recipientData['customer_no'] != 0) { $pdf->Cell(40, 5, $GLOBALS['locPDFCustomerNumber'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $recipientData['customer_no'], 0, 1); } if ($recipientData['company_id']) { $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFClientVATID'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $recipientData['company_id'], 0, 1); } $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS["locPDF{$locStr}Number"] . ': ', 0, 0, 'R'); $pdf->Cell(60, 5, $invoiceData['invoice_no'], 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS["locPDF{$locStr}Date"] . ': ', 0, 0, 'R'); $strInvoiceDate = $this->_formatDate($invoiceData['invoice_date']); $strDueDate = $this->_formatDate($invoiceData['due_date']); $pdf->Cell(60, 5, $strInvoiceDate, 0, 1); if ($this->printStyle == 'invoice') { $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFDueDate'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $strDueDate, 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFTermsOfPayment'] . ": ", 0, 0, 'R'); $paymentDays = round(dbDate2UnixTime($invoiceData['due_date']) / 3600 / 24 - dbDate2UnixTime($invoiceData['invoice_date']) / 3600 / 24); if ($paymentDays < 0) { // This shouldn't happen, but try to be safe... $paymentDays = getPaymentDays($invoiceData['company_id']); } $pdf->Cell(60, 5, sprintf(getTermsOfPayment($invoiceData['company_id']), $paymentDays), 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFPeriodForComplaints'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, getSetting('invoice_period_for_complaints'), 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFPenaltyInterest'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $this->_formatNumber(getSetting('invoice_penalty_interest'), 1, true) . ' %', 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFRecipientBankAccount'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $senderData['bank_iban'], 0, 1); $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFRecipientBankBIC'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $senderData['bank_swiftbic'], 0, 1); $pdf->SetX(115); if ($this->refNumber) { $pdf->Cell(40, 5, $GLOBALS['locPDFInvoiceRefNr'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $this->refNumber, 0, 1); } } if ($invoiceData['reference'] && $this->printStyle != 'dispatch') { $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFYourReference'] . ": ", 0, 0, 'R'); $pdf->Cell(60, 5, $invoiceData['reference'], 0, 1); } if (isset($invoiceData['info']) && $invoiceData['info']) { $pdf->SetX(115); $pdf->Cell(40, 5, $GLOBALS['locPDFAdditionalInformation'] . ': ', 0, 0, 'R'); $pdf->MultiCell(50, 5, $invoiceData['info'], 0, 'L', 0); } if ($this->printStyle == 'invoice') { if ($invoiceData['refunded_invoice_no']) { $pdf->SetX(115); $pdf->Cell(40, 5, sprintf($GLOBALS['locPDFRefundsInvoice'], $invoiceData['refunded_invoice_no']), 0, 1, 'R'); } if ($invoiceData['state_id'] == 5) { $pdf->SetX(108); $pdf->SetFont('Helvetica', 'B', 10); $pdf->MultiCell(98, 5, $GLOBALS['locPDFFirstReminderNote'], 0, 'L', 0); $pdf->SetFont('Helvetica', '', 10); } elseif ($invoiceData['state_id'] == 6) { $pdf->SetX(108); $pdf->SetFont('Helvetica', 'B', 10); $pdf->MultiCell(98, 5, $GLOBALS['locPDFSecondReminderNote'], 0, 'L', 0); $pdf->SetFont('Helvetica', '', 10); } } }
echo htmlPageStart(_PAGE_TITLE_, getSetting('session_keepalive') ? ['js/keepalive.js'] : null); ?> <body> <div class="ui-widget"> <div class="form_container ui-widget-content"> <?php echo $GLOBALS['locRecordNotFound'] . "\n"; ?> </div> </div> </body> </html> <?php return; } $paymentDays = getPaymentDays($invoiceData['company_id']); unset($invoiceData['id']); unset($invoiceData['invoice_no']); if (!$boolRefund) { unset($invoiceData['ref_number']); if (!empty($invoiceData['company_id'])) { $res = mysqli_param_query('SELECT default_ref_number FROM {prefix}company WHERE id=?', [$invoiceData['company_id']]); $invoiceData['ref_number'] = mysqli_fetch_value($res); } } $invoiceData['invoice_date'] = date('Ymd'); $invoiceData['due_date'] = date('Ymd', mktime(0, 0, 0, date('m'), date('d') + $paymentDays, date('Y'))); $invoiceData['payment_date'] = null; $invoiceData['state_id'] = 1; $invoiceData['archived'] = false; $invoiceData['refunded_invoice_id'] = $boolRefund ? $intInvoiceId : null;
protected function transform($xslt, $xsd = '') { $xml = new SimpleXMLElement('<?xml version="1.0"?><invoicedata/>'); $sender = $xml->addChild('sender'); $this->arrayToXML($this->senderData, $sender); $recipient = $xml->addChild('recipient'); $this->arrayToXML($this->recipientData, $recipient); $invoice = $xml->addChild('invoice'); $invoiceData = $this->invoiceData; $invoiceData['totalsum'] = $this->totalSum; $invoiceData['totalvat'] = $this->totalVAT; $invoiceData['totalsumvat'] = $this->totalSumVAT; $invoiceData['formatted_ref_number'] = $this->refNumber; $invoiceData['barcode'] = $this->barcode; $invoiceData['groupedvats'] = $this->groupedVATs; $this->arrayToXML($invoiceData, $invoice); $rows = $invoice->addChild('rows'); $this->arrayToXML($this->invoiceRowData, $rows, 'row'); foreach ($this->invoiceRowData as &$data) { if (isset($GLOBALS["locPDF{$data['type']}"])) { $data['type'] = $GLOBALS["locPDF{$data['type']}"]; } } require 'settings_def.php'; $settingsData = array(); foreach ($arrSettings as $key => $value) { if (substr($key, 0, 8) == 'invoice_' && $value['type'] != 'LABEL') { switch ($key) { case 'invoice_terms_of_payment': $settingsData[$key] = sprintf(getTermsOfPayment($invoiceData['company_id']), getPaymentDays($invoiceData['company_id'])); break; case 'invoice_pdf_filename': $settingsData[$key] = $this->getPrintOutFileName(getSetting('invoice_pdf_filename')); break; default: $settingsData[$key] = getSetting($key); } } } $settingsData['invoice_penalty_interest_desc'] = $GLOBALS['locPDFPenaltyInterestDesc'] . ': ' . miscRound2OptDecim(getSetting('invoice_penalty_interest'), 1) . ' %'; $settingsData['current_time_year'] = date('Y'); $settingsData['current_time_mon'] = date('m'); $settingsData['current_time_day'] = date('d'); $settingsData['current_time_hour'] = date('H'); $settingsData['current_time_min'] = date('i'); $settingsData['current_time_sec'] = date('s'); $settingsData['current_timestamp'] = date('c'); $settingsData['current_timestamp_utc'] = gmdate('Y-m-d\\TH:i:s\\Z'); $settings = $xml->addChild('settings'); $this->arrayToXML($settingsData, $settings); $xsltproc = new XSLTProcessor(); $xsl = new DOMDocument(); $xsl->load($xslt); $xsltproc->importStylesheet($xsl); $xsltproc->setParameter('', 'stylesheet', $this->printStyle); $domDoc = dom_import_simplexml($xml)->ownerDocument; $this->xml = $xsltproc->transformToXML($domDoc); if ($xsd) { libxml_use_internal_errors(true); $xmlDoc = new DOMDocument(); $xmlDoc->loadXML($this->xml); if (!$xmlDoc->schemaValidate($xsd)) { header("Content-Type: text/plain"); echo "Result XML validation failed:\n\n"; $errors = libxml_get_errors(); foreach ($errors as $error) { switch ($error->level) { case LIBXML_ERR_WARNING: $type = 'Warning'; break; case LIBXML_ERR_FATAL: $type = 'Fatal'; break; default: $type = 'Error'; } echo "{$type} {$error->code}({$error->level}) at {$error->line}:{$error->column}: {$error->message}\n"; } echo "\n\nXML:\n\n"; $lineno = 1; foreach (explode("\n", $this->xml) as $line) { echo "{$lineno}\t{$line}\n"; ++$lineno; } exit(1); } } }
} } if (!$invNr) { $maxNr = get_max_invoice_number($invoiceId, getSetting('invoice_numbering_per_base') && $baseId ? $baseId : null, $perYear); if ($maxNr === null && $perYear) { $maxNr = get_max_invoice_number($invoiceId, getSetting('invoice_numbering_per_base') && $baseId ? $baseId : null, false); } $invNr = $maxNr + 1; } if ($invNr < 100) { $invNr = 100; } // min ref number length is 3 + check digit, make sure invoice number matches that $refNr = $invNr . miscCalcCheckNo($invNr); $strDate = date($GLOBALS['locDateFormat']); $strDueDate = date($GLOBALS['locDateFormat'], mktime(0, 0, 0, date('m'), date('d') + getPaymentDays($companyId), date('Y'))); switch ($intervalType) { case 2: $nextIntervalDate = date($GLOBALS['locDateFormat'], mktime(0, 0, 0, date('m') + 1, date('d'), date('Y'))); break; case 3: $nextIntervalDate = date($GLOBALS['locDateFormat'], mktime(0, 0, 0, date('m'), date('d'), date('Y') + 1)); break; default: $nextIntervalDate = ''; } $arrData = ['invoice_no' => $invNr, 'ref_no' => $refNr, 'date' => $strDate, 'due_date' => $strDueDate, 'next_interval_date' => $nextIntervalDate]; header('Content-Type: application/json'); echo json_encode($arrData); break; case 'get_table_columns':
} } if (!$invNr) { $maxNr = get_max_invoice_number($invoiceId, getSetting('invoice_numbering_per_base') && $baseId ? $baseId : null, $perYear); if ($maxNr === null && $perYear) { $maxNr = get_max_invoice_number($invoiceId, getSetting('invoice_numbering_per_base') && $baseId ? $baseId : null, false); } $invNr = $maxNr + 1; } if ($invNr < 100) { $invNr = 100; } // min ref number length is 3 + check digit, make sure invoice number matches that $refNr = $invNr . miscCalcCheckNo($invNr); $strDate = date($GLOBALS['locDateFormat']); $strDueDate = date($GLOBALS['locDateFormat'], mktime(0, 0, 0, date("m"), date("d") + getPaymentDays($companyId), date("Y"))); switch ($intervalType) { case 2: $nextIntervalDate = date($GLOBALS['locDateFormat'], mktime(0, 0, 0, date("m") + 1, date("d"), date("Y"))); break; case 3: $nextIntervalDate = date($GLOBALS['locDateFormat'], mktime(0, 0, 0, date("m"), date("d"), date("Y") + 1)); break; default: $nextIntervalDate = ''; } $arrData = array('invoice_no' => $invNr, 'ref_no' => $refNr, 'date' => $strDate, 'due_date' => $strDueDate, 'next_interval_date' => $nextIntervalDate); header('Content-Type: application/json'); echo json_encode($arrData); break; case 'get_table_columns':