| 
									
										
										
										
											2010-06-21 04:18:06 +00:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  | $bill_id = mres($vars['bill_id']); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  | if ($_SESSION['userlevel'] >= "10") | 
					
						
							| 
									
										
										
										
											2010-09-26 22:10:04 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   include("pages/bill/actions.inc.php"); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (bill_permitted($bill_id)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-12-02 22:11:06 +00:00
										 |  |  |   $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |   $bill_name = $bill_data['bill_name']; | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-13 13:52:01 +00:00
										 |  |  |   $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()")); | 
					
						
							|  |  |  |   $yesterday = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)")); | 
					
						
							|  |  |  |   $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)")); | 
					
						
							|  |  |  |   $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)")); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   $rightnow = $today . date(His); | 
					
						
							|  |  |  |   $before = $yesterday . date(His); | 
					
						
							|  |  |  |   $lastmonth = $last_month . date(His); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   $bill_name  = $bill_data['bill_name']; | 
					
						
							|  |  |  |   $dayofmonth = $bill_data['bill_day']; | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   $day_data     = getDates($dayofmonth); | 
					
						
							| 
									
										
										
										
											2011-09-05 17:09:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   $datefrom     = $day_data['0']; | 
					
						
							|  |  |  |   $dateto       = $day_data['1']; | 
					
						
							| 
									
										
										
										
											2011-12-02 22:11:06 +00:00
										 |  |  |   $lastfrom     = $day_data['2']; | 
					
						
							|  |  |  |   $lastto       = $day_data['3']; | 
					
						
							| 
									
										
										
										
											2011-09-12 10:51:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-03 12:26:45 +00:00
										 |  |  |   $rate_95th    = $bill_data['rate_95th']; | 
					
						
							|  |  |  |   $dir_95th     = $bill_data['dir_95th']; | 
					
						
							|  |  |  |   $total_data   = $bill_data['total_data']; | 
					
						
							|  |  |  |   $rate_average = $bill_data['rate_average']; | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if ($rate_95th > $paid_kb) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     $over = $rate_95th - $paid_kb; | 
					
						
							|  |  |  |     $bill_text = $over . "Kbit excess."; | 
					
						
							|  |  |  |     $bill_color = "#cc0000"; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     $under = $paid_kb - $rate_95th; | 
					
						
							|  |  |  |     $bill_text = $under . "Kbit headroom."; | 
					
						
							|  |  |  |     $bill_color = "#0000cc"; | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-13 13:52:01 +00:00
										 |  |  |   $fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"); | 
					
						
							|  |  |  |   $totext   = dbFetchCell("SELECT DATE_FORMAT($dateto, '%M %D %Y')"); | 
					
						
							|  |  |  |   $unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')"); | 
					
						
							|  |  |  |   $unixto   = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')"); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-20 09:55:11 +00:00
										 |  |  |   $unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')"); | 
					
						
							| 
									
										
										
										
											2011-05-13 13:52:01 +00:00
										 |  |  |   $unix_prev_to   = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')"); | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |   # Speeds up loading for other included pages by setting it before progessing of mysql data!
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   $ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
 | 
					
						
							| 
									
										
										
										
											2012-05-16 13:25:50 +00:00
										 |  |  |                         WHERE B.bill_id = ? AND P.port_id = B.port_id | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |                         AND D.device_id = P.device_id", array($bill_id));
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   echo("<font face=\"Verdana, Arial, Sans-Serif\"><h2>
 | 
					
						
							| 
									
										
										
										
											2011-12-02 18:51:47 +00:00
										 |  |  |   Bill : " . $bill_data['bill_name'] . "</h2>");
 | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   print_optionbar_start(); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |   echo("<span style='font-weight: bold;'>Bill</span> » "); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   if (!$vars['view']) { $vars['view'] = "quick"; } | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |   if ($vars['view'] == "quick") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   echo('<a href="'.generate_url($vars, array('view' => 'quick')).'">Quick Graphs</a>'); | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |   if ($vars['view'] == "quick") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2011-09-12 10:51:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   echo(" | "); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |   if ($vars['view'] == "accurate") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   echo('<a href="'.generate_url($vars, array('view' => 'accurate')).'">Accurate Graphs</a>'); | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |   if ($vars['view'] == "accurate") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |   echo(" | "); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   if ($vars['view'] == "transfer") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							|  |  |  |   echo('<A href="'.generate_url($vars, array('view' => 'transfer')).'">Transfer Graphs</a>'); | 
					
						
							|  |  |  |   if ($vars['view'] == "transfer") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2011-11-30 12:45:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   echo(" | "); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   if ($vars['view'] == "history") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							|  |  |  |   echo('<A href="'.generate_url($vars, array('view' => 'history')).'">Historical Usage</a>'); | 
					
						
							|  |  |  |   if ($vars['view'] == "history") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  |   if ($_SESSION['userlevel'] >= "10") | 
					
						
							| 
									
										
										
										
											2010-08-01 17:09:13 +00:00
										 |  |  |   { | 
					
						
							|  |  |  |     echo(" | "); | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |     if ($vars['view'] == "edit") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							|  |  |  |     echo('<A href="'.generate_url($vars, array('view' => 'edit')).'">Edit</a>'); | 
					
						
							|  |  |  |     if ($vars['view'] == "edit") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2010-09-26 22:10:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     echo(" | "); | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |     if ($vars['view'] == "delete") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							| 
									
										
										
										
											2012-03-18 16:23:49 +00:00
										 |  |  |     echo('<A href="'.generate_url($vars, array('view' => 'delete')).'">Delete</a>'); | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |     if ($vars['view'] == "delete") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2012-03-18 16:23:49 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     echo(" | "); | 
					
						
							|  |  |  |     if ($vars['view'] == "reset") { echo("<span class='pagemenu-selected'>"); } | 
					
						
							|  |  |  |     echo('<A href="'.generate_url($vars, array('view' => 'reset')).'">Reset</a>'); | 
					
						
							|  |  |  |     if ($vars['view'] == "reset") { echo("</span>"); } | 
					
						
							| 
									
										
										
										
											2010-08-01 17:09:13 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   echo('<div style="font-weight: bold; float: right;"><a href="'.generate_url(array('page' => "bills")).'/"><img align=absmiddle src="/images/16/arrow_left.png"> Back to Bills</a></div>'); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |   print_optionbar_end(); | 
					
						
							| 
									
										
										
										
											2010-09-26 22:10:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  |   if ($vars['view'] == "edit" && $_SESSION['userlevel'] >= "10") | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  |   { | 
					
						
							|  |  |  |     include("pages/bill/edit.inc.php"); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  |   elseif ($vars['view'] == "delete" && $_SESSION['userlevel'] >= "10") | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2010-09-26 22:10:04 +00:00
										 |  |  |     include("pages/bill/delete.inc.php"); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  |   elseif ($vars['view'] == "reset" && $_SESSION['userlevel'] >= "10") | 
					
						
							| 
									
										
										
										
											2012-03-18 16:23:49 +00:00
										 |  |  |   { | 
					
						
							|  |  |  |     include("pages/bill/reset.inc.php"); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   elseif ($vars['view'] == "history") | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     include("pages/bill/history.inc.php"); | 
					
						
							| 
									
										
										
										
											2011-11-30 12:45:46 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   elseif ($vars['view'] == "transfer") | 
					
						
							| 
									
										
										
										
											2011-11-30 12:45:46 +00:00
										 |  |  |   { | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |     include("pages/bill/transfer.inc.php"); | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |   elseif ($vars['view'] == "quick" || $vars['view'] == "accurate") { | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     echo("<h3>Billed Ports</h3>"); | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-25 12:24:34 +00:00
										 |  |  |     // Collected Earlier
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     foreach ($ports as $port) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       echo(generate_port_link($port) . " on " . generate_device_link($port) . "<br />"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     echo("<h3>Bill Summary</h3>"); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     if ($bill_data['bill_type'] == "quota") | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-12-07 13:52:46 +00:00
										 |  |  |       // The Customer is billed based on a pre-paid quota with overage in xB
 | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       echo("<h4>Quota Bill</h4>"); | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |       $percent = round(($total_data) / $bill_data['bill_quota'] * 100, 2); | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $unit = "MB"; | 
					
						
							|  |  |  |       $total_data = round($total_data, 2); | 
					
						
							| 
									
										
										
										
											2011-12-07 14:48:04 +00:00
										 |  |  |       echo("Billing Period from " . $fromtext . " to " . $totext); | 
					
						
							|  |  |  |       echo("<br />Transferred ".format_bytes_billing($total_data)." of ".format_bytes_billing($bill_data['bill_quota'])." (".$percent."%)"); | 
					
						
							|  |  |  |       echo("<br />Average rate " . formatRates($rate_average)); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $background = get_percentage_colours($percent); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-07 13:52:46 +00:00
										 |  |  |       echo("<p>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</p>"); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $type="&ave=yes"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     elseif ($bill_data['bill_type'] == "cdr") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       // The customer is billed based on a CDR with 95th%ile overage
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       echo("<h4>CDR / 95th Bill</h4>"); | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $unit = "kbps"; | 
					
						
							| 
									
										
										
										
											2011-12-07 13:52:46 +00:00
										 |  |  |       $cdr = $bill_data['bill_cdr']; | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $rate_95th = round($rate_95th, 2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $percent = round(($rate_95th) / $cdr * 100, 2); | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $type="&95th=yes"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       echo("<strong>" . $fromtext . " to " . $totext . "</strong>
 | 
					
						
							| 
									
										
										
										
											2011-12-07 13:52:46 +00:00
										 |  |  |       <br />Measured ".format_si($rate_95th)."bps of ".format_si($cdr)."bps (".$percent."%) @ 95th %ile");
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-07 13:52:46 +00:00
										 |  |  |       $background = get_percentage_colours($percent); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-07 13:52:46 +00:00
										 |  |  |       echo("<p>".print_percentage_bar (350, 20, $percent, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</p>"); | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       #  echo("<p>Billing Period : " . $fromtext . " to " . $totext . "<br />
 | 
					
						
							|  |  |  |       #  " . $paidrate_text . " <br />
 | 
					
						
							|  |  |  |       #  " . $total_data . "MB transfered in the current billing cycle. <br />
 | 
					
						
							|  |  |  |       #  " . $rate_average . "Kbps Average during the current billing cycle. </p>
 | 
					
						
							|  |  |  |       #  <font face=\"Trebuchet MS, Verdana, Arial, Sans-Serif\" color=" . $bill_color . "><B>" . $rate_95th . "Kbps @ 95th Percentile.</b> (" . $dir_95th . ") (" . $bill_text . ")</font>
 | 
					
						
							|  |  |  |       #  </td><td><img src=\"images/billing-key.png\"></td></tr></table>
 | 
					
						
							|  |  |  |       #  <br />");
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"); | 
					
						
							|  |  |  |     $yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"); | 
					
						
							|  |  |  |     $rightnow = date(U); | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 17:11:28 +00:00
										 |  |  |     if ($vars['view'] == "accurate") { | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-02 15:53:50 +00:00
										 |  |  |       $bi  = "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code']; | 
					
						
							|  |  |  |       $bi .= "&from=" . $unixfrom .  "&to=" . $unixto; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  | //    $bi .= "&x=800&y=250";
 | 
					
						
							| 
									
										
										
										
											2011-12-02 15:53:50 +00:00
										 |  |  |       $bi .= "&x=1190&y=250"; | 
					
						
							|  |  |  |       $bi .= "$type'>"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $li  = "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code']; | 
					
						
							|  |  |  |       $li .= "&from=" . $unix_prev_from .  "&to=" . $unix_prev_to; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  | //    $li .= "&x=800&y=250";
 | 
					
						
							| 
									
										
										
										
											2011-12-02 15:53:50 +00:00
										 |  |  |       $li .= "&x=1190&y=250"; | 
					
						
							|  |  |  |       $li .= "$type'>"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $di  = "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code']; | 
					
						
							|  |  |  |       $di .= "&from=" . $config['time']['day'] .  "&to=" . $config['time']['now']; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  | //    $di .= "&x=800&y=250";
 | 
					
						
							| 
									
										
										
										
											2011-12-02 15:53:50 +00:00
										 |  |  |       $di .= "&x=1190&y=250"; | 
					
						
							|  |  |  |       $di .= "$type'>"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       $mi  = "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code']; | 
					
						
							|  |  |  |       $mi .= "&from=" . $lastmonth .  "&to=" . $rightnow; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  | //    $mi .= "&x=800&y=250";
 | 
					
						
							| 
									
										
										
										
											2011-12-02 15:53:50 +00:00
										 |  |  |       $mi .= "&x=1190&y=250"; | 
					
						
							|  |  |  |       $mi .= "$type'>"; | 
					
						
							| 
									
										
										
										
											2011-04-08 11:25:13 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2011-09-08 02:57:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $bi = "<img src='graph.php?type=bill_bits&id=" . $bill_id; | 
					
						
							|  |  |  |       $bi .= "&from=" . $unixfrom .  "&to=" . $unixto; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |       $bi .= "&width=1000&height=200&total=1'>"; | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $li = "<img src='graph.php?type=bill_bits&id=" . $bill_id; | 
					
						
							|  |  |  |       $li .= "&from=" . $unix_prev_from .  "&to=" . $unix_prev_to; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |       $li .= "&width=1000&height=200&total=1'>"; | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $di = "<img src='graph.php?type=bill_bits&id=" . $bill_id; | 
					
						
							|  |  |  |       $di .= "&from=" . $config['time']['day'] .  "&to=" . $config['time']['now']; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |       $di .= "&width=1000&height=200&total=1'>"; | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |       $mi = "<img src='graph.php?type=bill_bits&id=" . $bill_id; | 
					
						
							|  |  |  |       $mi .= "&from=" . $lastmonth .  "&to=" . $rightnow; | 
					
						
							| 
									
										
										
										
											2011-12-06 22:17:37 +00:00
										 |  |  |       $mi .= "&width=1000&height=200&total=1'>"; | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-09-12 10:51:50 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     if ($null) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       echo("
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   <script type='text/javascript' src='js/calendarDateInput.js'> | 
					
						
							|  |  |  |   </script> | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   <FORM action='/' method='get'> | 
					
						
							|  |  |  |     <INPUT type='hidden' name='bill' value='".$_GET['bill']."'> | 
					
						
							|  |  |  |     <INPUT type='hidden' name='code' value='".$_GET['code']."'> | 
					
						
							|  |  |  |     <INPUT type='hidden' name='page' value='bills'> | 
					
						
							|  |  |  |     <INPUT type='hidden' name='custom' value='yes'> | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     From: | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |     <script>DateInput('fromdate', true, 'YYYYMMDD')</script> | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     To: | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |     <script>DateInput('todate', true, 'YYYYMMDD')</script> | 
					
						
							|  |  |  |     <INPUT type='submit' value='Generate Graph'> | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   </FORM> | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   ");
 | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ($_GET['all']) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       $ai = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code']; | 
					
						
							|  |  |  |       $ai .= "&from=0&to=" . $rightnow; | 
					
						
							|  |  |  |       $ai .= "&x=715&y=250"; | 
					
						
							|  |  |  |       $ai .= "&count=60\">"; | 
					
						
							|  |  |  |       echo("<h3>Entire Data View</h3>$ai"); | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |      elseif ($_GET['custom']) | 
					
						
							|  |  |  |      { | 
					
						
							|  |  |  |       $cg = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code']; | 
					
						
							|  |  |  |       $cg .= "&from=" . $_GET['fromdate'] . "000000&to=" . $_GET['todate'] . "235959"; | 
					
						
							|  |  |  |       $cg .= "&x=715&y=250"; | 
					
						
							|  |  |  |       $cg .= "&count=60\">"; | 
					
						
							|  |  |  |       echo("<h3>Custom Graph</h3>$cg"); | 
					
						
							|  |  |  |      } | 
					
						
							|  |  |  |      else | 
					
						
							|  |  |  |      { | 
					
						
							|  |  |  |        echo("<h3>Billing View</h3>$bi"); | 
					
						
							| 
									
										
										
										
											2011-11-12 15:19:05 +00:00
										 |  |  | #       echo("<h3>Previous Bill View</h3>$li");
 | 
					
						
							| 
									
										
										
										
											2011-11-05 14:55:08 +00:00
										 |  |  |        echo("<h3>24 Hour View</h3>$di"); | 
					
						
							|  |  |  |        echo("<h3>Monthly View</h3>$mi"); | 
					
						
							|  |  |  | #       echo("<br /><a href=\"rate.php?" . $_SERVER['QUERY_STRING'] . "&all=yes\">Graph All Data (SLOW)</a>");
 | 
					
						
							|  |  |  |      } | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   } # End if details
 | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-07-31 21:08:35 +00:00
										 |  |  |   include("includes/error-no-perm.inc.php"); | 
					
						
							| 
									
										
										
										
											2010-06-21 04:18:06 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2011-03-17 00:09:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-04-08 11:25:13 +00:00
										 |  |  | ?>
 |