You are not logged in.
Bonjour,
Nouvel arrivant, je tenais à remercier toute l'équipe pour ce MAGNIFIQUE soft et lui souhaite une longue Vie.
Après avoir parcouru le forum et n'ayant pas trouver le sujet pouvant me concerner, je vous expose ma question : existe-t-il un moyen (plugin ?) d'afficher les différents status (stock, déployé...) par type (desktop / laptop...) et modèle (Dell GX520 - HP dc7700...) et cela pour les UCS, les 2crans ou les Imprimantes ?
En vous remerciant d'avance...
Offline
.... Je pense n'avoir pas été assez précis : sur la même base pour le "Rapport par défaut" (dans Outils---> Rapport) , afficher les nombres de machines par Etats / Types / Modèles.
Je sais qu'on peut obtenir le même résultat en jouant sur les filtres mais s'il est possible d'obtenir le même résultat de façon + automatique.
Offline
Bonjour messieurs,
Une petite réponse si possible svp...?
Dans tout les cas, merci pour cette belle résussite que "Gloupi" (surnom affectueux de GLPI).
Cordialement,
PS : Je vais essayer de convaincre ma direction pour un don pour son efficacité et son utilité.
Offline
Il faut écrire un nouveau rapport.
Le plugin "reports" apporte un solution simple et rapidement (simpleReports) pour cela, ainsi que de nombreux exemple.
Il suffit souvent d'écrire une requete SQL (le moteur de recherche en mode Debug permet d'obtenir un squellete rapidement).
Sinon, le rapport pcsbyentity peut aussi être un point de départ (comptage par statut, 1 colonne par statut).
Autre solution : export CSV et travail dans un tableur.
+
Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/
Offline
Merci pour la réponse Rémi (et pour le plugin Rapports supplémentaires),
Ce sont les méthodes que j'utilise à ce jour (sauf pour les requetes SQL car je n'ai aucune connaissance là-dessus même si je tente qqes manips... Je ne désespère pas).
L'idée était en effet soit de détailler pcsbyentity soit d'ajouter un nouveau rapports dans RAPPORTS SUPPLEMENTAIRES mais je ne connais rien en PHP non plus.Snifff.
Donc, je vais continuer de faire comme avant, à la mano.
Merci encore Rémi.
Offline
Bonjour,
Pour ceux qui seraient intéressés par des états détaillés par MODEL & STATUS des PCs, Ecrans, Imprimantes, voici le code modifié à partir du plugin Reports de Rémi.
Insertion à partir de la ligne 179. Modification des lignes 307 & 324
Le fichier concerné est ...\xampp\htdocs\glpi\plugins\reports\report\plugin_reports.pcsbyentity.php
Code:
<?php
/*
----------------------------------------------------------------------
GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2008 by the INDEPNET Development Team.
http://indepnet.net/ http://glpi-project.org/
----------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------------------
*/
// Original Author of file: Remi Collet
// Purpose of file:
// ----------------------------------------------------------------------
function cmpStat ($a, $b) {
return $a["tot"]-$b["tot"];
}
function doStatBis ($table, $entities, $header) {
global $DB, $LANG, $GEDIFFREPORTLANG;
// Compute stat
$counts=array();
foreach ($entities as $entity) {
// Count for this entity
$sql = "SELECT state,count(*) as cpt FROM " . $table .
" WHERE deleted=0 AND is_template=0 AND FK_entities=" . $entity . " GROUP BY state";
$result = $DB->query($sql);
$counts[$entity]=array();
while ($data = $DB->fetch_array($result)) {
$counts[$entity][$data["state"]]=$data["cpt"];
}
$counts[$entity]["tot"]=0;
foreach ($header as $id => $name) {
if (isset($counts[$entity][$id]))
$counts[$entity]["tot"] += $counts[$entity][$id];
else
$counts[$entity][$id]=0;
}
}
// Sort result
uasort($counts,"cmpStat");
// Display result
$total["tot"]=0;
foreach ($header as $id => $name) $total[$id]=0;
foreach ($counts as $entity => $count) if ($count["tot"]){
$Ent = new Entity();
$Ent->getFromDB($entity);
echo "<tr class='tab_bg_2'><td align='left'>";
if ($entity)
echo $Ent->fields["name"] . "</td>";
else
echo $LANG["entity"][2] . "</td>";
echo "<td align='right'>" . $count["tot"] . "</td>";
$total["tot"] += $count["tot"];
foreach ($header as $id => $name) {
echo "<td align='right'>" . $count[$id] . "</td>";
$total[$id] += $count[$id];
}
echo "</tr>\n";
}
// Display total
if (count($entities)>1) {
echo "<tr class='tab_bg_1'><td align='left'>" . $GEDIFFREPORTLANG["pcsbyentity"][3] . "</td>";
echo "<td align='right'>" . $total["tot"] . "</td>";
foreach ($header as $id => $name) {
echo "<td align='right'>" . $total[$id] . "</td>";
}
echo "</tr>\n";
}
}
function doStat ($table, $entity, $header, $level=0) {
global $DB, $LANG, $GEDIFFREPORTLANG;
$Ent = new Entity();
$Ent->getFromDB($entity);
// Count for this entity
$sql = "SELECT state,count(*) as cpt FROM " . $table .
" WHERE deleted=0 AND is_template=0 AND FK_entities=" . $entity . " GROUP BY state";
$result = $DB->query($sql);
$count=array();
while ($data = $DB->fetch_array($result)) {
$count[$data["state"]]=$data["cpt"];
}
$count["tot"]=0;
foreach ($header as $id => $name) {
if (isset($count[$id]))
$count["tot"] += $count[$id];
else
$count[$id]=0;
}
// Display counters for this entity
if ($count["tot"]>0) {
echo "<tr class='tab_bg_2'><td align='left'>";
for ($i=0 ; $i<$level ; $i++) echo " ";
if ($entity) {
echo $Ent->fields["name"] . "</td>";
}
else
echo $LANG["entity"][2] . "</td>";
echo "<td align='right'>" . $count["tot"] . "</td>";
foreach ($header as $id => $name) {
echo "<td align='right'>" . $count[$id] . "</td>";
}
echo "</tr>\n";
}
// Call for Childs
$save=$count["tot"];
doStatChilds($table,$entity, $header, $count, $level+1);
// Display total (Current+Childs)
if ($save != $count["tot"]) {
echo "<tr class='tab_bg_1'><td align='left'>";
for ($i=0 ; $i<$level ; $i++) echo " ";
echo $GEDIFFREPORTLANG["pcsbyentity"][3] . " ";
if ($entity)
echo $Ent->fields["name"] . "</td>";
else
echo $LANG["entity"][2] . "</td>";
echo "<td align='right'>" . $count["tot"] . "</td>";
foreach ($header as $id => $name) {
echo "<td align='right'>" . $count[$id] . "</td>";
}
echo "</tr>\n";
}
return $count;
}
function doStatChilds($table, $entity, $header, &$total, $level) {
global $DB, $LANG;
// Search child entities
$sql = "SELECT ID FROM glpi_entities WHERE parentID=" . $entity . " ORDER BY name";
$result = $DB->query($sql);
while ($data = $DB->fetch_array($result)) {
$fille=doStat($table, $data["ID"], $header, $level);
foreach ($header as $id => $name){
$total[$id] += $fille[$id];
}
$total["tot"] += $fille["tot"];
}
}
//Tri par model
function doStatModel($table)
{
$tmp_table = explode('_', $table);
$model_table = 'glpi_dropdown_model';
if($tmp_table[1] != 'computers')
$model_table .= '_' . $tmp_table[1];
// model
$sql = "SELECT m.ID AS id_model, m.name AS model";
$sql .= " FROM $model_table m";
$sql .= " ORDER BY m.name;";
$model_result = mysql_query($sql);
while($model = mysql_fetch_assoc($model_result))
{
// total
$sql = "SELECT count(ID) AS total";
$sql .= " FROM $table";
$sql .= " WHERE deleted = 0";
$sql .= " AND model = " . $model['id_model'];
$total_result = mysql_query($sql);
$total_tmp = mysql_fetch_assoc($total_result);
$total = $total_tmp['total'];
// On n'affiche pas les models sans unité
if(!$total)
continue;
// inconnu
$sql = "SELECT count(ID) AS uk";
$sql .= " FROM $table";
$sql .= " WHERE deleted = 0";
$sql .= " AND model = " . $model['id_model'];
$sql .= " AND state = 0;";
$uk_result = mysql_query($sql);
$uk_tmp = mysql_fetch_assoc($uk_result);
$uk = $uk_tmp['uk'];
echo "<tr class='tab_bg_2'><td align='left'>" . $model['model'] . "</td>";
echo "<td align='right'>" . $total . '</td>';
echo "<td align='right'>" . $uk . '</td>';
// state
$sql = "SELECT ID AS state";
$sql .= " FROM glpi_dropdown_state";
$sql .= " ORDER BY ID;";
$state_result = mysql_query($sql);
while($state_tmp = mysql_fetch_assoc($state_result))
{
$state = $state_tmp['state'];
$sql = "SELECT count(t.ID) AS nb";
$sql .= " FROM $table t";
$sql .= " WHERE t.deleted = 0 ";
$sql .= " AND t.model = " . $model['id_model'];
$sql .= " AND t.state = $state;";
$state_nb_result = mysql_query($sql) or die(mysql_error());
$state_nb = mysql_fetch_assoc($state_nb_result);
echo "<td align='right'>" . $state_nb['nb'] . '</td>';
}
echo '</tr>';
}
}
//Options for GLPI 0.71 and newer : need slave db to access the report
$USEDBREPLICATE=1;
$DBCONNECTION_REQUIRED=0;
$NEEDED_ITEMS=array("entity");
define('GLPI_ROOT', '../../..');
include (GLPI_ROOT . "/inc/includes.php");
includeLocales("plugin_reports.pcsbyentity");
plugin_reports_checkRight("pcsbyentity","r");
commonHeader($GEDIFFREPORTLANG["pcsbyentity"][1],$_SERVER['PHP_SELF'],"utils","report");
echo "<div align='center'>";
// ---------- Form ------------
echo "<form action='".$_SERVER["PHP_SELF"]."' method='post'>";
echo "<table class='tab_cadre' cellpadding='5'>\n";
echo "<tr class='tab_bg_1' align='center'><th colspan='2'>" . $GEDIFFREPORTLANG["pcsbyentity"][1] . "</th></tr>\n";
echo "<tr class='tab_bg_1'><td align='right'>" . $GEDIFFREPORTLANG["pcsbyentity"][2] . " : </td>";
echo "<td><select name='type'><option value=''>---</option>";
$choix=array(
COMPUTER_TYPE => $LANG["Menu"][0],
MONITOR_TYPE => $LANG["Menu"][3],
PRINTER_TYPE => $LANG["Menu"][2],
NETWORKING_TYPE => $LANG["title"][6],
PHONE_TYPE => $LANG["help"][35]);
foreach ($choix as $id => $name) {
if (haveTypeRight($id, "r")) {
echo "<option value='" . $id;
if(isset($_POST["type"]) && $_POST["type"]==$id)
echo "' selected='selected'>";
else
echo "'>";
echo $name . "</option>";
}
}
echo "</select></td></tr>\n";
if (count($_SESSION["glpiactiveentities"])>1) {
echo "<tr class='tab_bg_1'><td align='right'>" . $GEDIFFREPORTLANG["pcsbyentity"][5] . " : </td>";
echo "<td><select name='sort'><option value='0'>".$GEDIFFREPORTLANG["pcsbyentity"][6]."</option>";
echo "<option value='1'>".$GEDIFFREPORTLANG["pcsbyentity"][7]."</option></select></td></tr>\n";
}
echo "<tr class='tab_bg_1' align='center'><td colspan='2'><input type='submit' value='Valider' class='submit' />";
echo "</td></tr>\n";
echo "</table>\n</form></div>\n";
// --------------- Result -------------
if(isset($_POST["type"]) && $_POST["type"]>0)
{
echo "<table class='tab_cadre'>\n";
//echo "<tr><th>".$LANG["entity"][0]. "</th>" .
echo "<tr><th>Model</th>" .
"<th> " . $GEDIFFREPORTLANG["pcsbyentity"][3] . " </th>" .
"<th> " . $GEDIFFREPORTLANG["pcsbyentity"][4] . " </th>";
$sql = "SELECT ID,name FROM glpi_dropdown_state ORDER BY ID";
$result = $DB->query($sql);
$header[0]=$GEDIFFREPORTLANG["pcsbyentity"][4];
while ($data = $DB->fetch_array($result)) {
$header[$data["ID"]]=$data["name"];
echo "<th> " . $data["name"] . " </th>";
}
echo "</tr>\n";
if(isset($_POST["sort"]) && $_POST["sort"]>0)
doStatBis($LINK_ID_TABLE[$_POST["type"]], $_SESSION["glpiactiveentities"], $header);
else
//doStat($LINK_ID_TABLE[$_POST["type"]], $_SESSION["glpiactive_entity"], $header);
doStatModel($LINK_ID_TABLE[$_POST["type"]]);
echo "</table></div>";
}
commonFooter();
?>
Offline