function getPredictedUsage($bill_day, $cur_used) { $tmp = getDates($bill_day, 0); $start = new DateTime($tmp[0], new DateTimeZone(date_default_timezone_get())); $end = new DateTime($tmp[1], new DateTimeZone(date_default_timezone_get())); $now = new DateTime(date("Y-m-d"), new DateTimeZone(date_default_timezone_get())); $total = $end->diff($start)->format("%a"); $since = $now->diff($start)->format("%a"); return $cur_used / $since * $total; }
?> ").removeClass("disabled"); }); </script> <?php } } getDates("314", "#second"); getDates("315", "#three"); getDates("316", "#four"); getDates("317", "#five"); getDates("318", "#six"); getDates("319", "#seven"); getDates("320", "#eight"); getDates("321", "#nine"); getDates("322", "#ten"); getDates("323", "#elf"); getDates("324", "#twaalf"); getDates("325", "#dertien"); getDates("326", "#viertien"); getDates("327", "#vijftien"); getDates("328", "#zestien"); getDates("329", "#zeventien"); getDates("330", "#achttien"); getDates("331", "#negentien"); getDates("332", "#twintig"); $p = isset($_GET['p']) ? intval($_GET['p']) : 1; ?>
<?php } ?> </tbody> </table> <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'cart_form', 'type' => 'horizontal', 'action' => Yii::app()->createUrl('product/addorder'), 'enableAjaxValidation' => false)); Yii::app()->user->setFlash('error', 'Ошибка'); $this->widget('bootstrap.widgets.TbAlert', array('alerts' => array('error' => array('block' => true, 'closeText' => '')))); echo $form->textFieldRow($model, 'clientname', array('maxlength' => 256)); echo $form->textFieldRow($model, 'phone', array('maxlength' => 32)); echo $form->checkBoxRow($model, 'mounting'); echo '<div class="address">', $form->textFieldRow($model, 'address', array('maxlength' => 512)), '</div>'; echo '<div class="date">', $form->radioButtonListInLineRow($model, 'date', getDates()), '</div>'; echo '<div class="time">', $form->radioButtonListInLineRow($model, 'time', array('10:00' => '10:00', '12:00' => '12:00', '14:00' => '14:00', '16:00' => '16:00', '18:00' => '18:00', '20:00' => '20:00', '21:00' => '21:00')), '</div>'; foreach ($pids as $value) { echo CHtml::hiddenField('pid_' . $value, $value); } $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Оформить заказ')); $this->endWidget(); ?> <?php } else { ?> <p>Корзина пуста.</p> <?php } ?>
function loadRAWData($from, $id_plan, $id_item, $to = null, $id_host = null) { $cacheAge = 60 * 60; $offset = getOffset(); setTimezone(); $cache = phpFastCache(); //$cache->clean(); $dt = getDates($from); $from = $dt[0]; if ($to == null) { $to = $dt[1]; } $from = str_replace("-", "/", $from); $to = str_replace("-", "/", $to); $phour = getPeakHours(); $unit = getUnit($id_item); $plan = getPlan($id_plan); $item = getItem($id_item); $div = 1; if (strtolower($unit) == 'bps') { $div = 1024 * 1024; $unit = 'Mbps'; } $rtag = ""; foreach ($_SESSION['tag'] as $key => $value) { if ($key != "" && $key != "None") { $rtag = $rtag . ',"' . $key . '"'; } } if ($rtag == '') { $rtag = 'bm_tags.tag like "%"'; } else { $rtag = 'bm_tags.tag in (' . substr($rtag, 1) . ')'; } if ($id_plan == 0) { $id_plan = '> 0'; } else { $id_plan = '=' . $id_plan; } if ($id_host == null) { $id_host = ""; } else { $id_host = " and bm_host.id_host=" . $id_host; } $hosts = 'select bm_host.id_host,bm_host.id_plan,bm_plan.plan,bm_plan.nacD,bm_plan.nacU,bm_threshold.critical,bm_threshold.warning,bm_threshold.nominal,bm_host.host from bm_host,bm_plan,bm_plan_groups,bm_threshold,bi_dashboard where bm_host.id_plan=bm_plan.id_plan and bm_host.groupid = ' . $_SESSION['groupid'] . ' and bm_plan.id_plan ' . $id_plan . ' and bm_plan_groups.id_plan = bm_plan.id_plan and bm_host.borrado=0 and bm_host.id_plan=bm_plan.id_plan and bm_plan_groups.groupid=bm_host.groupid and bm_threshold.id_item=bi_dashboard.id_item and bm_host.id_host in (select id from bm_tags where ' . $rtag . ') and bi_dashboard.id_item=' . $id_item . $id_host . ' order by bm_host.id_plan'; //var_dump($hosts); // Find Percentile 5 and 95 if (true) { $hostsr = mysql_query($hosts); while ($host = mysql_fetch_array($hostsr, MYSQL_ASSOC)) { $id_host = $host['id_host']; $hostName = $host['host']; $nominal = $host['nominal']; $critical = $host['critical']; $warning = $host['warning']; $nacD = $host['nacD'] * 1024; $nacU = $host['nacU'] * 1024; if ($nominal == -1) { $nominal = $nacD; } if ($nominal == -2) { $nominal = $nacU; } $hostList[] = array('host' => $hostName, 'id_host' => $id_host, 'nominal' => $nominal, 'critical' => $critical, 'warning' => $warning, 'nacD' => $nacD, 'nacU' => $nacU); $incache = true; unset($cachedData); $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days')); while ($dfrom != $to) { $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days')); $key = $dfrom . '-' . $id_host . '-' . $id_item; //if (isset($_SESSION['cache'][$key])) // $obj = $_SESSION['cache'][$key]; //else //echo $key . "<br>"; $obj = $cache->get($key); if ($obj == null) { $incache = false; $_SESSION['cacheFull'] = false; } else { $_SESSION['cachePartial'] = true; foreach ($obj as $key => $value) { if (isset($value['clock'])) { $cachedData[] = $value; } } } } if (!isset($cachedData)) { $incache = false; } if ($incache) { foreach ($cachedData as $key => $row) { $skip = false; if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) { $skip = true; } if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) { $skip = true; } if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) { $skip = true; } if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) { $skip = true; } if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') { $skip = true; } if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') { $skip = true; } if (!$skip) { $allData[] = $row['value']; $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); } } } else { $table = 'xyz_' . str_pad($id_item, 10, "0", STR_PAD_LEFT); //var_dump($table); if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '" . $table . "'")) == 1) { if ($phour['peak'] > $phour['offpeak']) { $q = 'select clock,value,valid,if((date_format(from_unixtime(clock),"%H")>=0 and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ') or date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ',"P","O") as t from ' . $table . ' where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and id_host=' . $id_host; } else { $q = 'select clock,value,valid,if(date_format(from_unixtime(clock),"%H")>=' . $phour['peak'] . ' and date_format(from_unixtime(clock),"%H")<=' . $phour['offpeak'] . ',"P","O") as t from ' . $table . ' where clock between unix_timestamp("' . $from . ' 00:00:00") AND unix_timestamp("' . $to . ' 23:59:59") and id_host=' . $id_host; } //var_dump($q); $qr = mysql_query($q); while ($row = mysql_fetch_array($qr, MYSQL_ASSOC)) { $key = date('Y/m/d', $row['clock']); $data[$key][$id_host . '-' . $id_item][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); $skip = false; if (isset($_SESSION['filter']['< 1.5x']) && $row['value'] > $nominal * 1.5) { $skip = true; } if (isset($_SESSION['filter']['< 2.0x']) && $row['value'] > $nominal * 2.0) { $skip = true; } if (isset($_SESSION['filter']['< 3.0x']) && $row['value'] > $nominal * 3.0) { $skip = true; } if (isset($_SESSION['filter']['> 0']) && $row['value'] <= 0) { $skip = true; } if (isset($_SESSION['filter']['Off Peak Hour']) && $row['t'] == 'P') { $skip = true; } if (isset($_SESSION['filter']['Peak Hour']) && $row['t'] == 'O') { $skip = true; } if (!$skip) { $allData[] = $row['value']; $historyList[$id_host][] = array('clock' => $row['clock'], 'value' => $row['value'], 'valid' => $row['valid'], 't' => $row['t']); } } } // check miising data $dfrom = $key = date('Y/m/d', strtotime($from . ' -1 days')); while ($dfrom != $to) { $dfrom = date('Y/m/d', strtotime($dfrom . ' +1 days')); $key = $dfrom . '-' . $id_host . '-' . $id_item; $obj = $cache->get($key); if ($obj == null) { $cache->set($key, array('clock' => 0, 'value' => 0, 'valid' => 0, 't' => ''), $cacheAge); //$_SESSION['cache'][$key]= array('clock'=>0,'value'=>0,'valid'=>0,'t'=>''); } } } } } if (isset($incache) && !$incache && isset($data)) { foreach ($data as $key => $value) { foreach ($value as $hkey => $hvalue) { $thekey = $key . '-' . $hkey; //echo $thekey . ' '; $cache->set($thekey, $hvalue, $cacheAge); //$_SESSION['cache'][$thekey] = $hvalue; } } } if (isset($allData)) { return array('allData' => $allData, 'historyList' => $historyList, 'hostList' => $hostList, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to); } else { return array('allData' => null, 'historyList' => null, 'hostList' => null, 'offpeak' => $phour['offpeak'], 'peak' => $phour['peak'], 'unit' => $unit, 'div' => $div, 'plan' => $plan, 'item' => $item, 'from' => $from, 'to' => $to); } }
function GraphPie($chart, $id_chart, $id_plan, $id_item, $tag, $from, $low, $mid, $max, $dir) { $dt = getDates($from); $plan = getPlan($id_plan); $item = getItem($id_item); $unit = getUnit($id_item); $from = $dt[0]; $to = $dt[1]; $sum = $low + $mid + $max; if ($sum == 0) { $sum = 1.0E+18; } if ($dir == 0) { $data0[] = array('name' => "Not acceptable measures", 'y' => round($low / $sum * 100, 2), 'color' => 'red'); $data0[] = array('name' => "Below acceptable measures", 'y' => round($mid / $sum * 100, 2), 'color' => '#F79E03'); $data0[] = array('name' => "Acceptable measures", 'y' => round($max / $sum * 100, 2), 'color' => 'green'); } else { $data0[] = array('name' => "Not acceptable measures", 'y' => round($low / $sum * 100, 2), 'color' => 'red'); $data0[] = array('name' => "Below acceptable measures", 'y' => round($mid / $sum * 100, 2), 'color' => '#F79E03'); $data0[] = array('name' => "Acceptable measures", 'y' => round($max / $sum * 100, 2), 'color' => 'green'); } $title = '% de results for "' . $item . '" on plan "' . $plan . '"'; $subtitle = 'From ' . $from . ' to ' . $to; $chart = chartHeader($chart, $id_chart, $title, $subtitle, 'Quantity', null); $chart->plotOptions->series->pointPadding = -0.333333; $chart->series[0]->type = 'pie'; $chart->series[0]->data = $data0; $chart->series[0]->tooltip->valueSuffix = '%'; $chart->series[0]->name = 'Number of occurencies'; $chart->series[0]->dataLabels->enabled = true; $chart->series[0]->dataLabels->crop = false; $chart->series[0]->dataLabels->align = 'center'; $chart->series[0]->dataLabels->y = -6; $chart->series[0]->dataLabels->color = 'black'; //'#000000'; $chart->series[0]->dataLabels->style->fontSize = '13px'; $chart->series[0]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[0]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.y, 2, '.') + '%';}"); return $chart; }
function GraphSonda($chart, $id_chart, $id_plan, $id_item, $from, $avg, $tag) { $offset = getOffset(); // setTimezone(); $dt = getDates($from); $index = 0; $average = getAverage($avg); $format = $average[0]; $divide = $average[1]; if ($divide == 60 * 60 * 6) { $offset = -60 * 60 * 2; } if ($divide == 60 * 60 * 12) { $offset = +60 * 60 * 4; } if ($divide == 60 * 60 * 24) { $offset = +60 * 60 * 4; } $colorIndex = 0; $ldata = loadRAWData($from, $id_plan, $id_item); $percentile = calculatePercentile($ldata['allData']); $div = $ldata['div']; if (isset($ldata['hostList'])) { foreach ($ldata['hostList'] as $host) { $id_host = $host['id_host']; $hostName = $host['host']; $nacD = $host['nacD']; $nacU = $host['nacU']; $critical = $host['critical']; $warning = $host['warning']; $nominal = $host['nominal']; if ($warning > 100) { $dir = 1; } else { $dir = 0; } if ($nominal == -1) { $nominal = $nacD; } if ($nominal == -2) { $nominal = $nacU; } unset($theSondaAvg); unset($theSondaQoE); unset($dataAvg); unset($dataQoE); if (isset($ldata['historyList'][$id_host])) { foreach ($ldata['historyList'][$id_host] as $key => $row) { $tk = round($row['clock'] / $divide, 0) * $divide; $skip = false; if (isset($_SESSION['filter']['P95']) && $row['value'] > $percentile['P95']) { $skip = true; } if (isset($_SESSION['filter']['P5']) && $row['value'] < $percentile['P5']) { $skip = true; } if (!$skip) { if (!isset($theSondaAvg[$tk])) { $theSondaAvg[$tk] = array($tk, 0, 0); } if (!isset($theSondaQoE[$tk])) { $theSondaQoE[$tk] = array($tk, 0, 0); } $sum = $theSondaAvg[$tk][1]; $cnt = $theSondaAvg[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $theSondaAvg[$tk] = array($tk, $x, $y); if ($row['value'] > $nominal) { $row['value'] = $nominal; } $sum = $theSondaQoE[$tk][1]; $cnt = $theSondaQoE[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $theSondaQoE[$tk] = array($tk, $x, $y); } } } if (isset($theSondaAvg)) { aasort($theSondaAvg, 0); $next = 0; $prev = 0; foreach ($theSondaAvg as $tvalue) { $next = $tvalue[0] + $offset; if ($prev > 0 && $next > 0 && $next - $prev > $divide * 2) { $dataAvg[] = array(($prev + 1000) * 1000, null); } $dataAvg[] = array($next * 1000, round($tvalue[1] / $tvalue[2] / $div, 2)); $prev = $next; } aasort($theSondaQoE, 0); $next = 0; $prev = 0; foreach ($theSondaQoE as $tvalue) { $next = $tvalue[0] + $offset; if ($prev > 0 && $next > 0 && $next - $prev > $divide * 2) { $dataQoE[] = array(($prev + 1000) * 1000, null); } $dataQoE[] = array($next * 1000, round($tvalue[1] / $tvalue[2] / $div, 2)); $prev = $next; } } if (isset($dataAvg)) { if (!isset($minClock)) { $minClock = $dataAvg[0][0]; $maxClock = $dataAvg[count($dataAvg) - 1][0]; } else { if ($dataAvg[0][0] < $minClock) { $minClock = $dataAvg[0][0]; } if ($dataAvg[count($dataAvg) - 2][0] > $maxClock) { $maxClock = $dataAvg[count($dataAvg) - 2][0]; } } if ($_GET['qoe'] == 'Average On' || $_GET['qoe'] == 'Both') { $chart->series[]->name = $hostName . "-AVG"; $chart->series[$index]->type = 'spline'; $chart->series[$index]->dashStyle = 'spline'; $chart->series[$index]->data = $dataAvg; $chart->series[$index]->color = getColor($colorIndex); $chart->series[$index]->lineWidth = 1; $chart->series[$index]->marker->radius = 2; $index++; } if ($_GET['qoe'] == 'QoE On' || $_GET['qoe'] == 'Both') { $chart->series[]->name = $hostName . '-QoE'; $chart->series[$index]->type = 'shortdot'; $chart->series[$index]->color = getColor($colorIndex); $chart->series[$index]->data = $dataQoE; $chart->series[$index]->lineWidth = 1; $chart->series[$index]->marker->radius = 2; $index++; } $colorIndex++; } } } $title = 'Sondas for "' . $ldata['item'] . '" on plan "' . $ldata['plan'] . '"'; $subtitle = 'From ' . $ldata['from'] . ' to ' . $ldata['to']; $chart = chartHeader($chart, $id_chart, $title, $subtitle, $ldata['unit'], null); if (!isset($minClock)) { $minClock = 0; $maxClock = 0; } $chart->xAxis->type = 'datetime'; $chart->tooltip->formatter = new HighchartJsExpr("\n function() {\n var s = '<b>'+ Highcharts.dateFormat('%e. %b %H:%M',this.x) +'</b>'; \n \$.each(this.points, function(i, point) {\n s += '<br/><span style=\"color:'+point.series.color+'\">'+ point.series.name +': '+ point.y +' " . $ldata['unit'] . "</span><b>';\n });\n return s;\n }"); echo "\n" . '<script> function redraw() { chart1.xAxis[0].setExtremes(' . $minClock . ', ' . (round($maxClock / (3600 * 24), 0) * 3600 * 24 + $divide * 1000) . ');} </script>'; //var_dump($chart->chart); return $chart; }
<?php require_once 'futures.php'; $datearray = getDates(); ?> <html> <head> <title>Форма добавления статей</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> </head> <body> <form name="addarticle" method="post" action="processAddArticle.php"> <table width="50%" border="0"> <tr> <td> <table border="0" style="background:#96E066;" width="100%"> <tr> <td><label for="idhead">Заголовок</label></td> <td><input type="text" name="txthead" id="idhead" size="30" /></td> <td><div id="errorhead" /></td> </tr> <tr> <td><label for="idauthor">Автор</label></td> <td><input type="text" name="txtauthor" id="idauthor" size="30" /></td> <td><div id="errorauthor" /></td> </tr> <tr> <td><label for="iddate">Дата публикации</label></td> <td><input type="text" name="txtdate" id="iddate" size="30" value="<?php echo $datearray[2] . '.' . $datearray[1] . '.' . $datearray[0]; ?>
function GraphGroup($chart, $id_chart, $item, $itemName, $from, $avg, $type) { $offset = getOffset(); setTimezone(); $dt = getDates($from); $from = $dt[0]; $to = $dt[1]; $chart->chart->renderTo = $id_chart; $chart->chart->zoomType = 'x'; $chart->chart->spacingRight = 20; $chart->xAxis->type = 'datetime'; $chart->xAxis->lineWidth = 0; $chart->xAxis->tickWidth = 1; $chart->chart->shadow = true; $chart->chart->plotShadow = true; $chart->yAxis->startOnTick = false; $chart->yAxis->showFirstLabel = false; $chart->yAxis->min = 0; $chart->xAxis->gridLineWidth = 1; $chart->tooltip->shared = true; $chart->legend->enabled = true; $chart->subtitle->text = 'From ' . $from . ' to ' . $to; $index = 0; $thezero = '-1'; $average = getAverage($avg); $format = $average[0]; $divide = $average[1]; $filterHost = ''; if ($_GET['host'] != '') { $filterHost = ' and host="' . $_GET['host'] . '" '; } switch ($type) { case 'YouTube': $list = '%video youtube%AVG%'; $txt = 'Youtube Average for Plan ' . $_GET['plan']; if ($_GET['host'] != '') { $txt .= ' for Sonda ' . $_GET['host']; } $chart->title->text = $txt; break; case 'File': $list = 'file download% speed'; $txt = 'File Download Average for Plan ' . $_GET['plan']; if ($_GET['host'] != '') { $txt .= ' for Sonda ' . $_GET['host']; } $chart->title->text = $txt; break; case 'Video': $list = 'Video %experience%'; $txt = 'Video Experience for Plan ' . $_GET['plan']; if ($_GET['host'] != '') { $txt .= ' for Sonda ' . $_GET['host']; } $chart->title->text = $txt; break; case 'Ping': $list = 'ping%avg%'; $txt = 'Ping Average for Plan ' . $_GET['plan']; if ($_GET['host'] != '') { $txt .= ' for Sonda ' . $_GET['host']; } $chart->title->text = $txt; break; } $thezero = '0'; $q = 'select distinct descriptionLong from bm_items where descriptionLong like "' . $list . '" order by 1'; $q1 = mysql_query($q); while ($r = mysql_fetch_array($q1, MYSQL_ASSOC)) { $desc = $r['descriptionLong']; $query = "SELECT descriptionLong,unix_timestamp(date_format(from_unixtime(round(clock/" . $divide . ",0)*" . $divide . "),'" . $format . "')) as clk,\n round(avg(value),0) as value,\n max(unit) as unit \n FROM bm_host,bm_items,bm_history,bm_plan,bm_host_groups\n WHERE bm_host.id_host=bm_history.id_host and bm_history.id_item=bm_items.id_item and descriptionLong = '" . $desc . "'\n and bm_host.id_plan=bm_plan.id_plan \n and clock between unix_timestamp('" . $from . "') and unix_timestamp('" . $to . " 23:59:59')+3600*24\n and value > " . $thezero . "\n and plan='" . $_GET['plan'] . "' " . $filterHost . " \n and bm_host_groups.groupid=bm_host.groupid\n and bm_host_groups.groupid=" . $_SESSION['groupid'] . "\n GROUP BY descriptionLong,unit,unix_timestamp(date_format(from_unixtime(round(clock/" . $divide . ",0)*" . $divide . "),'" . $format . "'))\n ORDER BY 1"; //var_dump($query); $result = mysql_query($query) or die("SQL Error 1: " . mysql_error()); unset($data2); $unit = ''; if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $unit = $row['unit']; $div = 1; if ($unit == 'bps') { $div = 1024 * 1024; $unit = 'Mbps'; } $data2[] = array($row['clk'] * 1000, round($row['value'] * 1 / $div, 2)); } $chart->yAxis->title->text = $unit; //$chart->tooltip->formatter = new HighchartJsExpr("function() { return '<b>'+ this.series.name +'</b><br/>'+ Highcharts.dateFormat('%e. %b %H:%M', this.x) +': '+ Highcharts.numberFormat(this.y, 2, ',') +' " . $unit . "';}"); $chart->series[]->name = $desc; $chart->series[$index]->type = 'spline'; $chart->series[$index]->data = $data2; $index++; } } return $chart; }
function list_bills() { global $config; $app = \Slim\Slim::getInstance(); $router = $app->router()->getCurrentRoute()->getParams(); $status = 'ok'; $err_msg = ''; $message = ''; $code = 200; $bills = array(); $bill_id = mres($router['bill_id']); $bill_ref = mres($_GET['ref']); $bill_custid = mres($_GET['custid']); if (!empty($bill_custid)) { $sql = '`bill_custid` = ?'; $param = array($bill_custid); } elseif (!empty($bill_ref)) { $sql = '`bill_ref` = ?'; $param = array($bill_ref); } elseif (is_numeric($bill_id)) { $sql = '`bill_id` = ?'; $param = array($bill_id); } else { $sql = ''; $param = array(); } if (count($param) >= 1) { $sql = "WHERE {$sql}"; } foreach (dbFetchRows("SELECT `bills`.*,COUNT(port_id) AS `ports_total` FROM `bills` LEFT JOIN `bill_ports` ON `bill_ports`.`bill_id`=`bills`.`bill_id` {$sql} GROUP BY `bill_name`,`bill_ref` ORDER BY `bill_name`", $param) as $bill) { $day_data = getDates($bill['bill_day']); $ports_total = $bill['ports_total']; $datefrom = $day_data['0']; $dateto = $day_data['1']; $rate_data = $bill; $rate_95th = $rate_data['rate_95th']; $dir_95th = $rate_data['dir_95th']; $total_data = $rate_data['total_data']; $rate_average = $rate_data['rate_average']; if ($bill['bill_type'] == "cdr") { $type = "CDR"; $allowed = format_si($bill['bill_cdr']) . "bps"; $used = format_si($rate_data['rate_95th']) . "bps"; $percent = round($rate_data['rate_95th'] / $bill['bill_cdr'] * 100, 2); $background = get_percentage_colours($percent); $overuse = $rate_data['rate_95th'] - $bill['bill_cdr']; $overuse = $overuse <= 0 ? "-" : format_si($overuse); } elseif ($bill['bill_type'] == "quota") { $type = "Quota"; $allowed = format_bytes_billing($bill['bill_quota']); $used = format_bytes_billing($rate_data['total_data']); $percent = round($rate_data['total_data'] / $bill['bill_quota'] * 100, 2); $background = get_percentage_colours($percent); $overuse = $rate_data['total_data'] - $bill['bill_quota']; $overuse = $overuse <= 0 ? "-" : format_bytes_billing($overus); } $bill['allowed'] = $allowed; $bill['used'] = $used; $bill['percent'] = $percent; $bill['overuse'] = $overuse; $bills[] = $bill; } $count = count($bills); $output = array("status" => $status, "err-msg" => $err_msg, "count" => $count, "bills" => $bills); $app->response->headers->set('Content-Type', 'application/json'); echo _json_encode($output); }
if ($USR_WHERE_CLAUSE != '') { $CUSTOM_REPORT = 1; } $GROUPBY_CLAUSE = $groupby; $ORDER_CUSTOM = " ORDER BY 1 ASC "; // Column 1 is assumed as Date $ORDERBY_CLAUSE = $orderby; if ($ORDERBY_CLAUSE == "") { $ORDERBY_CLAUSE = $ORDER_CUSTOM; } $LIMIT_CUSTOM = limitResults(); $LIMITTO_CLAUSE = $limitto; if ($LIMITTO_CLAUSE == "") { $LIMITTO_CLAUSE = $LIMIT_CUSTOM; } $USR_DATERANGE = getDates($type, $range_type, $multiply_factor, $selMonth1, $selDay1, $selYear1, $selMonth2, $selDay2, $selYear2); $SAVED_REPORT = 0; $SAVED_DATERANGE = 0; $SAVED_CLAUSE = ''; $save_status = 0; if (isset($subFolderID) && $subFolderID != '') { if (isset($rptAction) && $rptAction == 'savereport') { $save_status = saveCondition($saveID, "{$USR_WHERE_CLAUSE} {$USR_DATERANGE} "); // Not saving $FILE_CLAUSE } else { $getCond = "SELECT sName, sDescription, sValue FROM setups WHERE sID = {$subFolderID}"; $result = mysql_query($getCond) or die("Invalid Condition: " . mysql_error()); $row = mysql_fetch_array($result); $savedName = $row['sName']; $savedDesc = $row['sDescription']; if (!isset($rptName) || $rptName == '') {
{ $query = "\nselect distinct DATE_FORMAT({$date_column}, \"{$timeslice}\") as date_column\nfrom {$table}\n LEFT JOIN giqwm_fleet_driver as driver on {$table}.id = driver.id\n LEFT JOIN giqwm_fleet_entity as dgroup on dgroup.id = driver.entity_id\n LEFT JOIN giqwm_fleet_entity as company on dgroup.parent_entity_id = company.id\n where driver.visible {$where}\norder by {$date_column}\n"; // Performing SQL query // file_put_contents("/tmp/mysqllog.txt", $query . "\n", FILE_APPEND); $sth = $conn->prepare($query); $sth->execute(); $result = $sth->fetchAll(PDO::FETCH_ASSOC); $cols = array(); foreach ($result as $line) { foreach ($line as $column) { array_push($cols, $column); } } return $cols; } $dateColumns = getDates($table, $date_column, $timeslice, $where, $conn); // Second query: do the transpose, average over values in each time slice. $query = ""; # Each aggregate column needs its own transpose query. foreach ($aggregate_columns as $aggcol) { $subquery = ""; $columns = ""; $subquery = "select "; if ($alias_columns != "") { $subquery .= " {$alias_columns},"; } # $subquery .= " \"$aggcol\" "; foreach ($dateColumns as $column) { if ($columns != "") { $columns .= ",\n"; }
function GraphPlan($chart, $id_chart, $id_item, $from, $avg, $tag) { //$cache = phpFastCache(); $dt = getDates($from); $item = getItem($id_item); $index = 0; $thezero = '-1'; $average = getAverage($avg); $format = $average[0]; $divide = $average[1]; $color = array('#89A54E', 'none', '#4572A7', 'none', '#AA4643', 'none', '#808080', 'none', 'darksilver', 'none', 'black', 'none', 'magenta', 'none', 'lighrblue', 'none'); $offset = 0; $colorIndex = 0; $cacheAge = 60 * 30; // 30 minutes if ($divide == 60 * 60 * 6) { $offset = -60 * 60 * 2; } if ($divide == 60 * 60 * 12) { $offset = +60 * 60 * 4; } if ($divide == 60 * 60 * 24) { $offset = +60 * 60 * 4; } $planList = readPlan(); foreach ($planList as $plan) { $id_plan = $plan['id_plan']; unset($data2); unset($data3); unset($dataAvg); unset($dataQoE); unset($planAvg); unset($planQoE); unset($percentile); unset($ldata); $ldata = loadRAWData($from, $id_plan, $id_item); $unit = $ldata['unit']; $div = $ldata['div']; $percentile = calculatePercentile($ldata['allData']); if (isset($ldata['hostList'])) { foreach ($ldata['hostList'] as $host) { $id_host = $host['id_host']; $nacD = $host['nacD']; $nacU = $host['nacU']; $critical = $host['critical']; $warning = $host['warning']; $nominal = $host['nominal']; if ($warning > 100) { $dir = 1; } else { $dir = 0; } if ($nominal == -1) { $nominal = $nacD; } if ($nominal == -2) { $nominal = $nacU; } if (isset($ldata['historyList'][$id_host])) { foreach ($ldata['historyList'][$id_host] as $key => $row) { $tk = round($row['clock'] / $divide, 0) * $divide; $skip = false; if (isset($_SESSION['filter']['P95']) && $row['value'] > $percentile['P95']) { $skip = true; } if (isset($_SESSION['filter']['P5']) && $row['value'] < $percentile['P5']) { $skip = true; } if (!$skip) { if (!isset($planAvg[$tk])) { $planAvg[$tk] = array($tk, 0, 0); } if (!isset($planQoE[$tk])) { $planQoE[$tk] = array($tk, 0, 0); } $sum = $planAvg[$tk][1]; $cnt = $planAvg[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $planAvg[$tk] = array($tk, $x, $y); if ($row['value'] > $nacD) { $row['value'] = $nacD; } $sum = $planQoE[$tk][1]; $cnt = $planQoE[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $planQoE[$tk] = array($tk, $x, $y); } } } } } if (isset($planAvg)) { $next = 0; $prev = 0; aasort($planAvg, 0); aasort($planQoE, 0); foreach ($planAvg as $tvalue) { $next = $planAvg[$tvalue[0]][0] + $offset; if ($prev > 0 && $next > 0 && $next - $prev > $divide * 2) { $dataAvg[] = array(($prev + 1000) * 1000, null); $dataQoE[] = array(($prev + 1000) * 1000, null); } $dataAvg[] = array($planAvg[$tvalue[0]][0] * 1000, round($planAvg[$tvalue[0]][1] / $planAvg[$tvalue[0]][2] / $div, 2)); $dataQoE[] = array($planQoE[$tvalue[0]][0] * 1000, round($planQoE[$tvalue[0]][1] / $planQoE[$tvalue[0]][2] / $div, 2)); $prev = $next; } } if (isset($dataAvg)) { if (!isset($minClock)) { $minClock = $dataAvg[0][0]; $maxClock = $dataAvg[count($dataAvg) - 2][0]; } else { if ($dataAvg[0][0] < $minClock) { $minClock = $dataAvg[0][0]; } if ($dataAvg[count($dataAvg) - 2][0] > $maxClock) { $maxClock = $dataAvg[count($dataAvg) - 2][0]; } } if ($_GET['qoe'] == 'Average On' || $_GET['qoe'] == 'Both') { $chart->series[]->name = $ldata['plan'] . '-AVG'; $chart->series[$index]->type = 'spline'; $chart->series[$index]->color = getColor($colorIndex); $chart->series[$index]->data = $dataAvg; $chart->series[$index]->lineWidth = 1; $chart->series[$index]->marker->radius = 2; $index++; } if ($_GET['qoe'] == 'QoE On' || $_GET['qoe'] == 'Both') { $chart->series[]->name = $ldata['plan'] . '-QoE'; $chart->series[$index]->type = 'spline'; $chart->series[$index]->color = getColor($colorIndex); $chart->series[$index]->dashStyle = 'shortdot'; $chart->series[$index]->data = $dataQoE; $chart->series[$index]->lineWidth = 1; $chart->series[$index]->marker->radius = 2; $index++; } $colorIndex++; } } $title = 'Average by Plan for "' . $item; $subtitle = 'From ' . $ldata['from'] . ' to ' . $ldata['to']; $chart = chartHeader($chart, $id_chart, $title, $subtitle, $unit, null); $chart->xAxis->type = 'datetime'; if (!isset($minClock)) { $minclock = 0; $maxClock = 0; } $chart->tooltip->formatter = new HighchartJsExpr("\n function() {\n var s = '<b>'+ Highcharts.dateFormat('%e. %b %H:%M',this.x) + '</b>'; \n \$.each(this.points, function(i, point) {\n s += '<br/><span style=\"color:'+point.series.color+'\">'+ point.series.name +': '+ point.y +' " . $unit . "</span><b>';\n });\n return s;\n }"); echo "\n" . '<script> function redraw() { chart1.xAxis[0].setExtremes(' . round($minClock / (60 * 60), 0) * 60 * 60 . ', ' . round(($maxClock + 60 * 60 * 4 * 1000) / (60 * 60), 0) * 60 * 60 . ');} </script>'; return $chart; }
function GraphBar($chart, $id_chart, $id_plan, $id_item, $tag, $from) { $offset = getOffset(); setTimezone(); $dt = getDates($from); $ldata = loadRAWData($from, $id_plan, $id_item); $unit = $ldata['unit']; $div = $ldata['div']; $percentile = calculatePercentile($ldata['allData']); if (isset($ldata['hostList'])) { foreach ($ldata['hostList'] as $host) { $nacD = $host['nacD']; $nacU = $host['nacU']; $critical = $host['critical']; $warning = $host['warning']; $nominal = $host['nominal']; if ($nominal == -1) { $nominal = $nacD; } if ($nominal == -2) { $nominal = $nacU; } $id_host = $host['id_host']; if (isset($ldata['historyList'][$id_host])) { foreach ($ldata['historyList'][$id_host] as $key => $row) { $tk = date('Y/m/d', $row['clock']); if (!isset($weekAvgPeak[$tk])) { $weekAvgPeak[$tk] = array($tk, 0, 0); } if (!isset($weekAvgOffPeak[$tk])) { $weekAvgOffPeak[$tk] = array($tk, 0, 0); } if (!isset($weekQoEPeak[$tk])) { $weekQoEPeak[$tk] = array($tk, 0, 0); } if (!isset($weekQoEOffPeak[$tk])) { $weekQoEOffPeak[$tk] = array($tk, 0, 0); } $skip = false; if (isset($_SESSION['filter']['P95']) && $row['value'] > $percentile['P95']) { $skip = true; } if (isset($_SESSION['filter']['P5']) && $row['value'] < $percentile['P5']) { $skip = true; } if (!$skip) { if ($row['t'] == 'P') { $sum = $weekAvgPeak[$tk][1]; $cnt = $weekAvgPeak[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $weekAvgPeak[$tk] = array($tk, $x, $y); } if ($row['t'] == 'O') { $sum = $weekAvgOffPeak[$tk][1]; $cnt = $weekAvgOffPeak[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $weekAvgOffPeak[$tk] = array($tk, $x, $y); } if ($row['value'] > $nacD) { $row['value'] = $nominal; } if ($row['t'] == 'P') { $sum = $weekQoEPeak[$tk][1]; $cnt = $weekQoEPeak[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $weekQoEPeak[$tk] = array($tk, $x, $y); } if ($row['t'] == 'O') { $sum = $weekQoEOffPeak[$tk][1]; $cnt = $weekQoEOffPeak[$tk][2]; $x = $sum + $row['value']; $y = $cnt + 1; $weekQoEOffPeak[$tk] = array($tk, $x, $y); } } } } } } if (isset($weekQoEPeak)) { aasort($weekQoEPeak, 0); aasort($weekQoEOffPeak, 0); aasort($weekAvgPeak, 0); aasort($weekAvgOffPeak, 0); $h = -100; foreach ($weekQoEPeak as $tvalue) { $key = $tvalue[0]; if ($weekQoEPeak[$key][2] > 0) { $dataQoEPeak[] = ColorBar($h, $nominal, $warning, $critical, $weekQoEPeak[$key][1] / $weekQoEPeak[$key][2], $div); } else { $dataQoEPeak[] = ColorBar($h, $nominal, $warning, $critical, 0, $div); } // ColorBar($x,$nominal,$warning,$critical,$value,$div) if ($weekQoEOffPeak[$key][2] > 0) { $dataQoEOffPeak[] = ColorBar($h, $nominal, $warning, $critical, $weekQoEOffPeak[$key][1] / $weekQoEOffPeak[$key][2], $div); } else { $dataQoEOffPeak[] = ColorBar($h, $nominal, $warning, $critical, 0, $div); } if ($weekAvgPeak[$key][2] > 0) { $dataAvgPeak[] = array('x' => $h, 'y' => round($weekAvgPeak[$key][1] / $weekAvgPeak[$key][2] / $div, 2), 'color' => 'silver'); } else { $dataAvgPeak[] = array('x' => $h, 'y' => 0, 'color' => 'silver'); } if ($weekAvgOffPeak[$key][2] > 0) { $dataAvgOffPeak[] = array('x' => $h, 'y' => round($weekAvgOffPeak[$key][1] / $weekAvgOffPeak[$key][2] / $div, 2), 'color' => 'silver'); } else { $dataAvgOffPeak[] = array('x' => $h, 'y' => 0, 'color' => 'silver'); } $dataNominal[] = array('x' => $h, 'y' => round($nominal / $div, 2)); $dataWarning[] = array('x' => $h, 'y' => round($nominal / $div * $warning / 100, 2)); $dataCritical[] = array('x' => $h, 'y' => round($nominal / $div * $critical / 100, 2)); $category[$h] = $key; $h++; } for ($i = 0; $i < count($dataAvgPeak); $i++) { $dataAvgPeak[$i]['y'] -= $dataQoEPeak[$i]['y']; $dataAvgOffPeak[$i]['y'] -= $dataQoEOffPeak[$i]['y']; } } if (!isset($category)) { $category = null; $dataAvgPeak = null; $dataQoEPeak = null; $dataAvgOffPeak = null; $dataQoEOffPeak = null; $dataNominal = null; $dataWarning = null; $dataCritical = null; $warning = 0; $critical = 0; } $title = 'Average by Hour for "' . $ldata['item'] . '" on plan "' . $ldata['plan'] . '"'; $subtitle = 'From ' . $ldata['from'] . ' to ' . $ldata['to']; $chart = chartHeader($chart, $id_chart, $title, $subtitle, $ldata['unit'], $category); $fontSize = '10px'; if (count($category) > 15) { $fontSize = '6px'; $chart->plotOptions->series->pointPadding = -1 / 300; } $chart->xAxis->type = 'datetime'; $chart->xAxis->labels->rotation = -90; $chart->xAxis->labels->style->color = "#000000"; $chart->legend->enabled = false; /* $chart->option3d->enabled = true; $chart->option3d->alpha = 45; $chart->option3d->beta = 0; $chart->option3d->depth = 50; $chart->option3d->viewDistance = 25; $chart->plotOptions->column->depth = 25; $chart->option3d->beta = 0; */ $chart->series[0]->type = 'column'; $chart->series[0]->stack = 0; $chart->series[0]->data = $dataAvgPeak; $chart->series[0]->tooltip->valueSuffix = ' ' . $unit; $chart->series[0]->name = 'Sample Average PEAK'; $chart->series[0]->dataLabels->enabled = true; $chart->series[0]->dataLabels->rotation = 0; $chart->series[0]->dataLabels->rotation = 0; $chart->series[0]->dataLabels->crop = false; $chart->series[0]->dataLabels->y = -10; $chart->series[0]->dataLabels->zIndexy = 12; $chart->series[0]->dataLabels->color = '#000000'; $chart->series[0]->dataLabels->style->fontSize = $fontSize; $chart->series[0]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[0]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.point.stackTotal, 2, '.');}"); $chart->series[1]->type = 'column'; $chart->series[1]->stack = 0; $chart->series[1]->data = $dataQoEPeak; $chart->series[1]->name = 'Sample Average PEAK'; $chart->series[1]->dataLabels->enabled = true; $chart->series[1]->dataLabels->crop = false; $chart->series[1]->dataLabels->rotation = -90; $chart->series[1]->dataLabels->align = 'left'; $chart->series[1]->tooltip->valueSuffix = ' ' . $unit; $chart->series[1]->dataLabels->x = 2; $chart->series[1]->dataLabels->color = '#FFFFFF'; $chart->series[1]->dataLabels->style->fontSize = $fontSize; $chart->series[1]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[1]->dataLabels->formatter = new HighchartJsExpr("function() { return 'PEAK: ' + Highcharts.numberFormat(this.y, 2, '.');}"); $chart->series[2]->type = 'column'; $chart->series[2]->stack = 1; $chart->series[2]->data = $dataAvgOffPeak; $chart->series[2]->name = 'Real Average OFFPEAK'; $chart->series[2]->tooltip->valueSuffix = ' ' . $unit; $chart->series[2]->dataLabels->crop = false; $chart->series[2]->dataLabels->enabled = true; $chart->series[2]->dataLabels->rotation = 0; $chart->series[2]->dataLabels->align = 'center'; $chart->series[2]->dataLabels->y = -10; $chart->series[2]->dataLabels->zIndexy = 12; $chart->series[2]->dataLabels->color = '#000000'; $chart->series[2]->dataLabels->style->fontSize = $fontSize; $chart->series[2]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[2]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.point.stackTotal, 2, '.');}"); $chart->series[3]->type = 'column'; $chart->series[3]->stack = 1; $chart->series[3]->data = $dataQoEOffPeak; $chart->series[3]->tooltip->valueSuffix = ' ' . $unit; $chart->series[3]->name = 'Real Average OFFPEAK'; $chart->series[3]->dataLabels->crop = false; $chart->series[3]->dataLabels->enabled = true; $chart->series[3]->dataLabels->rotation = -90; $chart->series[3]->dataLabels->align = 'left'; $chart->series[3]->dataLabels->x = 2; $chart->series[3]->dataLabels->color = '#FFFFFF'; $chart->series[3]->dataLabels->style->fontSize = $fontSize; $chart->series[3]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[3]->dataLabels->formatter = new HighchartJsExpr("function() { return 'OFFPEAK: ' +Highcharts.numberFormat(this.y, 2, '.');}"); $chart->series[4]->type = 'spline'; $chart->series[4]->data = $dataNominal; $chart->series[4]->stack = 2; $chart->series[4]->tooltip->valueSuffix = ' ' . $unit; $chart->series[4]->dataLabels->crop = false; $chart->series[4]->name = 'Nominal PEAK'; $chart->series[4]->dataLabels->enabled = false; $chart->series[4]->dataLabels->rotation = -90; $chart->series[4]->dataLabels->align = 'right'; $chart->series[4]->dataLabels->x = 4; $chart->series[4]->dataLabels->y = 10; $chart->series[4]->dataLabels->color = '#FFFFFF'; $chart->series[4]->dataLabels->style->fontSize = $fontSize; $chart->series[4]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[4]->lineWidth = 2; $chart->series[4]->color = 'green'; $chart->series[4]->marker->fillColor = 'green'; $chart->series[4]->marker->radius = 2; $chart->series[4]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.y, 2, '.');}"); $chart->series[5]->type = 'spline'; $chart->series[5]->data = $dataWarning; $chart->series[5]->stack = 2; $chart->series[5]->tooltip->valueSuffix = ' ' . $unit; $chart->series[5]->dataLabels->crop = false; $chart->series[5]->name = $warning . '% of the plan'; $chart->series[5]->dataLabels->enabled = false; $chart->series[5]->dataLabels->rotation = -90; $chart->series[5]->dataLabels->align = 'right'; $chart->series[5]->dataLabels->x = 4; $chart->series[5]->dataLabels->y = 10; $chart->series[5]->dataLabels->color = '#FFFFFF'; $chart->series[5]->dataLabels->style->fontSize = $fontSize; $chart->series[5]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[5]->lineWidth = 2; $chart->series[5]->color = '#F79E03'; $chart->series[5]->marker->fillColor = '#F79E03'; $chart->series[5]->marker->radius = 2; $chart->series[5]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.y, 2, '.');}"); $chart->series[6]->type = 'spline'; $chart->series[6]->data = $dataCritical; $chart->series[6]->stack = 2; $chart->series[6]->tooltip->valueSuffix = ' ' . $unit; $chart->series[6]->dataLabels->crop = false; $chart->series[6]->name = $critical . '% of the plan'; $chart->series[6]->dataLabels->enabled = false; $chart->series[6]->dataLabels->rotation = -90; $chart->series[6]->dataLabels->align = 'right'; $chart->series[6]->dataLabels->x = 4; $chart->series[6]->dataLabels->y = 10; $chart->series[6]->dataLabels->color = '#FFFFFF'; $chart->series[6]->dataLabels->style->fontSize = $fontSize; $chart->series[6]->dataLabels->style->fontFamily = 'Verdana, sans-serif'; $chart->series[6]->lineWidth = 2; $chart->series[6]->color = 'red'; $chart->series[6]->marker->fillColor = 'red'; $chart->series[6]->marker->radius = 2; $chart->series[6]->dataLabels->formatter = new HighchartJsExpr("function() { return Highcharts.numberFormat(this.y, 2, '.');}"); return $chart; }
$bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); if ($vars['view'] == "quick" || $vars['view'] == "accurate" || $vars['view'] == "transfer" || $vars['view'] == "edit") { # $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id)); $bill_name = $bill_data['bill_name']; $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)")); $lastmonth_unix = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 1 MONTH))"); $rightnow_unix = dbFetchCell("SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP())"); $rightnow = $today . date(His); $before = $yesterday . date(His); $lastmonth = $last_month . date(His); $bill_name = $bill_data['bill_name']; $dayofmonth = $bill_data['bill_day']; $day_data = getDates($dayofmonth); $datefrom = $day_data['0']; $dateto = $day_data['1']; $lastfrom = $day_data['2']; $lastto = $day_data['3']; $rate_95th = $bill_data['rate_95th']; $dir_95th = $bill_data['dir_95th']; $total_data = $bill_data['total_data']; $rate_average = $bill_data['rate_average']; 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.";
$val_2 = $_GET['val_2']; function getDates($val_1, $val_2) { $subject = $val_1; $pattern = '/[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])/'; preg_match($pattern, $subject, $matches); $new_val_1 = $matches[0]; $new_val_1_time = strtotime($new_val_1); $subject = $val_1; $pattern = '/[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])/'; preg_match($pattern, $subject, $matches, $preg_offset_capture, 13); $new_val_2 = $matches[0]; $new_val_2_time = strtotime($new_val_2); $subject_d = $val_2; $pattern = '/([0-9]{4})-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])/'; preg_match($pattern, $subject_d, $matches_d); $new_val_3 = $matches_d[0]; $new_val_3_time = strtotime($new_val_3); if ($new_val_3_time < $new_val_2_time && $new_val_3_time > $new_val_1_time || ($new_val_3_time == $new_val_1_time || $new_val_3_time == $new_val_2_time)) { echo "true"; } else { echo "false"; } } if (isset($_GET['val_1'])) { getDates($val_1, $val_2); } ?> </body> </head> </html>
require 'includes/defaults.inc.php'; require 'config.php'; require 'includes/definitions.inc.php'; require 'includes/functions.php'; $options = getopt('r'); if (isset($options['r'])) { echo "Clearing history table.\n"; dbQuery('TRUNCATE TABLE `bill_history`'); } foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_id`') as $bill) { echo str_pad($bill['bill_id'] . ' ' . $bill['bill_name'], 30) . " \n"; $i = 0; while ($i <= 24) { unset($class); unset($rate_data); $day_data = getDates($bill['bill_day'], $i); $datefrom = $day_data['0']; $dateto = $day_data['1']; $check = dbFetchRow('SELECT * FROM `bill_history` WHERE bill_id = ? AND bill_datefrom = ? AND bill_dateto = ? LIMIT 1', array($bill['bill_id'], $datefrom, $dateto)); $period = getPeriod($bill['bill_id'], $datefrom, $dateto); $date_updated = str_replace('-', '', str_replace(':', '', str_replace(' ', '', $check['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']; $total_data = $rate_data['total_data']; $rate_average = $rate_data['rate_average']; if ($bill['bill_type'] == 'cdr') { $type = 'CDR'; $allowed = $bill['bill_cdr']; $used = $rate_data['rate_95th'];
<?php include_once "credentials.php"; ini_set('display_errors', 'On'); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // Create connection $connection = oci_connect($username = CISE_USER, $password = CISE_PASS, $connection_string = '//oracle.cise.ufl.edu/orcl'); //Select which type of query $sql = ""; switch ($_GET["queryType"]) { case "frequency": $sql = getFrequencyQuery($_GET["startDate"], $_GET["endDate"], $_GET["numberType"]); break; case "dates": $sql = getDates(); break; case "datesOfSystem": $sql = getDatesOfSystem($_GET["systemNumber"]); break; case "sumJackpot": $sql = getSumJackpot($_GET["winDate"], $_GET["tableName"]); break; case "bestWinnings": $sql = getBestWinnings($_GET["rn1"], $_GET["rn2"], $_GET["rn3"], $_GET["rn4"], $_GET["rn5"], $_GET["pbNum"]); break; case "frequencyInSystem": $sql = getFrequencyInSystem($_GET["startDate"], $_GET["endDate"], $_GET["numberType"], $_GET["systemNumber"]); break; case "jackpotPerYear": $sql = getJackpotPerYear();