Skip to content

Commit

Permalink
improvement: lms-payments.php: phone numer support for phone call inv… (
Browse files Browse the repository at this point in the history
#516)

* improvement: lms-payments.php: phone numer support for phone call invoice positions
  • Loading branch information
chilek authored Mar 20, 2018
1 parent 151880a commit b67eb4b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bin/lms-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,14 @@ function get_period($period) {
DISPOSABLE, $today, DAILY, WEEKLY, $weekday, MONTHLY, $dom, QUARTERLY, $quarter, HALFYEARLY, $halfyear, YEARLY, $yearday,
$currtime, $currtime));

$billing_invoice_description = ConfigHelper::getConfig('payments.billing_invoice_description', 'Phone calls between %backward_periods');
$billing_invoice_description = ConfigHelper::getConfig('payments.billing_invoice_description', 'Phone calls between %backward_periods (for %phones)');

$query = "SELECT
a.tariffid, a.customerid, a.period, a.at, a.suspended, a.settlement, a.datefrom,
a.pdiscount, a.vdiscount, a.invoice, a.separatedocument, t.description AS description, a.id AS assignmentid,
c.divisionid, c.paytype, a.paytype AS a_paytype, a.numberplanid, a.attribute,
d.inv_paytype AS d_paytype, t.period AS t_period, t.numberplanid AS tariffnumberplanid,
t.type AS tarifftype, t.taxid AS taxid, '' as prodid, voipcost.value,
t.type AS tarifftype, t.taxid AS taxid, '' as prodid, voipcost.value, voipphones.phones,
'set' AS liabilityid, '$billing_invoice_description' AS name,
(SELECT COUNT(id)
FROM assignments
Expand Down Expand Up @@ -422,6 +422,12 @@ function get_period($period) {
END)
GROUP BY va.ownerid, a2.id
) voipcost ON voipcost.customerid = a.customerid AND voipcost.assignmentid = a.id
LEFT JOIN (
SELECT vna2.assignment_id, " . $DB->GroupConcat('vn2.phone') . " AS phones
FROM voip_number_assignments vna2
LEFT JOIN voip_numbers vn2 ON vn2.id = vna2.number_id
GROUP BY vna2.assignment_id
) voipphones ON voipphones.assignment_id = a.id
LEFT JOIN tariffs t ON (a.tariffid = t.id)
LEFT JOIN divisions d ON (d.id = c.divisionid)
WHERE
Expand Down Expand Up @@ -504,6 +510,10 @@ function get_period($period) {
$desc = preg_replace("/\%period/" , $forward_periods[$p] , $desc);
$desc = preg_replace("/\%aligned_period/" , $forward_aligned_periods[$p] , $desc);

// for phone calls
if (isset($assign['phones']))
$desc = preg_replace('/\%phones/', $assign['phones'], $desc);

if ($suspension_percentage && ($assign['suspended'] || $assign['allsuspended']))
$desc .= " ".$suspension_description;

Expand Down

0 comments on commit b67eb4b

Please sign in to comment.