本文整理汇总了PHP中f_round函数的典型用法代码示例。如果您正苦于以下问题:PHP f_round函数的具体用法?PHP f_round怎么用?PHP f_round使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了f_round函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: SUM
COALESCE((SELECT SUM((a.value+b.value)*(a.count+b.count)) - SUM(b.value*b.count)
FROM documents dd
JOIN invoicecontents a ON (a.docid = dd.id)
JOIN invoicecontents b ON (dd.reference = b.docid AND a.itemid = b.itemid)
WHERE dd.reference = d.id
GROUP BY dd.reference), 0) AS value
FROM documents d
WHERE d.customerid = ? AND d.type = ? AND d.closed = 0
GROUP BY d.id, d.cdate ORDER BY d.cdate', array($balance['customerid'], DOC_INVOICE))) {
foreach ($invoices as $inv) {
$sum += $inv['value'];
}
$bval = $LMS->GetCustomerBalance($balance['customerid']);
$value = f_round($bval + $import['value'] + $sum);
foreach ($invoices as $inv) {
$inv['value'] = f_round($inv['value']);
if ($inv['value'] > $value) {
break;
} else {
// close invoice and assigned credit notes
$DB->Execute('UPDATE documents SET closed = 1
WHERE id = ? OR reference = ?', array($inv['id'], $inv['id']));
if ($SYSLOG) {
$docid = $DB->GetOne('SELECT id FROM documents
WHERE id = ? OR reference = ?', array($inv['id'], $inv['id']));
$args = array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_DOC] => $docid, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST] => $balance['customerid'], 'closed' => 1);
$SYSLOG->AddMessage(SYSLOG_RES_DOC, SYSLOG_OPER_UPDATE, $args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_DOC], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST]));
}
$value -= $inv['value'];
}
}
开发者ID:oswida,项目名称:lms,代码行数:31,代码来源:cashimport.php
示例2: foreach
$invoicelist[$idx]['tax'] += $tax;
$invoicelist[$idx]['brutto'] += $sum;
if (!isset($listdata[$taxid])) {
$listdata[$taxid]['tax'] = 0;
$listdata[$taxid]['val'] = 0;
}
$listdata[$taxid]['tax'] += $tax;
$listdata[$taxid]['val'] += $val;
$listdata['tax'] += $tax;
$listdata['brutto'] += $sum;
}
// get used tax rates for building report table
foreach ($listdata as $idx => $val) {
if (is_int($idx)) {
$tax = $taxes[$idx];
$tax['value'] = f_round($tax['value']);
$taxeslist[$idx] = $tax;
$taxescount += $tax['value'] ? 2 : 1;
}
}
}
$SMARTY->assign('listdata', $listdata);
$SMARTY->assign('taxes', $taxeslist);
$SMARTY->assign('taxescount', $taxescount);
$SMARTY->assign('layout', $layout);
$SMARTY->assign('invoicelist', $invoicelist);
if (isset($_POST['extended'])) {
$pages = array();
$totals = array();
$reccount = sizeof($invoicelist);
// hidden option: records count for one page of printout
开发者ID:oswida,项目名称:lms,代码行数:31,代码来源:invoicereport.php
示例3: AddAssignment
function AddAssignment($data)
{
$result = array();
// Create assignments according to promotion schema
if (!empty($data['promotiontariffid']) && !empty($data['schemaid'])) {
$data['tariffid'] = $data['promotiontariffid'];
$tariff = $this->DB->GetRow('SELECT a.data, s.data AS sdata,
t.name, t.value, t.period, t.id, t.prodid, t.taxid,
s.continuation, s.ctariffid
FROM promotionassignments a
JOIN promotionschemas s ON (s.id = a.promotionschemaid)
JOIN tariffs t ON (t.id = a.tariffid)
WHERE a.promotionschemaid = ? AND a.tariffid = ?', array($data['schemaid'], $data['promotiontariffid']));
$data_schema = explode(';', $tariff['sdata']);
$data_tariff = explode(';', $tariff['data']);
$datefrom = $data['datefrom'];
$cday = date('d', $datefrom);
foreach ($data_tariff as $idx => $dt) {
list($value, $period) = explode(':', $dt);
// Activation
if (!$idx) {
// if activation value specified, create disposable liability
if (f_round($value)) {
$start_day = date('d', $data['datefrom']);
$start_month = date('n', $data['datefrom']);
$start_year = date('Y', $data['datefrom']);
// payday is before the start of the period
// set activation payday to next month's payday
if ($start_day > $data['at']) {
$_datefrom = $data['datefrom'];
$datefrom = mktime(0, 0, 0, $start_month + 1, $data['at'], $start_year);
}
$this->DB->Execute('INSERT INTO liabilities (name, value, taxid, prodid)
VALUES (?, ?, ?, ?)', array(trans('Activation payment'), str_replace(',', '.', $value), intval($tariff['taxid']), $tariff['prodid']));
$lid = $this->DB->GetLastInsertID('liabilities');
$tariffid = 0;
$period = DISPOSABLE;
$at = $datefrom;
} else {
continue;
}
} else {
$lid = 0;
if (!$period) {
$period = $data['period'];
}
$datefrom = $_datefrom ? $_datefrom : $datefrom;
$_datefrom = 0;
$at = $this->CalcAt($period, $datefrom);
$length = $data_schema[$idx - 1];
$month = date('n', $datefrom);
$year = date('Y', $datefrom);
// assume $data['at'] == 1, set last day of the specified month
$dateto = mktime(23, 59, 59, $month + $length + ($cday && $cday != 1 ? 1 : 0), 0, $year);
$cday = 0;
// Find tariff with specified name+value+period...
$tariffid = $this->DB->GetOne('SELECT id FROM tariffs
WHERE name = ? AND value = ? AND period = ?
LIMIT 1', array($tariff['name'], str_replace(',', '.', $value), $tariff['period']));
// ... if not found clone tariff
if (!$tariffid) {
$this->DB->Execute('INSERT INTO tariffs (name, value, period,
taxid, type, upceil, downceil, uprate, downrate,
prodid, plimit, climit, dlimit, upceil_n, downceil_n, uprate_n, downrate_n,
domain_limit, alias_limit, sh_limit, www_limit, ftp_limit, mail_limit, sql_limit,
quota_sh_limit, quota_www_limit, quota_ftp_limit, quota_mail_limit, quota_sql_limit)
SELECT ?, ?, ?, taxid, type, upceil, downceil, uprate, downrate,
prodid, plimit, climit, dlimit, upceil_n, downceil_n, uprate_n, downrate_n,
domain_limit, alias_limit, sh_limit, www_limit, ftp_limit, mail_limit, sql_limit,
quota_sh_limit, quota_www_limit, quota_ftp_limit, quota_mail_limit, quota_sql_limit
FROM tariffs WHERE id = ?', array($tariff['name'], str_replace(',', '.', $value), $tariff['period'], $tariff['id']));
$tariffid = $this->DB->GetLastInsertId('tariffs');
}
}
// Create assignment
$this->DB->Execute('INSERT INTO assignments (tariffid, customerid, period, at, invoice,
settlement, numberplanid, paytype, datefrom, dateto, pdiscount, vdiscount, liabilityid)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array($tariffid, $data['customerid'], $period, $at, !empty($data['invoice']) ? 1 : 0, !empty($data['settlement']) ? 1 : 0, !empty($data['numberplanid']) ? $data['numberplanid'] : NULL, !empty($data['paytype']) ? $data['paytype'] : NULL, $idx ? $datefrom : 0, $idx ? $dateto : 0, 0, 0, $lid));
$result[] = $this->DB->GetLastInsertID('assignments');
if ($idx) {
$datefrom = $dateto + 1;
}
}
// add "after promotion" tariff(s)
if ($tariff['continuation'] || !$data_schema[0]) {
$tariffs[] = $tariff['id'];
if ($tariff['ctariffid'] && $data_schema[0] != 0) {
$tariffs[] = $tariff['ctariffid'];
}
// Create assignments
foreach ($tariffs as $t) {
$this->DB->Execute('INSERT INTO assignments (tariffid, customerid, period, at, invoice,
settlement, numberplanid, paytype, datefrom, dateto, pdiscount, vdiscount, liabilityid)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array($t, $data['customerid'], $data['period'], $this->CalcAt($data['period'], $datefrom), !empty($data['invoice']) ? 1 : 0, !empty($data['settlement']) ? 1 : 0, !empty($data['numberplanid']) ? $data['numberplanid'] : NULL, !empty($data['paytype']) ? $data['paytype'] : NULL, $datefrom, 0, 0, 0, 0));
$result[] = $this->DB->GetLastInsertID('assignments');
}
}
} else {
if (!empty($data['value'])) {
$this->DB->Execute('INSERT INTO liabilities (name, value, taxid, prodid)
//.........这里部分代码省略.........
开发者ID:repcio,项目名称:lms,代码行数:101,代码来源:LMS.class.php
示例4: commit_cashimport
function commit_cashimport()
{
global $LMS;
$DB = LMSDB::getInstance();
$imports = $DB->GetAll('SELECT i.*, f.idate
FROM cashimport i
LEFT JOIN sourcefiles f ON (f.id = i.sourcefileid)
WHERE i.closed = 0 AND i.customerid <> 0');
if (!empty($imports)) {
$idate = ConfigHelper::checkValue(ConfigHelper::getConfig('finances.cashimport_use_idate', false));
$icheck = ConfigHelper::checkValue(ConfigHelper::getConfig('finances.cashimport_checkinvoices', false));
foreach ($imports as $import) {
$DB->BeginTrans();
$balance['time'] = $idate ? $import['idate'] : $import['date'];
$balance['type'] = 1;
$balance['value'] = $import['value'];
$balance['customerid'] = $import['customerid'];
$balance['comment'] = $import['description'];
$balance['importid'] = $import['id'];
$balance['sourceid'] = $import['sourceid'];
$balance['userid'] = 0;
if ($import['value'] > 0 && $icheck) {
if ($invoices = $DB->GetAll('SELECT x.id, x.value FROM (
SELECT d.id,
(SELECT SUM(value*count) FROM invoicecontents WHERE docid = d.id) +
COALESCE((
SELECT SUM((a.value+b.value)*(a.count+b.count)) - SUM(b.value*b.count)
FROM documents dd
JOIN invoicecontents a ON (a.docid = dd.id)
JOIN invoicecontents b ON (dd.reference = b.docid AND a.itemid = b.itemid)
WHERE dd.reference = d.id
GROUP BY dd.reference), 0) AS value,
d.cdate
FROM documents d
WHERE d.customerid = ? AND d.type = ? AND d.closed = 0
GROUP BY d.id, d.cdate
UNION
SELECT d.id, dn.value, d.cdate
FROM documents d
JOIN debitnotecontents dn ON dn.docid = d.id
WHERE d.customerid = ?
) x ORDER BY x.cdate', array($balance['customerid'], DOC_INVOICE, $balance['customerid']))) {
foreach ($invoices as $inv) {
$sum += $inv['value'];
}
$bval = $LMS->GetCustomerBalance($balance['customerid']);
$value = f_round($bval + $import['value'] + $sum);
foreach ($invoices as $inv) {
$inv['value'] = f_round($inv['value']);
if ($inv['value'] > $value) {
break;
} else {
// close invoice and assigned credit notes
$DB->Execute('UPDATE documents SET closed = 1
WHERE id = ? OR reference = ?', array($inv['id'], $inv['id']));
$value -= $inv['value'];
}
}
}
}
$DB->Execute('UPDATE cashimport SET closed = 1 WHERE id = ?', array($import['id']));
$LMS->AddBalance($balance);
$DB->CommitTrans();
}
}
}
开发者ID:itav,项目名称:lms,代码行数:66,代码来源:lms-cashimport.php
示例5: floatval
if (preg_match('/^[0-9]+(\\.[0-9]+)*$/', $contents[$idx]['discount'])) {
$contents[$idx]['pdiscount'] = $contents[$idx]['discount_type'] == DISCOUNT_PERCENTAGE ? floatval($contents[$idx]['discount']) : 0;
$contents[$idx]['vdiscount'] = $contents[$idx]['discount_type'] == DISCOUNT_AMOUNT ? floatval($contents[$idx]['discount']) : 0;
}
if ($contents[$idx]['pdiscount'] < 0 || $contents[$idx]['pdiscount'] > 99.90000000000001 || $contents[$idx]['vdiscount'] < 0) {
$error['discount'] = trans('Wrong discount value!');
}
$contents[$idx]['name'] = isset($newcontents['name'][$idx]) ? $newcontents['name'][$idx] : $item['name'];
$contents[$idx]['tariffid'] = isset($newcontents['tariffid'][$idx]) ? $newcontents['tariffid'][$idx] : $item['tariffid'];
$contents[$idx]['valuebrutto'] = $newcontents['valuebrutto'][$idx] != '' ? $newcontents['valuebrutto'][$idx] : $item['valuebrutto'];
$contents[$idx]['valuenetto'] = $newcontents['valuenetto'][$idx] != '' ? $newcontents['valuenetto'][$idx] : $item['valuenetto'];
$contents[$idx]['valuebrutto'] = f_round($contents[$idx]['valuebrutto']);
$contents[$idx]['valuenetto'] = f_round($contents[$idx]['valuenetto']);
$contents[$idx]['count'] = f_round($contents[$idx]['count']);
$contents[$idx]['pdiscount'] = f_round($contents[$idx]['pdiscount']);
$contents[$idx]['vdiscount'] = f_round($contents[$idx]['vdiscount']);
$taxvalue = $taxeslist[$contents[$idx]['taxid']]['value'];
if ($contents[$idx]['valuenetto'] != $item['valuenetto']) {
$contents[$idx]['valuebrutto'] = round($contents[$idx]['valuenetto'] * ($taxvalue / 100 + 1), 2);
}
if (isset($item['deleted']) && $item['deleted']) {
$contents[$idx]['valuebrutto'] = 0;
$contents[$idx]['cash'] = round($item['valuebrutto'] * $item['count'], 2);
$contents[$idx]['count'] = 0;
} elseif ($contents[$idx]['count'] != $item['count'] || $contents[$idx]['valuebrutto'] != $item['valuebrutto']) {
$contents[$idx]['cash'] = round($item['valuebrutto'] * $item['count'], 2) - round($contents[$idx]['valuebrutto'] * $contents[$idx]['count'], 2);
}
$contents[$idx]['valuebrutto'] = $contents[$idx]['valuebrutto'] - $item['valuebrutto'];
$contents[$idx]['count'] = $contents[$idx]['count'] - $item['count'];
}
$DB->BeginTrans();
开发者ID:oswida,项目名称:lms,代码行数:31,代码来源:invoicenote.php
示例6: foreach
break;
case 'additemlist':
if ($marks = $_POST['marks']) {
foreach ($marks as $id) {
$cash = $DB->GetRow('SELECT value, comment, taxid
FROM cash WHERE id = ?', array($id));
$itemdata['cashid'] = $id;
$itemdata['name'] = $cash['comment'];
$itemdata['taxid'] = $cash['taxid'];
$itemdata['tax'] = isset($taxeslist[$itemdata['taxid']]) ? $taxeslist[$itemdata['taxid']]['label'] : '';
$itemdata['discount'] = 0;
$itemdata['pdiscount'] = 0;
$itemdata['vdiscount'] = 0;
$itemdata['count'] = f_round($_POST['l_count'][$id]);
$itemdata['valuebrutto'] = f_round(-$cash['value'] / $itemdata['count']);
$itemdata['s_valuebrutto'] = f_round(-$cash['value']);
$itemdata['valuenetto'] = round($itemdata['valuebrutto'] / ((isset($taxeslist[$itemdata['taxid']]) ? $taxeslist[$itemdata['taxid']]['value'] : 0) / 100 + 1), 2);
$itemdata['s_valuenetto'] = round($itemdata['s_valuebrutto'] / ((isset($taxeslist[$itemdata['taxid']]) ? $taxeslist[$itemdata['taxid']]['value'] : 0) / 100 + 1), 2);
$itemdata['prodid'] = $_POST['l_prodid'][$id];
$itemdata['jm'] = $_POST['l_jm'][$id];
$itemdata['posuid'] = (string) (getmicrotime() + $id);
$itemdata['tariffid'] = 0;
$contents[] = $itemdata;
}
}
break;
case 'deletepos':
if (sizeof($contents)) {
foreach ($contents as $idx => $row) {
if ($row['posuid'] == $_GET['posuid']) {
unset($contents[$idx]);
开发者ID:itav,项目名称:lms,代码行数:31,代码来源:invoicenew.php
示例7: f_round
if ($itemdata['valuenetto'] != 0) {
$itemdata['valuenetto'] = f_round($itemdata['valuenetto'] - $itemdata['valuenetto'] * f_round($itemdata['pdiscount']) / 100 - $itemdata['vdiscount']);
$itemdata['valuebrutto'] = $itemdata['valuenetto'] * ($taxvalue / 100 + 1);
$itemdata['s_valuebrutto'] = f_round($itemdata['valuenetto'] * $itemdata['count'] * ($taxvalue / 100 + 1));
} elseif ($itemdata['valuebrutto'] != 0) {
$itemdata['valuebrutto'] = f_round($itemdata['valuebrutto'] - $itemdata['valuebrutto'] * $itemdata['pdiscount'] / 100 - $itemdata['vdiscount']);
$itemdata['valuenetto'] = round($itemdata['valuebrutto'] / ($taxvalue / 100 + 1), 2);
$itemdata['s_valuebrutto'] = f_round($itemdata['valuebrutto'] * $itemdata['count']);
}
// str_replace here is needed because of bug in some PHP versions (4.3.10)
$itemdata['s_valuenetto'] = f_round($itemdata['s_valuebrutto'] / ($taxvalue / 100 + 1));
$itemdata['valuenetto'] = f_round($itemdata['valuenetto']);
$itemdata['count'] = f_round($itemdata['count']);
$itemdata['discount'] = f_round($itemdata['discount']);
$itemdata['pdiscount'] = f_round($itemdata['pdiscount']);
$itemdata['vdiscount'] = f_round($itemdata['vdiscount']);
$itemdata['tax'] = $taxeslist[$itemdata['taxid']]['label'];
$itemdata['posuid'] = (string) getmicrotime();
$contents[] = $itemdata;
}
break;
case 'deletepos':
if ($invoice['closed']) {
break;
}
if (sizeof($contents)) {
foreach ($contents as $idx => $row) {
if ($row['posuid'] == $_GET['posuid']) {
unset($contents[$idx]);
}
}
开发者ID:prezeskk,项目名称:lms,代码行数:31,代码来源:invoiceedit.php
示例8: AddAssignment
public function AddAssignment($data)
{
global $SYSLOG_RESOURCE_KEYS;
$result = array();
// Create assignments according to promotion schema
if (!empty($data['promotiontariffid']) && !empty($data['schemaid'])) {
$data['tariffid'] = $data['promotiontariffid'];
$tariff = $this->DB->GetRow('SELECT a.data, s.data AS sdata,
t.name, t.value, t.period, t.id, t.prodid, t.taxid,
s.continuation, s.ctariffid
FROM promotionassignments a
JOIN promotionschemas s ON (s.id = a.promotionschemaid)
JOIN tariffs t ON (t.id = a.tariffid)
WHERE a.promotionschemaid = ? AND a.tariffid = ?', array($data['schemaid'], $data['promotiontariffid']));
$data_schema = explode(';', $tariff['sdata']);
$data_tariff = explode(';', $tariff['data']);
$datefrom = $data['datefrom'];
$cday = date('d', $datefrom);
foreach ($data_tariff as $idx => $dt) {
list($value, $period) = explode(':', $dt);
// Activation
if (!$idx) {
// if activation value specified, create disposable liability
if (f_round($value)) {
$start_day = date('d', $data['datefrom']);
$start_month = date('n', $data['datefrom']);
$start_year = date('Y', $data['datefrom']);
// payday is before the start of the period
// set activation payday to next month's payday
if ($start_day > $data['at']) {
$_datefrom = $data['datefrom'];
$datefrom = mktime(0, 0, 0, $start_month + 1, $data['at'], $start_year);
}
$args = array('name' => trans('Activation payment'), 'value' => str_replace(',', '.', $value), $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TAX] => intval($tariff['taxid']), 'prodid' => $tariff['prodid']);
$this->DB->Execute('INSERT INTO liabilities (name, value, taxid, prodid)
VALUES (?, ?, ?, ?)', array_values($args));
$lid = $this->DB->GetLastInsertID('liabilities');
if ($this->SYSLOG) {
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_LIAB]] = $lid;
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST]] = $data['customerid'];
$this->SYSLOG->AddMessage(SYSLOG_RES_LIAB, SYSLOG_OPER_ADD, $args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_LIAB], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TAX]));
}
$tariffid = 0;
$period = DISPOSABLE;
$at = $datefrom;
} else {
continue;
}
} else {
$lid = 0;
if (!$period) {
$period = $data['period'];
}
$datefrom = $_datefrom ? $_datefrom : $datefrom;
$_datefrom = 0;
$at = $this->CalcAt($period, $datefrom);
$length = $data_schema[$idx - 1];
$month = date('n', $datefrom);
$year = date('Y', $datefrom);
// assume $data['at'] == 1, set last day of the specified month
$dateto = mktime(23, 59, 59, $month + $length + ($cday && $cday != 1 ? 1 : 0), 0, $year);
$cday = 0;
// Find tariff with specified name+value+period...
$tariffid = $this->DB->GetOne('SELECT id FROM tariffs
WHERE name = ? AND value = ? AND period = ?
LIMIT 1', array($tariff['name'], str_replace(',', '.', $value), $tariff['period']));
// ... if not found clone tariff
if (!$tariffid) {
$args = $this->DB->GetRow('SELECT name, value, period,
taxid AS ' . $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TAX] . ', type, upceil, downceil, uprate, downrate,
prodid, plimit, climit, dlimit, upceil_n, downceil_n, uprate_n, downrate_n,
domain_limit, alias_limit, sh_limit, www_limit, ftp_limit, mail_limit, sql_limit,
quota_sh_limit, quota_www_limit, quota_ftp_limit, quota_mail_limit, quota_sql_limit
FROM tariffs WHERE id = ?', array($tariff['id']));
$args = array_merge($args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TAX] => $args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TAX]], 'name' => $tariff['name'], 'value' => str_replace(',', '.', $value), 'period' => $tariff['period']));
unset($args['taxid']);
$this->DB->Execute('INSERT INTO tariffs (name, value, period,
taxid, type, upceil, downceil, uprate, downrate,
prodid, plimit, climit, dlimit, upceil_n, downceil_n, uprate_n, downrate_n,
domain_limit, alias_limit, sh_limit, www_limit, ftp_limit, mail_limit, sql_limit,
quota_sh_limit, quota_www_limit, quota_ftp_limit, quota_mail_limit, quota_sql_limit)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
$tariffid = $this->DB->GetLastInsertId('tariffs');
if ($this->SYSLOG) {
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TARIFF]] = $tariffid;
$this->SYSLOG->AddMessage(SYSLOG_RES_TARIFF, SYSLOG_OPER_ADD, $args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TARIFF], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TAX]));
}
}
}
// Create assignment
$args = array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TARIFF] => $tariffid, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST] => $data['customerid'], 'period' => $period, 'at' => $at, 'invoice' => !empty($data['invoice']) ? 1 : 0, 'settlement' => !empty($data['settlement']) ? 1 : 0, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_NUMPLAN] => !empty($data['numberplanid']) ? $data['numberplanid'] : NULL, 'paytype' => !empty($data['paytype']) ? $data['paytype'] : NULL, 'datefrom' => $idx ? $datefrom : 0, 'dateto' => $idx ? $dateto : 0, 'pdiscount' => 0, 'vdiscount' => 0, $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_LIAB] => $lid);
$this->DB->Execute('INSERT INTO assignments (tariffid, customerid, period, at, invoice,
settlement, numberplanid, paytype, datefrom, dateto, pdiscount, vdiscount, liabilityid)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
$id = $this->DB->GetLastInsertID('assignments');
if ($this->SYSLOG) {
$args[$SYSLOG_RESOURCE_KEYS[SYSLOG_RES_ASSIGN]] = $id;
$this->SYSLOG->AddMessage(SYSLOG_RES_ASSIGN, SYSLOG_OPER_ADD, $args, array($SYSLOG_RESOURCE_KEYS[SYSLOG_RES_ASSIGN], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_CUST], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_TARIFF], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_LIAB], $SYSLOG_RESOURCE_KEYS[SYSLOG_RES_NUMPLAN]));
}
$result[] = $id;
//.........这里部分代码省略.........
开发者ID:oswida,项目名称:lms,代码行数:101,代码来源:LMS.class.php
示例9: isset
$error['count'] = 'Incorrect ammount!';
}
$itemdata['unitname'] = $LMSST->QuantityGetNameById($itemdata['unit']);
if (!preg_match('/^\\d+[,.]{0,1}\\d{0,2}$/i', $itemdata['price']['net']) && !preg_match('/^\\d+[,.]{0,1}\\d{0,2}$/i', $itemdata['price']['gross'])) {
$error['price'] = 'Wrong or missing price!';
}
$itemdata['price']['tax'] = isset($itemdata['price']['taxid']) ? $taxeslist[$itemdata['price']['taxid']]['label'] : '';
if (!$error) {
$taxvalue = isset($itemdata['price']['taxid']) ? $taxeslist[$itemdata['price']['taxid']]['value'] : 0;
if ($itemdata['price']['net'] != 0) {
$itemdata['price']['net'] = f_round($itemdata['price']['net']);
$itemdata['price']['gross'] = f_round($itemdata['price']['net'] * ($taxvalue / 100 + 1), 2);
$itemdata['price']['net'] = f_round($itemdata['price']['gross'] / ($taxvalue / 100 + 1), 2);
} elseif ($itemdata['price']['gross'] != 0) {
$itemdata['price']['gross'] = f_round($itemdata['price']['gross'], 2);
$itemdata['price']['net'] = f_round($itemdata['price']['gross'] / ($taxvalue / 100 + 1), 2);
}
if ($itemdata['count'] > 1) {
$serials = array();
$rnepl['doc']['net'] += $itemdata['count'] * $itemdata['price']['net'];
$rnepl['doc']['gross'] += $itemdata['count'] * $itemdata['price']['gross'];
for ($i = 1; $i < $itemdata['count']; ++$i) {
$serials[] = strtoupper($itemdata['serial'][$i]);
unset($itemdata['serial'][$i]);
}
$itemdata['count'] = 1;
$itemdata['serial'] = strtoupper($itemdata['serial'][0]);
$rnepl['product'][] = $itemdata;
foreach ($serials as $serial) {
$itemdata['serial'] = $serial;
$rnepl['product'][] = $itemdata;
开发者ID:krzysztofpuchala,项目名称:lms-magazyn,代码行数:31,代码来源:stckreceivenoteedit.php
示例10: unset
} else {
unset($productedit['leavedate']);
unset($productedit['pricesell']);
}
if (!$error) {
if ($productedit['leavedate']) {
$productedit['leavedate'] = DateChange($productedit['leavedate']);
}
$taxvalue = isset($productedit['taxid']) ? $taxeslist[$productedit['taxid']]['value'] : 0;
if ($productedit['pricebuynet'] != 0) {
$productedit['pricebuynet'] = f_round($productedit['pricebuynet']);
$productedit['pricebuygross'] = f_round($productedit['pricebuynet'] * ($taxvalue / 100 + 1), 2);
$productedit['pricebuynet'] = f_round($productedit['pricebuygross'] / ($taxvalue / 100 + 1), 2);
} elseif ($productedit['pricebuygross'] != 0) {
$productedit['pricebuygross'] = f_round($productedit['pricebuygross'], 2);
$productedit['pricebuynet'] = f_round($productedit['pricebuygross'] / ($taxvalue / 100 + 1), 2);
}
if ($LMSST->StockPositionEdit($productedit)) {
$SMARTY->assign('success', 1);
$SMARTY->assign('reload', 1);
} else {
$error['general'] = trans('Unknown error!');
}
}
} else {
$productedit = $LMSST->StockPositionGetById($_GET['id']);
}
$wlist = $LMSST->WarehouseGetList();
unset($wlist['total']);
unset($wlist['order']);
unset($wlist['direction']);
开发者ID:krzysztofpuchala,项目名称:lms-magazyn,代码行数:31,代码来源:stckstockproductedit.php
示例11: GetInvoicesList
function GetInvoicesList($search = NULL, $cat = NULL, $group = NULL, $hideclosed = NULL, $order, $pagelimit = 100, $page = NULL, $proforma = 0)
{
global $DB;
if ($order == '') {
$order = 'id,asc';
}
list($order, $direction) = sscanf($order, '%[^,],%s');
$direction == 'desc' ? $direction = 'desc' : ($direction = 'asc');
switch ($order) {
case 'id':
$sqlord = ' ORDER BY d.id';
break;
case 'cdate':
$sqlord = ' ORDER BY d.cdate';
break;
case 'number':
$sqlord = ' ORDER BY number';
break;
case 'value':
$sqlord = ' ORDER BY value';
break;
case 'count':
$sqlord = ' ORDER BY count';
break;
case 'name':
$sqlord = ' ORDER BY name';
break;
}
$where = '';
if ($search != '' && $cat) {
switch ($cat) {
case 'number':
$where = ' AND number = ' . intval($search);
break;
case 'cdate':
$where = ' AND cdate >= ' . intval($search) . ' AND cdate < ' . (intval($search) + 86400);
break;
case 'month':
$last = mktime(23, 59, 59, date('n', $search) + 1, 0, date('Y', $search));
$where = ' AND cdate >= ' . intval($search) . ' AND cdate <= ' . $last;
break;
case 'ten':
$where = ' AND ten = ' . $DB->Escape($search);
break;
case 'customerid':
$where = ' AND d.customerid = ' . intval($search);
break;
case 'name':
$where = ' AND UPPER(d.name) ?LIKE? UPPER(' . $DB->Escape('%' . $search . '%') . ')';
break;
case 'address':
$where = ' AND UPPER(address) ?LIKE? UPPER(' . $DB->Escape('%' . $search . '%') . ')';
break;
case 'value':
$having = ' HAVING CASE reference WHEN 0 THEN
SUM(a.value*a.count)
ELSE
SUM((a.value+b.value)*(a.count+b.count)) - SUM(b.value*b.count)
END = ' . str_replace(',', '.', f_round($search)) . ' ';
break;
}
}
if ($hideclosed) {
$where .= ' AND closed = 0';
}
if ($res = $DB->Exec('SELECT d.id AS id, number, cdate, type,
d.customerid, d.name, address, zip, city, countries.name AS country, template, closed, cancelled, published,
CASE reference WHEN 0 THEN
SUM(a.value*a.count)
ELSE
SUM((a.value+b.value)*(a.count+b.count)) - SUM(b.value*b.count)
END AS value,
COUNT(a.docid) AS count,
i.sendinvoices
FROM documents d
JOIN invoicecontents a ON (a.docid = d.id)
LEFT JOIN invoicecontents b ON (d.reference = b.docid AND a.itemid = b.itemid)
LEFT JOIN countries ON (countries.id = d.countryid)
LEFT JOIN numberplans ON (d.numberplanid = numberplans.id)
LEFT JOIN (
SELECT DISTINCT c.id AS customerid, 1 AS sendinvoices FROM customers c
JOIN customercontacts cc ON cc.customerid = c.id
WHERE invoicenotice = 1 AND cc.type & ' . (CONTACT_INVOICES | CONTACT_DISABLED) . ' = ' . CONTACT_INVOICES . '
) i ON i.customerid = d.customerid
LEFT JOIN (
SELECT DISTINCT a.customerid FROM customerassignments a
JOIN excludedgroups e ON (a.customergroupid = e.customergroupid)
WHERE e.userid = lms_current_user()
) e ON (e.customerid = d.customerid)
WHERE e.customerid IS NULL AND ' . ($proforma ? 'type = ' . DOC_INVOICE_PRO : '(type = ' . DOC_CNOTE . ($cat != 'cnotes' ? ' OR type = ' . DOC_INVOICE : '') . ')') . $where . (!empty($group['group']) ? ' AND ' . (!empty($group['exclude']) ? 'NOT' : '') . ' EXISTS (
SELECT 1 FROM customerassignments WHERE customergroupid = ' . intval($group['group']) . '
AND customerid = d.customerid)' : '') . ' GROUP BY d.id, number, cdate, d.customerid,
d.name, address, zip, city, template, closed, type, reference, countries.name, cancelled, published, sendinvoices ' . (isset($having) ? $having : '') . $sqlord . ' ' . $direction)) {
if ($page > 0) {
$start = ($page - 1) * $pagelimit;
$stop = $start + $pagelimit;
}
$id = 0;
while ($row = $DB->FetchRow($res)) {
$row['customlinks'] = array();
//.........这里部分代码省略.........
开发者ID:prezeskk,项目名称:lms,代码行数:101,代码来源:invoicelist.php
示例12: trans
if ($itemdata['pdiscount'] < 0 || $itemdata['pdiscount'] > 99.90000000000001 || $itemdata['vdiscount'] < 0) {
$error['discount'] = trans('Wrong discount value!');
}
if ($error) {
break;
}
foreach (array('count', 'discount', 'pdiscount', 'vdiscount', 'valuenetto', 'valuebrutto') as $key) {
$itemdata[$key] = round((double) str_replace(',', '.', $itemdata[$key]), 2);
}
if ($itemdata['count'] > 0 && $itemdata['name'] != '') {
$taxvalue = $taxeslist[$itemdata['taxid']]['value'];
if ($itemdata['valuenetto'] != 0) {
$itemdata['valuenetto'] = f_round($itemdata['valuenetto'] - $itemdata['valuenetto'] * f_round($itemdata['pdiscount']) / 100 - $itemdata['vdiscount']);
$itemdata['valuebrutto'] = round($itemdata['valuenetto'] * ($taxvalue / 100 + 1), 2);
} elseif ($itemdata['valuebrutto'] != 0) {
$itemdata['valuebrutto'] = f_round($itemdata['valuebrutto'] - $itemdata['valuebrutto'] * $itemdata['pdiscount'] / 100 - $itemdata['vdiscount']);
$itemdata['valuenetto'] = round($itemdata['valuebrutto'] / ($taxvalue / 100 + 1), 2);
}
// str_replace here is needed because of bug in some PHP versions (4.3.10)
$itemdata['s_valuebrutto'] = str_replace(',', '.', $itemdata['valuebrutto'] * $itemdata['count']);
$itemdata['s_valuenetto'] = str_replace(',', '.', $itemdata['s_valuebrutto'] / ($taxvalue / 100 + 1));
$itemdata['valuenetto'] = str_replace(',', '.', $itemdata['valuenetto']);
$itemdata['valuebrutto'] = str_replace(',', '.', $itemdata['valuebrutto']);
$itemdata['count'] = str_replace(',', '.', $itemdata['count']);
$itemdata['discount'] = str_replace(',', '.', $itemdata['discount']);
$itemdata['pdiscount'] = str_replace(',', '.', $itemdata['pdiscount']);
$itemdata['vdiscount'] = str_replace(',', '.', $itemdata['vdiscount']);
$itemdata['tax'] = $taxeslist[$itemdata['taxid']]['label'];
$itemdata['posuid'] = (string) getmicrotime();
$contents[] = $itemdata;
}
开发者ID:oswida,项目名称:lms,代码行数:31,代码来源:invoiceedit.php
示例13: form_num
function form_num($num)
{
return str_replace(',', '.', sprintf('%.2f', f_round($num)));
}
开发者ID:prezeskk,项目名称:lms,代码行数:4,代码来源:export.php
示例14: GetRecipients
function GetRecipients($filter, $type = MSG_MAIL)
{
global $LMS;
$group = intval($filter['group']);
$network = intval($filter['network']);
if (is_array($filter['customergroup'])) {
$customergroup = array_map('intval', $filter['customergroup']);
$customergroup = implode(',', $customergroup);
} else {
$customergroup = intval($filter['customergroup']);
}
$nodegroup = intval($filter['nodegroup']);
$linktype = intval($filter['linktype']);
$tarifftype = intval($filter['tarifftype']);
$consent = isset($filter['consent']);
if ($group == 50) {
$deleted = 1;
$network = NULL;
$customergroup = NULL;
} else {
$deleted = 0;
}
$disabled = $group == 51 ? 1 : 0;
$indebted = $group == 52 ? 1 : 0;
$notindebted = $group == 53 ? 1 : 0;
$indebted2 = $group == 57 ? 1 : 0;
$indebted3 = $group == 58 ? 1 : 0;
if ($group >= 50) {
$group = 0;
}
if ($network) {
$net = $LMS->GetNetworkParams($network);
}
if ($type == MSG_SMS) {
$smstable = 'JOIN (SELECT ' . $LMS->DB->GroupConcat('contact') . ' AS phone, customerid
FROM customercontacts
WHERE ((type & ' . (CONTACT_MOBILE | CONTACT_DISABLED) . ') = ' . CONTACT_MOBILE . ' )
GROUP BY customerid
) x ON (x.customerid = c.id) ';
} elseif ($type == MSG_MAIL) {
$mailtable = 'JOIN (SELECT ' . $LMS->DB->GroupConcat('contact') . ' AS email, customerid
FROM customercontacts
WHERE ((type & ' . (CONTACT_EMAIL | CONTACT_DISABLED) . ') = ' . CONTACT_EMAIL . ')
GROUP BY customerid
) cc ON (cc.customerid = c.id) ';
}
if ($tarifftype) {
$tarifftable = 'JOIN (
SELECT DISTINCT a.customerid FROM assignments a
JOIN tariffs t ON t.id = a.tariffid
WHERE a.suspended = 0
AND (a.datefrom = 0 OR a.datefrom < ?NOW?)
AND (a.dateto = 0 OR a.dateto > ?NOW?)
AND t.type = ' . $tarifftype . '
) a ON a.customerid = c.id ';
}
$suspension_percentage = f_round(ConfigHelper::getConfig('finances.suspension_percentage'));
$recipients = $LMS->DB->GetAll('SELECT c.id, pin, ' . ($type == MSG_MAIL ? 'cc.email, ' : '') . ($type == MSG_SMS ? 'x.phone, ' : '') . $LMS->DB->Concat('c.lastname', "' '", 'c.name') . ' AS customername,
COALESCE(b.value, 0) AS balance
FROM customerview c
LEFT JOIN (
SELECT SUM(value) AS value, customerid
FROM cash GROUP BY customerid
) b ON (b.customerid = c.id)
LEFT JOIN (SELECT a.customerid,
SUM((CASE a.suspended
WHEN 0 THEN (((100 - a.pdiscount) * (CASE WHEN t.value IS null THEN l.value ELSE t.value END) / 100) - a.vdiscount)
ELSE ((((100 - a.pdiscount) * (CASE WHEN t.value IS null THEN l.value ELSE t.value END) / 100) - a.vdiscount) * ' . $suspension_percentage . ' / 100) END)
* (CASE t.period
WHEN ' . MONTHLY . ' THEN 1
WHEN ' . YEARLY . ' THEN 1/12.0
WHEN ' . HALFYEARLY . ' THEN 1/6.0
WHEN ' . QUARTERLY . ' THEN 1/3.0
ELSE (CASE a.period
WHEN ' . MONTHLY . ' THEN 1
WHEN ' . YEARLY . ' THEN 1/12.0
WHEN ' . HALFYEARLY . ' THEN 1/6.0
WHEN ' . QUARTERLY . ' THEN 1/3.0
ELSE 0 END)
END)
) AS value
FROM assignments a
LEFT JOIN tariffs t ON (t.id = a.tariffid)
LEFT JOIN liabilities l ON (l.id = a.liabilityid AND a.period != ' . DISPOSABLE . ')
WHERE (a.datefrom <= ?NOW? OR a.datefrom = 0) AND (a.dateto > ?NOW? OR a.dateto = 0)
GROUP BY a.customerid
) t ON (t.customerid = c.id) ' . (isset($mailtable) ? $mailtable : '') . (isset($smstable) ? $smstable : '') . ($tarifftype ? $tarifftable : '') . 'WHERE deleted = ' . $deleted . ($consent ? ' AND c.mailingnotice = 1' : '') . ($type == MSG_WWW ? ' AND c.id IN (SELECT DISTINCT ownerid FROM nodes)' : '') . ($group != 0 ? ' AND status = ' . $group : '') . ($network ? ' AND c.id IN (SELECT ownerid FROM vnodes WHERE
(netid = ' . $net['id'] . ' AND ipaddr > ' . $net['address'] . ' AND ipaddr < ' . $net['broadcast'] . ')
OR (ipaddr_pub > ' . $net['address'] . ' AND ipaddr_pub < ' . $net['broadcast'] . '))' : '') . ($customergroup ? ' AND c.id IN (SELECT customerid FROM customerassignments
WHERE customergroupid IN (' . $customergroup . '))' : '') . ($nodegroup ? ' AND c.id IN (SELECT ownerid FROM vnodes
JOIN nodegroupassignments ON (nodeid = vnodes.id)
WHERE nodegroupid = ' . $nodegroup . ')' : '') . ($linktype != '' ? ' AND c.id IN (SELECT ownerid FROM vnodes
WHERE linktype = ' . $linktype . ')' : '') . ($disabled ? ' AND EXISTS (SELECT 1 FROM vnodes WHERE ownerid = c.id
GROUP BY ownerid HAVING (SUM(access) != COUNT(access)))' : '') . ($indebted ? ' AND COALESCE(b.value, 0) < 0' : '') . ($indebted2 ? ' AND COALESCE(b.value, 0) < -t.value' : '') . ($indebted3 ? ' AND COALESCE(b.value, 0) < -t.value * 2' : '') . ($notindebted ? ' AND COALESCE(b.value, 0) >= 0' : '') . ($tarifftype ? ' AND NOT EXISTS (SELECT id FROM assignments
WHERE customerid = c.id AND tariffid = 0 AND liabilityid = 0
AND (datefrom = 0 OR datefrom < ?NOW?)
AND (dateto = 0 OR dateto > ?NOW?))' : '') . ' ORDER BY customername');
return $recipients;
}
开发者ID:Akheon23,项目名称:lms,代码行数:99,代码来源:messageadd.php
示例15: getCustomerList
//.........这里部分代码省略.........
$val = explode(':', $value);
// <doctype>:<fromdate>:<todate>
$searchargs[] = 'EXISTS (SELECT 1 FROM documents
WHERE customerid = c.id' . (!empty($val[0]) ? ' AND type = ' . intval($val[0]) : '') . (!empty($val[1]) ? ' AND cdate >= ' . intval($val[1]) : '') . (!empty($val[2]) ? ' AND cdate <= ' . intval($val[2]) : '') . ')';
break;
case 'stateid':
$searchargs[] = 'EXISTS (SELECT 1 FROM zipcodes z
WHERE z.zip = c.zip AND z.stateid = ' . intval($value) . ')';
break;
case 'tariffs':
$searchargs[] = 'EXISTS (SELECT 1 FROM assignments a
WHERE a.customerid = c.id
AND (datefrom <= ?NOW? OR datefrom = 0)
AND (dateto >= ?NOW? OR dateto = 0)
AND (tariffid IN (' . $value . ')))';
break;
case 'tarifftype':
$searchargs[] = 'EXISTS (SELECT 1 FROM assignments a
JOIN tariffs t ON t.id = a.tariffid
WHERE a.customerid = c.id
AND (datefrom <= ?NOW? OR datefrom = 0)
AND (dateto >= ?NOW? OR dateto = 0)
AND (t.type = ' . intval($value) . '))';
break;
default:
$searchar
|
请发表评论