[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/HelpDesk/ -> TicketStatisticsUtil.php (source)

   1  <?php
   2  /*********************************************************************************
   3  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   4   * ("License"); You may not use this file except in compliance with the License
   5   * The Original Code is:  vtiger CRM Open Source
   6   * The Initial Developer of the Original Code is vtiger.
   7   * Portions created by vtiger are Copyright (C) vtiger.
   8   * All Rights Reserved.
   9  *
  10   ********************************************************************************/
  11  require_once ('include/database/PearDatabase.php');
  12  
  13  
  14  /**    Function to get the total number of tickets ie.. count of all tickets 
  15   *    @return int $totTickets - total count of tickets
  16  **/
  17  function getTotalNoofTickets()
  18  {
  19      global $log;
  20      $log->debug("Entering getTotalNoofTickets() method ...");
  21      global $adb;
  22      $query = "select count(*) as totalticketcount from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0";
  23      $result = $adb->query($query);
  24      $totTickets = $adb->query_result($result,0,"totalticketcount");
  25      $log->debug("Exiting getTotalNoofTickets method ...");
  26      return $totTickets;
  27  }
  28  
  29  /**     Function to get the total number of tickets which are not Closed
  30   *      @return int $totTickets - total count of not Closed tickets
  31  **/
  32  function getTotalNoofOpenTickets()
  33  {
  34      global $log;
  35      $log->debug("Entering getTotalNoofOpenTickets() method ...");
  36      global $adb;
  37      $query = "select count(*) as totalopenticketcount from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status !='Closed'";
  38      $result = $adb->query($query);
  39      $totOpenTickets = $adb->query_result($result,0,"totalopenticketcount");
  40      $log->debug("Exiting getTotalNoofOpenTickets method ...");
  41      return $totOpenTickets;
  42  }
  43  
  44  /**     Function to get the total number of Closed tickets
  45   *      @return int $totTickets - total count of Closed tickets
  46  **/
  47  function getTotalNoofClosedTickets()
  48  {
  49      global $log;
  50      $log->debug("Entering getTotalNoofClosedTickets() method ...");
  51      global $adb;
  52      $query = "select count(*) as totalclosedticketcount from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and vtiger_troubletickets.status ='Closed'";
  53      $result = $adb->query($query);
  54      $totClosedTickets = $adb->query_result($result,0,"totalclosedticketcount");
  55      $log->debug("Exiting getTotalNoofClosedTickets method ...");
  56      return $totClosedTickets;
  57  }
  58  
  59  /**     Function to get the length of the bar to be displayed for the given value
  60   *    @param  int $val - the number of tickets value
  61   *    @param  string $image_path - image path of the bar per theme basis
  62   *    @param  int $singleUnit - the single bar length value which is calculated as 80/total no. of tickets
  63   *      @return int $out - the bar length value to be displayed which is calculated based on the $val parameter
  64  **/
  65  function outBar($val,$image_path,$singleUnit) 
  66  {
  67      global $log;
  68      $log->debug("Entering outBar(".$val.",".$image_path.",".$singleUnit.") method ...");
  69      $scale = round($val*$singleUnit);
  70      if($scale < 1 && $scale > 0)
  71      {
  72          $scale = 1;
  73      }
  74          $out = '<img src='.$image_path.'bl_bar.jpg height=10 width='. $scale .'%>';
  75          $out .= str_pad($val, (3-strlen(strval($val)))*12 + strlen(strval($val)), "&nbsp;&nbsp;", STR_PAD_LEFT);
  76  
  77      $log->debug("Exiting outBar method ...");
  78      return $out;
  79  }
  80  
  81  /**     Function to display the statistics based on the Priority ie., will display all the Priorities and the no. of tickets per Priority
  82   *      @param  string $image_path - image path of the bar per theme basis
  83   *      @param  int $singleUnit - the single bar length value which is calculated as 80/total no. of tickets
  84   *      @return void. 
  85  **/
  86  function showPriorities($image_path, $singleUnit)
  87  {
  88      global $log;
  89      $log->debug("Entering showPriorities(".$image_path.",". $singleUnit.") method ...");
  90      global $adb;
  91      global $mod_strings;
  92      $prresult = getFromDB("ticketpriorities");
  93      $noofrows = $adb->num_rows($prresult);
  94      $prOut = '';
  95  
  96      for($i=0; $i<$noofrows; $i++)
  97      {
  98          $priority_val = $adb->query_result($prresult,$i,"ticketpriorities");
  99          $prOut .= '<tr>';
 100          if($i == 0)
 101          {
 102                  $prOut .=  '<td class="dataLabel" width="10%" noWrap><div align="left">'.$mod_strings['LBL_PRIORITIES'].'</div></td>';
 103          }
 104          else
 105          {
 106              
 107                  $prOut .=  '<td class="dataLabel" width="10%" noWrap><div align="left"> </div></td>';
 108          }
 109                $prOut .= '<TD  class="dataLabel" width="10%" noWrap ><div align="left">'.$priority_val.'</div></TD>';
 110          $noofOpenTickets = getTicketCount("Open", $priority_val, "priority");
 111          $noofClosedTickets = getTicketCount("Closed", $priority_val, "priority"); 
 112          $noofTotalTickets = getTicketCount("Total", $priority_val, "priority");
 113          $openOut = outBar($noofOpenTickets, $image_path, $singleUnit); 
 114          $closeOut = outBar($noofClosedTickets, $image_path, $singleUnit); 
 115          $totOut = outBar($noofTotalTickets, $image_path, $singleUnit); 
 116                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$openOut.'</div></TD>';
 117                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$closeOut.'</div></TD>';
 118                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$totOut.'</div></TD>';
 119          $prOut .= '</tr>';
 120          
 121      }
 122      $log->debug("Exiting showPriorities method ...");
 123      return $prOut;
 124  }
 125  
 126  /**     Function to display the statistics based on the Category ie., will display all the Categories and the no. of tickets per Category
 127   *      @param  string $image_path - image path of the bar per theme basis
 128   *      @param  int $singleUnit - the single bar length value which is calculated as 80/total no. of tickets
 129   *      @return void.
 130  **/
 131  function showCategories($image_path, $singleUnit)
 132  {
 133      global $log;
 134      $log->debug("Entering showCategories(".$image_path.",". $singleUnit.") method ...");
 135      global $adb;
 136      global $mod_strings;
 137      $prresult = getFromDB("ticketcategories");
 138      $noofrows = $adb->num_rows($prresult);
 139      $prOut = '';
 140  
 141      for($i=0; $i<$noofrows; $i++)
 142      {
 143          $priority_val = $adb->query_result($prresult,$i,"ticketcategories");
 144          $prOut .= '<tr>';
 145          if($i == 0)
 146          {
 147                  $prOut .=  '<td class="dataLabel" width="10%" noWrap><div align="left">'.$mod_strings['LBL_CATEGORIES'].'</div></td>';
 148          }
 149          else
 150          {
 151              
 152                  $prOut .=  '<td class="dataLabel" width="10%" noWrap><div align="left"> </div></td>';
 153          }    
 154                $prOut .= '<TD  class="dataLabel" width="10%" noWrap ><div align="left">'.$priority_val.'</div></TD>';
 155          $noofOpenTickets = getTicketCount("Open", $priority_val, "category");
 156          $noofClosedTickets = getTicketCount("Closed", $priority_val, "category"); 
 157          $noofTotalTickets = getTicketCount("Total", $priority_val, "category");
 158          $openOut = outBar($noofOpenTickets, $image_path, $singleUnit); 
 159          $closeOut = outBar($noofClosedTickets, $image_path, $singleUnit); 
 160          $totOut = outBar($noofTotalTickets, $image_path, $singleUnit); 
 161                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$openOut.'</div></TD>';
 162                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$closeOut.'</div></TD>';
 163                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$totOut.'</div></TD>';
 164          $prOut .= '</tr>';
 165          
 166      }
 167      $log->debug("Exiting showCategories method ...");
 168      return $prOut;
 169          
 170      
 171  }
 172  
 173  /**     Function to display the statistics based on the Users ie., will display all the vtiger_users and the no. of tickets per user
 174   *      @param  string $image_path - image path of the bar per theme basis
 175   *      @param  int $singleUnit - the single bar length value which is calculated as 80/total no. of tickets
 176   *      @return void.
 177  **/
 178  function showUserBased($image_path, $singleUnit)
 179  {
 180      global $log;
 181      $log->debug("Entering showUserBased(".$image_path.",". $singleUnit.") method ...");
 182      global $adb;
 183      global $mod_strings;
 184      $prresult = getFromDB("users");
 185      $noofrows = $adb->num_rows($prresult);
 186      $prOut = '';
 187  
 188      for($i=0; $i<$noofrows; $i++)
 189      {
 190          $priority_val = $adb->query_result($prresult,$i,"id");
 191          $user_name = $adb->query_result($prresult,$i,"user_name");
 192          $prOut .= '<tr>';
 193          if($i == 0)
 194          {
 195                  $prOut .=  '<td class="dataLabel" width="10%" noWrap><div align="left">'.$mod_strings['LBL_SUPPORTERS'].'</div></td>';
 196          }
 197          else
 198          {
 199              
 200                  $prOut .=  '<td class="dataLabel" width="10%" noWrap><div align="left"> </div></td>';
 201          }    
 202                $prOut .= '<TD  class="dataLabel" width="10%" noWrap ><div align="left">'.$user_name.'</div></TD>';
 203          $noofOpenTickets = getTicketCount("Open", $priority_val, "smownerid");
 204          $noofClosedTickets = getTicketCount("Closed", $priority_val, "smownerid"); 
 205          $noofTotalTickets = getTicketCount("Total", $priority_val, "smownerid");
 206          $openOut = outBar($noofOpenTickets, $image_path, $singleUnit); 
 207          $closeOut = outBar($noofClosedTickets, $image_path, $singleUnit); 
 208          $totOut = outBar($noofTotalTickets, $image_path, $singleUnit); 
 209                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$openOut.'</div></TD>';
 210                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$closeOut.'</div></TD>';
 211                $prOut .= '<TD  width="25%" noWrap ><div align="left">'.$totOut.'</div></TD>';
 212          $prOut .= '</tr>';
 213          
 214      }
 215      $log->debug("Exiting showUserBased method ...");
 216      return $prOut;
 217          
 218      
 219  }
 220  
 221  /**     Function to retrieve all values from the vtiger_table which is passed as the parameter
 222   *      @param  string $tableName - vtiger_table name in which we want to get the result
 223   *      @return result $result - the result of the query "select * from $tableName" will be return
 224  **/
 225  function getFromDB($tableName)
 226  {
 227      global $log;
 228      $log->debug("Entering getFromDB(".$tableName.") method ...");
 229      global $adb;
 230      $query = "select * from ".$tableName;
 231      $result = $adb->query($query);
 232      $log->debug("Exiting getFromDB method ...");
 233      return $result;
 234  }
 235  
 236  /**     Function to get the number of tickets based on the User or Priority or Category which is passed as a parameter
 237   *      @param  string $mode - the status of the ticket ie., Open or Closed. if Total then all tickets count will be retrieved
 238   *      @param  string $priority_val - the value based on which we get tickets ie., id of the user or vtiger_ticketcategories or vtiger_ticketpriorities
 239   *      @param  int $critColName - smownerid or category or vtiger_priority which is the vtiger_fieldname of the vtiger_table in which we check $priority_val
 240   *      @return void.
 241  **/
 242  function getTicketCount($mode, $priority_val, $critColName)
 243  {
 244      global $log;
 245      $log->debug("Entering getTicketCount(".$mode.",". $priority_val.",". $critColName.") method ...");
 246      if($critColName == "smownerid")
 247      {
 248          $table_name = 'crmentity';
 249      }
 250      else
 251      {
 252          $table_name = 'troubletickets';
 253      }
 254      global $adb;
 255      if($mode == 'Open')
 256      {
 257          $query = "select count(*) as count from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0  and ".$table_name.".".$critColName."='".$priority_val."' and vtiger_troubletickets.status !='Closed'";
 258          
 259      }
 260      elseif($mode == 'Closed')
 261      {
 262          $query = "select count(*) as count from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and ".$table_name.".".$critColName."='".$priority_val."' and vtiger_troubletickets.status ='Closed'";
 263      }
 264      elseif($mode == 'Total')
 265      {
 266          $query = "select count(*) as count from vtiger_troubletickets inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_troubletickets.ticketid where vtiger_crmentity.deleted=0 and ".$table_name.".".$critColName."='".$priority_val."' and deleted='0'";
 267      }
 268      $result = $adb->query($query);
 269      $nooftickets = $adb->query_result($result,0,"count");
 270      $log->debug("Exiting getTicketCount method ...");
 271      return $nooftickets;
 272  }
 273  
 274  
 275  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7