ryxeo-glpi-git / htdocs / front / report.infocom.conso.php @ 1c14bcc4
Historique | Voir | Annoter | Télécharger (7,42 ko)
1 | 1c14bcc4 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: report.infocom.conso.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","software","cartridge","consumable","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' align='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 for items like consumables
|
||
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.* FROM glpi_infocoms 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."') "; |
||
88 | |||
89 | switch ($device_type){ |
||
90 | case CONSUMABLE_ITEM_TYPE : |
||
91 | $query.=" INNER JOIN glpi_consumables_type ON (glpi_consumables.FK_glpi_consumables_type = glpi_consumables_type.ID) ".getEntitiesRestrictRequest("WHERE","glpi_consumables_type"); |
||
92 | break;
|
||
93 | case CARTRIDGE_ITEM_TYPE : |
||
94 | $query.=" INNER JOIN glpi_cartridges_type ON (glpi_cartridges.FK_glpi_cartridges_type = glpi_cartridges_type.ID) ".getEntitiesRestrictRequest("WHERE","glpi_cartridges_type"); |
||
95 | break;
|
||
96 | case LICENSE_TYPE : |
||
97 | $query.=" INNER JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID) ".getEntitiesRestrictRequest("WHERE","glpi_software"); |
||
98 | break;
|
||
99 | |||
100 | } |
||
101 | |||
102 | if (!empty($begin)) $query.= " AND (glpi_infocoms.buy_date >= '".$begin."' OR glpi_infocoms.use_date >= '".$begin."' )"; |
||
103 | if (!empty($end)) $query.= " AND (glpi_infocoms.buy_date <= '".$end."' OR glpi_infocoms.use_date <= '".$end."' )"; |
||
104 | |||
105 | $result=$DB->query($query); |
||
106 | if ($DB->numrows($result)>0){ |
||
107 | $comp=new CommonItem(); |
||
108 | $comp->getFromDB($device_type,0); |
||
109 | |||
110 | echo "<h2>".$comp->getType()."</h2>"; |
||
111 | |||
112 | echo "<table class='tab_cadre'>"; |
||
113 | |||
114 | $valeursoustot=0; |
||
115 | $valeurnettesoustot=0; |
||
116 | $valeurnettegraph=array(); |
||
117 | $valeurgraph=array(); |
||
118 | |||
119 | while ($line=$DB->fetch_array($result)){ |
||
120 | |||
121 | if ($device_type==LICENSE_TYPE){ |
||
122 | $comp->getFromDB($device_type,$line["FK_device"]); |
||
123 | if ($comp->obj->fields["serial"]=="global"){ |
||
124 | $line["value"]*=getInstallionsForLicense($line["FK_device"]); |
||
125 | } |
||
126 | } |
||
127 | if ($line["value"]>0) $valeursoustot+=$line["value"]; |
||
128 | |||
129 | $valeurnette=TableauAmort($line["amort_type"],$line["value"],$line["amort_time"],$line["amort_coeff"],$line["buy_date"],$line["use_date"],$CFG_GLPI["date_fiscale"],"n"); |
||
130 | $tmp=TableauAmort($line["amort_type"],$line["value"],$line["amort_time"],$line["amort_coeff"],$line["buy_date"],$line["use_date"],$CFG_GLPI["date_fiscale"],"all"); |
||
131 | |||
132 | if (is_array($tmp)&&count($tmp)>0) |
||
133 | foreach ($tmp["annee"] as $key => $val){ |
||
134 | if ($tmp["vcnetfin"][$key]>0){ |
||
135 | if (!isset($valeurnettegraph[$val])) $valeurnettegraph[$val]=0; |
||
136 | $valeurnettegraph[$val]+=$tmp["vcnetdeb"][$key]; |
||
137 | } |
||
138 | } |
||
139 | if ($line["buy_date"]!="0000-00-00"){ |
||
140 | $year=substr($line["buy_date"],0,4); |
||
141 | if ($line["value"]>0){ |
||
142 | if (!isset($valeurgraph[$year])) $valeurgraph[$year]=0; |
||
143 | $valeurgraph[$year]+=$line["value"]; |
||
144 | } |
||
145 | } |
||
146 | |||
147 | |||
148 | $valeurnettesoustot+=str_replace(" ","",$valeurnette); |
||
149 | |||
150 | |||
151 | } |
||
152 | |||
153 | $valeurtot+=$valeursoustot; |
||
154 | $valeurnettetot+=$valeurnettesoustot; |
||
155 | |||
156 | |||
157 | if (count($valeurnettegraph)>0){ |
||
158 | |||
159 | echo "<tr><td colspan='5' align='center'>"; |
||
160 | ksort($valeurnettegraph); |
||
161 | |||
162 | $valeurnettegraphdisplay=array_map('round',$valeurnettegraph); |
||
163 | |||
164 | foreach ($valeurnettegraph as $key => $val) { |
||
165 | if (!isset($valeurnettegraphtot[$key])) $valeurnettegraphtot[$key]=0; |
||
166 | $valeurnettegraphtot[$key]+=$valeurnettegraph[$key]; |
||
167 | } |
||
168 | |||
169 | graphBy($valeurnettegraphdisplay,$LANG["financial"][81],"",0,"year"); |
||
170 | |||
171 | echo "</td></tr>"; |
||
172 | } |
||
173 | |||
174 | if (count($valeurgraph)>0){ |
||
175 | echo "<tr><td colspan='5' align='center'>"; |
||
176 | |||
177 | ksort($valeurgraph); |
||
178 | |||
179 | $valeurgraphdisplay=array_map('round',$valeurgraph); |
||
180 | |||
181 | foreach ($valeurgraph as $key => $val) { |
||
182 | if (!isset($valeurgraphtot[$key])) $valeurgraphtot[$key]=0; |
||
183 | $valeurgraphtot[$key]+=$valeurgraph[$key]; |
||
184 | } |
||
185 | |||
186 | graphBy($valeurgraphdisplay,$LANG["financial"][21],"",0,"year"); |
||
187 | |||
188 | echo "</td></tr>"; |
||
189 | } |
||
190 | echo "</table>"; |
||
191 | |||
192 | } |
||
193 | } |
||
194 | |||
195 | echo "<table width='90%'>"; |
||
196 | echo "<tr><td align='center' valign='top'>"; |
||
197 | display_infocoms_report(CONSUMABLE_ITEM_TYPE,$_POST["date1"],$_POST["date2"]); |
||
198 | echo "</td><td align='center' valign='top'>"; |
||
199 | display_infocoms_report(CARTRIDGE_ITEM_TYPE,$_POST["date1"],$_POST["date2"]); |
||
200 | echo "</td></tr>"; |
||
201 | echo "<tr><td>"; |
||
202 | display_infocoms_report(LICENSE_TYPE,$_POST["date1"],$_POST["date2"]); |
||
203 | echo "</td><td valign='top'> "; |
||
204 | |||
205 | echo "</td></tr>"; |
||
206 | echo "</table>"; |
||
207 | |||
208 | |||
209 | |||
210 | echo "<div align='center'><h3>".$LANG["common"][33].": ".$LANG["financial"][21]."=".formatNumber($valeurtot)." - ".$LANG["financial"][81]."=".formatNumber($valeurnettetot)."</h3></div>"; |
||
211 | |||
212 | if (count($valeurnettegraphtot)>0){ |
||
213 | $valeurnettegraphtotdisplay=array_map('round',$valeurnettegraphtot); |
||
214 | graphBy($valeurnettegraphtotdisplay,$LANG["financial"][81],"",0,"year"); |
||
215 | } |
||
216 | if (count($valeurgraphtot)>0){ |
||
217 | $valeurgraphtotdisplay=array_map('round',$valeurgraphtot); |
||
218 | graphBy($valeurgraphtotdisplay,$LANG["financial"][21],"",0,"year"); |
||
219 | } |
||
220 | |||
221 | commonFooter(); |
||
222 | ?> |