| 1 |
<?php |
|---|
| 2 |
include ("lib/customer.defines.php"); |
|---|
| 3 |
include ("lib/customer.module.access.php"); |
|---|
| 4 |
include ("lib/customer.smarty.php"); |
|---|
| 5 |
|
|---|
| 6 |
if (!$A2B->config["webcustomerui"]['invoice']) exit(); |
|---|
| 7 |
|
|---|
| 8 |
if (! has_rights (ACX_ACCESS)) { |
|---|
| 9 |
Header ("HTTP/1.0 401 Unauthorized"); |
|---|
| 10 |
Header ("Location: PP_error.php?c=accessdenied"); |
|---|
| 11 |
die(); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
getpost_ifset(array('id','customer', 'posted', 'Period', 'choose_currency','exporttype', 'invoice_type', 'choose_billperiod')); |
|---|
| 15 |
|
|---|
| 16 |
$customer = $_SESSION["pr_login"]; |
|---|
| 17 |
$vat = $_SESSION["vat"]; |
|---|
| 18 |
if ($invoice_type == "") { |
|---|
| 19 |
$invoice_type = 1; |
|---|
| 20 |
} |
|---|
| 21 |
if ($invoice_type == 1) { |
|---|
| 22 |
$invoice_heading = gettext("Unbilled Details"); |
|---|
| 23 |
} else { |
|---|
| 24 |
$invoice_heading = gettext("Billed Details"); |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
$FG_DEBUG = 0; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
$FG_TABLE_NAME="cc_call t1"; |
|---|
| 32 |
|
|---|
| 33 |
$DBHandle = DbConnect(); |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
$FG_TABLE_COL = array(); |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
$FG_TABLE_COL[]=array (gettext("Calldate"), "starttime", "18%", "center", "SORT", "19", "", "", "", "", "", "display_dateformat"); |
|---|
| 45 |
$FG_TABLE_COL[]=array (gettext("Source"), "src", "10%", "center", "SORT", "30"); |
|---|
| 46 |
$FG_TABLE_COL[]=array (gettext("Callednumber"), "calledstation", "18%", "right", "SORT", "30", "", "", "", "", "", ""); |
|---|
| 47 |
$FG_TABLE_COL[]=array (gettext("Destination"), "destination", "18%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix"); |
|---|
| 48 |
$FG_TABLE_COL[]=array (gettext("Duration"), "sessiontime", "8%", "center", "SORT", "30", "", "", "", "", "", "display_minute"); |
|---|
| 49 |
|
|---|
| 50 |
if (!(isset($customer) && ($customer>0)) && !(isset($entercustomer) && ($entercustomer>0))){ |
|---|
| 51 |
$FG_TABLE_COL[]=array (gettext("Cardused"), "username", "11%", "center", "SORT", "30"); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
$FG_TABLE_COL[]=array (gettext("Cost"), "sessionbill", "9%", "center", "SORT", "30", "", "", "", "", "", "display_2bill"); |
|---|
| 55 |
|
|---|
| 56 |
$FG_TABLE_DEFAULT_ORDER = "t1.starttime"; |
|---|
| 57 |
$FG_TABLE_DEFAULT_SENS = "DESC"; |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
$FG_COL_QUERY='t1.starttime, t1.src, t1.calledstation, t1.destination, t1.sessiontime '; |
|---|
| 62 |
if (!(isset($customer) && ($customer>0)) && !(isset($entercustomer) && ($entercustomer>0))){ |
|---|
| 63 |
$FG_COL_QUERY.=', t1.username'; |
|---|
| 64 |
} |
|---|
| 65 |
$FG_COL_QUERY.=', t1.sessionbill'; |
|---|
| 66 |
if (LINK_AUDIO_FILE == 'YES') { |
|---|
| 67 |
$FG_COL_QUERY .= ', t1.uniqueid'; |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
$FG_COL_QUERY_GRAPH='t1.callstart, t1.duration'; |
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
$FG_LIMITE_DISPLAY = 500; |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
$FG_NB_TABLE_COL=count($FG_TABLE_COL); |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
$FG_EDITION=true; |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
$FG_TOTAL_TABLE_COL = $FG_NB_TABLE_COL; |
|---|
| 83 |
if ($FG_DELETION || $FG_EDITION) $FG_TOTAL_TABLE_COL++; |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
$FG_HTML_TABLE_TITLE=" - Call Logs - "; |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
$FG_HTML_TABLE_WIDTH="70%"; |
|---|
| 90 |
|
|---|
| 91 |
if ($FG_DEBUG == 3) echo "<br>Table : $FG_TABLE_NAME - Col_query : $FG_COL_QUERY"; |
|---|
| 92 |
$instance_table = new Table($FG_TABLE_NAME, $FG_COL_QUERY); |
|---|
| 93 |
$instance_table_graph = new Table($FG_TABLE_NAME, $FG_COL_QUERY_GRAPH); |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
if ( is_null ($order) || is_null($sens) ) { |
|---|
| 97 |
$order = $FG_TABLE_DEFAULT_ORDER; |
|---|
| 98 |
$sens = $FG_TABLE_DEFAULT_SENS; |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
if ($posted==1) { |
|---|
| 102 |
$SQLcmd = ''; |
|---|
| 103 |
$SQLcmd = do_field($SQLcmd, 'src', 'src'); |
|---|
| 104 |
$SQLcmd = do_field($SQLcmd, 'dst', 'calledstation'); |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
$date_clause=''; |
|---|
| 109 |
|
|---|
| 110 |
$lastdayofmonth = date("t", strtotime($tostatsmonth.'-01')); |
|---|
| 111 |
|
|---|
| 112 |
if (strpos($SQLcmd, 'WHERE') > 0) { |
|---|
| 113 |
$FG_TABLE_CLAUSE = substr($SQLcmd,6).$date_clause; |
|---|
| 114 |
} elseif (strpos($date_clause, 'AND') > 0) { |
|---|
| 115 |
$FG_TABLE_CLAUSE = substr($date_clause,5); |
|---|
| 116 |
} |
|---|
| 117 |
|
|---|
| 118 |
if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND "; |
|---|
| 119 |
$FG_TABLE_CLAUSE.="t1.username='$customer'"; |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
if (strlen($FG_TABLE_CLAUSE)>0) { |
|---|
| 123 |
$FG_TABLE_CLAUSE.=" AND "; |
|---|
| 124 |
} |
|---|
| 125 |
if ($invoice_type == 1) { |
|---|
| 126 |
$FG_TABLE_CLAUSE.="t1.starttime >(Select CASE WHEN max(cover_enddate) IS NULL THEN '0001-01-01 01:00:00' ELSE max(cover_enddate) END from cc_invoices WHERE cardid = ".$_SESSION["card_id"].")"; |
|---|
| 127 |
} else { |
|---|
| 128 |
$FG_TABLE_CLAUSE.="t1.starttime >(Select cover_startdate from cc_invoices where id ='$id') AND t1.stoptime <(Select cover_enddate from cc_invoices where id ='$id') "; |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
$_SESSION["pr_sql_export"]="SELECT $FG_COL_QUERY FROM $FG_TABLE_NAME WHERE $FG_TABLE_CLAUSE"; |
|---|
| 132 |
|
|---|
| 133 |
$QUERY = "SELECT substring(t1.starttime,1,10) AS day, sum(t1.sessiontime) AS calltime, sum(t1.sessionbill) AS cost, count(*) as nbcall FROM $FG_TABLE_NAME WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(t1.starttime,1,10) ORDER BY day"; |
|---|
| 134 |
//echo "$QUERY"; exit; |
|---|
| 135 |
|
|---|
| 136 |
if (!$nodisplay) { |
|---|
| 137 |
$list_total_day = $instance_table -> SQLExec ($DBHandle, $QUERY); |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
/************************************************ DID Billing Section *********************************************/ |
|---|
| 142 |
// Fixed + Dial = 0 ; ixed = 1 ; Dail = 2 ; Free = 3 |
|---|
| 143 |
|
|---|
| 144 |
// 1. Billing Type:: All DID Calls that have DID Type 0 and 2 |
|---|
| 145 |
if ($invoice_type == 1) { |
|---|
| 146 |
$QUERY = "SELECT t1.amount, t1.creationdate, t1.description, t3.countryname, t2.did ". |
|---|
| 147 |
" FROM cc_charge t1 LEFT JOIN (cc_did t2, cc_country t3 ) ON ( t1.id_cc_did = t2.id AND t2.id_cc_country = t3.id ) ". |
|---|
| 148 |
" WHERE (t1.chargetype = 1 OR t1.chargetype = 2) AND t1.id_cc_card = ".$_SESSION["card_id"]. |
|---|
| 149 |
" AND t1.creationdate >(Select CASE WHEN max(cover_enddate) IS NULL THEN '0001-01-01 01:00:00' ELSE max(cover_enddate) END from cc_invoices)"; |
|---|
| 150 |
} else { |
|---|
| 151 |
$QUERY = "SELECT t1.amount, t1.creationdate, t1.description, t3.countryname, t2.did ". |
|---|
| 152 |
" FROM cc_charge t1 LEFT JOIN (cc_did t2, cc_country t3 ) ON ( t1.id_cc_did = t2.id AND t2.id_cc_country = t3.id ) ". |
|---|
| 153 |
" WHERE (t1.chargetype = 1 OR t1.chargetype = 2) AND t1.id_cc_card = ".$_SESSION["card_id"]. |
|---|
| 154 |
" AND t1.creationdate > (Select cover_startdate from cc_invoices where id = '$id') AND t1.creationdate < (Select cover_enddate from cc_invoices where id = '$id')"; |
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
if (!$nodisplay) { |
|---|
| 158 |
$list_total_did = $instance_table->SQLExec ($DBHandle, $QUERY); |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
|
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
if ($invoice_type == 1) { |
|---|
| 173 |
$QUERY = "SELECT t1.id_cc_card, t1.iduser, t1.creationdate, t1.amount, t1.chargetype, t1.id_cc_did, t1.currency, t1.description" . |
|---|
| 174 |
" FROM cc_charge t1, cc_card t2 WHERE (t1.chargetype <> 1 AND t1.chargetype <> 2) " . |
|---|
| 175 |
" AND t2.username = '$customer' AND t1.id_cc_card = t2.id AND t1.creationdate >= (Select CASE WHEN max(cover_enddate) is NULL " . |
|---|
| 176 |
" THEN '0001-01-01 01:00:00' ELSE max(cover_enddate) END from cc_invoices) Order by t1.creationdate"; |
|---|
| 177 |
} else { |
|---|
| 178 |
$QUERY = "SELECT t1.id_cc_card, t1.iduser, t1.creationdate, t1.amount, t1.chargetype, t1.id_cc_did, t1.currency" . |
|---|
| 179 |
" FROM cc_charge t1, cc_card t2 WHERE (t1.chargetype <> 1 AND t1.chargetype <> 2) AND" . |
|---|
| 180 |
" t2.username = '$customer' AND t1.id_cc_card = t2.id AND " . |
|---|
| 181 |
" t1.creationdate >(Select cover_startdate from cc_invoices where id ='$id') " . |
|---|
| 182 |
" AND t1.creationdate <(Select cover_enddate from cc_invoices where id ='$id')"; |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
if (!$nodisplay) { |
|---|
| 186 |
$list_total_charges = $instance_table->SQLExec ($DBHandle, $QUERY); |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
$QUERY = "SELECT destination, sum(t1.sessiontime) AS calltime, |
|---|
| 194 |
sum(t1.sessionbill) AS cost, count(*) as nbcall FROM $FG_TABLE_NAME WHERE ".$FG_TABLE_CLAUSE." GROUP BY destination"; |
|---|
| 195 |
|
|---|
| 196 |
if (!$nodisplay) { |
|---|
| 197 |
$list_total_destination = $instance_table->SQLExec ($DBHandle, $QUERY); |
|---|
| 198 |
} |
|---|
| 199 |
|
|---|
| 200 |
if ($nb_record<=$FG_LIMITE_DISPLAY) { |
|---|
| 201 |
$nb_record_max=1; |
|---|
| 202 |
} else { |
|---|
| 203 |
if ($nb_record % $FG_LIMITE_DISPLAY == 0) { |
|---|
| 204 |
$nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)); |
|---|
| 205 |
} else { |
|---|
| 206 |
$nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)+1); |
|---|
| 207 |
} |
|---|
| 208 |
} |
|---|
| 209 |
if ($FG_DEBUG == 3) echo "<br>Nb_record : $nb_record"; |
|---|
| 210 |
if ($FG_DEBUG == 3) echo "<br>Nb_record_max : $nb_record_max"; |
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
|
|---|
| 214 |
if ((isset($customer) && ($customer>0)) || (isset($entercustomer) && ($entercustomer>0))){ |
|---|
| 215 |
|
|---|
| 216 |
$FG_TABLE_CLAUSE = ""; |
|---|
| 217 |
if (isset($customer) && ($customer>0)){ |
|---|
| 218 |
$FG_TABLE_CLAUSE =" username='$customer' "; |
|---|
| 219 |
}elseif (isset($entercustomer) && ($entercustomer>0)){ |
|---|
| 220 |
$FG_TABLE_CLAUSE =" username='$entercustomer' "; |
|---|
| 221 |
} |
|---|
| 222 |
$instance_table_customer = new Table("cc_card", "id, username, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, activated, creationdate"); |
|---|
| 223 |
$info_customer = $instance_table_customer -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, "id", "ASC", null, null, null, null); |
|---|
| 224 |
} |
|---|
| 225 |
|
|---|
| 226 |
if($invoice_type == 2) { |
|---|
| 227 |
$QUERY = "Select t1.invoicecreated_date from cc_invoices t1, cc_card t2 where t2.id = t1.cardid and t2.username = '$customer' order by t1.invoicecreated_date"; |
|---|
| 228 |
|
|---|
| 229 |
$res = $DBHandle -> Execute($QUERY); |
|---|
| 230 |
if ($res){ |
|---|
| 231 |
$total_invoices = $res -> RecordCount(); |
|---|
| 232 |
if ($total_invoices > 0) |
|---|
| 233 |
{ |
|---|
| 234 |
$billperiod_list = $res; |
|---|
| 235 |
} |
|---|
| 236 |
} |
|---|
| 237 |
} |
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 |
if($invoice_type == 1) { |
|---|
| 241 |
$QUERY = "Select CASE WHEN max(cover_enddate) is NULL THEN '0001-01-01 01:00:00' ELSE max(cover_enddate) END from cc_invoices WHERE cardid = ".$cardid; |
|---|
| 242 |
} else { |
|---|
| 243 |
$QUERY = "Select cover_enddate, cover_startdate from cc_invoices where id ='$id'"; |
|---|
| 244 |
} |
|---|
| 245 |
|
|---|
| 246 |
if (!$nodisplay) { |
|---|
| 247 |
$invoice_dates = $instance_table->SQLExec ($DBHandle, $QUERY); |
|---|
| 248 |
if ($invoice_dates[0][0] == '0001-01-01 01:00:00') { |
|---|
| 249 |
$invoice_dates[0][0] = $info_customer[0][13]; |
|---|
| 250 |
} |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
$smarty->display( 'main.tpl'); |
|---|
| 255 |
$currencies_list = get_currencies(); |
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
$totalcost = 0; |
|---|
| 260 |
$totalcallmade = 0; |
|---|
| 261 |
|
|---|
| 262 |
$totalcost_did = $totalcost; |
|---|
| 263 |
if (is_array($list_total_destination) && count($list_total_destination)>0) |
|---|
| 264 |
{ |
|---|
| 265 |
$totalcallmade = $totalcallmade + count($list_total_destination); |
|---|
| 266 |
$mmax=0; |
|---|
| 267 |
$totalcall=0; |
|---|
| 268 |
$totalminutes=0; |
|---|
| 269 |
foreach ($list_total_destination as $data){ |
|---|
| 270 |
if ($mmax < $data[1]) $mmax=$data[1]; |
|---|
| 271 |
$totalcall+=$data[3]; |
|---|
| 272 |
$totalminutes+=$data[1]; |
|---|
| 273 |
$totalcost+=$data[2]; |
|---|
| 274 |
} |
|---|
| 275 |
} |
|---|
| 276 |
|
|---|
| 277 |
?> |
|---|
| 278 |
|
|---|
| 279 |
<table cellspacing="0" class="invoice_main_table"> |
|---|
| 280 |
|
|---|
| 281 |
<tr> |
|---|
| 282 |
<td class="invoice_heading"><?php echo $invoice_heading; ?></td> |
|---|
| 283 |
</tr> |
|---|
| 284 |
<tr> |
|---|
| 285 |
<td valign="top"><table width="60%" align="left" cellpadding="0" cellspacing="0"> |
|---|
| 286 |
<tr> |
|---|
| 287 |
<td width="35%"> </td> |
|---|
| 288 |
<td width="65%"> </td> |
|---|
| 289 |
</tr> |
|---|
| 290 |
<tr> |
|---|
| 291 |
<td width="35%" class="invoice_td"><?php echo gettext("Name")?> : </td> |
|---|
| 292 |
<td width="65%" class="invoice_td"><?php echo $info_customer[0][3] ." ".$info_customer[0][2] ?></td> |
|---|
| 293 |
</tr> |
|---|
| 294 |
<tr> |
|---|
| 295 |
<td width="35%" class="invoice_td"><?php echo gettext("Card Number")?> :</td> |
|---|
| 296 |
<td width="65%" class="invoice_td"><?php echo $info_customer[0][1] ?> </td> |
|---|
| 297 |
</tr> |
|---|
| 298 |
<?php |
|---|
| 299 |
if ($invoice_type == 1){ |
|---|
| 300 |
?> |
|---|
| 301 |
<tr> |
|---|
| 302 |
<td width="35%" class="invoice_td"><?php echo gettext("From Date");?> :</td> |
|---|
| 303 |
<td width="65%" class="invoice_td"><?php echo display_GMT($invoice_dates[0][0], $_SESSION["gmtoffset"], 0);?> </td> |
|---|
| 304 |
</tr> |
|---|
| 305 |
<?php }else{ ?> |
|---|
| 306 |
<tr> |
|---|
| 307 |
<td width="35%" class="invoice_td"><?php echo gettext("From Date");?> :</td> |
|---|
| 308 |
<td width="65%" class="invoice_td"><?php echo display_GMT($invoice_dates[0][0], $_SESSION["gmtoffset"], 0);?> </td> |
|---|
| 309 |
</tr> |
|---|
| 310 |
<tr> |
|---|
| 311 |
<td width="35%" class="invoice_td"><?php echo gettext("To Date");?> :</td> |
|---|
| 312 |
<td width="65%" class="invoice_td"><?php echo display_GMT($invoice_dates[0][0], $_SESSION["gmtoffset"], 0);?></td> |
|---|
| 313 |
</tr> |
|---|
| 314 |
<?php } ?> |
|---|
| 315 |
<tr> |
|---|
| 316 |
<td > </td> |
|---|
| 317 |
<td > </td> |
|---|
| 318 |
</tr> |
|---|
| 319 |
</table></td> |
|---|
| 320 |
</tr> |
|---|
| 321 |
|
|---|
| 322 |
<tr> |
|---|
| 323 |
<td align="right"> |
|---|
| 324 |
<a href="A2B_entity_invoice_detail_pdf.php?exporttype=pdf&id=<?php echo $id; ?>&cardid=<?php echo $cardid; ?>&invoice_type=<?php echo $invoice_type; ?>"><img src="<?php echo Images_Path;?>/pdf.gif" height="20" width="20" title="Download as PDF."> </a> |
|---|
| 325 |
</td> |
|---|
| 326 |
</tr> |
|---|
| 327 |
|
|---|
| 328 |
<tr> |
|---|
| 329 |
<td valign="top"><table width="100%" align="left" cellpadding="0" cellspacing="0"> |
|---|
| 330 |
<?php |
|---|
| 331 |
if (is_array($list_total_destination) && count($list_total_destination)>0) |
|---|
| 332 |
{ |
|---|
| 333 |
?> |
|---|
| 334 |
<tr> |
|---|
| 335 |
<td colspan="5" align="center"><font></font> <b><?php echo gettext("Calls by Destination")?></b></font> </td> |
|---|
| 336 |
</tr> |
|---|
| 337 |
|
|---|
| 338 |
<tr class="invoice_subheading"> |
|---|
| 339 |
<td class="invoice_td" width="29%"><?php echo gettext("Destination")?> </td> |
|---|
| 340 |
<td width="19%" class="invoice_td"><?php echo gettext("Duration")?> </td> |
|---|
| 341 |
<td width="20%" class="invoice_td"><?php echo gettext("Graphic")?> </td> |
|---|
| 342 |
<td width="11%" class="invoice_td"><?php echo gettext("Calls")?> </td> |
|---|
| 343 |
<td width="21%" class="invoice_td" align="right"><?php echo gettext("Amount")." (".BASE_CURRENCY.")"; ?> </td> |
|---|
| 344 |
</tr> |
|---|
| 345 |
<?php |
|---|
| 346 |
$i=0; |
|---|
| 347 |
|
|---|
| 348 |
foreach ($list_total_destination as $data){ |
|---|
| 349 |
$i=($i+1)%2; |
|---|
| 350 |
$tmc = $data[1]/$data[3]; |
|---|
| 351 |
|
|---|
| 352 |
if ((!isset($resulttype)) || ($resulttype=="min")){ |
|---|
| 353 |
$tmc = sprintf("%02d",intval($tmc/60)).":".sprintf("%02d",intval($tmc%60)); |
|---|
| 354 |
}else{ |
|---|
| 355 |
|
|---|
| 356 |
$tmc =intval($tmc); |
|---|
| 357 |
} |
|---|
| 358 |
|
|---|
| 359 |
if ((!isset($resulttype)) || ($resulttype=="min")){ |
|---|
| 360 |
$minutes = sprintf("%02d",intval($data[1]/60)).":".sprintf("%02d",intval($data[1]%60)); |
|---|
| 361 |
}else{ |
|---|
| 362 |
$minutes = $data[1]; |
|---|
| 363 |
} |
|---|
| 364 |
if ($mmax>0) $widthbar= intval(($data[1]/$mmax)*200); |
|---|
| 365 |
|
|---|
| 366 |
?> |
|---|
| 367 |
<tr class="invoice_rows"> |
|---|
| 368 |
<td width="29%" class="invoice_td"><?php echo $data[0]?></td> |
|---|
| 369 |
<td width="19%" class="invoice_td"><?php echo $minutes?> </td> |
|---|
| 370 |
<td width="20%" class="invoice_td"><img src="<?php echo Images_Path_Main ?>/sidenav-selected.gif" height="6" width="<?php echo $widthbar?>"> </td> |
|---|
| 371 |
<td width="11%" class="invoice_td"><?php echo $data[3]?> </td> |
|---|
| 372 |
<td width="21%" align="right" class="invoice_td"><?php display_2bill($data[2]) ?></td> |
|---|
| 373 |
</tr> |
|---|
| 374 |
<?php } |
|---|
| 375 |
|
|---|
| 376 |
if ((!isset($resulttype)) || ($resulttype=="min")){ |
|---|
| 377 |
$total_tmc = sprintf("%02d",intval(($totalminutes/$totalcall)/60)).":".sprintf("%02d",intval(($totalminutes/$totalcall)%60)); |
|---|
| 378 |
$totalminutes = sprintf("%02d",intval($totalminutes/60)).":".sprintf("%02d",intval($totalminutes%60)); |
|---|
| 379 |
}else{ |
|---|
| 380 |
$total_tmc = intval($totalminutes/$totalcall); |
|---|
| 381 |
} |
|---|
| 382 |
?> |
|---|
| 383 |
<tr > |
|---|
| 384 |
<td width="29%" class="invoice_td"> </td> |
|---|
| 385 |
<td width="19%" class="invoice_td"> </td> |
|---|
| 386 |
<td width="20%" class="invoice_td"> </td> |
|---|
| 387 |
<td width="11%" class="invoice_td"> </td> |
|---|
| 388 |
<td width="21%" class="invoice_td"> </td> |
|---|
| 389 |
|
|---|
| 390 |
</tr> |
|---|
| 391 |
<tr class="invoice_subheading"> |
|---|
| 392 |
<td width="29%" class="invoice_td"><?php echo gettext("TOTAL");?> </td> |
|---|
| 393 |
<td width="39%" class="invoice_td"colspan="2"><?php echo $totalminutes?></td> |
|---|
| 394 |
<td width="11%" class="invoice_td"><?php echo $totalcall?> </td> |
|---|
| 395 |
<td width="21%" align="right" class="invoice_td"><?php display_2bill($totalcost -$totalcost_did) ?> </td> |
|---|
| 396 |
</tr> |
|---|
| 397 |
|
|---|
| 398 |
<tr > |
|---|
| 399 |
<td width="29%"> </td> |
|---|
| 400 |
<td width="19%"> </td> |
|---|
| 401 |
<td width="20%"> </td> |
|---|
| 402 |
<td width="11%"> </td> |
|---|
| 403 |
<td width="21%"> </td> |
|---|
| 404 |
|
|---|
| 405 |
</tr> |
|---|
| 406 |
<?php }?> |
|---|
| 407 |
<!-- Start Here ****************************************--> |
|---|
| 408 |
<?php |
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
$mmax=0; |
|---|
| 412 |
$totalcall=0; |
|---|
| 413 |
$totalminutes=0; |
|---|
| 414 |
$totalcost_day=0; |
|---|
| 415 |
if (is_array($list_total_day) && count($list_total_day) > 0) |
|---|
| 416 |
{ |
|---|
| 417 |
foreach ($list_total_day as $data){ |
|---|
| 418 |
if ($mmax < $data[1]) $mmax=$data[1]; |
|---|
| 419 |
$totalcall+=$data[3]; |
|---|
| 420 |
$totalminutes+=$data[1]; |
|---|
| 421 |
$totalcost_day+=$data[2]; |
|---|
| 422 |
} |
|---|
| 423 |
?> |
|---|
| 424 |
<tr> |
|---|
| 425 |
<td colspan="5" align="center"><b><?php echo gettext("Calls by Date")?></b> </td> |
|---|
| 426 |
</tr> |
|---|
| 427 |
<tr class="invoice_subheading"> |
|---|
| 428 |
<td class="invoice_td" width="29%"><?php echo gettext("Date")?> </td> |
|---|
| 429 |
<td width="19%" class="invoice_td"><?php echo gettext("Duration")?> </td> |
|---|
| 430 |
<td width="20%" class="invoice_td"><?php echo gettext("Graphic")?> </td> |
|---|
| 431 |
<td width="11%" class="invoice_td"><?php echo gettext("Calls")?> </td> |
|---|
| 432 |
<td width="21%" class="invoice_td" align="right"><?php echo gettext("Amount" |
|---|