Hi list,

Before, I have request a wish list to display the entity column on the stat 
page. After some try and error, here the modified functions displayStats on 
stat.function.php file to list the entity column before the number of ticket 
column. I don't know if it was already implement, but this mod was against GLPI 
14-11-2007 trunk.

Before you edit the stat.function.php file, please edit en_GB.php ( I'm using 
the english locale ) and include :
    $LANG["stats"][50]="Entity";
in that file.

Sorry, I'm not a full time programmer.. and this was my first attempt to 
contribute back to the community. Please pardon my coding style. The comment is 
include inside the code.

Thanks and Regards

=========== stat.function.php ============================

function displayStats($type,$field,$date1,$date2,$start,$value,$value2=""){
 // Add global $DB, so we could make some SQL query under this functions.
 global $DB,$LANG,$CFG_GLPI;

 // Set display type for export if define
 $output_type=HTML_OUTPUT;
 if (isset($_GET["display_type"]))
  $output_type=$_GET["display_type"];

 if ($output_type==HTML_OUTPUT) // HTML display
  echo "<div align ='center'>";

 if (is_array($value)){


  $end_display=$start+$_SESSION["glpilist_limit"];
  $numrows=count($value);
  if (isset($_GET['export_all'])) {
   $start=0;
   $end_display=$numrows;
  }
  $nbcols=8;
  if ($output_type!=HTML_OUTPUT) // not HTML display
   $nbcols--;
  echo displaySearchHeader($output_type,$end_display-$start+1,$nbcols);
  echo displaySearchNewLine($output_type);
  $header_num=1;
  echo displaySearchHeaderItem($output_type,"&nbsp;",$header_num);
  if ($output_type==HTML_OUTPUT){ // HTML display
   echo displaySearchHeaderItem($output_type,"",$header_num);
  }
  
  //echo $type;
  // Display Entity First if selected item is author,recipient,tech assign and 
tech followup - 11-12-2007
  if ($type=="user" || $type=="recipient" || $type=="technicien" || 
$type=="technicien_followup") {
   echo displaySearchHeaderItem($output_type,$LANG["stats"][50],$header_num);
  } // End Entity Display - 11-12-2007
  echo displaySearchHeaderItem($output_type,$LANG["stats"][13],$header_num);
  echo displaySearchHeaderItem($output_type,$LANG["stats"][14],$header_num);
  echo displaySearchHeaderItem($output_type,$LANG["stats"][15],$header_num);
  echo displaySearchHeaderItem($output_type,$LANG["stats"][25],$header_num);
  echo displaySearchHeaderItem($output_type,$LANG["stats"][27],$header_num);
  echo displaySearchHeaderItem($output_type,$LANG["stats"][30],$header_num);
  // End Line for column headers  
  echo displaySearchEndLine($output_type);
  $row_num=1;
  for ($i=$start;$i< $numrows && $i<($end_display);$i++){
   $row_num++;
   $item_num=1;
   echo displaySearchNewLine($output_type,$i%2);
   echo displaySearchItem($output_type,$value[$i]['link'],$item_num,$row_num);
   if ($output_type==HTML_OUTPUT){ // HTML display
    
    $link="";
    if ($value[$i]['ID']>0){
     $link="<a 
href='stat.graph.php?ID=".$value[$i]['ID']."&amp;date1=$date1&amp;date2=$date2&amp;type=$type".(!empty($value2)?"&amp;champ=$value2":"")."'><img
 src=\"".$CFG_GLPI["root_doc"]."/pics/stats_item.png\" alt='' title=''></a>";
    }
    echo displaySearchItem($output_type,$link,$item_num,$row_num);
   }
   
   // Display Entity Value if selected item is author,recipient,tech assign and 
tech followup - 11-12-2007
   if ($type=="user" || $type=="recipient" || $type=="technicien" || 
$type=="technicien_followup") {
    // Create query for full entity name refer by users id
    $query="SELECT GROUP_CONCAT( glpi_entities.completename SEPARATOR ' / ') AS 
ENTITY FROM glpi_users LEFT JOIN glpi_users_profiles ON (glpi_users.ID = 
glpi_users_profiles.FK_users) LEFT JOIN ( SELECT * FROM glpi_entities UNION 
SELECT 0 AS ID, 'Root entity' AS name, -1 AS parentID, 'Root entity' AS 
completename, '' AS comments, -1 AS level) AS glpi_entities ON 
(glpi_users_profiles.FK_entities = glpi_entities.ID) LEFT JOIN glpi_profiles ON 
(glpi_users_profiles.FK_profiles = glpi_profiles.ID) WHERE 
glpi_users.ID=".$value[$i]['ID'].";";
    $result=$DB->query($query);
    if ($DB->numrows($result)>0){
      while ($data=$DB->fetch_array($result)){
        echo displaySearchItem($output_type,$data['ENTITY'],$item_num,$row_num);
      }
    }
   } // End Entity Display - 11-12-2007

   //le nombre d'intervention
   //the number of intervention
   
$opened=constructEntryValues("inter_total",$date1,$date2,$type,$value[$i]["ID"],$value2);
   $nb_opened=array_sum($opened);
   echo displaySearchItem($output_type,$nb_opened,$item_num,$row_num);
   //le nombre d'intervention resolues
   //the number of resolved intervention
   
$solved=constructEntryValues("inter_solved",$date1,$date2,$type,$value[$i]["ID"],$value2);
   $nb_solved=array_sum($solved);
   echo displaySearchItem($output_type,$nb_solved,$item_num,$row_num);
   //Le temps moyen de resolution
   //The average time to resolv
   
$data=constructEntryValues("inter_avgsolvedtime",$date1,$date2,$type,$value[$i]["ID"],$value2);
   foreach ($data as $key2 => $val2){
    $data[$key2]*=$solved[$key2];
   }
   if ($nb_solved>0)
    $nb=array_sum($data)/$nb_solved;
   else $nb=0;

   $timedisplay=$nb*HOUR_TIMESTAMP;
   if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT){
    $timedisplay=timestampToString($timedisplay,0);
   }
   echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num);
   //Le temps moyen de l'intervention r�lle
   //The average realtime to resolv
   
$data=constructEntryValues("inter_avgrealtime",$date1,$date2,$type,$value[$i]["ID"],$value2);
   foreach ($data as $key2 => $val2){
    $data[$key2]*=$solved[$key2];
   }
   $total_realtime=array_sum($data);
   if ($nb_solved>0)
    $nb=$total_realtime/$nb_solved;
   else $nb=0;

   $timedisplay=$nb*MINUTE_TIMESTAMP;
   if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT){
    $timedisplay=timestampToString($timedisplay,0);
   }
   echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num);
   //Le temps total de l'intervention r�lle
   //The total realtime to resolv
   $timedisplay=$total_realtime*MINUTE_TIMESTAMP;
   if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT){
    $timedisplay=timestampToString($timedisplay,0);
   }
   echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num);    
   //Le temps moyen de prise en compte du ticket
   //The average time to take a ticket into account
   
$data=constructEntryValues("inter_avgtakeaccount",$date1,$date2,$type,$value[$i]["ID"],$value2);

   foreach ($data as $key2 => $val2){
    $data[$key2]*=$solved[$key2];
   }
   if ($nb_solved>0)
    $nb=array_sum($data)/$nb_solved;
   else $nb=0;

   $timedisplay=$nb*HOUR_TIMESTAMP;
   if ($output_type==HTML_OUTPUT || $output_type==PDF_OUTPUT){
    $timedisplay=timestampToString($timedisplay,0);
   }
   echo displaySearchItem($output_type,$timedisplay,$item_num,$row_num);

   echo displaySearchEndLine($output_type);
  }
  // Display footer
  echo displaySearchFooter($output_type);
 } else {
  echo $LANG["stats"][23];
 }
 if ($output_type==HTML_OUTPUT) // HTML display
  echo "</div>";
}
========================== stat.function.php =========================



_______________________________________________
Glpi-dev mailing list
Glpi-dev@gna.org
https://mail.gna.org/listinfo/glpi-dev

Reply via email to