ryxeo-glpi-git / htdocs / front / report.infocom.php @ 1c14bcc4
Historique | Voir | Annoter | Télécharger (8,51 ko)
1 | 1c14bcc4 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: report.infocom.php 7763 2009-01-06 18:44:50Z moyo $
|
||
4 | -------------------------------------------------------------------------
|
||
5 | GLPI - Gestionnaire Libre de Parc Informatique
|
||
6 | Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
||
7 | |||
8 | http://indepnet.net/ http://glpi-project.org
|
||
9 | -------------------------------------------------------------------------
|
||
10 | |||
11 | LICENSE
|
||
12 | |||
13 | This file is part of GLPI.
|
||
14 | |||
15 | GLPI is free software; you can redistribute it and/or modify
|
||
16 | it under the terms of the GNU General Public License as published by
|
||
17 | the Free Software Foundation; either version 2 of the License, or
|
||
18 | (at your option) any later version.
|
||
19 | |||
20 | GLPI is distributed in the hope that it will be useful,
|
||
21 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
23 | GNU General Public License for more details.
|
||
24 | |||
25 | You should have received a copy of the GNU General Public License
|
||
26 | along with GLPI; if not, write to the Free Software
|
||
27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
28 | --------------------------------------------------------------------------
|
||
29 | */
|
||
30 | |||
31 | // ----------------------------------------------------------------------
|
||
32 | // Original Author of file: Julien Dombre
|
||
33 | // Purpose of file:
|
||
34 | // ----------------------------------------------------------------------
|
||
35 | |||
36 | |||
37 | |||
38 | |||
39 | $NEEDED_ITEMS=array("contract","infocom","computer","printer","monitor","peripheral","networking","software","phone","stat"); |
||
40 | |||
41 | define('GLPI_ROOT', '..'); |
||
42 | include (GLPI_ROOT . "/inc/includes.php"); |
||
43 | |||
44 | checkRight("reports","r"); |
||
45 | |||
46 | commonHeader($LANG["Menu"][6],$_SERVER['PHP_SELF'],"utils","report"); |
||
47 | |||
48 | |||
49 | if(empty($_POST["date1"])&&empty($_POST["date2"])) { |
||
50 | $year=date("Y")-1; |
||
51 | $_POST["date1"]=date("Y-m-d",mktime(1,0,0,date("m"),date("d"),$year)); |
||
52 | |||
53 | $_POST["date2"]=date("Y-m-d"); |
||
54 | } |
||
55 | if ($_POST["date1"]!=""&&$_POST["date2"]!=""&&strcmp($_POST["date2"],$_POST["date1"])<0){ |
||
56 | $tmp=$_POST["date1"]; |
||
57 | $_POST["date1"]=$_POST["date2"]; |
||
58 | $_POST["date2"]=$tmp; |
||
59 | } |
||
60 | |||
61 | echo "<div align='center'><form method=\"post\" name=\"form\" action=\"".$_SERVER['PHP_SELF']."\">"; |
||
62 | echo "<table class='tab_cadre'><tr class='tab_bg_2'><td align='right'>"; |
||
63 | echo $LANG["search"][8]." :</td><td>"; |
||
64 | showCalendarForm("form","date1",$_POST["date1"]); |
||
65 | echo "</td><td rowspan='2' class='center'><input type=\"submit\" class='button' name=\"submit\" Value=\"". $LANG["buttons"][7] ."\" /></td></tr>"; |
||
66 | echo "<tr class='tab_bg_2'><td align='right'>".$LANG["search"][9]." :</td><td>"; |
||
67 | showCalendarForm("form","date2",$_POST["date2"]); |
||
68 | echo "</td></tr>"; |
||
69 | echo "</table></form></div>"; |
||
70 | |||
71 | |||
72 | |||
73 | |||
74 | $valeurtot=0; |
||
75 | $valeurnettetot=0; |
||
76 | $valeurnettegraphtot=array(); |
||
77 | $valeurgraphtot=array(); |
||
78 | |||
79 | /** Display an infocom report
|
||
80 | * @param $device_type item type
|
||
81 | * @param $begin begin date
|
||
82 | * @param $end end date
|
||
83 | */
|
||
84 | function display_infocoms_report($device_type,$begin,$end){ |
||
85 | global $DB,$valeurtot,$valeurnettetot, $valeurnettegraphtot, $valeurgraphtot,$LANG,$CFG_GLPI,$LINK_ID_TABLE; |
||
86 | |||
87 | $query="SELECT glpi_infocoms.*, ".$LINK_ID_TABLE[$device_type].".name AS name, ".$LINK_ID_TABLE[$device_type].".ticket_tco, glpi_entities.completename as entname, glpi_entities.ID as entID FROM glpi_infocoms |
||
88 | INNER JOIN ".$LINK_ID_TABLE[$device_type]." ON (".$LINK_ID_TABLE[$device_type].".ID = glpi_infocoms.FK_device AND glpi_infocoms.device_type='".$device_type."')"; |
||
89 | $query.= " LEFT JOIN glpi_entities ON (".$LINK_ID_TABLE[$device_type].".FK_entities = glpi_entities.ID) "; |
||
90 | |||
91 | $query.= " WHERE ".$LINK_ID_TABLE[$device_type].".is_template='0' ".getEntitiesRestrictRequest("AND",$LINK_ID_TABLE[$device_type]); |
||
92 | |||
93 | if (!empty($begin)) $query.= " AND (glpi_infocoms.buy_date >= '".$begin."' OR glpi_infocoms.use_date >= '".$begin."' )"; |
||
94 | if (!empty($end)) $query.= " AND (glpi_infocoms.buy_date <= '".$end."' OR glpi_infocoms.use_date <= '".$end."' )"; |
||
95 | |||
96 | $query .=" ORDER BY entname ASC, buy_date, use_date"; |
||
97 | |||
98 | $display_entity=isMultiEntitiesMode();
|
||
99 | |||
100 | $result=$DB->query($query); |
||
101 | if ($DB->numrows($result)>0){ |
||
102 | $comp=new CommonItem(); |
||
103 | $comp->getFromDB($device_type,0); |
||
104 | |||
105 | echo "<h2>".$comp->getType()."</h2>"; |
||
106 | |||
107 | echo "<table class='tab_cadre'><tr><th>".$LANG["common"][16]."</th>"; |
||
108 | if ($display_entity){ |
||
109 | echo "<th>".$LANG["entity"][0]."</th>"; |
||
110 | } |
||
111 | |||
112 | echo "<th>".$LANG["financial"][21]."</th><th>".$LANG["financial"][92]."</th><th>".$LANG["financial"][91]."</th><th>".$LANG["financial"][14]."</th><th>".$LANG["financial"][76]."</th><th>".$LANG["financial"][80]."</th></tr>"; |
||
113 | |||
114 | |||
115 | $valeursoustot=0; |
||
116 | $valeurnettesoustot=0; |
||
117 | $valeurnettegraph=array(); |
||
118 | $valeurgraph=array(); |
||
119 | |||
120 | while ($line=$DB->fetch_array($result)){ |
||
121 | |||
122 | if (isset($line["is_global"])&&$line["is_global"]){ |
||
123 | $line["value"]*=getNumberConnections($device_type,$line["FK_device"]); |
||
124 | } |
||
125 | |||
126 | if ($line["value"]>0) $valeursoustot+=$line["value"]; |
||
127 | |||
128 | $valeurnette=TableauAmort($line["amort_type"],$line["value"],$line["amort_time"],$line["amort_coeff"],$line["buy_date"],$line["use_date"],$CFG_GLPI["date_fiscale"],"n"); |
||
129 | $tmp=TableauAmort($line["amort_type"],$line["value"],$line["amort_time"],$line["amort_coeff"],$line["buy_date"],$line["use_date"],$CFG_GLPI["date_fiscale"],"all"); |
||
130 | |||
131 | if (is_array($tmp)&&count($tmp)>0) |
||
132 | foreach ($tmp["annee"] as $key => $val){ |
||
133 | if ($tmp["vcnetfin"][$key]>0){ |
||
134 | if (!isset($valeurnettegraph[$val])) $valeurnettegraph[$val]=0; |
||
135 | $valeurnettegraph[$val]+=$tmp["vcnetdeb"][$key]; |
||
136 | } |
||
137 | } |
||
138 | if ($line["buy_date"]!="0000-00-00"){ |
||
139 | $year=substr($line["buy_date"],0,4); |
||
140 | if ($line["value"]>0){ |
||
141 | if (!isset($valeurgraph[$year])) $valeurgraph[$year]=0; |
||
142 | $valeurgraph[$year]+=$line["value"]; |
||
143 | } |
||
144 | } |
||
145 | |||
146 | |||
147 | $valeurnettesoustot+=str_replace(" ","",$valeurnette); |
||
148 | |||
149 | echo "<tr class='tab_bg_1'><td>".$line["name"]."</td>"; |
||
150 | if ($display_entity){ |
||
151 | if ($line['entID']==0){ |
||
152 | echo "<td>".$LANG["entity"][2]."</td>"; |
||
153 | } else {
|
||
154 | echo "<td>".$line['entname']."</td>"; |
||
155 | } |
||
156 | } |
||
157 | |||
158 | echo "<td class='right'>".formatNumber($line["value"])."</td><td class='right'>".formatNumber($valeurnette)."</td><td class='right'>".showTco($line["ticket_tco"],$line["value"])."</td><td>".convDate($line["buy_date"])."</td><td>".convDate($line["use_date"])."</td><td>".getWarrantyExpir($line["buy_date"],$line["warranty_duration"])."</td></tr>"; |
||
159 | |||
160 | |||
161 | } |
||
162 | |||
163 | $valeurtot+=$valeursoustot; |
||
164 | $valeurnettetot+=$valeurnettesoustot; |
||
165 | |||
166 | echo "<tr><td colspan='6' class='center'><h3>".$LANG["common"][33].": ".$LANG["financial"][21]."=".formatNumber($valeursoustot)." - ".$LANG["financial"][81]."=".formatNumber($valeurnettesoustot)."</h3></td></tr>"; |
||
167 | |||
168 | |||
169 | if (count($valeurnettegraph)>0){ |
||
170 | |||
171 | echo "<tr><td colspan='5' class='center'>"; |
||
172 | ksort($valeurnettegraph); |
||
173 | |||
174 | $valeurnettegraphdisplay=array_map('round',$valeurnettegraph); |
||
175 | |||
176 | foreach ($valeurnettegraph as $key => $val) { |
||
177 | if (!isset($valeurnettegraphtot[$key])) $valeurnettegraphtot[$key]=0; |
||
178 | $valeurnettegraphtot[$key]+=$valeurnettegraph[$key]; |
||
179 | } |
||
180 | |||
181 | graphBy($valeurnettegraphdisplay,$LANG["financial"][81],"",0,"year"); |
||
182 | |||
183 | echo "</td></tr>"; |
||
184 | } |
||
185 | |||
186 | if (count($valeurgraph)>0){ |
||
187 | echo "<tr><td colspan='5' class='center'>"; |
||
188 | |||
189 | ksort($valeurgraph); |
||
190 | |||
191 | $valeurgraphdisplay=array_map('round',$valeurgraph); |
||
192 | |||
193 | foreach ($valeurgraph as $key => $val) { |
||
194 | if (!isset($valeurgraphtot[$key])) $valeurgraphtot[$key]=0; |
||
195 | $valeurgraphtot[$key]+=$valeurgraph[$key]; |
||
196 | } |
||
197 | |||
198 | graphBy($valeurgraphdisplay,$LANG["financial"][21],"",0,"year"); |
||
199 | |||
200 | echo "</td></tr>"; |
||
201 | } |
||
202 | echo "</table>"; |
||
203 | |||
204 | } |
||
205 | } |
||
206 | |||
207 | echo "<table>"; |
||
208 | echo "<tr><td>"; |
||
209 | display_infocoms_report(COMPUTER_TYPE,$_POST["date1"],$_POST["date2"]); |
||
210 | echo "</td><td valign='top'>"; |
||
211 | display_infocoms_report(MONITOR_TYPE,$_POST["date1"],$_POST["date2"]); |
||
212 | echo "</td></tr>"; |
||
213 | echo "<tr><td>"; |
||
214 | display_infocoms_report(NETWORKING_TYPE,$_POST["date1"],$_POST["date2"]); |
||
215 | echo "</td><td valign='top'>"; |
||
216 | display_infocoms_report(PRINTER_TYPE,$_POST["date1"],$_POST["date2"]); |
||
217 | echo "</td></tr>"; |
||
218 | echo "<tr><td>"; |
||
219 | display_infocoms_report(PERIPHERAL_TYPE,$_POST["date1"],$_POST["date2"]); |
||
220 | echo "</td><td valign='top'>"; |
||
221 | display_infocoms_report(PHONE_TYPE,$_POST["date1"],$_POST["date2"]); |
||
222 | echo "</td></tr>"; |
||
223 | echo "</table>"; |
||
224 | |||
225 | |||
226 | |||
227 | echo "<div align='center'><h3>".$LANG["common"][33].": ".$LANG["financial"][21]."=".formatNumber($valeurtot)." - ".$LANG["financial"][81]."=".formatNumber($valeurnettetot)."</h3></div>"; |
||
228 | |||
229 | if (count($valeurnettegraphtot)>0){ |
||
230 | $valeurnettegraphtotdisplay=array_map('round',$valeurnettegraphtot); |
||
231 | graphBy($valeurnettegraphtotdisplay,$LANG["financial"][81],"",0,"year"); |
||
232 | } |
||
233 | if (count($valeurgraphtot)>0){ |
||
234 | $valeurgraphtotdisplay=array_map('round',$valeurgraphtot); |
||
235 | graphBy($valeurgraphtotdisplay,$LANG["financial"][21],"",0,"year"); |
||
236 | } |
||
237 | commonFooter(); |
||
238 | ?> |