$result['invoice_date'] = makeNicePresentableDate($result['invoice_date'], $lng['panel']['dateformat_function']); $invoice_states_option = ''; foreach ($lng['invoice']['states'] as $stateid => $statename) { if ((int) $result['state'] <= (int) $stateid) { $invoice_states_option .= makeoption($statename, $stateid, $result['state'], true); } } $contact = htmlentities_array($contact); eval('echo "' . getTemplate('billing/invoices_edit') . '";'); } } } if ($action == 'pdf') { $result = $db->query_first('SELECT * FROM `' . getModeDetails($mode, 'TABLE_BILLING_INVOICES', 'table') . '` WHERE `id` = \'' . $id . '\' '); if ($result['id'] == $id && $id != '0') { $invoice = new pdfInvoice(); if ((int) $result['state'] >= CONST_BILLING_INVOICESTATE_CANCELLED_NO_REINVOICE) { $invoice->cancellation = true; } $invoice->processData($result['xml'], $lng); $invoice->outputBrowser(); } } if ($action == 'reminder') { $result = $db->query_first('SELECT * FROM `' . getModeDetails($mode, 'TABLE_BILLING_INVOICES', 'table') . '` WHERE `id` = \'' . $id . '\' '); if ($result['id'] == $id && $id != '0') { $invoice = new pdfReminder(); $invoice->processData($result['xml'], $lng); $invoice->outputBrowser(); } }
$state = intval($_POST['state']); } $myInvoice = new invoice(&$db, $mode, explode('-', $user['customer_categories_once']), explode('-', $user['customer_categories_period'])); if ($myInvoice->collect($id, true) === true) { $invoiceXmlString = $myInvoice->exportXml($lng, $invoice_number); $invoiceXml = new SimpleXMLElement($invoiceXmlString); $db->query('INSERT INTO `' . getModeDetails($mode, 'TABLE_BILLING_INVOICES', 'table') . '` (`' . getModeDetails($mode, 'TABLE_BILLING_INVOICES', 'key') . '`, `xml`, `invoice_date`, `invoice_number`, `state`, `state_change`, `total_fee`, `total_fee_taxed`) VALUES(\'' . $db->escape($id) . '\', \'' . $db->escape($invoiceXmlString) . '\', \'' . $db->escape(date('Y-m-d')) . '\', \'' . $db->escape($invoice_number) . '\', \'' . $db->escape($state) . '\', \'' . time() . '\', \'' . $db->escape((string) $invoiceXml->total_fee[0]) . '\', \'' . $db->escape((string) $invoiceXml->total_fee_taxed[0]) . '\' ) '); if (preg_match('/^' . strtr($lng['invoice']['invoicenumbertemplate'], array('/' => '\\/', '{number}' => '(\\d+)', '{year}' => date('Y'), '{month}' => date('m'), '{day}' => date('d'))) . '$/', $invoice_number, $invoicenumber_count)) { $db->query('UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = \'' . (int) $invoicenumber_count[1] . '\' WHERE `settinggroup` = \'billing\' AND `varname` = \'invoicenumber_count\''); } } cacheInvoiceFees($mode, null, null, $id); redirectTo($filename, array('s' => $s, 'mode' => $mode, 'page' => 'overview')); } else { $invoice_states_option = ''; foreach ($lng['invoice']['states'] as $stateid => $statename) { $invoice_states_option .= makeoption($statename, $stateid, $result['state'], true); } eval("echo \"" . getTemplate("billing/openinvoices_invoice_fix") . "\";"); } } if ($action == 'preview') { $myInvoice = new invoice(&$db, $mode, explode('-', $user['customer_categories_once']), explode('-', $user['customer_categories_period'])); if ($myInvoice->collect($id) === true) { $invoice = new pdfInvoice(); $invoice->processData($myInvoice->exportXml($lng, $lng['invoice']['preview']), $lng); $invoice->outputBrowser(); } } } }