Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*********************************************************************
- stats.php
- Stats board - Get some stats!
- Jorge Ferreira
- TCA
- **********************************************************************/
- require('staff.inc.php');
- $nav->setTabActive('statistics');
- $ost->addExtraHeader('<meta name="tip-namespace" content="dashboard.dashboard" />',
- "$('#content').data('tipNamespace', 'dashboard.dashboard');");
- require(STAFFINC_DIR.'header.inc.php');
- ?>
- <h2><?php echo __('');
- ?></h2>
- <!-- QUERIES -->
- <?php
- // created queries
- //
- $arrmonth = array();
- for($i=1; $i<13; $i++){
- $query = 'select count(*) as value
- from ost_ticket
- where MONTH(created)='.$i;
- $exquery = db_query($query);
- $arrmonth[$i] = db_result($exquery,0,"value");
- if($arrmonth[$i]==0){
- $arrmonth[$i]=null;
- }
- }
- $jan = $arrmonth[1];
- $fev = $arrmonth[2];
- $mar = $arrmonth[3];
- $may = $arrmonth[4];
- $apr = $arrmonth[5];
- $jun = $arrmonth[6];
- $jul = $arrmonth[7];
- $aug = $arrmonth[8];
- $set = $arrmonth[9];
- $oct = $arrmonth[10];
- $nov = $arrmonth[11];
- $dez = $arrmonth[12];
- $arrmonthclo = array();
- for($j=1; $j<13; $j++){
- $cloquery = 'select count(*) as value
- from ost_ticket
- where status_id = 3 and MONTH(created)='.$j;
- $cloexquery = db_query($cloquery);
- $arrmonthclo[$j] = db_result($cloexquery,0,"value");
- if($arrmonthclo[$j]==0){
- $arrmonthclo[$j]=null;
- }
- }
- $janclo = $arrmonthclo[1];
- $fevclo = $arrmonthclo[2];
- $marclo = $arrmonthclo[3];
- $mayclo = $arrmonthclo[4];
- $aprclo = $arrmonthclo[5];
- $junclo = $arrmonthclo[6];
- $julclo = $arrmonthclo[7];
- $augclo = $arrmonthclo[8];
- $setclo = $arrmonthclo[9];
- $octclo = $arrmonthclo[10];
- $novclo = $arrmonthclo[11];
- $dezclo = $arrmonthclo[12];
- $curmonthq = 'select month(curdate()) as value';
- $curmonthquery = db_query($curmonthq);
- $curmonth = db_result($curmonthquery,0,"value");
- $arrmonthove = array();
- for($k=1; $k<$curmonth+1; $k++){
- $ovequery = 'select count(*) as value
- from ost_ticket
- where MONTH(created)='.$k.' and isoverdue = 1';
- $oveexquery = db_query($ovequery);
- $arrmonthove[$k] = db_result($oveexquery,0,"value");
- if($arrmonthove[$k]==0){
- $arrmonthove[$k]=null;
- }
- }
- $janove = $arrmonthove[1];
- $fevove = $arrmonthove[2];
- $marove = $arrmonthove[3];
- $mayove = $arrmonthove[4];
- $aprove = $arrmonthove[5];
- $junove = $arrmonthove[6];
- $julove = $arrmonthove[7];
- $augove = $arrmonthove[8];
- $setove = $arrmonthove[9];
- $octove = $arrmonthove[10];
- $novove = $arrmonthove[11];
- $dezove = $arrmonthove[12];
- ?>
- <?php
- // Queries to fill table below
- //created by
- $arrstaff = array();
- for($l=1; $l<13; $l++){
- $query = 'select count(*) as value
- from ost_ticket
- where staff_id='.$l;
- $exquery = db_query($query);
- $arrstaff[$l] = db_result($exquery,0,"value");
- }
- $jorge = $arrstaff[1];
- $tiago = $arrstaff[2];
- $antonio = $arrstaff[3];
- $humberto = $arrstaff[4];
- $duarte = $arrstaff[5];
- $joao = $arrstaff[6];
- $dina = $arrstaff[12];
- //opened
- $arrstaffopened = array();
- for($l=1; $l<13; $l++){
- $query = 'select count(*) as value
- from ost_ticket
- where staff_id='.$l.' and closed is null';
- $exquery = db_query($query);
- $arrstaffopened[$l] = db_result($exquery,0,"value");
- }
- $jorgeopened = $arrstaffopened[1];
- $tiagoopened = $arrstaffopened[2];
- $antonioopened = $arrstaffopened[3];
- $humbertoopened = $arrstaffopened[4];
- $duarteopened = $arrstaffopened[5];
- $joaoopened = $arrstaffopened[6];
- $dinaopened = $arrstaffopened[12];
- //closed by
- $arrstaffclosed = array();
- for($l=1; $l<13; $l++){
- $query = 'select count(*) as value
- from ost_ticket
- where staff_id='.$l.' and closed is not null';
- $exquery = db_query($query);
- $arrstaffclosed[$l] = db_result($exquery,0,"value");
- }
- $jorgeclosed = $arrstaffclosed[1];
- $tiagoclosed = $arrstaffclosed[2];
- $antonioclosed = $arrstaffclosed[3];
- $humbertoclosed = $arrstaffclosed[4];
- $duarteclosed = $arrstaffclosed[5];
- $joaoclosed = $arrstaffclosed[6];
- $dinaclosed = $arrstaffclosed[12];
- ?>
- <?php
- $sqlqry = 'select distinct(o.name) as val, count(*) as nts
- from ost_ticket t, ost_user u, ost_organization o
- where t.user_id =u.id and u.org_id=o.id
- group by org_id
- order by count(*) desc
- limit 21';
- $sqlresult = db_query($sqlqry);
- $arrnameorg= array();
- $arrtksorg= array();
- $ctr=2;
- if ($sqlresult->num_rows > 0) {
- // output data of each row
- while($row = $sqlresult->fetch_assoc()) {
- $arrnameorg[$ctr]=$row["val"];
- $arrtksorg[$ctr]=$row["nts"];
- $ctr++;
- }
- }
- ?>
- <!-- END OF QUERIES -->
- <!-- SCRIPTS -->
- <script src="https://code.highcharts.com/highcharts.js"></script>
- <script src="https://code.highcharts.com/modules/data.js"></script>
- <script src="https://code.highcharts.com/modules/exporting.js"></script>
- <script type="text/javascript">
- $( function () {
- Highcharts.chart('rotatedbars', {
- chart: {
- type: 'column'
- },
- title: {
- text: 'Tickets by Company'
- },
- subtitle: {
- text: ''
- },
- xAxis: {
- type: 'category',
- labels: {
- rotation: -45,
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- },
- yAxis: {
- min: 0,
- title: {
- text: 'Tickets'
- }
- },
- legend: {
- enabled: false
- },
- tooltip: {
- pointFormat: 'Tickets: <b>{point.y:.0f}</b>'
- },
- series: [{
- name: 'Number',
- data: [
- ['<?php echo $arrnameorg[2]?>',<?php echo $arrtksorg[2]?>],
- ['<?php echo $arrnameorg[3]?>',<?php echo $arrtksorg[3]?>],
- ['<?php echo $arrnameorg[4]?>',<?php echo $arrtksorg[4]?>],
- ['<?php echo $arrnameorg[5]?>',<?php echo $arrtksorg[5]?>],
- ['<?php echo $arrnameorg[6]?>',<?php echo $arrtksorg[6]?>],
- ['<?php echo $arrnameorg[7]?>',<?php echo $arrtksorg[7]?>],
- ['<?php echo $arrnameorg[8]?>',<?php echo $arrtksorg[8]?>],
- ['<?php echo $arrnameorg[9]?>',<?php echo $arrtksorg[9]?>],
- ['<?php echo $arrnameorg[10]?>',<?php echo $arrtksorg[10]?>],
- ['<?php echo $arrnameorg[11]?>',<?php echo $arrtksorg[11]?>],
- ['<?php echo $arrnameorg[12]?>',<?php echo $arrtksorg[12]?>],
- ['<?php echo $arrnameorg[13]?>',<?php echo $arrtksorg[13]?>],
- ['<?php echo $arrnameorg[14]?>',<?php echo $arrtksorg[14]?>],
- ['<?php echo $arrnameorg[15]?>',<?php echo $arrtksorg[15]?>],
- ['<?php echo $arrnameorg[16]?>',<?php echo $arrtksorg[16]?>],
- ['<?php echo $arrnameorg[17]?>',<?php echo $arrtksorg[17]?>],
- ['<?php echo $arrnameorg[18]?>',<?php echo $arrtksorg[18]?>],
- ['<?php echo $arrnameorg[19]?>',<?php echo $arrtksorg[19]?>],
- ['<?php echo $arrnameorg[20]?>',<?php echo $arrtksorg[20]?>],
- ],
- dataLabels: {
- enabled: true,
- rotation: -90,
- color: '#FFFFFF',
- align: 'right',
- format: '{point.y:.0f}', // one decimal
- y: 10, // 10 pixels down from the top
- style: {
- fontSize: '13px',
- fontFamily: 'Verdana, sans-serif'
- }
- }
- }]
- });
- });
- </script>
- <script>
- //bar graph
- $( function () {
- Highcharts.chart('bargraph', {
- data: {
- table: 'datatable'
- },
- chart: {
- type: 'column'
- },
- title: {
- text: 'Ticket Stats by user'
- },
- yAxis: {
- allowDecimals: false,
- title: {
- text: 'Units'
- }
- },
- tooltip: {
- formatter: function () {
- return '<b>' + this.series.name + '</b><br/>' +
- this.point.y + ' ' + this.point.name.toLowerCase();
- }
- }
- });
- });
- </script>
- <script>
- //line graph
- $( function () {
- $('#linegraph').highcharts({
- title: {
- text: 'Monthly Ticket Report',
- x: -20 //center
- },
- xAxis: {
- categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
- },
- yAxis: {
- title: {
- text: '# Tickets'
- },
- plotLines: [{
- value: 0,
- width: 1,
- color: '#808080'
- }]
- },
- tooltip: {
- valueSuffix: ''
- },
- legend: {
- layout: 'vertical',
- align: 'right',
- verticalAlign: 'middle',
- borderWidth: 0
- },
- series: [{
- name: 'Created',
- data: [<?php echo $jan ?>,<?php echo $fev ?>,<?php echo $mar ?>,<?php echo $may ?>,<?php echo $apr ?>,<?php echo $jun ?>,
- <?php echo $jul ?>,<?php echo $aug ?>,<?php echo $set ?>,<?php echo $oct ?>,<?php echo $nov ?>,<?php echo $dez ?>]
- }, {
- name: 'Closed',
- data: [<?php echo $janclo ?>,<?php echo $fevclo ?>,<?php echo $marclo ?>,<?php echo $mayclo ?>,<?php echo $aprclo ?>,<?php echo $junclo ?>,
- <?php echo $julclo ?>,<?php echo $augclo ?>,<?php echo $setclo ?>,<?php echo $octclo ?>,<?php echo $novclo ?>,<?php echo $dezclo ?>]
- }, {
- name: 'Overdue',
- data: [<?php echo $janove ?>,<?php echo $fevove ?>,<?php echo $marove ?>,<?php echo $mayove ?>,<?php echo $aprove ?>,<?php echo $junove ?>,
- <?php echo $julove ?>,<?php echo $augove ?>,<?php echo $setove ?>,<?php echo $octove ?>,<?php echo $novove ?>,<?php echo $dezove ?>]
- }]
- });
- });
- </script>
- <!-- END OF SCRIPTS -->
- <!-- GRAPHS -->
- <div id="linegraph" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
- <div id="bargraph" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
- <div id="rotatedbars" style="min-width: 300px; height: 400px; margin: 0 auto"></div>
- <!-- END OF GRAPHS -->
- <!-- ADDITIONAL DATA -->
- <div>
- <table>
- <tr>
- <td>
- <table id="datatable" border="0">
- <thead>
- <tr>
- <th width="40"></th>
- <th width="60">António</th>
- <th width="60">Tiago</th>
- <th width="60">Humberto</th>
- <th width="60">Dina</th>
- <th width="60">João</th>
- <th width="60">Duarte</th>
- <th width="60">Jorge</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <th>Created</th>
- <td align="center"><?php echo $antonio; ?></td>
- <td align="center"><?php echo $tiago; ?></td>
- <td align="center"><?php echo $humberto; ?></td>
- <td align="center"><?php echo $dina; ?></td>
- <td align="center"><?php echo $joao; ?></td>
- <td align="center"><?php echo $duarte; ?></td>
- <td align="center"><?php echo $jorge; ?></td>
- </tr>
- <tr>
- <th>Closed</th>
- <td align="center"><?php echo $antonioclosed; ?></td>
- <td align="center"><?php echo $tiagoclosed; ?></td>
- <td align="center"><?php echo $humbertoclosed; ?></td>
- <td align="center"><?php echo $dinaclosed; ?></td>
- <td align="center"><?php echo $joaoclosed; ?></td>
- <td align="center"><?php echo $duarteclosed; ?></td>
- <td align="center"><?php echo $jorgeclosed; ?></td>
- </tr>
- <tr>
- <th>Open</th>
- <td align="center"><?php echo $antonioopened; ?></td>
- <td align="center"><?php echo $tiagoopened; ?></td>
- <td align="center"><?php echo $humbertoopened; ?></td>
- <td align="center"><?php echo $dinaopened; ?></td>
- <td align="center"><?php echo $joaoopened; ?></td>
- <td align="center"><?php echo $duarteopened; ?></td>
- <td align="center"><?php echo $jorgeopened; ?></td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </table>
- </div>
- <!-- END OF ADDITIONAL DATA -->
- <?php
- include(STAFFINC_DIR.'footer.inc.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement