diff --git a/billing-calculate.php b/billing-calculate.php index 246bcc25a..dd730f6c1 100755 --- a/billing-calculate.php +++ b/billing-calculate.php @@ -13,7 +13,6 @@ if (isset($options['r'])) { echo("Clearing history table.\n"); mysql_query("TRUN foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_id`") as $bill) { - echo(str_pad($bill['bill_id']." ".$bill['bill_name'], 30)." \n"); $i=0; @@ -32,9 +31,8 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_id`") as $bill) $date_updated = str_replace("-", "", str_replace(":", "", str_replace(" ", "", $check['updated']))); - if($period > 0 && $dateto > $date_updated) + if ($period > 0 && $dateto > $date_updated) { - $rate_data = getRates($bill['bill_id'],$datefrom,$dateto); $rate_95th = $rate_data['rate_95th']; $dir_95th = $rate_data['dir_95th']; @@ -51,20 +49,20 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_id`") as $bill) $overuse = $used - $allowed; $overuse = (($overuse <= 0) ? "0" : $overuse); $percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2); - } elseif ($bill['bill_type'] == "quota") { $type = "Quota"; $allowed = $bill['bill_quota']; $used = $rate_data['total_data']; $allowed_text = format_bytes_billing($allowed); - $used_text = format_bytes_billing($used); + $used_text = format_bytes_billing($used); $overuse = $used - $allowed; $overuse = (($overuse <= 0) ? "0" : $overuse); $percent = round(($rate_data['total_data'] / $bill['bill_quota']) * 100,2); } + echo(strftime("%x @ %X", strtotime($datefrom))." to ".strftime("%x @ %X", strtotime($dateto))." ".str_pad($type,8)." ".str_pad($allowed_text,10)." ".str_pad($used_text,10)." ".$percent."%"); - if($i == '0') + if ($i == '0') { $update = array('rate_95th' => $rate_data['rate_95th'], 'rate_95th_in' => $rate_data['rate_95th_in'], @@ -82,8 +80,8 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_id`") as $bill) echo(" Updated! "); } - if ($check['bill_id'] == $bill['bill_id']) { - + if ($check['bill_id'] == $bill['bill_id']) + { $update = array('rate_95th' => $rate_data['rate_95th'], 'rate_95th_in' => $rate_data['rate_95th_in'], 'rate_95th_out' => $rate_data['rate_95th_out'], @@ -101,7 +99,6 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_id`") as $bill) dbUpdate($update, 'bill_history', '`bill_hist_id` = ?', array($check['bill_hist_id'])); echo(" Updated history! "); - } else { $update = array('rate_95th' => $rate_data['rate_95th'], 'rate_95th_in' => $rate_data['rate_95th_in'], @@ -120,7 +117,7 @@ foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_id`") as $bill) 'bill_used' => $used, 'bill_overuse' => $overuse, 'bill_percent' => $percent, - 'bill_datefrom' => $datefrom, + 'bill_datefrom' => $datefrom, 'bill_dateto' => $dateto, 'bill_id' => $bill['bill_id'] ); dbInsert($update, 'bill_history'); diff --git a/check-services.php b/check-services.php index b9e619ac6..32648028e 100755 --- a/check-services.php +++ b/check-services.php @@ -1,5 +1,6 @@ #!/usr/bin/env php