Exemple #1
0
}
$userlist = $DB->GetAll('SELECT hc.id AS id, hc.ext_billing_id AS id_ext, ' . $DB->Year('hc.create_date') . ' AS create_year, ' . $DB->Month('hc.create_date') . ' AS create_month, ' . $DB->Day('hc.create_date') . ' AS create_day ' . ' FROM hv_customers hc 
			JOIN hv_assign ha ON (ha.customerid = hc.id) 
			WHERE ha.keytype = ? AND ha.keyvalue = ? ', array('issue_invoice', '2'));
$count_u = sizeof($userlist);
$rok = intval(date('Y', strtotime('-' . $leftmonth . ' month')));
$msc = intval(date('m', strtotime('-' . $leftmonth . ' month')));
$taxid = $DB->GetOne('SELECT id FROM taxes WHERE value=? ' . $DB->Limit('1') . ' ;', array(intval(get_conf('hiperus_c5.taxrate', get_conf('phpui.default_taxrate', 23)))));
$mscstr = array('', 'Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień');
$vat = intval(get_conf('hiperus_c5.taxrate', get_conf('phpui.default_taxrate', 23))) / 100 + 1;
for ($i = 0; $i < $count_u; $i++) {
    $userlist[$i]['rok'] = $rok;
    $userlist[$i]['miesiac'] = $msc;
    $userlist[$i]['sum_cost'] = 0;
    $userlist[$i]['terminal'] = array();
    $userlist[$i]['numberplanid'] = get_conf('hiperus_c5.numberplanid', $LMS->GetDefaultNumberPlanIDByCustomer($userlist[$i]['id_ext'], DOC_INVOICE));
    $terminalinfo = $HIPERUS->GetTerminalOneOrList(NULL, $userlist[$i]['id']);
    $count_t = sizeof($terminalinfo);
    for ($j = 0; $j < $count_t; $j++) {
        $userlist[$i]['terminal'][$j]['pricelist_name'] = $terminalinfo[$j]['pricelist_name'];
        $userlist[$i]['terminal'][$j]['name'] = $terminalinfo[$j]['username'];
        $userlist[$i]['terminal'][$j]['invoice_value'] = $DB->GetOne('SELECT invoice_value FROM hv_subscriptionlist WHERE id=? LIMIT 1 ;', array(intval($terminalinfo[$j]['id_subscription'])));
        $cost = $HIPERUS->GetListBillingByCustomer2($userlist[$i]['id'], $rok, $msc, $terminalinfo[$j]['username']);
        $userlist[$i]['terminal'][$j]['cost'] = $cost[0]['cost'] ? $cost[0]['cost'] : 0;
        $userlist[$i]['sum_cost'] += ($userlist[$i]['terminal'][$j]['invoice_value'] + $userlist[$i]['terminal'][$j]['cost']) * $vat;
        $userlist[$i]['content'][] = array('valuebrutto' => $userlist[$i]['terminal'][$j]['invoice_value'] * $vat, 'taxid' => $taxid, 'prodid' => get_conf('hiperus_c5.prodid', ''), 'jm' => get_conf('hiperus_c5.content', 'szt'), 'count' => '1', 'discount' => '0', 'pdiscount' => '0', 'vdiscount' => '0', 'name' => 'Abonament VoIP : ' . $userlist[$i]['terminal'][$j]['pricelist_name'] . ' za okres ' . $mscstr[$msc] . ' ' . $rok, 'tariffid' => 0);
        $userlist[$i]['content'][] = array('valuebrutto' => $userlist[$i]['terminal'][$j]['cost'] * $vat, 'taxid' => $taxid, 'prodid' => get_conf('hiperus_c5.prodid', ''), 'jm' => get_conf('hiperus_c5.content', 'szt'), 'count' => '1', 'discount' => '0', 'pdiscount' => '0', 'vdiscount' => '0', 'name' => 'Koszt rozmów poza abonamentem ' . $userlist[$i]['terminal'][$j]['pricelist_name'], 'tariffid' => 0);
    }
    unset($userlist[$i]['terminal']);
}
//end for