PageRenderTime 59ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/site/views/report/tmpl/default.php

https://bitbucket.org/johansundell/hodumahelpdesk
PHP | 211 lines | 168 code | 21 blank | 22 comment | 19 complexity | d8dcd76f064086d8dee92b1345856d59 MD5 | raw file
  1. <?php
  2. /**
  3. * @package Hoduma
  4. * @copyright Copyright (c)2012 Hoduma.com, (c)2009-2011 Huru Helpdesk Developers
  5. * @license GNU General Public License version 3, or later
  6. *
  7. * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. * You should have received a copy of the GNU General Public License along with this program.
  12. * If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. defined('_JEXEC') or die('Restricted access');
  15. //check user auth level
  16. require_once JPATH_COMPONENT.DS.'helpers'.DS.'head.php';
  17. require_once JPATH_COMPONENT.DS.'helpers'.DS.'auth.php';
  18. $mainframe = &JFactory::getApplication();
  19. if(!checkuser('reports')) $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH'));
  20. //display page title if configured
  21. $params =& $mainframe->getParams('com_content');
  22. $this->assignRef('params' , $params);
  23. if ($this->params->get('show_page_title',1))
  24. {
  25. ?>
  26. <div class="componentheading<?php echo $this->escape($this->params->get('pageclass_sfx')); ?>">
  27. <?php echo $this->escape($this->params->get('page_title')); ?>
  28. </div>
  29. <?php
  30. }
  31. ?>
  32. <div class="pagetitle"><?php echo lang('PageTitle');?></div>
  33. <?php
  34. //report type
  35. $rtype = JRequest::getVar('rtype');
  36. //setup toolbar
  37. toolbar('closereport','refresh','home');
  38. //add up the totals
  39. $total_problems = 0;
  40. $total_time = 0;
  41. for($i=0,$n=count($this->rows); $i<$n; $i++)
  42. {
  43. $row =& $this->rows[$i];
  44. $total_problems += $row->total;
  45. $total_time += $row->total_time;
  46. }
  47. //build google chart URL
  48. $baseURL = 'http://chart.apis.google.com/chart?cht=p3&chs=700x200';
  49. $chartDataBase = '&amp;chd=t:';
  50. $chartLabelsBase = '&amp;chl=';
  51. $chartColors = '&amp;chco=ff0000,880000,00ff00,008800,0000ff,000088';
  52. ?>
  53. <form action="index.php" method="post" name="report">
  54. <table class="reporttable">
  55. <thead>
  56. <tr>
  57. <th align="center" class="report">
  58. <?php
  59. switch ($rtype)
  60. {
  61. case 'department':
  62. echo lang('Department');
  63. break;
  64. case 'category':
  65. echo lang('Category');
  66. break;
  67. case 'rep':
  68. echo lang('Rep');
  69. break;
  70. }
  71. ?>
  72. </th>
  73. <th align="center" class="report"><?php echo lang('Problems');?></th>
  74. <th align="center" class="report"><?php echo lang('Time').' ('.lang('min').')';?></th>
  75. <th align="center" class="report"><?php echo lang('AverageTime').' ('.lang('min').')';?></th>
  76. <th align="center" class="report"><?php echo lang('PercentProblemTotal');?></th>
  77. <th align="center" class="report"><?php echo lang('PercentTimeTotal');?></th>
  78. </tr>
  79. </thead>
  80. <?php
  81. if($total_problems > 0)
  82. {
  83. for($i=0,$n=count($this->rows); $i<$n; $i++)
  84. {
  85. $row =& $this->rows[$i];
  86. ?>
  87. <tr>
  88. <td align="center" class="">
  89. <?php
  90. //##my201004080406 { Fix warning
  91. if (!isset($chartLabels)) {
  92. $chartLabels = null;
  93. }
  94. //##my201004080406 }
  95. if(strlen($row->name)>0) echo $row->name; else echo lang('Unknown');
  96. if(strlen($chartLabels) > 0) $chartLabels = $chartLabels.'|'; //add delimiter if this is not the first label
  97. if(strlen($row->name)>0) $chartLabels = $chartLabels.$row->name; else $chartLabels = $chartLabels.lang('Unknown');
  98. ?>
  99. </td>
  100. <td align="center" class="">
  101. <?php echo number_format($row->total);?>
  102. </td>
  103. <td align="center" class="">
  104. <?php echo number_format($row->total_time);?>
  105. </td>
  106. <td align="center" class="">
  107. <?php echo number_format($row->total_time/$row->total);?>
  108. </td>
  109. <td align="center" class="">
  110. <?php
  111. //##my201004080406 { Fix warning
  112. if (!isset($chartData)) {
  113. $chartData = null;
  114. }
  115. //##my201004080406 }
  116. echo number_format(100*$row->total/$total_problems,1);
  117. if(strlen($chartData) > 0) $chartData = $chartData.','; //add a delimiter if this is not the first data point
  118. $chartData = $chartData.number_format(100*$row->total/$total_problems,1);
  119. ?>
  120. </td>
  121. <td align="center" class="">
  122. <?php
  123. if($total_time >0)
  124. {
  125. if (!isset($chart2Data)) {
  126. $chart2Data = null;
  127. }
  128. echo number_format(100*$row->total_time/$total_time,1);
  129. if(strlen($chart2Data) > 0) $chart2Data = $chart2Data.','; //add a delimiter if this is not the first data point
  130. $chart2Data = $chart2Data.number_format(100*$row->total_time/$total_time,1);
  131. }
  132. ?>
  133. </td>
  134. </tr>
  135. <?php
  136. }
  137. ?>
  138. <tr class="totals">
  139. <td align="center" class="totals">
  140. <?php echo lang('Total');?>
  141. </td>
  142. <td align="center" class="totals">
  143. <?php echo number_format($total_problems);?>
  144. </td>
  145. <td align="center" class="totals">
  146. <?php echo number_format($total_time);?>
  147. </td>
  148. <td align="center" class="totals">
  149. <?php echo number_format($total_time/$total_problems);?>
  150. </td>
  151. <td align="center" class="totals">
  152. </td>
  153. <td align="center" class="totals">
  154. </td>
  155. </tr>
  156. <?php
  157. }
  158. else
  159. {
  160. ?>
  161. <tr><td colspan="6"><?php echo lang('NoResultsFound');?></td></tr>
  162. <?php
  163. }
  164. ?>
  165. </table>
  166. <?php
  167. if($total_problems > 0)
  168. {
  169. $chartURL = $baseURL.$chartDataBase.$chartData.$chartLabelsBase.$chartLabels.$chartColors;
  170. ?>
  171. <p class="charttitle"><?php echo lang('PercentProblemTotal');?>
  172. <img src="<?php echo $chartURL;?>" alt="<?php echo lang('PercentProblemTotal');?>" align="center"/></p>
  173. <?php
  174. if($total_time >0)
  175. {
  176. $chartURL = $baseURL.$chartDataBase.$chart2Data.$chartLabelsBase.$chartLabels.$chartColors;
  177. ?>
  178. <p class="charttitle"><?php echo lang('PercentTimeTotal');?>
  179. <img src="<?php echo $chartURL;?>" alt="<?php echo lang('PercentTimeTotal');?>" align="center"/></p>
  180. <?php
  181. }
  182. }
  183. ?>
  184. <input type="hidden" name="option" value="<?php echo JRequest::getCmd('option'); ?>" />
  185. <input type="hidden" name="view" value="<?php echo JRequest::getVar('view',''); ?>" />
  186. <input type="hidden" name="task" value="" />
  187. <input type="hidden" name="type" value="<?php echo JRequest::getVar('type',''); ?>" />
  188. <input type="hidden" name="Itemid" value="<?php echo JRequest::getVar('Itemid',''); ?>" />
  189. <?php echo JHTML::_('form.token'); ?>
  190. </form>