本文整理汇总了PHP中docnumber函数的典型用法代码示例。如果您正苦于以下问题:PHP docnumber函数的具体用法?PHP docnumber怎么用?PHP docnumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了docnumber函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetReceipt
function GetReceipt($id)
{
global $CONFIG, $DB;
if ($receipt = $DB->GetRow('SELECT d.*, u.name AS user, n.template,
ds.name AS d_name, ds.address AS d_address,
ds.zip AS d_zip, ds.city AS d_city
FROM documents d
LEFT JOIN users u ON (d.userid = u.id)
LEFT JOIN numberplans n ON (d.numberplanid = n.id)
LEFT JOIN customers c ON (d.customerid = c.id)
LEFT JOIN divisions ds ON (ds.id = c.divisionid)
WHERE d.type = 2 AND d.id = ?', array($id))) {
$receipt['contents'] = $DB->GetAll('SELECT * FROM receiptcontents WHERE docid = ? ORDER BY itemid', array($id));
$receipt['total'] = 0;
foreach ($receipt['contents'] as $row) {
$receipt['total'] += $row['value'];
}
$receipt['number'] = docnumber($receipt['number'], $receipt['template'], $receipt['cdate'], $receipt['extnumber']);
if ($receipt['total'] < 0) {
$receipt['type'] = 'out';
// change values sign
foreach ($receipt['contents'] as $idx => $row) {
$receipt['contents'][$idx]['value'] *= -1;
}
$receipt['total'] *= -1;
} else {
$receipt['type'] = 'in';
}
$receipt['totalg'] = round($receipt['total'] * 100 - (int) $receipt['total'] * 100);
return $receipt;
}
}
示例2: smarty_function_number
function smarty_function_number($params, $template)
{
$result = docnumber($params['number'], $params['template'], $params['time']);
if (isset($params['assign'])) {
$template->assign($params['assign'], $result);
} else {
return $result;
}
}
示例3: smarty_function_number
function smarty_function_number($params, $template)
{
$result = docnumber(array('number' => $params['number'], 'template' => $params['template'], 'cdate' => $params['time'], 'customerid' => $params['customerid']));
if (isset($params['assign'])) {
$template->assign($params['assign'], $result);
} else {
return $result;
}
}
示例4: docnumber
function docnumber($id)
{
if ($doc = $this->DB->GetRow('SELECT number, cdate, template
FROM documents
LEFT JOIN numberplans ON (numberplanid = numberplans.id)
WHERE documents.id = ?', array($id))) {
return docnumber($doc['number'], $doc['template'], $doc['cdate']);
} else {
return NULL;
}
}
示例5: EXISTS
EXISTS (SELECT 1 FROM customerassignments a
WHERE a.customergroupid = ' . intval($_GET['groupid']) . '
AND a.customerid = d.customerid)' : '') . ' AND NOT EXISTS (
SELECT 1 FROM customerassignments a
JOIN excludedgroups e ON (a.customergroupid = e.customergroupid)
WHERE e.userid = lms_current_user() AND a.customerid = d.customerid)' . ' ORDER BY CEIL(cdate/86400), id', array($_GET['from'], $_GET['to']));
if (!$ids) {
$SESSION->close();
die;
}
$DIVISIONS = $DB->GetAllByKey('SELECT * FROM divisions', 'id');
$count = strstr($which, '+') ? sizeof($ids) * 2 : sizeof($ids);
$i = 0;
foreach ($ids as $idx => $invoiceid) {
$invoice = $LMS->GetInvoiceContent($invoiceid);
$invoice['t_number'] = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
if ($invoice['divisionid'] && isset($DIVISIONS[$invoice['divisionid']])) {
$_NAME = $DIVISIONS[$invoice['divisionid']]['name'];
$_SHORT_NAME = $DIVISIONS[$invoice['divisionid']]['shortname'];
$_ADDRESS = $DIVISIONS[$invoice['divisionid']]['address'];
$_ZIP = $DIVISIONS[$invoice['divisionid']]['zip'];
$_CITY = $DIVISIONS[$invoice['divisionid']]['city'];
} else {
$_NAME = $_SHORT_NAME = $_ADDRESS = $_ZIP = $_CITY = '';
}
main_fill(177, 12, 0.395);
main_fill(177, 313, 0.396);
simple_fill_mip(5, 12, 0.395);
simple_fill_mip(5, 313, 0.395);
address_box(390, 600, 0.395);
$i++;
示例6: additem
function additem(&$content, $item)
{
for ($i = 0, $x = sizeof($content); $i < $x; $i++) {
if ($content[$i]['value'] == $item['value'] && $content[$i]['description'] == $item['description'] && $content[$i]['posuid'] > $item['posuid'] - 1) {
break;
}
}
if ($i == $x) {
$content[] = $item;
}
}
$SESSION->restore('receiptcontents', $contents);
$SESSION->restore('receiptcustomer', $customer);
$SESSION->restore('receipt', $receipt);
$SESSION->restore('receiptediterror', $error);
$receipt['titlenumber'] = docnumber($receipt['number'], $receipt['template'], $receipt['cdate'], isset($receipt['extnumber']) ? $receipt['extnumber'] : '');
if ($receipt['type'] == 'in') {
$layout['pagetitle'] = trans('Cash-in Receipt Edit: $a', $receipt['titlenumber']);
} else {
$layout['pagetitle'] = trans('Cash-out Receipt Edit: $a', $receipt['titlenumber']);
}
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'additem':
$itemdata = r_trim($_POST);
$itemdata['value'] = round((double) str_replace(',', '.', $itemdata['value']), 2);
// workaround for PHP 4.3.10 bug
$itemdata['value'] = str_replace(',', '.', $itemdata['value']);
$itemdata['posuid'] = (string) getmicrotime();
if ($itemdata['value'] && $itemdata['description']) {
additem($contents, $itemdata);
示例7: invoice_body_ft0100
public function invoice_body_ft0100()
{
$this->invoice_date();
$this->invoice_title();
$this->invoice_seller();
$this->invoice_buyer();
$this->invoice_data();
$this->invoice_to_pay();
$this->invoice_balance();
$this->invoice_dates();
$this->invoice_expositor();
$this->invoice_footnote();
if ($this->data['customerbalance'] < 0 || ConfigHelper::checkValue(ConfigHelper::getConfig('invoices.always_show_form', true))) {
/* draw FT-0100 form */
$this->invoice_simple_form_draw();
$this->invoice_main_form_draw();
/* fill FT-0100 form */
$this->invoice_simple_form_fill();
$this->invoice_main_form_fill();
}
$docnumber = docnumber($this->data['number'], $this->data['template'], $this->data['cdate']);
$this->backend->SetTitle(trans('Invoice No. $a', $docnumber));
$this->backend->SetAuthor($this->data['division_name']);
/* setup your cert & key file */
$cert = 'file://' . LIB_DIR . '/tcpdf/config/lms.cert';
$key = 'file://' . LIB_DIR . '/tcpdf/config/lms.key';
/* setup signature additional information */
$info = array('Name' => $this->data['division_name'], 'Location' => trans('Invoices'), 'Reason' => trans('Invoice No. $a', $docnumber), 'ContactInfo' => $this->data['division_author']);
/* set document digital signature & protection */
if (file_exists($cert) && file_exists($key)) {
$this->backend->setSignature($cert, $key, 'lms-invoices', '', 1, $info);
$this->backend->setSignatureAppearance(13, 10, 50, 20);
}
if (!$this->data['disable_protection']) {
$this->backend->SetProtection(array('modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble'), '', 'PASSWORD_CHANGEME', '1');
}
}
示例8: unset
* $Id$
*/
$cid = $document['customerid'];
$customerinfo = $LMS->GetCustomer($cid);
$assignments = $LMS->GetCustomerAssignments($cid);
$customernodes = $LMS->GetCustomerNodes($cid);
$tariffs = $LMS->GetTariffs();
unset($customernodes['total']);
if ($customernodes) {
foreach ($customernodes as $idx => $row) {
$customernodes[$idx]['net'] = $DB->GetRow('SELECT *, inet_ntoa(address) AS ip FROM networks WHERE address = (inet_aton(mask) & ?)', array($row['ipaddr']));
}
}
if ($customeraccounts = $DB->GetAll('SELECT passwd.*, domains.name AS domain
FROM passwd LEFT JOIN domains ON (domainid = domains.id)
WHERE passwd.ownerid = ? ORDER BY login', array($cid))) {
foreach ($customeraccounts as $idx => $account) {
$customeraccounts[$idx]['aliases'] = $DB->GetCol('SELECT login FROM aliases a
LEFT JOIN aliasassignments aa ON a.id = aa.aliasid WHERE aa.accountid=?', array($account['id']));
/*// create random password
$pass = '';
for ($i = 0; $i < 8; $i++)
$pass .= substr('0123456789abcdefghijklmnopqrstuvwxyz', rand(0,36), 1);
$customeraccounts[$idx]['password'] = $pass;
*/
}
}
$document['template'] = $DB->GetOne('SELECT template FROM numberplans WHERE id=?', array($document['numberplanid']));
$document['nr'] = docnumber($document['number'], $document['template']);
$SMARTY->assign(array('customernodes' => $customernodes, 'assignments' => $assignments, 'customerinfo' => $customerinfo, 'tariffs' => $tariffs, 'customeraccounts' => $customeraccounts, 'document' => $document, 'engine' => $engine));
$output = $SMARTY->fetch(DOC_DIR . '/templates/' . $engine['name'] . '/' . $engine['template']);
示例9: elseif
if (!empty($note['paytime_default'])) {
if ($customer['paytime'] != -1) {
$note['paytime'] = $customer['paytime'];
} elseif (($paytime = $DB->GetOne('SELECT inv_paytime FROM divisions
WHERE id = ?', array($customer['divisionid']))) !== NULL) {
$note['paytime'] = $paytime;
} else {
$note['paytime'] = ConfigHelper::getConfig('notes.paytime');
}
}
$cdate = !empty($note['cdate']) ? $note['cdate'] : time();
$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ? ;', array($customer['divisionid']));
if ($note['numberplanid']) {
$fullnumber = docnumber($note['number'], $DB->GetOne('SELECT template FROM numberplans WHERE id = ?', array($note['numberplanid'])), $cdate);
} else {
$fullnumber = null;
}
$args = array('number' => $note['number'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_NUMPLAN] => !empty($note['numberplanid']) ? $note['numberplanid'] : 0, 'type' => DOC_DNOTE, 'cdate' => $cdate, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_USER] => $AUTH->id, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST] => $customer['id'], 'name' => $customer['customername'], 'address' => $customer['address'], 'paytime' => $note['paytime'], 'ten' => $customer['ten'], 'ssn' => $customer['ssn'], 'zip' => $customer['zip'], 'city' => $customer['city'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_COUNTRY] => $customer['countryid'], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_DIV] => $customer['divisionid'], 'div_name' => $division['name'] ? $division['name'] : '', 'div_shortname' => $division['shortname'] ? $division['shortname'] : '', 'div_address' => $division['address'] ? $division['address'] : '', 'div_city' => $division['city'] ? $division['city'] : '', 'div_zip' => $division['zip'] ? $division['zip'] : '', 'div_' . $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_COUNTRY] => $division['countryid'] ? $division['countryid'] : 0, 'div_ten' => $division['ten'] ? $division['ten'] : '', 'div_regon' => $division['regon'] ? $division['regon'] : '', 'div_account' => $division['account'] ? $division['account'] : '', 'div_inv_header' => $division['inv_header'] ? $division['inv_header'] : '', 'div_inv_footer' => $division['inv_footer'] ? $division['inv_footer'] : '', 'div_inv_author' => $division['inv_author'] ? $division['inv_author'] : '', 'div_inv_cplace' => $division['inv_cplace'] ? $division['inv_cplace'] : '', 'fullnumber' => $fullnumber);
$DB->Execute('INSERT INTO documents (number, numberplanid, type,
cdate, userid, customerid, name, address, paytime,
ten, ssn, zip, city, countryid, divisionid,
div_name, div_shortname, div_address, div_city, div_zip, div_countryid,
div_ten, div_regon, div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
$nid = $DB->GetLastInsertID('documents');
if ($SYSLOG) {
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_DOC]] = $nid;
unset($args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_USER]]);
示例10: trans
$numberplans[] = $plan;
}
/*
if($dirs = getdir(DOC_DIR.'/templates', '^[a-z0-9_-]+$'))
foreach($dirs as $dir)
{
$infofile = DOC_DIR.'/templates/'.$dir.'/info.php';
if(file_exists($infofile))
{
unset($engine);
include($infofile);
$docengines[$dir] = $engine;
}
}
if($docengines) ksort($docengines);
*/
$layout['pagetitle'] = trans('Edit Document: $a', docnumber($document['number'], $document['template'], $document['cdate']));
//$SMARTY->assign('docengines', $docengines);
$SMARTY->assign('numberplans', $numberplans);
$SMARTY->assign('docrights', $rights);
$SMARTY->assign('allnumberplans', $allnumberplans);
$SMARTY->assign('error', $error);
$SMARTY->assign('document', $document);
$SMARTY->display('documentedit.html');
?>
示例11: explode
}
$i++;
}
if ($ctype != 'pdf' && strtolower(ConfigHelper::getConfig('phpui.document_type')) == 'pdf') {
$margins = explode(",", ConfigHelper::getConfig('phpui.document_margins', '10,5,15,5'));
html2pdf($htmlbuffer, trans('Document'), NULL, NULL, NULL, 'P', $margins);
}
die;
}
} elseif ($doc = $DB->GetRow('SELECT c.filename, c.md5sum, c.contenttype, d.id, d.number, d.cdate, d.type, n.template
FROM documentcontents c
JOIN documents d ON (d.id = c.docid)
LEFT JOIN numberplans n ON (d.numberplanid = n.id)
JOIN docrights r ON (r.doctype = d.type)
WHERE c.docid = ? AND r.userid = ? AND (r.rights & 1) = 1', array($_GET['id'], $AUTH->id))) {
$docnumber = docnumber($doc['number'], $doc['template'], $doc['cdate']);
$filename = DOC_DIR . DIRECTORY_SEPARATOR . substr($doc['md5sum'], 0, 2) . DIRECTORY_SEPARATOR . $doc['md5sum'];
if (file_exists($filename)) {
$filename_pdf = DOC_DIR . DIRECTORY_SEPARATOR . substr($doc['md5sum'], 0, 2) . DIRECTORY_SEPARATOR . $doc['md5sum'] . '.pdf';
if (file_exists($filename_pdf)) {
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $docnumber . '.pdf"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($filename_pdf));
header('Accept-Ranges: bytes');
readfile($filename_pdf);
} elseif ($doc['contenttype'] != 'pdf' && strtolower(ConfigHelper::getConfig('phpui.document_type')) == 'pdf') {
if ($doc['type'] == DOC_CONTRACT) {
$subject = trans('Contract');
$title = trans('Contract No. $a', $docnumber);
} elseif ($doc['type'] == DOC_ANNEX) {
示例12: docnumber
$document['number'] = $LMS->GetNewDocumentNumber(array('doctype' => $document['type'], 'planid' => $document['numberplanid'], 'customerid' => $document['customerid']));
}
$fullnumber = docnumber(array('number' => $document['number'], 'template' => $numtemplate, 'cdate' => $time, 'customerid' => $document['customerid']));
$DB->Execute('INSERT INTO documents (type, number, numberplanid, cdate, customerid, userid, divisionid, name, address, zip, city, ten, ssn, closed,
div_name, div_shortname, div_address, div_city, div_zip, div_countryid, div_ten, div_regon,
div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array($document['type'], $document['number'], $document['numberplanid'], $time, $document['customerid'], $AUTH->id, $gencust['divisionid'], $gencust['customername'], $gencust['address'] ? $gencust['address'] : '', $gencust['zip'] ? $gencust['zip'] : '', $gencust['city'] ? $gencust['city'] : '', $gencust['ten'] ? $gencust['ten'] : '', $gencust['ssn'] ? $gencust['ssn'] : '', !empty($document['closed']) ? 1 : 0, $division['name'] ? $division['name'] : '', $division['shortname'] ? $division['shortname'] : '', $division['address'] ? $division['address'] : '', $division['city'] ? $division['city'] : '', $division['zip'] ? $division['zip'] : '', $division['countryid'] ? $division['countryid'] : 0, $division['ten'] ? $division['ten'] : '', $division['regon'] ? $division['regon'] : '', $division['account'] ? $division['account'] : '', $division['inv_header'] ? $division['inv_header'] : '', $division['inv_footer'] ? $division['inv_footer'] : '', $division['inv_author'] ? $division['inv_author'] : '', $division['inv_cplace'] ? $division['inv_cplace'] : '', $fullnumber));
$docid = $DB->GetLastInsertID('documents');
$DB->Execute('INSERT INTO documentcontents (docid, title, fromdate, todate, description)
VALUES (?, ?, ?, ?, ?)', array($docid, $document['title'], $document['fromdate'], $document['todate'], $document['description']));
foreach ($files as $file) {
$DB->Execute('INSERT INTO documentattachments (docid, filename, contenttype, md5sum, main)
VALUES (?, ?, ?, ?, ?)', array($docid, $file['name'], $file['type'], $file['md5sum'], $file['main'] ? 1 : 0));
}
$DB->CommitTrans();
$genresult .= docnumber(array('number' => $document['number'], 'template' => $numtemplate, 'cdate' => $time, 'customerid' => $document['customerid'])) . '.<br>';
if (!$customernumtemplate) {
$document['number']++;
}
if (isset($_GET['print']) && isset($docfile) && $docfile['contenttype'] == 'text/html') {
print $output;
print '<DIV style="page-break-after: always;"></DIV>';
flush();
}
}
if (!isset($_GET['print'])) {
$SMARTY->display('header.html');
print $genresult;
$SMARTY->display('footer.html');
}
die;
示例13: elseif
if (!empty($note['paytime_default'])) {
if ($customer['paytime'] != -1) {
$note['paytime'] = $customer['paytime'];
} elseif (($paytime = $DB->GetOne('SELECT inv_paytime FROM divisions
WHERE id = ?', array($customer['divisionid']))) !== NULL) {
$note['paytime'] = $paytime;
} else {
$note['paytime'] = ConfigHelper::getConfig('notes.paytime');
}
}
$cdate = !empty($note['cdate']) ? $note['cdate'] : time();
$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ? ;', array($customer['divisionid']));
if ($note['numberplanid']) {
$fullnumber = docnumber(array('number' => $note['number'], 'template' => $DB->GetOne('SELECT template FROM numberplans WHERE id = ?', array($note['numberplanid'])), 'cdate' => $cdate, 'customerid' => $customer['id']));
} else {
$fullnumber = null;
}
$args = array('number' => $note['number'], SYSLOG::RES_NUMPLAN => !empty($note['numberplanid']) ? $note['numberplanid'] : 0, 'type' => DOC_DNOTE, 'cdate' => $cdate, SYSLOG::RES_USER => $AUTH->id, SYSLOG::RES_CUST => $customer['id'], 'name' => $customer['customername'], 'address' => $customer['address'], 'paytime' => $note['paytime'], 'ten' => $customer['ten'], 'ssn' => $customer['ssn'], 'zip' => $customer['zip'], 'city' => $customer['city'], SYSLOG::RES_COUNTRY => $customer['countryid'], SYSLOG::RES_DIV => $customer['divisionid'], 'div_name' => $division['name'] ? $division['name'] : '', 'div_shortname' => $division['shortname'] ? $division['shortname'] : '', 'div_address' => $division['address'] ? $division['address'] : '', 'div_city' => $division['city'] ? $division['city'] : '', 'div_zip' => $division['zip'] ? $division['zip'] : '', 'div_' . SYSLOG::getResourceKey(SYSLOG::RES_COUNTRY) => $division['countryid'] ? $division['countryid'] : 0, 'div_ten' => $division['ten'] ? $division['ten'] : '', 'div_regon' => $division['regon'] ? $division['regon'] : '', 'div_account' => $division['account'] ? $division['account'] : '', 'div_inv_header' => $division['inv_header'] ? $division['inv_header'] : '', 'div_inv_footer' => $division['inv_footer'] ? $division['inv_footer'] : '', 'div_inv_author' => $division['inv_author'] ? $division['inv_author'] : '', 'div_inv_cplace' => $division['inv_cplace'] ? $division['inv_cplace'] : '', 'fullnumber' => $fullnumber);
$DB->Execute('INSERT INTO documents (number, numberplanid, type,
cdate, userid, customerid, name, address, paytime,
ten, ssn, zip, city, countryid, divisionid,
div_name, div_shortname, div_address, div_city, div_zip, div_countryid,
div_ten, div_regon, div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
$nid = $DB->GetLastInsertID('documents');
if ($SYSLOG) {
$args[SYSLOG::RES_DOC] = $nid;
unset($args[SYSLOG::RES_USER]);
示例14: ON
*
* (C) Copyright 2001-2016 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id$
*/
if ($doc = $DB->GetRow('SELECT number, cdate, template, extnumber, paytime, paytype, customerid
FROM documents
LEFT JOIN numberplans ON (numberplanid = numberplans.id)
WHERE documents.id = ?', array($_GET['id']))) {
$doc['ntempl'] = docnumber(array('number' => $doc['number'], 'template' => $doc['template'], 'cdate' => $doc['cdate'], 'ext_num' => $doc['extnumber'], 'customerid' => $doc['customerid']));
$doc['pdate'] = $doc['cdate'] + $doc['paytime'] * 86400;
$doc['paytypename'] = $PAYTYPES[$doc['paytype']];
$SMARTY->assign('invoice', $doc);
$SMARTY->display('invoice/invoiceinfoshort.html');
}
示例15: curl_init
$ch = curl_init();
if (!$ch) {
die("Fatal error: Can't init curl library!\n");
}
$query = "SELECT d.id, d.number, d.cdate, c.email, d.name, d.customerid, n.template \n\t\tFROM documents d \n\t\tLEFT JOIN customers c ON c.id = d.customerid \n\t\tLEFT JOIN numberplans n ON n.id = d.numberplanid \n\t\tWHERE c.deleted = 0 AND d.type IN (1,3) AND c.email <> '' AND c.invoicenotice = 1 " . (!empty($invoiceid) ? "AND d.id = " . $invoiceid : "AND d.cdate >= {$daystart} AND d.cdate <= {$dayend}") . (!empty($groupnames) ? $customergroups : "") . " ORDER BY d.number";
$docs = $DB->GetAll($query);
if (!empty($docs)) {
foreach ($docs as $doc) {
curl_setopt_array($ch, array(CURLOPT_URL => $lms_url . '/?m=invoice&override=1&original=1&id=' . $doc['id'] . '&loginform[login]=' . $lms_user . '&loginform[pwd]=' . $lms_password, CURLOPT_HTTPGET => TRUE, CURLOPT_POST => FALSE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_COOKIEJAR => COOKIE_FILE, CURLOPT_COOKIEFILE => COOKIE_FILE, CURLOPT_SSLVERSION => 3, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_USERAGENT => USER_AGENT));
$res = curl_exec($ch);
if (!empty($res)) {
$custemail = !empty($debug_email) ? $debug_email : $doc['email'];
$invoice_number = !empty($doc['template']) ? $doc['template'] : '%N/LMS/%Y';
$body = $mail_body;
$subject = $mail_subject;
$invoice_number = docnumber($doc['number'], $invoice_number, $doc['cdate'] + date('Z'));
$body = preg_replace('/%invoice/', $invoice_number, $body);
$body = preg_replace('/%balance/', $LMS->GetCustomerBalance($doc['customerid']), $body);
$day = sprintf("%02d", $day);
$month = sprintf("%02d", $month);
$year = sprintf("%04d", $year);
$body = preg_replace('/%today/', $year . "-" . $month . "-" . $day, $body);
$body = str_replace('\\n', "\n", $body);
$subject = preg_replace('/%invoice/', $invoice_number, $subject);
$filename = preg_replace('/%docid/', $doc['id'], $invoice_filename);
if (!$quiet || $test) {
printf("Invoice No. {$invoice_number} for " . $doc['name'] . " <{$custemail}>\n");
}
if (!$test) {
$headers = array('From' => $from, 'To' => qp_encode($doc['name']) . ' <' . $custemail . '>', 'Subject' => $subject);
if (!empty($notify_email)) {