$DBCONNECTION_REQUIRED=0;
include ("../../inc/includes.php");
+include_once ("inc/functions.php");
+
+$svg_color_names = Array('green', 'yellow', 'red', 'blue');
Session::checkRight("reports", "r");
Session::checkRight("computer", "r");
+$report_title = "Systèmes d'exploitation par implantation";
+
#Html::header(Report::getTypeName(2), $_SERVER['PHP_SELF'], "utils", "report");
-Html::header("Systèmes d'exploitation par implantation", $_SERVER['PHP_SELF'], "utils", "report");
+Html::header($report_title, $_SERVER['PHP_SELF'], "utils", "report");
Report::title();
-$computer = new Computer();
+echo "\n<p class='big b' style='margin: 5px; text-align: center'><span id='report_date' style='float: right; margin: 2px 20px; font-size: 75%; font-style: italic'>(".date('Y-m-d H:i:s')." UTC)</span>$report_title</p>";
-$state_sql = "";
-if (($state != "") AND ($state != "0")) {
- $state_sql = " AND `states_id` = '".$state."' ";
-}
+$computer = new Computer();
$itemtype = 'Computer';
$table_item = getTableForItemType($itemtype);
-echo "<span class='big b'>Systèmes d'exploitation par implantation</span><br><br>";
+//echo "<span class='big b'>Systèmes d'exploitation par implantation</span><br><br>";
echo "<table class='tab_cadrehov'>";
echo "<tr class='tab_bg_1'><th>Implantation</th><th>Système d'exploitation</th><th>Quantité</th></tr>";
$green_grand_total = 0;
$region_id = $region_data['id'];
if ($region_id != 0) {
$region_name = getTreeLeafValueName("glpi_entities", $region_id);
+ echo "<tr><th colspan='3'></th></tr>\n";
} else {
$region_name = "AUF (non classé)";
}
$query = "SELECT COUNT(c.id) AS count, e.name AS ename,
(CASE WHEN o.name REGEXP '^Debian ' THEN SUBSTRING_INDEX(REPLACE(o.name,' GNU/Linux',''),'.',1)
WHEN o.name REGEXP '^Ubuntu ' THEN SUBSTRING_INDEX(REPLACE(o.name,' LTS',''),'.',2)
- WHEN o.name REGEXP '^Microsoft ' THEN REPLACE(o.name,'Microsoft ','')
+ WHEN o.name REGEXP '^Microsoft' THEN REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(o.name,'(R)',''),'™',''),'®',''),'fessional',''),'fessionnel',''),'Microsoft ','')
WHEN o.name REGEXP '^Mac ' THEN REPLACE(o.name,'Mac ','')
ELSE o.name END) AS oname
FROM `$table_item` c
if (empty($data['oname'])) {
$data['oname'] = "<i>(indéterminé)</i>";
}
- if (($data['oname'] == 'Debian 7') || ($data['oname'] == 'Ubuntu 12.04')) {
- $oname_plus = '<svg width="5" height="5" style="background-color: #00ff00; margin: 1px;"/>';
+ if (($data['oname'] == 'Debian 8') || ($data['oname'] == 'Ubuntu 12.04')) {
+ $oname_plus = svg_bar(Array(1,0,0,0), 5, 5);
$green_total += $data['count'];
- } elseif (($data['oname'] == 'Debian 6') || ($data['oname'] == 'Ubuntu 10.04')) {
- $oname_plus = '<svg width="5" height="5" style="background-color: #ffff00; margin: 1px;"/>';
+ } elseif (($data['oname'] == 'Debian 7') || ($data['oname'] == 'Ubuntu 14.04')) {
+ $oname_plus = svg_bar(Array(0,1,0,0), 5, 5);
$yellow_total += $data['count'];
} elseif ((substr($data['oname'],0,7) == 'Windows') || (substr($data['oname'],strlen($data['oname'])-4,4) == 'OS X')) {
- $oname_plus = '<svg width="5" height="5" style="background-color: #0000ff; margin: 1px;"/>';
+ $oname_plus = svg_bar(Array(0,0,0,1), 5, 5);
$blue_total += $data['count'];
} else {
- $oname_plus = '<svg width="5" height="5" style="background-color: #ff0000; margin: 1px;"/>';
+ $oname_plus = svg_bar(Array(0,0,1,0), 5, 5);
$red_total += $data['count'];
}
echo "<tr class='tab_bg_2 auf_show_details'>";
$region_total += $data['count'];
}
-$green_svg = '<svg width="'.(400*$green_total/$region_total).'" height="5" style="background-color: #00ff00; margin: 1px 0;"/>';
-$yellow_svg = '<svg width="'.(400*$yellow_total/$region_total).'" height="5" style="background-color: #ffff00; margin: 1px 0;"/>';
-$red_svg = '<svg width="'.(400*$red_total/$region_total).'" height="5" style="background-color: #ff0000; margin: 1px 0;"/>';
-$blue_svg = '<svg width="'.(400*$blue_total/$region_total).'" height="5" style="background-color: #0000ff; margin: 1px 0;"/>';
echo "<tr class='tab_bg_2'><td class='b'> Sous-total</td>";
-echo "<td>".$green_svg.$yellow_svg.$red_svg.$blue_svg."</td>";
+echo "<td>".svg_bar(Array($green_total,$yellow_total,$red_total,$blue_total), 400, 5)."</td>";
echo "<td class='numeric b'>$region_total</td></tr>";
$green_grand_total += $green_total;
$grand_total += $region_total;
} // fin des régions
-echo "<tr class='tab_bg_1'><td colspan='3'> </td></tr>";
+#echo "<tr class='tab_bg_1'><td colspan='3'> </td></tr>";
+echo "<tr><th colspan='3'></th></tr>\n";
# total operating systems
$query = "SELECT COUNT(*) FROM `".$table_item."`
$result = $DB->query($query);
$total = $DB->result($result, 0, 0);
-$green_svg = '<svg width="'.(400*$green_grand_total/$grand_total).'" height="5" style="background-color: #00ff00; margin: 1px 0;"/>';
-$yellow_svg = '<svg width="'.(400*$yellow_grand_total/$grand_total).'" height="5" style="background-color: #ffff00; margin: 1px 0;"/>';
-$red_svg = '<svg width="'.(400*$red_grand_total/$grand_total).'" height="5" style="background-color: #ff0000; margin: 1px 0;"/>';
-$blue_svg = '<svg width="'.(400*$blue_grand_total/$grand_total).'" height="5" style="background-color: #0000ff; margin: 1px 0;"/>';
echo "<tr class='tab_bg_1'><td class='b'>Total général</td>";
-echo "<td>".$green_svg.$yellow_svg.$red_svg.$blue_svg."</td>";
+echo "<td>".svg_bar(Array($green_grand_total,$yellow_grand_total,$red_grand_total,$blue_grand_total), 400, 5)."</td>";
echo "<td class='numeric b'>$total</td></tr>";
echo "</table>";