ryxeo-glpi-git / plugins / pdf / inc / plugin_pdf.functions.php @ af89ba35
Historique | Voir | Annoter | Télécharger (87,7 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
----------------------------------------------------------------------
|
4 |
GLPI - Gestionnaire Libre de Parc Informatique
|
5 |
Copyright (C) 2003-2008 by the INDEPNET Development Team.
|
6 |
|
7 |
http://indepnet.net/ http://glpi-project.org/
|
8 |
----------------------------------------------------------------------
|
9 |
|
10 |
LICENSE
|
11 |
|
12 |
This file is part of GLPI.
|
13 |
|
14 |
GLPI is free software; you can redistribute it and/or modify
|
15 |
it under the terms of the GNU General Public License as published by
|
16 |
the Free Software Foundation; either version 2 of the License, or
|
17 |
(at your option) any later version.
|
18 |
|
19 |
GLPI is distributed in the hope that it will be useful,
|
20 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
GNU General Public License for more details.
|
23 |
|
24 |
You should have received a copy of the GNU General Public License
|
25 |
along with GLPI; if not, write to the Free Software
|
26 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
27 |
------------------------------------------------------------------------
|
28 |
*/
|
29 |
|
30 |
// Original Author of file: BALPE Dévi
|
31 |
// Purpose of file:
|
32 |
// ----------------------------------------------------------------------
|
33 |
|
34 |
function plugin_pdf_menu_computer($action,$compID,$export=true){ |
35 |
global $LANGPDF,$LANG,$DB; |
36 |
|
37 |
echo "<form name='computer' action='$action' target='blank' method='post'><table class='tab_cadre_fixe'>"; |
38 |
$values = array(); |
39 |
$result = $DB->query("select table_num from glpi_plugin_pdf_preference WHERE user_id =" . $_SESSION['glpiID'] . " and cat=" . COMPUTER_TYPE); |
40 |
|
41 |
while ($data = $DB->fetch_array($result)) |
42 |
$values["check".$data["table_num"]] = $data["table_num"]; |
43 |
|
44 |
echo "<tr><th colspan='6'>" . $LANGPDF["title"][2]. " : ".$LANG["Menu"][0] . "</th></tr>"; |
45 |
echo "<tr class='tab_bg_1'>"; |
46 |
checkbox("check0",$LANG["Menu"][26],0,(isset($values["check0"])?true:false)); |
47 |
checkbox("check2",$LANG["title"][30],2,(isset($values["check2"])?true:false)); |
48 |
checkbox("check4",$LANG["title"][28],4,(isset($values["check4"])?true:false)); |
49 |
checkbox("check6",$LANG["title"][43],6,(isset($values["check6"])?true:false)); |
50 |
checkbox("check8",$LANG["title"][37],8,(isset($values["check8"])?true:false)); |
51 |
checkbox("check10",$LANG["title"][38],10,(isset($values["check10"])?true:false)); |
52 |
echo "</tr>"; |
53 |
|
54 |
echo "<tr class='tab_bg_1'>"; |
55 |
checkbox("check1",$LANG["title"][27],1,(isset($values["check1"])?true:false)); |
56 |
checkbox("check3",$LANG["Menu"][4],3,(isset($values["check3"])?true:false)); |
57 |
checkbox("check5",$LANG["Menu"][27],5,(isset($values["check5"])?true:false)); |
58 |
checkbox("check7",$LANG["title"][34],7,(isset($values["check7"])?true:false)); |
59 |
checkbox("check9",$LANG["Menu"][17],9,(isset($values["check9"])?true:false)); |
60 |
echo "<td></td>"; |
61 |
echo "</tr>"; |
62 |
|
63 |
echo "<tr class='tab_bg_2'><td colspan='6' align='center'>"; |
64 |
echo "<input type='hidden' name='plugin_pdf_inventory_type' value='" . COMPUTER_TYPE . "'>"; |
65 |
echo "<input type='hidden' name='indice' value='11'>"; |
66 |
echo "<input type='hidden' name='itemID' value='$compID'>"; |
67 |
|
68 |
echo "<input type='submit' value='" . (!$export?$LANGPDF["button"][2]:$LANGPDF["button"][1]) . "' name='plugin_pdf_user_preferences_save' class='submit'></td></tr>"; |
69 |
echo "</table></form>"; |
70 |
} |
71 |
|
72 |
function plugin_pdf_menu_software($action,$softID){ |
73 |
global $LANGPDF,$LANG,$DB; |
74 |
|
75 |
echo "<form name='software' action='$action' target='blank' method='post'><table class='tab_cadre_fixe'>"; |
76 |
$values = array(); |
77 |
$result = $DB->query("select table_num from glpi_plugin_pdf_preference WHERE user_id =" . $_SESSION['glpiID'] . " and cat=" . SOFTWARE_TYPE); |
78 |
|
79 |
while ($data = $DB->fetch_array($result)) |
80 |
$values["check".$data["table_num"]] = $data["table_num"]; |
81 |
|
82 |
echo "<tr><th colspan='6'>" . $LANGPDF["title"][2]." : ".$LANG["Menu"][4] . "</th></tr>"; |
83 |
|
84 |
echo "<tr class='tab_bg_1'>"; |
85 |
checkbox("check0",$LANG["title"][26],0,(isset($values["check0"])?true:false)); |
86 |
checkbox("check2",$LANG["Menu"][26],2,(isset($values["check2"])?true:false)); |
87 |
checkbox("check4",$LANG["title"][28],4,(isset($values["check4"])?true:false)); |
88 |
checkbox("check6",$LANG["title"][37],6,(isset($values["check6"])?true:false)); |
89 |
checkbox("check8",$LANG["title"][38],8,(isset($values["check10"])?true:false)); |
90 |
echo "<td></td>"; |
91 |
echo "</tr>"; |
92 |
|
93 |
echo "<tr class='tab_bg_1'>"; |
94 |
|
95 |
checkbox("check1",$LANG["software"][19],1,(isset($values["check1"])?true:false)); |
96 |
checkbox("check3",$LANG["Menu"][27],3,(isset($values["check3"])?true:false)); |
97 |
checkbox("check5",$LANG["title"][34],5,(isset($values["check5"])?true:false)); |
98 |
checkbox("check7",$LANG["Menu"][17],7,(isset($values["check7"])?true:false)); |
99 |
echo "<td></td>"; |
100 |
echo "<td></td>"; |
101 |
echo "</tr>"; |
102 |
|
103 |
echo "<tr class='tab_bg_2'><td colspan='6' align='center'>"; |
104 |
echo "<input type='hidden' name='plugin_pdf_inventory_type' value='" . SOFTWARE_TYPE . "'>"; |
105 |
echo "<input type='hidden' name='indice' value='7'>"; |
106 |
echo "<input type='hidden' name='itemID' value='$softID'>"; |
107 |
|
108 |
echo "<input type='submit' value='" . $LANGPDF["button"][2] . "' name='plugin_pdf_user_preferences_save' class='submit'></td></tr>"; |
109 |
echo "</table></form>"; |
110 |
} |
111 |
|
112 |
function plugin_pdf_getDropdownName($table,$id){ |
113 |
|
114 |
$name = getDropdownName($table,$id); |
115 |
|
116 |
if($name==" ") |
117 |
$name=""; |
118 |
|
119 |
return $name; |
120 |
} |
121 |
|
122 |
|
123 |
function plugin_pdf_background($tab,$width){ |
124 |
|
125 |
$start_tab = $tab["start_tab"]; |
126 |
$pdf = $tab["pdf"]; |
127 |
|
128 |
$height = $pdf->ez['pageHeight']; |
129 |
$id_pdf=$pdf->openObject(); |
130 |
$pdf->saveState();
|
131 |
$pdf->ezStartPageNumbers(575,10,10,'left',convDate(date("Y-m-d"))." - {PAGENUM}/{TOTALPAGENUM}"); |
132 |
$pdf->setStrokeColor(0,0,0); |
133 |
$pdf->setLineStyle(1,'round','round'); |
134 |
$pdf->rectangle(20,20,$width-40,$height-40); |
135 |
//erics le logo
|
136 |
$pdf->addJpegFromFile("../pics/fd_logo.jpg",25,$height-50); |
137 |
$pdf->selectFont("../fonts/Times-Roman.afm"); |
138 |
$pdf->setFontFamily('Times-Roman.afm',array('b'=>'Times-Bold.afm','i'=>'Times-Italic.afm','bi'=>'Times-BoldItalic.afm')); |
139 |
$pdf->restoreState();
|
140 |
$pdf->closeObject();
|
141 |
$pdf->addObject($id_pdf,'all'); |
142 |
|
143 |
$tab["start_tab"] = $start_tab; |
144 |
$tab["pdf"] = $pdf; |
145 |
|
146 |
return $tab; |
147 |
} |
148 |
|
149 |
function plugin_pdf_add_header($pdf,$ID,$type){ |
150 |
|
151 |
global $LANG; |
152 |
|
153 |
$height = $pdf->ez['pageHeight']; |
154 |
|
155 |
switch($type){ |
156 |
case COMPUTER_TYPE: |
157 |
$computer = new Computer(); |
158 |
$computer->getFromDB($ID); |
159 |
|
160 |
//erics on ajoute un peu de texte et
|
161 |
//erics on simplifie l'affichage
|
162 |
$siteT = explode('>', plugin_pdf_getDropdownName('glpi_entities',$computer->fields['FK_entities'])); |
163 |
if($computer->fields['name']) |
164 |
$pdf->addText(180,$height-45,14,utf8_decode('<b>'. $siteT[count($siteT)-1] . " -- " .$computer->fields['name'])); |
165 |
else
|
166 |
$pdf->addText(180,$height-45,14,utf8_decode('<b>'.$LANG["common"][2].' '.$computer->fields['ID'].' ('.plugin_pdf_getDropdownName('glpi_entities',$computer->fields['FK_entities']).')</b>')); |
167 |
|
168 |
break;
|
169 |
case SOFTWARE_TYPE: |
170 |
$software = new Software(); |
171 |
$software->getFromDB($ID); |
172 |
if($software->fields['name']) |
173 |
$pdf->addText(200,$height-45,14,utf8_decode('<b>'.$software->fields['name'].' ('.plugin_pdf_getDropdownName('glpi_entities',$software->fields['FK_entities']).')</b>')); |
174 |
else
|
175 |
$pdf->addText(200,$height-45,14,utf8_decode('<b>'.$LANG["common"][2].' '.$software->fields['ID'].' ('.plugin_pdf_getDropdownName('glpi_entities',$software->fields['FK_entities']).')</b>')); |
176 |
break;
|
177 |
} |
178 |
|
179 |
return $pdf; |
180 |
} |
181 |
|
182 |
function plugin_pdf_config_computer($tab,$width,$ID){ |
183 |
|
184 |
global $LANG; |
185 |
|
186 |
$start_tab = $tab["start_tab"]; |
187 |
$pdf = $tab["pdf"]; |
188 |
|
189 |
$computer=new Computer(); |
190 |
$computer->getFromDB($ID); |
191 |
|
192 |
$length_tab = (($width-50)/2)-2.5; |
193 |
|
194 |
$pdf->saveState();
|
195 |
$pdf->setColor(0.8,0.8,0.8); |
196 |
|
197 |
//erics deux rectangles pour mettre l'entite et des choses que je vire
|
198 |
/*
|
199 |
$pdf->filledRectangle(25,$start_tab-5,$length_tab,15);
|
200 |
$pdf->filledRectangle(25+$length_tab+5,$start_tab-5,$length_tab,15);
|
201 |
*/
|
202 |
//J'en met un seul pour "informations generales"
|
203 |
$pdf->filledRectangle(25,$start_tab-5,$length_tab*2+5,15); |
204 |
|
205 |
for($i=0;$i<13;$i++) |
206 |
{ |
207 |
//erics pour avoir la couleur une ligne sur deux
|
208 |
if($i%2){ |
209 |
$pdf->setColor(0.90,0.90,0.90); |
210 |
} |
211 |
else {
|
212 |
$pdf->setColor(1,1,1); |
213 |
} |
214 |
|
215 |
if($i<11) |
216 |
{ |
217 |
//des lignes complètes pour l'arriere plan
|
218 |
$pdf->filledRectangle(25,($start_tab-20)-(15*$i),2*$length_tab+5,15); |
219 |
//$pdf->filledRectangle(25+$length_tab+5,($start_tab-25)-(20*$i),$length_tab,15);
|
220 |
} |
221 |
else
|
222 |
if($i==11) |
223 |
{ |
224 |
$pdf->filledRectangle(25,($start_tab-20)-(15*$i),2*$length_tab+5,15); |
225 |
} |
226 |
/*
|
227 |
else
|
228 |
{
|
229 |
$i+=2;
|
230 |
$pdf->filledRectangle(25,($start_tab-20)-(15*$i),2*$length_tab+5,30);
|
231 |
}
|
232 |
*/
|
233 |
} |
234 |
$pdf->restoreState();
|
235 |
|
236 |
//erics on simplifie pas besoin de ca
|
237 |
// $pdf->addText(100,$start_tab,9,utf8_decode('<b>'.$LANG["common"][2].' '.$computer->fields['ID'].' ('.plugin_pdf_getDropdownName('glpi_entities',$computer->fields['FK_entities']).')</b>'));
|
238 |
$pdf->addText(275,$start_tab,9,utf8_decode('<b>Généralités</b>')); |
239 |
|
240 |
$pdf->addText(30,$start_tab-15,9,utf8_decode('<b><i>'.$LANG["common"][16].' :</i></b> '.$computer->fields['name'])); |
241 |
$pdf->addText(30,$start_tab-30,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName('glpi_type_computers',$computer->fields['type']))); |
242 |
$pdf->addText(30,$start_tab-45,9,utf8_decode('<b><i>'.$LANG["common"][22].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_model',$computer->fields['model']))); |
243 |
$pdf->addText(30,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][5].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_manufacturer',$computer->fields['FK_glpi_enterprise']))); |
244 |
$pdf->addText(30,$start_tab-75,9,utf8_decode('<b><i>'.$LANG["computers"][9].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os',$computer->fields['os']))); |
245 |
$pdf->addText(30,$start_tab-90,9,utf8_decode('<b><i>'.$LANG["computers"][52].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os_version',$computer->fields['os_version']))); |
246 |
$pdf->addText(30,$start_tab-105,9,utf8_decode('<b><i>'.$LANG["computers"][53].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os_sp',$computer->fields['os_sp']))); |
247 |
$pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["computers"][10].' :</i></b> '.$computer->fields['os_license_number'])); |
248 |
$pdf->addText(30,$start_tab-135,9,utf8_decode('<b><i>'.$LANG["computers"][11].' :</i></b> '.$computer->fields['os_license_id'])); |
249 |
|
250 |
if($computer->fields['ocs_import']) |
251 |
$pdf->addText(30,$start_tab-150,9,utf8_decode('<b><i>'.$LANG["ocsng"][6].' '.$LANG["Menu"][33].' :</i></b> '.$LANG["choice"][1])); |
252 |
else
|
253 |
$pdf->addText(30,$start_tab-150,9,utf8_decode('<b><i>'.$LANG["ocsng"][6].' '.$LANG["Menu"][33].' :</i></b> '.$LANG["choice"][0])); |
254 |
$pdf->addText(30,$start_tab-165,9,utf8_decode('<b><i>'.$LANG["common"][15].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_locations',$computer->fields['location']))); |
255 |
$pdf->addText(30,$start_tab-180,9,utf8_decode('<b><i>'.$LANG["common"][25].' :</i></b> ')); |
256 |
|
257 |
$y=$start_tab-195; |
258 |
$temp=utf8_decode($computer->fields['comments']); |
259 |
while($temp = $pdf->addTextWrap(105,$y,2*$length_tab-80,9,$temp)) |
260 |
$y-=9; |
261 |
|
262 |
//seconde colone
|
263 |
/*
|
264 |
if(!empty($computer->fields['tplname']))
|
265 |
$pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).' ('.$LANG["common"][13].' : '.$computer->fields['tplname'].')</b>'));
|
266 |
elseif($computer->fields['ocs_import'])
|
267 |
$pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).' ('.$LANG["ocsng"][7].')</b>'));
|
268 |
else
|
269 |
$pdf->addText($length_tab+80,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).'</b>'));
|
270 |
*/
|
271 |
|
272 |
$pdf->addText($length_tab+35,$start_tab-15,9,utf8_decode('<b><i>'.$LANG["common"][18].' :</i></b> '.$computer->fields['contact'])); |
273 |
$pdf->addText($length_tab+35,$start_tab-30,9,utf8_decode('<b><i>'.$LANG["common"][21].' :</i></b> '.$computer->fields['contact_num'])); |
274 |
$pdf->addText($length_tab+35,$start_tab-45,9,utf8_decode('<b><i>'.$LANG["common"][34].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$computer->fields['FK_users']))); |
275 |
$pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][35].' :</i></b> '.plugin_pdf_getDropdownName('glpi_groups',$computer->fields['FK_groups']))); |
276 |
$pdf->addText($length_tab+35,$start_tab-75,9,utf8_decode('<b><i>'.$LANG["common"][10].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$computer->fields['tech_num']))); |
277 |
$pdf->addText($length_tab+35,$start_tab-90,9,utf8_decode('<b><i>'.$LANG["setup"][88].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_network',$computer->fields['network']))); |
278 |
$pdf->addText($length_tab+35,$start_tab-105,9,utf8_decode('<b><i>'.$LANG["setup"][89].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_domain',$computer->fields['domain']))); |
279 |
$pdf->addText($length_tab+35,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["common"][19].' :</i></b> '.$computer->fields['serial'])); |
280 |
$pdf->addText($length_tab+35,$start_tab-135,9,utf8_decode('<b><i>'.$LANG["common"][20].' :</i></b> '.$computer->fields['otherserial'])); |
281 |
$pdf->addText($length_tab+35,$start_tab-150,9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_state',$computer->fields['state']))); |
282 |
$pdf->addText($length_tab+35,$start_tab-165,9,utf8_decode('<b><i>'.$LANG["computers"][51].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_auto_update',$computer->fields['auto_update']))); |
283 |
|
284 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
285 |
|
286 |
$tab["start_tab"] = $start_tab; |
287 |
$tab["pdf"] = $pdf; |
288 |
|
289 |
return $tab; |
290 |
} |
291 |
|
292 |
function plugin_pdf_config_software($tab,$width,$ID){ |
293 |
|
294 |
global $LANG; |
295 |
|
296 |
$start_tab = $tab["start_tab"]; |
297 |
$pdf = $tab["pdf"]; |
298 |
|
299 |
$software=new Software(); |
300 |
$software->getFromDB($ID); |
301 |
|
302 |
$length_tab = (($width-50)/2)-2.5; |
303 |
|
304 |
$pdf->saveState();
|
305 |
$pdf->setColor(0.8,0.8,0.8); |
306 |
$pdf->filledRectangle(25,$start_tab-5,$length_tab,15); |
307 |
$pdf->filledRectangle(25+$length_tab+5,$start_tab-5,$length_tab,15); |
308 |
$pdf->setColor(0.90,0.90,0.90); |
309 |
|
310 |
for($i=0;$i<7;$i++) |
311 |
{ |
312 |
if($i<5) |
313 |
{ |
314 |
$pdf->filledRectangle(25,($start_tab-20)-(20*$i),$length_tab,15); |
315 |
$pdf->filledRectangle(25+$length_tab+5,($start_tab-20)-(20*$i),$length_tab,15); |
316 |
} |
317 |
else
|
318 |
if($i==5) |
319 |
{ |
320 |
$pdf->filledRectangle(25,($start_tab-20)-(20*$i),2*$length_tab+5,15); |
321 |
} |
322 |
else
|
323 |
{ |
324 |
$i+=2; |
325 |
$pdf->filledRectangle(25,($start_tab-20)-(20*$i),2*$length_tab+5,55); |
326 |
} |
327 |
} |
328 |
$pdf->restoreState();
|
329 |
|
330 |
$pdf->addText(100,$start_tab,9,utf8_decode('<b>'.$LANG["common"][2].' '.$software->fields['ID'].' ('.plugin_pdf_getDropdownName('glpi_entities',$software->fields['FK_entities']).')</b>')); |
331 |
$pdf->addText(30,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][16].' :</i></b> '.$software->fields['name'])); |
332 |
$pdf->addText(30,$start_tab-40,9,utf8_decode('<b><i>'.$LANG["software"][3].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os',$software->fields['platform']))); |
333 |
$pdf->addText(30,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][34].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$software->fields["FK_users"]))); |
334 |
$pdf->addText(30,$start_tab-80,9,utf8_decode('<b><i>'.$LANG["common"][10].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$software->fields["tech_num"]))); |
335 |
$pdf->addText(30,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["common"][15].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_locations',$software->fields['location']))); |
336 |
|
337 |
if($software->fields['is_update']) |
338 |
$pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["software"][29].' :</i></b> '.$LANG["choice"][1])); |
339 |
else
|
340 |
$pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["software"][29].' :</i></b> '.$LANG["choice"][0])); |
341 |
|
342 |
if($software->fields["update_software"]!=null) |
343 |
$pdf->addText(100,$start_tab-120,9,utf8_decode('<b><i> '.$LANG["pager"][2].' </i></b> '.plugin_pdf_getDropdownName('glpi_software',$software->fields["update_software"]))); |
344 |
|
345 |
$pdf->addText(30,$start_tab-140,9,utf8_decode('<b><i>'.$LANG["common"][25].' :</i></b> ')); |
346 |
|
347 |
$y=$start_tab-140; |
348 |
$temp=utf8_decode($software->fields['comments']); |
349 |
while($temp = $pdf->addTextWrap(105,$y,2*$length_tab-80,9,$temp)) |
350 |
$y-=9; |
351 |
|
352 |
if(!empty($software->fields['tplname'])) |
353 |
$pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($software->fields["date_mod"]).' ('.$LANG["common"][13].' : '.$software->fields['tplname'].')</b>')); |
354 |
else
|
355 |
$pdf->addText($length_tab+80,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($software->fields["date_mod"]).'</b>')); |
356 |
|
357 |
$pdf->addText($length_tab+35,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][36].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_software_category',$software->fields["category"]))); |
358 |
$pdf->addText($length_tab+35,$start_tab-40,9,utf8_decode('<b><i>'.$LANG["common"][5].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_manufacturer',$software->fields['FK_glpi_enterprise']))); |
359 |
$pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][35].' :</i></b> '.plugin_pdf_getDropdownName('glpi_groups',$software->fields['FK_groups']))); |
360 |
$pdf->addText($length_tab+35,$start_tab-80,9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_state',$software->fields["state"]))); |
361 |
|
362 |
if($software->fields['helpdesk_visible']) |
363 |
$pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["software"][46].' :</i></b> '.$LANG["choice"][1])); |
364 |
else
|
365 |
$pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["software"][46].' :</i></b> '.$LANG["choice"][0])); |
366 |
|
367 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
368 |
|
369 |
$tab["start_tab"] = $start_tab; |
370 |
$tab["pdf"] = $pdf; |
371 |
|
372 |
return $tab; |
373 |
} |
374 |
|
375 |
function plugin_pdf_device($tab,$width,$ID,$type){ |
376 |
|
377 |
global $LANG; |
378 |
|
379 |
$start_tab = $tab["start_tab"]; |
380 |
$pdf = $tab["pdf"]; |
381 |
|
382 |
$computer=new Computer(); |
383 |
$computer->getFromDBwithDevices($ID); |
384 |
|
385 |
$pdf->saveState();
|
386 |
$pdf->setColor(0.8,0.8,0.8); |
387 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
388 |
$pdf->restoreState();
|
389 |
$pdf->addText(275,$start_tab,9,'<b>'.utf8_decode($LANG["title"][30].'</b>')); |
390 |
|
391 |
$i=0; |
392 |
|
393 |
foreach($computer->devices as $key => $val) { |
394 |
$device = new Device($val["devType"]); |
395 |
$device->getFromDB($val["devID"]); |
396 |
|
397 |
$nb_x = 27 ; |
398 |
$device_x = 47; |
399 |
$design_x = 127; |
400 |
$other_x = 362; |
401 |
$spec_x = 468; |
402 |
|
403 |
$pdf->saveState();
|
404 |
|
405 |
//erics pour avoir la couleur une ligne sur deux
|
406 |
if($i%2){ |
407 |
$pdf->setColor(0.90,0.90,0.90); |
408 |
} |
409 |
else {
|
410 |
$pdf->setColor(1,1,1); |
411 |
} |
412 |
|
413 |
//$pdf->setColor(0.90,0.90,0.90);
|
414 |
//un seul rectangle qui fait toute la ligne
|
415 |
$pdf->filledRectangle(25,$start_tab-20-(15*$i),$width-50,15); |
416 |
$pdf->restoreState();
|
417 |
|
418 |
switch($device->devtype) { |
419 |
case HDD_DEVICE : |
420 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
421 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][1])); |
422 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
423 |
$pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["device_hdd"][4].' :</i></b> '.$val["specificity"])); |
424 |
if (!empty($device->fields["rpm"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["device_hdd"][0].' :</i></b> '.$device->fields["rpm"])); |
425 |
else if (!empty($device->fields["interface"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_interface",$device->fields["interface"]))); |
426 |
else if (!empty($device->fields["cache"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["device_hdd"][1].' :</i></b> '.$device->fields["cache"])); |
427 |
break;
|
428 |
case GFX_DEVICE : |
429 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
430 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][2])); |
431 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
432 |
if (!empty($device->fields["ram"])) $pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["device_gfxcard"][0].' :</i></b> '.$device->fields["ram"])); |
433 |
if (!empty($device->fields["interface"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.$device->fields["interface"])); |
434 |
break;
|
435 |
case NETWORK_DEVICE : |
436 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
437 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][3])); |
438 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
439 |
$pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["networking"][15].' :</i></b> '.$val["specificity"])); |
440 |
if (!empty($device->fields["bandwidth"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["device_iface"][0].' :</i></b> '.$device->fields["bandwidth"])); |
441 |
break;
|
442 |
case MOBOARD_DEVICE : |
443 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
444 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][5])); |
445 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
446 |
if (!empty($device->fields["chipset"])) $pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["device_moboard"][0].' :</i></b> '.$device->fields["chipset"])); |
447 |
break;
|
448 |
case PROCESSOR_DEVICE : |
449 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
450 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][4])); |
451 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
452 |
$pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["device_ram"][1].' :</i></b> '.$val["specificity"])); |
453 |
break;
|
454 |
case RAM_DEVICE : |
455 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
456 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][6])); |
457 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
458 |
$pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["monitors"][21].' :</i></b> '.$val["specificity"])); |
459 |
if (empty($device->fields["frequence"])) { |
460 |
if (!empty($device->fields["type"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_ram_type",$device->fields["type"]))); |
461 |
} else {
|
462 |
if (!empty($device->fields["type"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),73,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_ram_type",$device->fields["type"]))); |
463 |
$pdf->addTextWrap($other_x+75,($start_tab-15)-(15*$i),28,9,utf8_decode($device->fields["frequence"])); |
464 |
} |
465 |
break;
|
466 |
case SND_DEVICE : |
467 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
468 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][7])); |
469 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
470 |
if (!empty($device->fields["type"])) $pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.$device->fields["type"])); |
471 |
break;
|
472 |
case DRIVE_DEVICE : |
473 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
474 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][19])); |
475 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
476 |
if (!empty($device->fields["is_writer"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["profiles"][11].' :</i></b> '.getYesNo($device->fields["is_writer"]))); |
477 |
else if (!empty($device->fields["speed"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["device_drive"][1].' :</i></b> '.$device->fields["speed"])); |
478 |
else if (!empty($device->fields["frequence"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["device_ram"][1].' :</i></b> '.$device->fields["frequence"])); |
479 |
break;
|
480 |
case CONTROL_DEVICE :; |
481 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(25*$i),13,9,utf8_decode($val["quantity"].'x')); |
482 |
$pdf->addTextWrap($device_x,($start_tab-15)-(25*$i),73,9,utf8_decode($LANG["devices"][20])); |
483 |
$pdf->addTextWrap($design_x,($start_tab-15)-(25*$i),228,9,utf8_decode($device->fields["designation"])); |
484 |
if (!empty($device->fields["interface"])) $pdf->addTextWrap($spec_x,($start_tab-15)-(15*$i),99,9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_interface",$device->fields["interface"]))); |
485 |
if (!empty($device->fields["raid"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["device_control"][0].' :</i></b> '.getYesNo($device->fields["raid"]))); |
486 |
break;
|
487 |
case PCI_DEVICE : |
488 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
489 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][21])); |
490 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
491 |
break;
|
492 |
case POWER_DEVICE : |
493 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
494 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][23])); |
495 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
496 |
if (!empty($device->fields["power"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["device_power"][0].' :</i></b> '.$device->fields["power"])); |
497 |
else if (!empty($device->fields["atx"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["device_power"][1].' :</i></b> '.getYesNo($device->fields["atx"]))); |
498 |
break;
|
499 |
case CASE_DEVICE : |
500 |
$pdf->addTextWrap($nb_x,($start_tab-15)-(15*$i),13,9,utf8_decode($val["quantity"].'x')); |
501 |
$pdf->addTextWrap($device_x,($start_tab-15)-(15*$i),73,9,utf8_decode($LANG["devices"][22])); |
502 |
$pdf->addTextWrap($design_x,($start_tab-15)-(15*$i),228,9,utf8_decode($device->fields["designation"])); |
503 |
if (!empty($device->fields["type"])) $pdf->addTextWrap($other_x,($start_tab-15)-(15*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_case_type",$device->fields["type"]))); |
504 |
break;
|
505 |
} |
506 |
$i++;
|
507 |
|
508 |
if(($start_tab-20)-(15*$i)<50){ |
509 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
510 |
$i=0; |
511 |
$start_tab = 750; |
512 |
} |
513 |
} |
514 |
|
515 |
$start_tab = ($start_tab-20)-(15*$i) - 20; |
516 |
|
517 |
$tab["start_tab"] = $start_tab; |
518 |
$tab["pdf"] = $pdf; |
519 |
|
520 |
return $tab; |
521 |
} |
522 |
|
523 |
function plugin_pdf_licenses($tab,$width,$ID,$show_computers,$type){ |
524 |
|
525 |
global $DB,$LANG,$LANGPDF; |
526 |
|
527 |
$start_tab = $tab["start_tab"]; |
528 |
$pdf = $tab["pdf"]; |
529 |
|
530 |
$ci=new CommonItem(); |
531 |
$query = "SELECT count(*) AS COUNT FROM glpi_licenses WHERE (sID = '$ID')"; |
532 |
$query_update = "SELECT count(glpi_licenses.ID) AS COUNT FROM glpi_licenses, glpi_software WHERE (glpi_software.ID = glpi_licenses.sID AND glpi_software.update_software = '$ID' and glpi_software.is_update='1')"; |
533 |
|
534 |
$i=0; |
535 |
|
536 |
if ($result = $DB->query($query)) { |
537 |
if ($DB->result($result,0,0)!=0) { |
538 |
$nb_licences=$DB->result($result, 0, "COUNT"); |
539 |
$result_update = $DB->query($query_update); |
540 |
$nb_updates=$DB->result($result_update, 0, "COUNT"); |
541 |
$installed = getInstalledLicence($ID); |
542 |
$tobuy=getLicenceToBuy($ID); |
543 |
$isfreeorglobal=isFreeSoftware($ID)||isGlobalSoftware($ID); |
544 |
|
545 |
$pdf->saveState();
|
546 |
$pdf->setColor(0.8,0.8,0.8); |
547 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
548 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15); |
549 |
$pdf->filledRectangle(130,($start_tab-25)-(20*$i),90,15); |
550 |
$pdf->filledRectangle(225,($start_tab-25)-(20*$i),30,15); |
551 |
$pdf->filledRectangle(260,($start_tab-25)-(20*$i),80,15); |
552 |
$pdf->filledRectangle(345,($start_tab-25)-(20*$i),30,15); |
553 |
$pdf->filledRectangle(380,($start_tab-25)-(20*$i),30,15); |
554 |
$pdf->filledRectangle(415,($start_tab-25)-(20*$i),155,15); |
555 |
$pdf->restoreState();
|
556 |
$pdf->addText(130,$start_tab,9,utf8_decode('<b>'.$nb_licences.' '.$LANG["software"][13].' '.$nb_updates.' '.$LANG["software"][36].' '.$installed.' '.$LANG["software"][19].' '.$tobuy.' '.$LANG["software"][37].'</b>')); |
557 |
$pdf->addText(60,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][5].'</b>')); |
558 |
$pdf->addText(145,$start_tab-20,9,utf8_decode('<b>'.$LANG["common"][19].'</b>')); |
559 |
$pdf->addText(230,$start_tab-20,9,utf8_decode('<b>'.$LANG["common"][33].'</b>')); |
560 |
$pdf->addText(280,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][32].'</b>')); |
561 |
$pdf->addText(350,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][28].'</b>')); |
562 |
$pdf->addText(382,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][35].'</b>')); |
563 |
$pdf->addText(470,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][19].'</b>')); |
564 |
|
565 |
$i++;
|
566 |
} |
567 |
else
|
568 |
{ |
569 |
$pdf->saveState();
|
570 |
$pdf->setColor(0.8,0.8,0.8); |
571 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
572 |
$pdf->restoreState();
|
573 |
$pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($LANG["software"][14]).'</b>'); |
574 |
} |
575 |
} |
576 |
|
577 |
$query = "SELECT count(ID) AS COUNT , version as VERSION, serial as SERIAL, expire as EXPIRE, oem as OEM, oem_computer as OEM_COMPUTER, buy as BUY FROM glpi_licenses WHERE (sID = '$ID') GROUP BY version, serial, expire, oem, oem_computer, buy ORDER BY version, serial,oem, oem_computer"; |
578 |
|
579 |
if ($result = $DB->query($query)) { |
580 |
while ($data=$DB->fetch_array($result)) { |
581 |
$version=$data["VERSION"]; |
582 |
$serial=$data["SERIAL"]; |
583 |
$num_tot=$data["COUNT"]; |
584 |
$expire=$data["EXPIRE"]; |
585 |
$oem=$data["OEM"]; |
586 |
$oem_computer=$data["OEM_COMPUTER"]; |
587 |
$buy=$data["BUY"]; |
588 |
|
589 |
$SEARCH_LICENCE="(glpi_licenses.sID = $ID AND glpi_licenses.serial = '".$serial."' AND glpi_licenses.oem = '$oem' AND glpi_licenses.oem_computer = '$oem_computer' AND glpi_licenses.buy = '$buy' "; |
590 |
if ($expire=="") |
591 |
$SEARCH_LICENCE.=" AND glpi_licenses.expire IS NULL"; |
592 |
else $SEARCH_LICENCE.=" AND glpi_licenses.expire = '$expire'"; |
593 |
|
594 |
if ($version=="") |
595 |
$SEARCH_LICENCE.=" AND glpi_licenses.version='')"; |
596 |
else $SEARCH_LICENCE.=" AND glpi_licenses.version = '$version')"; |
597 |
|
598 |
$today=date("Y-m-d"); |
599 |
$expirer=0; |
600 |
if ($expire!=NULL&&$today>$expire) |
601 |
$expirer=1; |
602 |
|
603 |
$query_inst = "SELECT glpi_inst_software.ID AS ID, glpi_inst_software.license AS lID, glpi_computers.deleted as deleted, "; |
604 |
$query_inst .= " glpi_infocoms.ID as infocoms, glpi_licenses.comments AS COMMENT, "; |
605 |
$query_inst .= " glpi_computers.ID AS cID, glpi_computers.name AS cname FROM glpi_licenses"; |
606 |
$query_inst .= " INNER JOIN glpi_inst_software "; |
607 |
$query_inst .= " ON ( glpi_inst_software.license = glpi_licenses.ID )"; |
608 |
$query_inst .= " INNER JOIN glpi_computers ON (glpi_computers.deleted='0' AND glpi_computers.is_template='0' AND glpi_inst_software.cID= glpi_computers.ID) "; |
609 |
$query_inst .= " LEFT JOIN glpi_infocoms ON (glpi_infocoms.device_type='".LICENSE_TYPE."' AND glpi_infocoms.FK_device=glpi_licenses.ID) "; |
610 |
$query_inst .= " WHERE $SEARCH_LICENCE ORDER BY cname"; |
611 |
|
612 |
$result_inst = $DB->query($query_inst); |
613 |
$num_inst=$DB->numrows($result_inst); |
614 |
|
615 |
$pdf->saveState();
|
616 |
$pdf->setColor(0.90,0.90,0.90); |
617 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15); |
618 |
$pdf->filledRectangle(130,($start_tab-25)-(20*$i),90,15); |
619 |
$pdf->filledRectangle(225,($start_tab-25)-(20*$i),30,15); |
620 |
$pdf->filledRectangle(260,($start_tab-25)-(20*$i),80,15); |
621 |
$pdf->filledRectangle(345,($start_tab-25)-(20*$i),30,15); |
622 |
$pdf->filledRectangle(380,($start_tab-25)-(20*$i),30,15); |
623 |
$pdf->filledRectangle(415,($start_tab-25)-(20*$i),155,15); |
624 |
$pdf->restoreState();
|
625 |
|
626 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($version)); |
627 |
$pdf->addText(135,($start_tab-20)-(20*$i),9,utf8_decode($serial)); |
628 |
$pdf->addText(235,($start_tab-20)-(20*$i),9,utf8_decode($num_tot)); |
629 |
|
630 |
if ($expire==NULL) |
631 |
$pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][26])); |
632 |
else{
|
633 |
if ($expirer) |
634 |
$pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][27])); |
635 |
else
|
636 |
$pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][25].' '.convDate($expire))); |
637 |
} |
638 |
|
639 |
if($oem) |
640 |
$pdf->addText(350,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1])); |
641 |
else
|
642 |
$pdf->addText(350,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0])); |
643 |
|
644 |
if ($serial!="free"){ |
645 |
if($buy) |
646 |
$pdf->addText(385,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1])); |
647 |
else
|
648 |
$pdf->addText(385,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0])); |
649 |
} |
650 |
|
651 |
if (!$show_computers) |
652 |
$pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][19].' '.$num_inst)); |
653 |
else
|
654 |
{ |
655 |
while ($data_inst=$DB->fetch_array($result_inst)) |
656 |
{ |
657 |
|
658 |
$ci->getFromDB(COMPUTER_TYPE,$data_inst["cID"]); |
659 |
$name=$ci->getNameID(); |
660 |
$computer = new Computer(); |
661 |
$computer->getFromDB($data_inst["cID"]); |
662 |
|
663 |
$pdf->saveState();
|
664 |
$pdf->setColor(0.90,0.90,0.90); |
665 |
$pdf->filledRectangle(415,($start_tab-25)-(20*$i),155,15); |
666 |
$pdf->restoreState();
|
667 |
$pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($name.' ('.$computer->fields['serial'].')')); |
668 |
|
669 |
$i++;
|
670 |
|
671 |
if(($start_tab-20)-(20*$i)<50){ |
672 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
673 |
$i=0; |
674 |
$start_tab = 750; |
675 |
} |
676 |
} |
677 |
$i--;
|
678 |
} |
679 |
$i++;
|
680 |
|
681 |
if(($start_tab-20)-(20*$i)<50){ |
682 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
683 |
$i=0; |
684 |
$start_tab = 750; |
685 |
} |
686 |
} |
687 |
} |
688 |
|
689 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
690 |
|
691 |
$tab["start_tab"] = $start_tab; |
692 |
$tab["pdf"] = $pdf; |
693 |
|
694 |
return $tab; |
695 |
} |
696 |
|
697 |
function plugin_pdf_software($tab,$width,$ID,$type){ |
698 |
|
699 |
global $DB,$LANG,$LANGPDF; |
700 |
|
701 |
$start_tab = $tab["start_tab"]; |
702 |
$pdf = $tab["pdf"]; |
703 |
|
704 |
$comp=new Computer(); |
705 |
$comp->getFromDB($ID); |
706 |
$FK_entities=$comp->fields["FK_entities"]; |
707 |
|
708 |
$query_cat = "SELECT 1 as TYPE, glpi_dropdown_software_category.name as category, glpi_software.category as category_id, glpi_software.name as softname, glpi_inst_software.license as license, glpi_inst_software.ID as ID,glpi_licenses.expire,glpi_software.deleted, glpi_licenses.sID, glpi_licenses.version, glpi_licenses.oem, glpi_licenses.oem_computer, glpi_licenses.serial, glpi_licenses.buy FROM glpi_inst_software LEFT JOIN glpi_licenses ON ( glpi_inst_software.license = glpi_licenses.ID ) |
709 |
LEFT JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID)
|
710 |
LEFT JOIN glpi_dropdown_software_category ON (glpi_dropdown_software_category.ID = glpi_software.category)";
|
711 |
|
712 |
$query_cat.=" WHERE glpi_inst_software.cID = '$ID' AND glpi_software.category > 0 "; |
713 |
$query_nocat = "SELECT 2 as TYPE, glpi_dropdown_software_category.name as category, glpi_software.category as category_id, glpi_software.name as softname, glpi_inst_software.license as license, glpi_inst_software.ID as ID,glpi_licenses.expire,glpi_software.deleted, glpi_licenses.sID, glpi_licenses.version, glpi_licenses.oem, glpi_licenses.oem_computer, glpi_licenses.serial, glpi_licenses.buy |
714 |
FROM glpi_inst_software LEFT JOIN glpi_licenses ON ( glpi_inst_software.license = glpi_licenses.ID )
|
715 |
LEFT JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID)
|
716 |
LEFT JOIN glpi_dropdown_software_category ON (glpi_dropdown_software_category.ID = glpi_software.category)";
|
717 |
$query_nocat.= " WHERE glpi_inst_software.cID = '$ID' AND (glpi_software.category <= 0 OR glpi_software.category IS NULL ) "; |
718 |
$query="( $query_cat ) UNION ($query_nocat) ORDER BY TYPE, category, softname, version"; |
719 |
|
720 |
$result = $DB->query($query); |
721 |
$i = 0; |
722 |
|
723 |
$pdf->saveState();
|
724 |
$pdf->setColor(0.8,0.8,0.8); |
725 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
726 |
$pdf->restoreState();
|
727 |
$pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$LANG["software"][17].'</b>')); |
728 |
|
729 |
$cat=-1; |
730 |
|
731 |
if ($DB->numrows($result)) |
732 |
while ($data=$DB->fetch_array($result)) { |
733 |
|
734 |
if($data["category_id"] != $cat) |
735 |
{ |
736 |
$cat = $data["category_id"]; |
737 |
$catname=$data["category"]; |
738 |
|
739 |
if (!$cat) |
740 |
$catname=$LANG["softwarecategories"][3]; |
741 |
|
742 |
$pdf->saveState();
|
743 |
$pdf->setColor(0.8,0.8,0.8); |
744 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
745 |
$pdf->restoreState();
|
746 |
$pdf->addText(240,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$catname.'</b>')); |
747 |
|
748 |
$i++;
|
749 |
|
750 |
$pdf->saveState();
|
751 |
$pdf->setColor(0.8,0.8,0.8); |
752 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),385,15); |
753 |
$pdf->filledRectangle(415,($start_tab-25)-(20*$i),65,15); |
754 |
$pdf->filledRectangle(485,($start_tab-25)-(20*$i),40,15); |
755 |
$pdf->filledRectangle(530,($start_tab-25)-(20*$i),40,15); |
756 |
$pdf->restoreState();
|
757 |
$pdf->addText(180,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["common"][16].'</b>')); |
758 |
$pdf->addText(425,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["financial"][98].'</b>')); |
759 |
$pdf->addText(493,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["software"][28].'</b>')); |
760 |
$pdf->addText(536,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["software"][35].'</b>')); |
761 |
|
762 |
$i++;
|
763 |
} |
764 |
|
765 |
$sw = new Software(); |
766 |
$sw->getFromDB($data['sID']); |
767 |
|
768 |
$pdf->saveState();
|
769 |
$pdf->setColor(0.90,0.90,0.90); |
770 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),385,15); |
771 |
$pdf->filledRectangle(415,($start_tab-25)-(20*$i),65,15); |
772 |
$pdf->filledRectangle(485,($start_tab-25)-(20*$i),40,15); |
773 |
$pdf->filledRectangle(530,($start_tab-25)-(20*$i),40,15); |
774 |
$pdf->restoreState();
|
775 |
|
776 |
$pdf->addText(27,($start_tab-20)-(20*$i),8,utf8_decode($sw->fields["name"].' ( '.$data["version"].' ) - '.$data['serial'])); |
777 |
|
778 |
if($data['expire']==null) |
779 |
$pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][26])); |
780 |
else{
|
781 |
if($data['deleted']) |
782 |
$pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][27])); |
783 |
else
|
784 |
$pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($data["expire"])); |
785 |
} |
786 |
|
787 |
if($data['serial']!="free" && $data['serial']!="global") |
788 |
{ |
789 |
if($data["oem"]) |
790 |
$pdf->addText(495,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1])); |
791 |
else
|
792 |
$pdf->addText(495,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0])); |
793 |
|
794 |
if($data["buy"]) |
795 |
$pdf->addText(543,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1])); |
796 |
else
|
797 |
$pdf->addText(543,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0])); |
798 |
} |
799 |
$i++;
|
800 |
|
801 |
if(($start_tab-20)-(20*$i)<50){ |
802 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
803 |
$i=0; |
804 |
$start_tab = 750; |
805 |
} |
806 |
} |
807 |
else
|
808 |
{ |
809 |
if(($start_tab-20)-(20*$i)<50){ |
810 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
811 |
$i=0; |
812 |
$start_tab = 750; |
813 |
} |
814 |
$pdf->saveState();
|
815 |
$pdf->setColor(0.8,0.8,0.8); |
816 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
817 |
$pdf->restoreState();
|
818 |
$pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANGPDF["software"][1]).'</b>'); |
819 |
} |
820 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
821 |
|
822 |
$tab["start_tab"] = $start_tab; |
823 |
$tab["pdf"] = $pdf; |
824 |
|
825 |
return $tab; |
826 |
} |
827 |
|
828 |
function plugin_pdf_connection($tab,$width,$ID,$type){ |
829 |
|
830 |
global $DB,$LANG; |
831 |
|
832 |
$start_tab = $tab["start_tab"]; |
833 |
$pdf = $tab["pdf"]; |
834 |
|
835 |
$items=array(PRINTER_TYPE=>$LANG["computers"][39],MONITOR_TYPE=>$LANG["computers"][40],PERIPHERAL_TYPE=>$LANG["computers"][46],PHONE_TYPE=>$LANG["computers"][55]); |
836 |
|
837 |
$ci=new CommonItem(); |
838 |
$comp=new Computer(); |
839 |
$info=new InfoCom(); |
840 |
$comp->getFromDB($ID); |
841 |
|
842 |
$i=0; |
843 |
|
844 |
$pdf->saveState();
|
845 |
$pdf->setColor(0.8,0.8,0.8); |
846 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
847 |
$pdf->restoreState();
|
848 |
$pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$LANG["connect"][0].' :</b>')); |
849 |
|
850 |
foreach ($items as $type=>$title){ |
851 |
$query = "SELECT * from glpi_connect_wire WHERE end2='$ID' AND type='".$type."'"; |
852 |
|
853 |
if ($result=$DB->query($query)) { |
854 |
$resultnum = $DB->numrows($result); |
855 |
if ($resultnum>0) { |
856 |
|
857 |
for ($j=0; $j < $resultnum; $j++, $i++) { |
858 |
$tID = $DB->result($result, $j, "end1"); |
859 |
$connID = $DB->result($result, $j, "ID"); |
860 |
$ci->getFromDB($type,$tID); |
861 |
$info->getFromDBforDevice($type,$tID) || $info->getEmpty(); |
862 |
|
863 |
$pdf->saveState();
|
864 |
$pdf->setColor(0.90,0.90,0.90); |
865 |
if ($ci->getField("otherserial")!=null || $info->fields["num_immo"]) { |
866 |
$pdf->filledRectangle(25,($start_tab-45)-(20*$i),$width-50, 35); |
867 |
} else {
|
868 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50, 15); |
869 |
} |
870 |
$pdf->restoreState();
|
871 |
if ($j==0) { |
872 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode('<b><i>'.$ci->getType().' :</i></b>')); |
873 |
} |
874 |
|
875 |
$tempo=$ci->getName()." - "; |
876 |
if($ci->getField("serial")!=null) { |
877 |
$tempo .=$LANG["common"][19] . " : " .$ci->getField("serial")." - "; |
878 |
} |
879 |
$pdf->addText(120,($start_tab-20)-(20*$i),9,utf8_decode($tempo . plugin_pdf_getDropdownName("glpi_dropdown_state",$ci->getField('state')))); |
880 |
|
881 |
$tempo=""; |
882 |
if($ci->getField("otherserial")!=null) { |
883 |
$tempo .=$LANG["common"][20] . " : " . $ci->getField("otherserial"); |
884 |
} |
885 |
if ($info->fields["num_immo"]) { |
886 |
if ($tempo) $tempo .= " - "; |
887 |
$tempo .=$LANG["financial"][20] . " : " . $info->fields["num_immo"]; |
888 |
} |
889 |
if ($tempo) { |
890 |
$i++;
|
891 |
$pdf->addText(200,($start_tab-20)-(20*$i),9,utf8_decode($tempo)); |
892 |
} |
893 |
}// each device of current type
|
894 |
|
895 |
} else { // No row |
896 |
|
897 |
$pdf->saveState();
|
898 |
$pdf->setColor(0.90,0.90,0.90); |
899 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
900 |
$pdf->restoreState();
|
901 |
|
902 |
switch ($type){ |
903 |
case PRINTER_TYPE: |
904 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][38])); |
905 |
break;
|
906 |
case MONITOR_TYPE: |
907 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][37])); |
908 |
break;
|
909 |
case PERIPHERAL_TYPE: |
910 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][47])); |
911 |
break;
|
912 |
case PHONE_TYPE: |
913 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][54])); |
914 |
break;
|
915 |
} |
916 |
$i++;
|
917 |
} // No row
|
918 |
} // Result
|
919 |
|
920 |
if(($start_tab-20)-(20*$i)<50){ |
921 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
922 |
$i=0; |
923 |
$start_tab = 750; |
924 |
} |
925 |
} // each type
|
926 |
|
927 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
928 |
|
929 |
$tab["start_tab"] = $start_tab; |
930 |
$tab["pdf"] = $pdf; |
931 |
|
932 |
return $tab; |
933 |
|
934 |
} |
935 |
|
936 |
function plugin_pdf_port($tab,$width,$ID,$type){ |
937 |
|
938 |
global $DB,$LANG; |
939 |
|
940 |
$start_tab = $tab["start_tab"]; |
941 |
$pdf = $tab["pdf"]; |
942 |
|
943 |
$query = "SELECT ID FROM glpi_networking_ports WHERE (on_device = ".$ID." AND device_type = ".COMPUTER_TYPE.") ORDER BY name, logical_number"; |
944 |
|
945 |
$i=0; |
946 |
|
947 |
if ($result = $DB->query($query)) |
948 |
{ |
949 |
|
950 |
$nb_connect = $DB->numrows($result); |
951 |
|
952 |
if ($nb_connect!=0) |
953 |
{ |
954 |
|
955 |
$pdf->saveState();
|
956 |
$pdf->setColor(0.8,0.8,0.8); |
957 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
958 |
$pdf->restoreState();
|
959 |
|
960 |
$pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$nb_connect.' '.$LANG["networking"][13].' :</b>')); |
961 |
|
962 |
while ($devid=$DB->fetch_row($result)) |
963 |
{ |
964 |
|
965 |
$netport = new Netport; |
966 |
$netport->getfromDB(current($devid)); |
967 |
|
968 |
for($j=0,$deb=0;$j<8;$j++,$deb++){ |
969 |
|
970 |
if(($start_tab-20)-(20*($i+$j))<50){ |
971 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
972 |
$i=0; |
973 |
$start_tab = 750; |
974 |
$deb=0; |
975 |
} |
976 |
|
977 |
if(!($nb_connect==1 && $j==7)){ |
978 |
$pdf->saveState();
|
979 |
if($j<7) |
980 |
$pdf->setColor(0.90,0.90,0.90); |
981 |
else
|
982 |
$pdf->setColor(0.8,0.8,0.8); |
983 |
$pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15); |
984 |
$pdf->restoreState();
|
985 |
} |
986 |
|
987 |
switch($j){ |
988 |
case 0: |
989 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>#</i></b> '.$netport->fields["logical_number"].' <b><i> '.$LANG["common"][16].' :</i></b> '.$netport->fields["name"])); |
990 |
break;
|
991 |
case 1: |
992 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][51].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_netpoint",$netport->fields["netpoint"]))); |
993 |
break;
|
994 |
case 2: |
995 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][14].' / '.$LANG["networking"][15].' :</i></b> '.$netport->fields["ifaddr"].' / '.$netport->fields["ifmac"])); |
996 |
break;
|
997 |
case 3: |
998 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][60].' / '.$LANG["networking"][61].' / '.$LANG["networking"][59].' :</i></b> '.$netport->fields["netmask"].' / '.$netport->fields["subnet"].' / '.$netport->fields["gateway"])); |
999 |
break;
|
1000 |
case 4: |
1001 |
$query="SELECT * from glpi_networking_vlan WHERE FK_port='$ID'"; |
1002 |
$result2=$DB->query($query); |
1003 |
if ($DB->numrows($result2)>0) |
1004 |
while ($line=$DB->fetch_array($result2)) |
1005 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][56].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_vlan",$line["FK_vlan"]))); |
1006 |
else
|
1007 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][56].' :</i></b> ')); |
1008 |
break;
|
1009 |
case 5: |
1010 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_iface",$netport->fields["iface"]))); |
1011 |
break;
|
1012 |
case 6: |
1013 |
$contact = new Netport; |
1014 |
$netport2 = new Netport; |
1015 |
|
1016 |
if ($contact->getContact($netport->fields["ID"])) |
1017 |
{ |
1018 |
$netport2->getfromDB($contact->contact_id); |
1019 |
$netport2->getDeviceData($netport2->fields["on_device"],$netport2->fields["device_type"]); |
1020 |
|
1021 |
if($netport2->device_name!=null) |
1022 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][17].' :</i></b> '.$netport2->device_name)); |
1023 |
else
|
1024 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][17].' :</i></b>'.$LANG["connect"][1])); |
1025 |
} |
1026 |
else
|
1027 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][17].' :</i></b>'.$LANG["connect"][1])); |
1028 |
break;
|
1029 |
case 7: |
1030 |
$i+=$deb+1; |
1031 |
break;
|
1032 |
} |
1033 |
} |
1034 |
} |
1035 |
if($nb_connect==1) |
1036 |
$i--;
|
1037 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1038 |
} |
1039 |
} |
1040 |
else
|
1041 |
{ |
1042 |
if(($start_tab-20)-(20*$i)<50){ |
1043 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1044 |
$i=0; |
1045 |
$start_tab = 750; |
1046 |
} |
1047 |
$pdf->saveState();
|
1048 |
$pdf->setColor(0.8,0.8,0.8); |
1049 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1050 |
$pdf->restoreState();
|
1051 |
$pdf->addText(250,$start_tab,9,utf8_decode('<b>0 '.$LANG["networking"][37].'</b>')); |
1052 |
} |
1053 |
|
1054 |
$tab["start_tab"] = $start_tab; |
1055 |
$tab["pdf"] = $pdf; |
1056 |
|
1057 |
return $tab; |
1058 |
} |
1059 |
|
1060 |
function plugin_pdf_financial($tab,$width,$ID,$type){ |
1061 |
|
1062 |
global $CFG_GLPI,$LANG,$LANGPDF; |
1063 |
|
1064 |
$start_tab = $tab["start_tab"]; |
1065 |
$pdf = $tab["pdf"]; |
1066 |
|
1067 |
$ic = new Infocom(); |
1068 |
$ci=new CommonItem(); |
1069 |
|
1070 |
$i=0; |
1071 |
|
1072 |
if ($ci->getFromDB($type,$ID)) |
1073 |
if ($ic->getFromDBforDevice($type,$ID)){ |
1074 |
|
1075 |
$length_tab = (($width-50)/2)-2.5; |
1076 |
|
1077 |
$pdf->saveState();
|
1078 |
$pdf->setColor(0.8,0.8,0.8); |
1079 |
$pdf->filledRectangle(25,$start_tab-5,2*$length_tab+5,15); |
1080 |
$pdf->setColor(0.90,0.90,0.90); |
1081 |
|
1082 |
for($i=0;$i<11;$i++) |
1083 |
{ |
1084 |
if($i<10) |
1085 |
{ |
1086 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$length_tab,15); |
1087 |
$pdf->filledRectangle(25+$length_tab+5,($start_tab-25)-(20*$i),$length_tab,15); |
1088 |
} |
1089 |
else
|
1090 |
{ |
1091 |
$i+=2; |
1092 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),2*$length_tab+5,55); |
1093 |
} |
1094 |
} |
1095 |
$pdf->restoreState();
|
1096 |
|
1097 |
$pdf->addText(250,$start_tab,9,"<b>".utf8_decode($LANG["financial"][3])."</b>"); |
1098 |
|
1099 |
$pdf->addText(30,$start_tab-20,9,utf8_decode("<b><i>".$LANG["financial"][26]." :</i></b> ".plugin_pdf_getDropdownName("glpi_enterprises",$ic->fields["FK_enterprise"]))); |
1100 |
$pdf->addText(30,$start_tab-40,9,utf8_decode("<b><i>".$LANG["financial"][18]." :</i></b> ".$ic->fields["num_commande"])); |
1101 |
$pdf->addText(30,$start_tab-60,9,utf8_decode("<b><i>".$LANG["financial"][14]." :</i></b> ".convDate($ic->fields["buy_date"]))); |
1102 |
$pdf->addText(30,$start_tab-80,9,utf8_decode("<b><i>".$LANG["financial"][15]." :</i></b> ".$ic->fields["warranty_duration"]." mois <b><i> Expire le</i></b> ".getWarrantyExpir($ic->fields["buy_date"],$ic->fields["warranty_duration"]))); |
1103 |
$pdf->addText(30,$start_tab-100,9,utf8_decode("<b><i>".$LANG["financial"][78]." :</i></b> ".formatNumber($ic->fields["warranty_value"]))); |
1104 |
$pdf->addText(30,$start_tab-120,9,utf8_decode("<b><i>".$LANG["rulesengine"][13]." :</i></b> ".formatNumber($ic->fields["value"]))); |
1105 |
$pdf->addText(30,$start_tab-140,9,utf8_decode("<b><i>".$LANG["financial"][20]." :</i></b> ".$ic->fields["num_immo"])); |
1106 |
$pdf->addText(30,$start_tab-160,9,utf8_decode("<b><i>".$LANG["financial"][23]." :</i></b> ".$ic->fields["amort_time"]." an(s)")); |
1107 |
$pdf->addText(30,$start_tab-180,9,utf8_decode("<b><i>".$LANG["financial"][89]." :</i></b> ".showTco($ci->getField('ticket_tco'),$ic->fields["value"]))); |
1108 |
if($ic->fields["alert"]==0) |
1109 |
$pdf->addText(30,$start_tab-200,9,utf8_decode("<b><i>".$LANG["setup"][247]." :</i></b> ")); |
1110 |
elseif($ic->fields["alert"]==4) |
1111 |
$pdf->addText(30,$start_tab-200,9,utf8_decode("<b><i>".$LANG["setup"][247]." :</i></b> ".$LANG["financial"][80])); |
1112 |
$pdf->addText(30,$start_tab-220,9,utf8_decode("<b><i>".$LANG["common"][25]." :</i></b> ")); |
1113 |
|
1114 |
$y=$start_tab-220; |
1115 |
$mytext=$ic->fields["comments"]; |
1116 |
while($mytext = $pdf->addTextWrap(105,$y,2*$length_tab-80,10,utf8_decode($mytext))) |
1117 |
$y-=10; |
1118 |
|
1119 |
$pdf->addText($length_tab+35,$start_tab-20,9,utf8_decode("<b><i>".$LANG["financial"][82]." :</i></b> ".$ic->fields["facture"])); |
1120 |
$pdf->addText($length_tab+35,$start_tab-40,9,utf8_decode("<b><i>".$LANG["financial"][19]." :</i></b> ".$ic->fields["bon_livraison"])); |
1121 |
$pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode("<b><i>".$LANG["financial"][76]." :</i></b> ".convDate($ic->fields["use_date"]))); |
1122 |
$pdf->addText($length_tab+35,$start_tab-80,9,utf8_decode("<b><i>".$LANG["financial"][87]." :</i></b> ".plugin_pdf_getDropdownName("glpi_dropdown_budget",$ic->fields["budget"]))); |
1123 |
$pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode("<b><i>".$LANG["financial"][16]." :</i></b> ".$ic->fields["warranty_info"])); |
1124 |
$pdf->addText($length_tab+35,$start_tab-120,9,utf8_decode("<b><i>".$LANG["financial"][81]." :</i></b> ".TableauAmort($ic->fields["amort_type"],$ic->fields["value"],$ic->fields["amort_time"],$ic->fields["amort_coeff"],$ic->fields["buy_date"],$ic->fields["use_date"],$CFG_GLPI["date_fiscale"],"n"))); |
1125 |
$pdf->addText($length_tab+35,$start_tab-140,9,utf8_decode("<b><i>".$LANG["financial"][22]." :</i></b> ".getAmortTypeName($ic->fields["amort_type"]))); |
1126 |
$pdf->addText($length_tab+35,$start_tab-160,9,utf8_decode("<b><i>".$LANG["financial"][77]." :</i></b> ".$ic->fields["amort_coeff"])); |
1127 |
$pdf->addText($length_tab+35,$start_tab-180,9,utf8_decode("<b><i>".$LANG["financial"][90]." :</i></b> ".showTco($ci->getField('ticket_tco'),$ic->fields["value"],$ic->fields["buy_date"]))); |
1128 |
|
1129 |
} |
1130 |
else
|
1131 |
{ |
1132 |
if(($start_tab-20)-(20*$i)<50){ |
1133 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1134 |
$i=0; |
1135 |
$start_tab = 750; |
1136 |
} |
1137 |
$pdf->saveState();
|
1138 |
$pdf->setColor(0.8,0.8,0.8); |
1139 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1140 |
$pdf->restoreState();
|
1141 |
$pdf->addText(245,$start_tab,9,utf8_decode("<b>".$LANGPDF["financial"][1]."</b>")); |
1142 |
} |
1143 |
|
1144 |
|
1145 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1146 |
|
1147 |
$tab["start_tab"] = $start_tab; |
1148 |
$tab["pdf"] = $pdf; |
1149 |
|
1150 |
return $tab; |
1151 |
} |
1152 |
|
1153 |
function plugin_pdf_contract($tab,$width,$ID,$type){ |
1154 |
|
1155 |
global $DB,$CFG_GLPI,$LANG,$LANGPDF; |
1156 |
|
1157 |
$start_tab = $tab["start_tab"]; |
1158 |
$pdf = $tab["pdf"]; |
1159 |
|
1160 |
$ci=new CommonItem(); |
1161 |
$ci->getFromDB($type,$ID); |
1162 |
|
1163 |
$query = "SELECT * FROM glpi_contract_device WHERE glpi_contract_device.FK_device = ".$ID." AND glpi_contract_device.device_type = ".$type; |
1164 |
|
1165 |
$result = $DB->query($query); |
1166 |
$number = $DB->numrows($result); |
1167 |
|
1168 |
$i=$j=0; |
1169 |
|
1170 |
if($number>0){ |
1171 |
|
1172 |
$pdf->saveState();
|
1173 |
$pdf->setColor(0.8,0.8,0.8); |
1174 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1175 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15); |
1176 |
$pdf->filledRectangle(130,($start_tab-25)-(20*$i),100,15); |
1177 |
$pdf->filledRectangle(235,($start_tab-25)-(20*$i),100,15); |
1178 |
$pdf->filledRectangle(340,($start_tab-25)-(20*$i),80,15); |
1179 |
$pdf->filledRectangle(425,($start_tab-25)-(20*$i),60,15); |
1180 |
$pdf->filledRectangle(490,($start_tab-25)-(20*$i),80,15); |
1181 |
$pdf->restoreState();
|
1182 |
$pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["financial"][66]).' :</b>'); |
1183 |
$pdf->addText(65,$start_tab-20,9,'<b>'.utf8_decode($LANG["common"][16]).'</b>'); |
1184 |
$pdf->addText(138,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][4]).'</b>'); |
1185 |
$pdf->addText(255,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][6]).'</b>'); |
1186 |
$pdf->addText(355,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][26]).'</b>'); |
1187 |
$pdf->addText(428,$start_tab-20,9,'<b>'.utf8_decode($LANG["search"][8]).'</b>'); |
1188 |
$pdf->addText(515,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][8]).'</b>'); |
1189 |
|
1190 |
$i++;
|
1191 |
|
1192 |
while ($j < $number) { |
1193 |
$cID=$DB->result($result, $j, "FK_contract"); |
1194 |
$assocID=$DB->result($result, $j, "ID"); |
1195 |
$con=new Contract; |
1196 |
$con->getFromDB($cID); |
1197 |
|
1198 |
$pdf->saveState();
|
1199 |
$pdf->setColor(0.90,0.90,0.90); |
1200 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15); |
1201 |
$pdf->filledRectangle(130,($start_tab-25)-(20*$i),100,15); |
1202 |
$pdf->filledRectangle(235,($start_tab-25)-(20*$i),100,15); |
1203 |
$pdf->filledRectangle(340,($start_tab-25)-(20*$i),80,15); |
1204 |
$pdf->filledRectangle(425,($start_tab-25)-(20*$i),60,15); |
1205 |
$pdf->filledRectangle(490,($start_tab-25)-(20*$i),80,15); |
1206 |
$pdf->restoreState();
|
1207 |
|
1208 |
if (empty($con->fields["name"])) |
1209 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["ID"])); |
1210 |
else
|
1211 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["name"])); |
1212 |
|
1213 |
$pdf->addText(135,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["num"])); |
1214 |
$pdf->addText(240,($start_tab-20)-(20*$i),9,utf8_decode(plugin_pdf_getDropdownName("glpi_dropdown_contract_type",$con->fields["contract_type"]))); |
1215 |
|
1216 |
$temp = str_replace("<br>", "", getContractEnterprises($cID)); |
1217 |
|
1218 |
if(strlen($temp)<14) |
1219 |
$pdf->addText(345,($start_tab-20)-(20*$i),9,utf8_decode($temp)); |
1220 |
else
|
1221 |
{ |
1222 |
$temp=$pdf->addTextWrap(345,($start_tab-20)-(20*$i)+4,70,8,utf8_decode($temp)); |
1223 |
$pdf->addTextWrap(345,($start_tab-20)-(20*$i)-4,70,8,utf8_decode($temp)); |
1224 |
} |
1225 |
|
1226 |
$pdf->addText(430,($start_tab-20)-(20*$i),9,utf8_decode(convDate($con->fields["begin_date"]))); |
1227 |
|
1228 |
if ($con->fields["begin_date"]!='' && $con->fields["begin_date"]!="0000-00-00") |
1229 |
{ |
1230 |
$pdf->addText(515,($start_tab-20)-(20*$i)+4,7,utf8_decode($con->fields["duration"]." ".$LANG["financial"][57])); |
1231 |
$pdf->addText(505,($start_tab-20)-(20*$i)-4,7,"-> ".utf8_decode(getWarrantyExpir($con->fields["begin_date"],$con->fields["duration"]))); |
1232 |
} |
1233 |
else
|
1234 |
$pdf->addText(510,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["duration"]." ".$LANG["financial"][57])); |
1235 |
|
1236 |
$i++;
|
1237 |
$j++;
|
1238 |
|
1239 |
if(($start_tab-20)-(20*$i)<50){ |
1240 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1241 |
$i=0; |
1242 |
$start_tab = 750; |
1243 |
} |
1244 |
} |
1245 |
} |
1246 |
else
|
1247 |
{ |
1248 |
if(($start_tab-20)-(20*$i)<50){ |
1249 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1250 |
$i=0; |
1251 |
$start_tab = 750; |
1252 |
} |
1253 |
$pdf->saveState();
|
1254 |
$pdf->setColor(0.8,0.8,0.8); |
1255 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1256 |
$pdf->restoreState();
|
1257 |
$pdf->addText(260,$start_tab,9,utf8_decode('<b>'.$LANGPDF["financial"][2].'</b>')); |
1258 |
} |
1259 |
|
1260 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1261 |
|
1262 |
$tab["start_tab"] = $start_tab; |
1263 |
$tab["pdf"] = $pdf; |
1264 |
|
1265 |
return $tab; |
1266 |
} |
1267 |
|
1268 |
function plugin_pdf_document($tab,$width,$ID,$type){ |
1269 |
|
1270 |
global $DB,$LANG,$LANGPDF; |
1271 |
|
1272 |
$start_tab = $tab["start_tab"]; |
1273 |
$pdf = $tab["pdf"]; |
1274 |
|
1275 |
$query = "SELECT glpi_doc_device.ID as assocID, glpi_docs.* FROM glpi_doc_device "; |
1276 |
$query .= "LEFT JOIN glpi_docs ON (glpi_doc_device.FK_doc=glpi_docs.ID)"; |
1277 |
$query .= "WHERE glpi_doc_device.FK_device = ".$ID." AND glpi_doc_device.device_type = ".$type; |
1278 |
|
1279 |
$result = $DB->query($query); |
1280 |
$number = $DB->numrows($result); |
1281 |
|
1282 |
$i=0; |
1283 |
|
1284 |
if($number>0){ |
1285 |
|
1286 |
$pdf->saveState();
|
1287 |
$pdf->setColor(0.8,0.8,0.8); |
1288 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1289 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),125,15); |
1290 |
$pdf->filledRectangle(155,($start_tab-25)-(20*$i),120,15); |
1291 |
$pdf->filledRectangle(280,($start_tab-25)-(20*$i),110,15); |
1292 |
$pdf->filledRectangle(395,($start_tab-25)-(20*$i),100,15); |
1293 |
$pdf->filledRectangle(500,($start_tab-25)-(20*$i),70,15); |
1294 |
$pdf->restoreState();
|
1295 |
$pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANG["document"][21]).' :</b>'); |
1296 |
$pdf->addText(80,$start_tab-20,9,'<b>'.utf8_decode($LANG["common"][16]).'</b>'); |
1297 |
$pdf->addText(195,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][2]).'</b>'); |
1298 |
$pdf->addText(315,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][33]).'</b>'); |
1299 |
$pdf->addText(425,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][3]).'</b>'); |
1300 |
$pdf->addText(510,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][4]).'</b>'); |
1301 |
|
1302 |
$i++;
|
1303 |
|
1304 |
while ($data=$DB->fetch_assoc($result)) { |
1305 |
|
1306 |
$pdf->saveState();
|
1307 |
$pdf->setColor(0.90,0.90,0.90); |
1308 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),125,15); |
1309 |
$pdf->filledRectangle(155,($start_tab-25)-(20*$i),120,15); |
1310 |
$pdf->filledRectangle(280,($start_tab-25)-(20*$i),110,15); |
1311 |
$pdf->filledRectangle(395,($start_tab-25)-(20*$i),100,15); |
1312 |
$pdf->filledRectangle(500,($start_tab-25)-(20*$i),70,15); |
1313 |
$pdf->restoreState();
|
1314 |
|
1315 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($data["name"])); |
1316 |
$pdf->addText(160,($start_tab-20)-(20*$i),9,utf8_decode($data["filename"])); |
1317 |
$pdf->addText(285,($start_tab-20)-(20*$i),9,utf8_decode($data["link"])); |
1318 |
$pdf->addText(400,($start_tab-20)-(20*$i),9,utf8_decode(plugin_pdf_getDropdownName("glpi_dropdown_rubdocs",$data["rubrique"]))); |
1319 |
$pdf->addText(505,($start_tab-20)-(20*$i),9,utf8_decode($data["mime"])); |
1320 |
|
1321 |
$i++;
|
1322 |
|
1323 |
if(($start_tab-20)-(20*$i)<50){ |
1324 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1325 |
$i=0; |
1326 |
$start_tab = 750; |
1327 |
} |
1328 |
} |
1329 |
} |
1330 |
else
|
1331 |
{ |
1332 |
if(($start_tab-20)-(20*$i)<50){ |
1333 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1334 |
$i=0; |
1335 |
$start_tab = 750; |
1336 |
} |
1337 |
$pdf->saveState();
|
1338 |
$pdf->setColor(0.8,0.8,0.8); |
1339 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1340 |
$pdf->restoreState();
|
1341 |
$pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANGPDF["document"][1]).'</b>'); |
1342 |
} |
1343 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1344 |
|
1345 |
$tab["start_tab"] = $start_tab; |
1346 |
$tab["pdf"] = $pdf; |
1347 |
|
1348 |
return $tab; |
1349 |
} |
1350 |
|
1351 |
function plugin_pdf_registry($tab,$width,$ID,$type){ |
1352 |
|
1353 |
global $DB,$LANG; |
1354 |
|
1355 |
$start_tab = $tab["start_tab"]; |
1356 |
$pdf = $tab["pdf"]; |
1357 |
|
1358 |
$REGISTRY_HIVE=array("HKEY_CLASSES_ROOT", |
1359 |
"HKEY_CURRENT_USER",
|
1360 |
"HKEY_LOCAL_MACHINE",
|
1361 |
"HKEY_USERS",
|
1362 |
"HKEY_CURRENT_CONFIG",
|
1363 |
"HKEY_DYN_DATA");
|
1364 |
|
1365 |
$query = "SELECT ID FROM glpi_registry WHERE computer_id='".$ID."'"; |
1366 |
|
1367 |
$i=0; |
1368 |
|
1369 |
if ($result = $DB->query($query)) { |
1370 |
if ($DB->numrows($result)!=0) { |
1371 |
|
1372 |
$pdf->saveState();
|
1373 |
$pdf->setColor(0.8,0.8,0.8); |
1374 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1375 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),130,15); |
1376 |
$pdf->filledRectangle(160,($start_tab-25)-(20*$i),130,15); |
1377 |
$pdf->filledRectangle(295,($start_tab-25)-(20*$i),140,15); |
1378 |
$pdf->filledRectangle(440,($start_tab-25)-(20*$i),130,15); |
1379 |
$pdf->restoreState();
|
1380 |
$pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($DB->numrows($result)." ".$LANG["registry"][4]).' :</b>'); |
1381 |
$pdf->addText(65,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][6]).'</b>'); |
1382 |
$pdf->addText(215,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][1]).'</b>'); |
1383 |
$pdf->addText(345,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][2]).'</b>'); |
1384 |
$pdf->addText(490,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][3]).'</b>'); |
1385 |
|
1386 |
$i++;
|
1387 |
|
1388 |
while ($regid=$DB->fetch_row($result)) { |
1389 |
$reg = new Registry; |
1390 |
$reg->getfromDB(current($regid)); |
1391 |
|
1392 |
$pdf->saveState();
|
1393 |
$pdf->setColor(0.90,0.90,0.90); |
1394 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),130,15); |
1395 |
$pdf->filledRectangle(160,($start_tab-25)-(20*$i),130,15); |
1396 |
$pdf->filledRectangle(295,($start_tab-25)-(20*$i),140,15); |
1397 |
$pdf->filledRectangle(440,($start_tab-25)-(20*$i),130,15); |
1398 |
$pdf->restoreState();
|
1399 |
|
1400 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_ocs_name"])); |
1401 |
$pdf->addText(165,($start_tab-20)-(20*$i),9,utf8_decode($REGISTRY_HIVE[$reg->fields["registry_hive"]])); |
1402 |
$pdf->addText(300,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_path"])); |
1403 |
$pdf->addText(445,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_value"])); |
1404 |
|
1405 |
$i++;
|
1406 |
|
1407 |
if(($start_tab-20)-(20*$i)<50){ |
1408 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1409 |
$i=0; |
1410 |
$start_tab = 750; |
1411 |
} |
1412 |
} |
1413 |
} |
1414 |
else
|
1415 |
{ |
1416 |
if(($start_tab-20)-(20*$i)<50){ |
1417 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1418 |
$i=0; |
1419 |
$start_tab = 750; |
1420 |
} |
1421 |
$pdf->saveState();
|
1422 |
$pdf->setColor(0.8,0.8,0.8); |
1423 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1424 |
$pdf->restoreState();
|
1425 |
$pdf->addText(230,$start_tab,9,'<b>'.utf8_decode($LANG["registry"][5]).'</b>'); |
1426 |
} |
1427 |
} |
1428 |
|
1429 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1430 |
|
1431 |
$tab["start_tab"] = $start_tab; |
1432 |
$tab["pdf"] = $pdf; |
1433 |
|
1434 |
return $tab; |
1435 |
} |
1436 |
|
1437 |
function plugin_pdf_ticket($tab,$width,$ID,$type){ |
1438 |
|
1439 |
global $DB,$CFG_GLPI, $LANG; |
1440 |
|
1441 |
$start_tab = $tab["start_tab"]; |
1442 |
$pdf = $tab["pdf"]; |
1443 |
|
1444 |
$sort="glpi_tracking.date"; |
1445 |
$order=getTrackingOrderPrefs($_SESSION["glpiID"]); |
1446 |
|
1447 |
$where = "(status = 'new' OR status= 'assign' OR status='plan' OR status='waiting')"; |
1448 |
|
1449 |
$query = "SELECT ".getCommonSelectForTrackingSearch()." FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch()." WHERE $where and (computer = '$ID' and device_type= ".$type.") ORDER BY $sort $order"; |
1450 |
|
1451 |
$result = $DB->query($query); |
1452 |
|
1453 |
$i = 0; |
1454 |
|
1455 |
$number = $DB->numrows($result); |
1456 |
|
1457 |
if ($number > 0) |
1458 |
{ |
1459 |
$pdf->saveState();
|
1460 |
$pdf->setColor(0.8,0.8,0.8); |
1461 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1462 |
$pdf->restoreState();
|
1463 |
$pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($number.' '.$LANG["job"][17].' '.$LANG["job"][16]).' :</b>'); |
1464 |
|
1465 |
while ($data=$DB->fetch_assoc($result)) |
1466 |
{ |
1467 |
for($j=0,$deb=0;$j<9;$j++,$deb++){ |
1468 |
|
1469 |
if(($start_tab-20)-(20*($i+$j))<50){ |
1470 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1471 |
$i=0; |
1472 |
$start_tab = 750; |
1473 |
$deb=0; |
1474 |
} |
1475 |
|
1476 |
if(!($number==1 && $j==8)){ |
1477 |
$pdf->saveState();
|
1478 |
if($j<8) |
1479 |
$pdf->setColor(0.90,0.90,0.90); |
1480 |
else
|
1481 |
$pdf->setColor(0.8,0.8,0.8); |
1482 |
$pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15); |
1483 |
$pdf->restoreState();
|
1484 |
} |
1485 |
|
1486 |
switch($j){ |
1487 |
case 0: |
1488 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> ID'.$data["ID"].' '.getStatusName($data["status"]))); |
1489 |
break;
|
1490 |
case 1: |
1491 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][27].' :</i></b> '.$LANG["joblist"][11].' : '.$data["date"])); |
1492 |
break;
|
1493 |
case 2: |
1494 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["joblist"][2].' :</i></b> '.getPriorityName($data["priority"]))); |
1495 |
break;
|
1496 |
case 3: |
1497 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][4].' :</i></b> '.getUserName($data["author"]))); |
1498 |
break;
|
1499 |
case 4: |
1500 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][5].' :</i></b> '.getUserName($data["assign"]))); |
1501 |
break;
|
1502 |
case 5: |
1503 |
$ci=new CommonItem(); |
1504 |
$ci->getFromDB($data["device_type"],$data["computer"]); |
1505 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][1].' :</i></b> '.$ci->getType())); |
1506 |
break;
|
1507 |
case 6: |
1508 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][36].' :</i></b> '.$data["catname"])); |
1509 |
break;
|
1510 |
case 7: |
1511 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][57].' :</i></b> '.$data["name"])); |
1512 |
break;
|
1513 |
case 8: |
1514 |
$i+=$deb+1; |
1515 |
break;
|
1516 |
} |
1517 |
} |
1518 |
if($number==1) |
1519 |
$i--;
|
1520 |
} |
1521 |
} |
1522 |
else
|
1523 |
{ |
1524 |
if(($start_tab-20)-(20*$i)<50){ |
1525 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1526 |
$i=0; |
1527 |
$start_tab = 750; |
1528 |
} |
1529 |
$pdf->saveState();
|
1530 |
$pdf->setColor(0.8,0.8,0.8); |
1531 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1532 |
$pdf->restoreState();
|
1533 |
$pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["joblist"][8]).'</b>'); |
1534 |
} |
1535 |
|
1536 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1537 |
|
1538 |
$tab["start_tab"] = $start_tab; |
1539 |
$tab["pdf"] = $pdf; |
1540 |
|
1541 |
return $tab; |
1542 |
|
1543 |
} |
1544 |
|
1545 |
function plugin_pdf_oldticket($tab,$width,$ID,$type){ |
1546 |
|
1547 |
global $DB,$CFG_GLPI, $LANG; |
1548 |
|
1549 |
$start_tab = $tab["start_tab"]; |
1550 |
$pdf = $tab["pdf"]; |
1551 |
|
1552 |
$sort="glpi_tracking.date"; |
1553 |
$order=getTrackingOrderPrefs($_SESSION["glpiID"]); |
1554 |
|
1555 |
$where = "(status = 'old_done' OR status = 'old_notdone')"; |
1556 |
$query = "SELECT ".getCommonSelectForTrackingSearch()." FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch()." WHERE $where and (device_type = ".$type." and computer = '$ID') ORDER BY $sort $order"; |
1557 |
|
1558 |
$result = $DB->query($query); |
1559 |
|
1560 |
$i = 0; |
1561 |
|
1562 |
$number = $DB->numrows($result); |
1563 |
|
1564 |
if ($number > 0) |
1565 |
{ |
1566 |
$pdf->saveState();
|
1567 |
$pdf->setColor(0.8,0.8,0.8); |
1568 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1569 |
$pdf->restoreState();
|
1570 |
$pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($number.' '.$LANG["job"][18].' '.$LANG["job"][17].' '.$LANG["job"][16]).' :</b>'); |
1571 |
|
1572 |
while ($data=$DB->fetch_assoc($result)) |
1573 |
{ |
1574 |
for($j=0,$deb=0;$j<9;$j++,$deb++){ |
1575 |
|
1576 |
if(($start_tab-20)-(20*($i+$j))<50 && !($number==1 && $j==8)){ |
1577 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1578 |
$i=0; |
1579 |
$start_tab = 750; |
1580 |
$deb=0; |
1581 |
} |
1582 |
|
1583 |
if(!($number==1 && $j==8)){ |
1584 |
$pdf->saveState();
|
1585 |
if($j<8) |
1586 |
$pdf->setColor(0.90,0.90,0.90); |
1587 |
else
|
1588 |
$pdf->setColor(0.8,0.8,0.8); |
1589 |
$pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15); |
1590 |
$pdf->restoreState();
|
1591 |
} |
1592 |
|
1593 |
switch($j){ |
1594 |
case 0: |
1595 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> ID'.$data["ID"].' '.getStatusName($data["status"]))); |
1596 |
break;
|
1597 |
case 1: |
1598 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][27].' :</i></b> '.$LANG["joblist"][11].' : '.$data["date"])); |
1599 |
break;
|
1600 |
case 2: |
1601 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["joblist"][2].' :</i></b> '.getPriorityName($data["priority"]))); |
1602 |
break;
|
1603 |
case 3: |
1604 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][4].' :</i></b> '.getUserName($data["author"]))); |
1605 |
break;
|
1606 |
case 4: |
1607 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][5].' :</i></b> '.getUserName($data["assign"]))); |
1608 |
break;
|
1609 |
case 5: |
1610 |
$ci=new CommonItem(); |
1611 |
$ci->getFromDB($data["device_type"],$data["computer"]); |
1612 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][1].' :</i></b> '.$ci->getType())); |
1613 |
break;
|
1614 |
case 6: |
1615 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][36].' :</i></b> '.$data["catname"])); |
1616 |
break;
|
1617 |
case 7: |
1618 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][57].' :</i></b> '.$data["name"])); |
1619 |
break;
|
1620 |
case 8: |
1621 |
$i+=$deb+1; |
1622 |
break;
|
1623 |
} |
1624 |
} |
1625 |
if($number==1) |
1626 |
$i--;
|
1627 |
} |
1628 |
} |
1629 |
else
|
1630 |
{ |
1631 |
if(($start_tab-20)-(20*$i)<50){ |
1632 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1633 |
$i=0; |
1634 |
$start_tab = 750; |
1635 |
} |
1636 |
$pdf->saveState();
|
1637 |
$pdf->setColor(0.8,0.8,0.8); |
1638 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1639 |
$pdf->restoreState();
|
1640 |
$pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($LANG["joblist"][22]).'</b>'); |
1641 |
} |
1642 |
|
1643 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1644 |
|
1645 |
$tab["start_tab"] = $start_tab; |
1646 |
$tab["pdf"] = $pdf; |
1647 |
|
1648 |
return $tab; |
1649 |
|
1650 |
} |
1651 |
|
1652 |
function plugin_pdf_link($tab,$width,$ID,$type){ |
1653 |
|
1654 |
global $DB,$LANG; |
1655 |
|
1656 |
$start_tab = $tab["start_tab"]; |
1657 |
$pdf = $tab["pdf"]; |
1658 |
|
1659 |
$query="SELECT glpi_links.ID as ID, glpi_links.link as link, glpi_links.name as name , glpi_links.data as data from glpi_links INNER JOIN glpi_links_device ON glpi_links.ID= glpi_links_device.FK_links WHERE glpi_links_device.device_type=".$type." ORDER BY glpi_links.name"; |
1660 |
|
1661 |
$result=$DB->query($query); |
1662 |
|
1663 |
$pdf->ezSetMargins(100,0,200,0); |
1664 |
|
1665 |
$i=0; |
1666 |
|
1667 |
$ci=new CommonItem; |
1668 |
if ($DB->numrows($result)>0){ |
1669 |
|
1670 |
$pdf->saveState();
|
1671 |
$pdf->setColor(0.8,0.8,0.8); |
1672 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1673 |
$pdf->restoreState();
|
1674 |
$pdf->addText(230,$start_tab,9,'<b>'.utf8_decode($LANG["title"][33]).'</b>'); |
1675 |
|
1676 |
while ($data=$DB->fetch_assoc($result)){ |
1677 |
|
1678 |
$pdf->saveState();
|
1679 |
$pdf->setColor(0.90,0.90,0.90); |
1680 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
1681 |
$pdf->restoreState();
|
1682 |
|
1683 |
$name=$data["name"]; |
1684 |
if (empty($name)) |
1685 |
$name=$data["link"]; |
1686 |
|
1687 |
$link=$data["link"]; |
1688 |
$file=trim($data["data"]); |
1689 |
if (empty($file)){ |
1690 |
|
1691 |
$ci->getFromDB($type,$ID); |
1692 |
if (ereg("\[NAME\]",$link)){ |
1693 |
$link=ereg_replace("\[NAME\]",$ci->getName(),$link); |
1694 |
} |
1695 |
if (ereg("\[ID\]",$link)){ |
1696 |
$link=ereg_replace("\[ID\]",$ID,$link); |
1697 |
} |
1698 |
|
1699 |
if (ereg("\[SERIAL\]",$link)){ |
1700 |
if ($tmp=$ci->getField('serial')){ |
1701 |
$link=ereg_replace("\[SERIAL\]",$tmp,$link); |
1702 |
} |
1703 |
} |
1704 |
if (ereg("\[OTHERSERIAL\]",$link)){ |
1705 |
if ($tmp=$ci->getField('otherserial')){ |
1706 |
$link=ereg_replace("\[OTHERSERIAL\]",$tmp,$link); |
1707 |
} |
1708 |
} |
1709 |
|
1710 |
if (ereg("\[LOCATIONID\]",$link)){ |
1711 |
if ($tmp=$ci->getField('location')){ |
1712 |
$link=ereg_replace("\[LOCATIONID\]",$tmp,$link); |
1713 |
} |
1714 |
} |
1715 |
|
1716 |
if (ereg("\[LOCATION\]",$link)){ |
1717 |
if ($tmp=$ci->getField('location')){ |
1718 |
$link=ereg_replace("\[LOCATION\]",plugin_pdf_getDropdownName("glpi_dropdown_locations",$tmp),$link); |
1719 |
} |
1720 |
} |
1721 |
if (ereg("\[NETWORK\]",$link)){ |
1722 |
if ($tmp=$ci->getField('network')){ |
1723 |
$link=ereg_replace("\[NETWORK\]",plugin_pdf_getDropdownName("glpi_dropdown_network",$tmp),$link); |
1724 |
} |
1725 |
} |
1726 |
if (ereg("\[DOMAIN\]",$link)){ |
1727 |
if ($tmp=$ci->getField('domain')) |
1728 |
$link=ereg_replace("\[DOMAIN\]",plugin_pdf_getDropdownName("glpi_dropdown_domain",$tmp),$link); |
1729 |
} |
1730 |
$ipmac=array(); |
1731 |
$j=0; |
1732 |
if (ereg("\[IP\]",$link)||ereg("\[MAC\]",$link)){ |
1733 |
$query2 = "SELECT ifaddr,ifmac FROM glpi_networking_ports WHERE (on_device = $ID AND device_type = ".$type.") ORDER BY logical_number"; |
1734 |
$result2=$DB->query($query2); |
1735 |
if ($DB->numrows($result2)>0) |
1736 |
while ($data2=$DB->fetch_array($result2)){ |
1737 |
$ipmac[$j]['ifaddr']=$data2["ifaddr"]; |
1738 |
$ipmac[$j]['ifmac']=$data2["ifmac"]; |
1739 |
$j++;
|
1740 |
} |
1741 |
} |
1742 |
|
1743 |
if (ereg("\[IP\]",$link)||ereg("\[MAC\]",$link)){ |
1744 |
if (count($ipmac)>0){ |
1745 |
foreach ($ipmac as $key => $val){ |
1746 |
$tmplink=$link; |
1747 |
$tmplink=ereg_replace("\[IP\]",$val['ifaddr'],$tmplink); |
1748 |
$tmplink=ereg_replace("\[MAC\]",$val['ifmac'],$tmplink); |
1749 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($tmplink)); |
1750 |
} |
1751 |
} |
1752 |
} else
|
1753 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($name)); |
1754 |
} else {
|
1755 |
$link=$data['name']; |
1756 |
$ci->getFromDB($type,$ID); |
1757 |
|
1758 |
if (ereg("\[NAME\]",$link)){ |
1759 |
$link=ereg_replace("\[NAME\]",$ci->getName(),$link); |
1760 |
} |
1761 |
|
1762 |
if (ereg("\[ID\]",$link)){ |
1763 |
$link=ereg_replace("\[ID\]",$_GET["ID"],$link); |
1764 |
} |
1765 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($name)); |
1766 |
} |
1767 |
} |
1768 |
$i++;
|
1769 |
|
1770 |
if(($start_tab-20)-(20*$i)<50){ |
1771 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1772 |
$i=0; |
1773 |
$start_tab = 750; |
1774 |
} |
1775 |
} |
1776 |
else
|
1777 |
{ |
1778 |
if(($start_tab-20)-(20*$i)<50){ |
1779 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1780 |
$i=0; |
1781 |
$start_tab = 750; |
1782 |
} |
1783 |
$pdf->saveState();
|
1784 |
$pdf->setColor(0.8,0.8,0.8); |
1785 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1786 |
$pdf->restoreState();
|
1787 |
$pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["links"][7]).'</b>'); |
1788 |
} |
1789 |
|
1790 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1791 |
|
1792 |
$tab["start_tab"] = $start_tab; |
1793 |
$tab["pdf"] = $pdf; |
1794 |
|
1795 |
return $tab; |
1796 |
} |
1797 |
|
1798 |
function plugin_pdf_note($tab,$width,$ID,$type){ |
1799 |
|
1800 |
global $LANGPDF,$LANG; |
1801 |
|
1802 |
$start_tab = $tab["start_tab"]; |
1803 |
$pdf = $tab["pdf"]; |
1804 |
|
1805 |
$ci =new CommonItem; |
1806 |
$ci->getfromDB ($type,$ID); |
1807 |
|
1808 |
$length = strlen($ci->getField('notes')); |
1809 |
|
1810 |
$i=0; |
1811 |
|
1812 |
if($length>0) |
1813 |
{ |
1814 |
|
1815 |
$pdf->saveState();
|
1816 |
$pdf->setColor(0.8,0.8,0.8); |
1817 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1818 |
$pdf->restoreState();
|
1819 |
$pdf->addText(280,$start_tab,9,'<b>'.utf8_decode($LANG["title"][37]).'</b>'); |
1820 |
|
1821 |
$nbline = $length/140; |
1822 |
$temp=utf8_decode($ci->getField('notes')); |
1823 |
$i=$j=0; |
1824 |
while($j<$nbline) |
1825 |
{ |
1826 |
$pdf->saveState();
|
1827 |
$pdf->setColor(0.90,0.90,0.90); |
1828 |
if($j==0) |
1829 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
1830 |
else
|
1831 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,20); |
1832 |
$pdf->restoreState();
|
1833 |
|
1834 |
$temp = $pdf->addTextWrap(40,($start_tab-20)-(20*$i),$width-80,9,$temp); |
1835 |
$i++;
|
1836 |
$j++;
|
1837 |
|
1838 |
if(($start_tab-20)-(20*$i)<50){ |
1839 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1840 |
$i=0; |
1841 |
$start_tab = 750; |
1842 |
} |
1843 |
} |
1844 |
} |
1845 |
else
|
1846 |
{ |
1847 |
if(($start_tab-20)-(20*$i)<50){ |
1848 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1849 |
$i=0; |
1850 |
$start_tab = 750; |
1851 |
} |
1852 |
$pdf->saveState();
|
1853 |
$pdf->setColor(0.8,0.8,0.8); |
1854 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1855 |
$pdf->restoreState();
|
1856 |
$pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANGPDF["note"][1]).'</b>'); |
1857 |
} |
1858 |
|
1859 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
1860 |
|
1861 |
$tab["start_tab"] = $start_tab; |
1862 |
$tab["pdf"] = $pdf; |
1863 |
|
1864 |
return $tab; |
1865 |
} |
1866 |
|
1867 |
function plugin_pdf_reservation($tab,$width,$ID,$type){ |
1868 |
|
1869 |
global $DB,$LANG,$CFG_GLPI; |
1870 |
|
1871 |
$start_tab = $tab["start_tab"]; |
1872 |
$pdf = $tab["pdf"]; |
1873 |
|
1874 |
$resaID=0; |
1875 |
|
1876 |
$i=0; |
1877 |
|
1878 |
$pdf->ezSetMargins(200,0,200,0); |
1879 |
|
1880 |
if ($resaID=isReservable($type,$ID)) |
1881 |
{ |
1882 |
$ri=new ReservationItem; |
1883 |
$ri->getFromDB($resaID); |
1884 |
|
1885 |
$now=$_SESSION["glpi_currenttime"]; |
1886 |
$query = "SELECT * FROM glpi_reservation_resa WHERE end > '".$now."' AND id_item='$resaID' ORDER BY begin"; |
1887 |
$result=$DB->query($query); |
1888 |
|
1889 |
$pdf->saveState();
|
1890 |
$pdf->setColor(0.8,0.8,0.8); |
1891 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
1892 |
$pdf->restoreState();
|
1893 |
$pdf->addText(245,$start_tab,9,'<b>'.utf8_decode($LANG["reservation"][35]).'</b>'); |
1894 |
|
1895 |
if(($start_tab-20)-(20*$i)<50){ |
1896 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1897 |
$i=0; |
1898 |
$start_tab = 750; |
1899 |
} |
1900 |
|
1901 |
if ($DB->numrows($result)==0) |
1902 |
{ |
1903 |
$pdf->saveState();
|
1904 |
$pdf->setColor(0.90,0.90,0.90); |
1905 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
1906 |
$pdf->restoreState();
|
1907 |
$pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["reservation"][37])); |
1908 |
$i++;
|
1909 |
|
1910 |
if(($start_tab-20)-(20*$i)<50){ |
1911 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1912 |
$i=0; |
1913 |
$start_tab = 750; |
1914 |
} |
1915 |
} |
1916 |
else
|
1917 |
{ |
1918 |
$pdf->saveState();
|
1919 |
$pdf->setColor(0.8,0.8,0.8); |
1920 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15); |
1921 |
$pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15); |
1922 |
$pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15); |
1923 |
$pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15); |
1924 |
$pdf->restoreState();
|
1925 |
|
1926 |
$pdf->addText(45,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][8]).'</b>'); |
1927 |
$pdf->addText(150,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][9]).'</b>'); |
1928 |
$pdf->addText(280,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][31]).'</b>'); |
1929 |
$pdf->addText(435,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["common"][25]).'</b>'); |
1930 |
|
1931 |
$i++;
|
1932 |
|
1933 |
if(($start_tab-20)-(20*$i)<50){ |
1934 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1935 |
$i=0; |
1936 |
$start_tab = 750; |
1937 |
} |
1938 |
|
1939 |
while ($data=$DB->fetch_assoc($result)) |
1940 |
{ |
1941 |
$pdf->saveState();
|
1942 |
$pdf->setColor(0.90,0.90,0.90); |
1943 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15); |
1944 |
$pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15); |
1945 |
$pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15); |
1946 |
$pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15); |
1947 |
$pdf->restoreState();
|
1948 |
|
1949 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode(convDateTime($data["begin"]))); |
1950 |
$pdf->addText(125,($start_tab-20)-(20*$i),9,utf8_decode($data["end"])); |
1951 |
$pdf->addText(220,($start_tab-20)-(20*$i),9,utf8_decode($data["id_user"])); |
1952 |
$pdf->addText(365,($start_tab-20)-(20*$i),9,utf8_decode($data["comment"])); |
1953 |
|
1954 |
$i++;
|
1955 |
|
1956 |
if(($start_tab-20)-(20*$i)<50){ |
1957 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1958 |
$i=0; |
1959 |
$start_tab = 750; |
1960 |
} |
1961 |
} |
1962 |
} |
1963 |
|
1964 |
$i++;
|
1965 |
|
1966 |
if(($start_tab-20)-(20*$i)<50){ |
1967 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1968 |
$i=0; |
1969 |
$start_tab = 750; |
1970 |
} |
1971 |
|
1972 |
$query = "SELECT * FROM glpi_reservation_resa WHERE end <= '".$now."' AND id_item='$resaID' ORDER BY begin DESC"; |
1973 |
$result=$DB->query($query); |
1974 |
|
1975 |
$pdf->saveState();
|
1976 |
$pdf->setColor(0.8,0.8,0.8); |
1977 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
1978 |
$pdf->restoreState();
|
1979 |
$pdf->addText(260,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][36]).'</b>'); |
1980 |
|
1981 |
$i++;
|
1982 |
|
1983 |
if(($start_tab-20)-(20*$i)<50){ |
1984 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
1985 |
$i=0; |
1986 |
$start_tab = 750; |
1987 |
} |
1988 |
|
1989 |
if ($DB->numrows($result)==0) |
1990 |
{ |
1991 |
$pdf->saveState();
|
1992 |
$pdf->setColor(0.90,0.90,0.90); |
1993 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15); |
1994 |
$pdf->restoreState();
|
1995 |
$pdf->addText(265,$start_tab,9,utf8_decode($LANG["reservation"][37])); |
1996 |
} |
1997 |
else
|
1998 |
{ |
1999 |
$pdf->saveState();
|
2000 |
$pdf->setColor(0.8,0.8,0.8); |
2001 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15); |
2002 |
$pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15); |
2003 |
$pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15); |
2004 |
$pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15); |
2005 |
$pdf->restoreState();
|
2006 |
|
2007 |
$pdf->addText(45,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][8]).'</b>'); |
2008 |
$pdf->addText(150,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][9]).'</b>'); |
2009 |
$pdf->addText(280,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][31]).'</b>'); |
2010 |
$pdf->addText(435,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["common"][25]).'</b>'); |
2011 |
|
2012 |
$i++;
|
2013 |
|
2014 |
if(($start_tab-20)-(20*$i)<50){ |
2015 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
2016 |
$i=0; |
2017 |
$start_tab = 750; |
2018 |
} |
2019 |
|
2020 |
while ($data=$DB->fetch_assoc($result)) |
2021 |
{ |
2022 |
$pdf->saveState();
|
2023 |
$pdf->setColor(0.90,0.90,0.90); |
2024 |
$pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15); |
2025 |
$pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15); |
2026 |
$pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15); |
2027 |
$pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15); |
2028 |
$pdf->restoreState();
|
2029 |
|
2030 |
$pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode(convDateTime($data["begin"]))); |
2031 |
$pdf->addText(125,($start_tab-20)-(20*$i),9,utf8_decode($data["end"])); |
2032 |
$pdf->addText(220,($start_tab-20)-(20*$i),9,utf8_decode($data["id_user"])); |
2033 |
$pdf->addText(365,($start_tab-20)-(20*$i),9,utf8_decode($data["comment"])); |
2034 |
|
2035 |
$i++;
|
2036 |
|
2037 |
if(($start_tab-20)-(20*$i)<50){ |
2038 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
2039 |
$i=0; |
2040 |
$start_tab = 750; |
2041 |
} |
2042 |
} |
2043 |
} |
2044 |
|
2045 |
} |
2046 |
else
|
2047 |
{ |
2048 |
if(($start_tab-20)-(20*$i)<50){ |
2049 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
2050 |
$i=0; |
2051 |
$start_tab = 750; |
2052 |
} |
2053 |
$pdf->saveState();
|
2054 |
$pdf->setColor(0.8,0.8,0.8); |
2055 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
2056 |
$pdf->restoreState();
|
2057 |
$pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANG["reservation"][34]).'</b>'); |
2058 |
} |
2059 |
|
2060 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
2061 |
|
2062 |
$tab["start_tab"] = $start_tab; |
2063 |
$tab["pdf"] = $pdf; |
2064 |
|
2065 |
return $tab; |
2066 |
} |
2067 |
|
2068 |
function plugin_pdf_history($tab,$width,$ID,$type){ |
2069 |
|
2070 |
global $DB,$LANG; |
2071 |
|
2072 |
$start_tab = $tab["start_tab"]; |
2073 |
$pdf = $tab["pdf"]; |
2074 |
|
2075 |
$SEARCH_OPTION=getSearchOptions();
|
2076 |
|
2077 |
$query="SELECT * FROM glpi_history WHERE FK_glpi_device='".$ID."' AND device_type='".$type."' ORDER BY ID DESC;"; |
2078 |
|
2079 |
$result = $DB->query($query); |
2080 |
$number = $DB->numrows($result); |
2081 |
|
2082 |
$pdf->saveState();
|
2083 |
$pdf->setColor(0.8,0.8,0.8); |
2084 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
2085 |
$pdf->restoreState();
|
2086 |
$pdf->addText(280,$start_tab,9,'<b>'.utf8_decode($LANG["title"][38]).'</b>'); |
2087 |
|
2088 |
$i=0; |
2089 |
|
2090 |
if($number!=0){ |
2091 |
while ($data =$DB->fetch_array($result)){ |
2092 |
$field=""; |
2093 |
if($data["linked_action"]){ |
2094 |
switch ($data["linked_action"]){ |
2095 |
|
2096 |
case HISTORY_ADD_DEVICE : |
2097 |
$field = getDeviceTypeLabel($data["device_internal_type"]); |
2098 |
$change = $LANG["devices"][25]." ".$data[ "new_value"]; |
2099 |
break;
|
2100 |
|
2101 |
case HISTORY_UPDATE_DEVICE : |
2102 |
$field = getDeviceTypeLabel($data["device_internal_type"]); |
2103 |
$change = getDeviceSpecifityLabel($data["device_internal_type"]).$data[ "old_value"].$data[ "new_value"]; |
2104 |
break;
|
2105 |
|
2106 |
case HISTORY_DELETE_DEVICE : |
2107 |
$field = getDeviceTypeLabel($data["device_internal_type"]); |
2108 |
$change = $LANG["devices"][26]." ".$data["old_value"]; |
2109 |
break;
|
2110 |
case HISTORY_INSTALL_SOFTWARE : |
2111 |
$field = $LANG["help"][31]; |
2112 |
$change = $LANG["software"][44]." ".$data["new_value"]; |
2113 |
break;
|
2114 |
case HISTORY_UNINSTALL_SOFTWARE : |
2115 |
$field = $LANG["help"][31]; |
2116 |
$change = $LANG["software"][45]." ".$data["old_value"]; |
2117 |
break;
|
2118 |
case HISTORY_DISCONNECT_DEVICE: |
2119 |
$ci = new CommonItem(); |
2120 |
$ci->setType($data["device_internal_type"]); |
2121 |
$field = $ci->getType(); |
2122 |
$change = $LANG["central"][6]." ".$data["old_value"]; |
2123 |
break;
|
2124 |
case HISTORY_CONNECT_DEVICE: |
2125 |
$ci = new CommonItem(); |
2126 |
$ci->setType($data["device_internal_type"]); |
2127 |
$field = $ci->getType(); |
2128 |
$change = $LANG["log"][55]." ".$data["new_value"]; |
2129 |
break;
|
2130 |
case HISTORY_OCS_IMPORT: |
2131 |
$ci = new CommonItem(); |
2132 |
$ci->setType($data["device_internal_type"]); |
2133 |
$field = $ci->getType(); |
2134 |
$change = $LANG["ocsng"][7]." ".$LANG["ocsng"][45]." : ".$data["new_value"]; |
2135 |
break;
|
2136 |
case HISTORY_OCS_DELETE: |
2137 |
$ci = new CommonItem(); |
2138 |
$ci->setType($data["device_internal_type"]); |
2139 |
$field = $ci->getType(); |
2140 |
$change = $LANG["ocsng"][46]." ".$LANG["ocsng"][45]." : ".$data["old_value"]; |
2141 |
break;
|
2142 |
case HISTORY_OCS_LINK: |
2143 |
$ci = new CommonItem(); |
2144 |
$ci->setType($data["device_internal_type"]); |
2145 |
$field = $ci->getType(); |
2146 |
$change = $LANG["ocsng"][47]." ".$LANG["ocsng"][45]." : ".$data["new_value"]; |
2147 |
break;
|
2148 |
case HISTORY_OCS_IDCHANGED: |
2149 |
$ci = new CommonItem(); |
2150 |
$ci->setType($data["device_internal_type"]); |
2151 |
$field = $ci->getType(); |
2152 |
$change = $LANG["ocsng"][48].$data["old_value"].$data["new_value"]; |
2153 |
break;
|
2154 |
} |
2155 |
} |
2156 |
else{
|
2157 |
$fieldname=""; |
2158 |
foreach($SEARCH_OPTION[COMPUTER_TYPE] as $key2 => $val2) |
2159 |
if($key2==$data["id_search_option"]){ |
2160 |
$field = $val2["name"]; |
2161 |
$fieldname = $val2["field"]; |
2162 |
} |
2163 |
|
2164 |
if ($fieldname=="comments") |
2165 |
$change = $LANG["log"][64]; |
2166 |
else
|
2167 |
$change = $data[ "old_value"].$data[ "new_value"]; |
2168 |
} |
2169 |
|
2170 |
for($j=0,$deb=0;$j<6;$j++,$deb++){ |
2171 |
|
2172 |
if(($start_tab-20)-(20*($i+$j))<50){ |
2173 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
2174 |
$i=0; |
2175 |
$start_tab = 750; |
2176 |
$deb=0; |
2177 |
} |
2178 |
|
2179 |
$pdf->saveState();
|
2180 |
if($j<5) |
2181 |
$pdf->setColor(0.90,0.90,0.90); |
2182 |
else
|
2183 |
$pdf->setColor(0.8,0.8,0.8); |
2184 |
$pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15); |
2185 |
$pdf->restoreState();
|
2186 |
|
2187 |
switch($j){ |
2188 |
case 0: |
2189 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["common"][2].' : </i></b> '.$data["ID"])); |
2190 |
break;
|
2191 |
case 1: |
2192 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["common"][27].' : </i></b> '.convDateTime($data["date_mod"]))); |
2193 |
break;
|
2194 |
case 2: |
2195 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["common"][34].' : </i></b> '.$data["user_name"])); |
2196 |
break;
|
2197 |
case 3: |
2198 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["event"][18].' : </i></b> '.$field)); |
2199 |
break;
|
2200 |
case 4: |
2201 |
$pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["event"][19].' : </i></b> '.$change)); |
2202 |
break;
|
2203 |
case 5: |
2204 |
$i+=$deb+1; |
2205 |
break;
|
2206 |
} |
2207 |
} |
2208 |
} |
2209 |
} |
2210 |
else
|
2211 |
{ |
2212 |
if(($start_tab-20)-(20*$i)<50){ |
2213 |
$pdf = plugin_pdf_newPage($pdf,$ID,$type); |
2214 |
$i=0; |
2215 |
$start_tab = 750; |
2216 |
} |
2217 |
$pdf->saveState();
|
2218 |
$pdf->setColor(0.8,0.8,0.8); |
2219 |
$pdf->filledRectangle(25,$start_tab-5,$width-50,15); |
2220 |
$pdf->restoreState();
|
2221 |
$pdf->addText(260,$start_tab,9,"<b>".utf8_decode($LANG["event"][20])."</b>"); |
2222 |
} |
2223 |
|
2224 |
$start_tab = ($start_tab-20)-(20*$i) - 20; |
2225 |
|
2226 |
$tab["start_tab"] = $start_tab; |
2227 |
$tab["pdf"] = $pdf; |
2228 |
|
2229 |
return $tab; |
2230 |
} |
2231 |
|
2232 |
function plugin_pdf_newPage($pdf,$ID,$type){ |
2233 |
$pdf->ezText("",1000); |
2234 |
$pdf->ezText("",9); |
2235 |
if($type!=-1) |
2236 |
$pdf = plugin_pdf_add_header($pdf,$ID,$type); |
2237 |
return $pdf; |
2238 |
} |
2239 |
|
2240 |
function plugin_pdf_general($type,$tab_id,$tab){ |
2241 |
|
2242 |
$pdf= new Cezpdf('a4','portrait'); |
2243 |
$width = $pdf->ez['pageWidth']; |
2244 |
$pdf->openHere('Fit'); |
2245 |
$start_tab = 750; |
2246 |
$tab_pdf = array("pdf"=>$pdf,"start_tab"=>$start_tab); |
2247 |
|
2248 |
$nb_id = count($tab_id); |
2249 |
|
2250 |
$tab_pdf = plugin_pdf_background($tab_pdf,$width); |
2251 |
|
2252 |
foreach($tab_id as $key => $ID) |
2253 |
{ |
2254 |
switch($type){ |
2255 |
case COMPUTER_TYPE: |
2256 |
|
2257 |
$tab_pdf["pdf"] = plugin_pdf_add_header($tab_pdf["pdf"],$ID,COMPUTER_TYPE); |
2258 |
$tab_pdf = plugin_pdf_config_computer($tab_pdf,$width,$ID); |
2259 |
//erics, on ajoute systematiquement le contenu materiel ...
|
2260 |
$tab_pdf = plugin_pdf_device($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2261 |
|
2262 |
for($i=0;$i<count($tab);$i++) |
2263 |
{ |
2264 |
switch($tab[$i]){ |
2265 |
case 0: |
2266 |
$tab_pdf = plugin_pdf_financial($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2267 |
$tab_pdf = plugin_pdf_contract($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2268 |
break;
|
2269 |
case 1: |
2270 |
$tab_pdf = plugin_pdf_connection($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2271 |
$tab_pdf = plugin_pdf_port($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2272 |
break;
|
2273 |
case 2: |
2274 |
$tab_pdf = plugin_pdf_device($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2275 |
break;
|
2276 |
case 3: |
2277 |
$tab_pdf = plugin_pdf_software($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2278 |
break;
|
2279 |
case 4: |
2280 |
$tab_pdf = plugin_pdf_ticket($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2281 |
$tab_pdf = plugin_pdf_oldticket($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2282 |
break;
|
2283 |
case 5: |
2284 |
$tab_pdf = plugin_pdf_document($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2285 |
break;
|
2286 |
case 6: |
2287 |
$tab_pdf = plugin_pdf_registry($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2288 |
break;
|
2289 |
case 7: |
2290 |
$tab_pdf = plugin_pdf_link($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2291 |
break;
|
2292 |
case 8: |
2293 |
$tab_pdf = plugin_pdf_note($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2294 |
break;
|
2295 |
case 9: |
2296 |
$tab_pdf = plugin_pdf_reservation($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2297 |
break;
|
2298 |
case 10: |
2299 |
$tab_pdf = plugin_pdf_history($tab_pdf,$width,$ID,COMPUTER_TYPE); |
2300 |
break;
|
2301 |
default:
|
2302 |
break;
|
2303 |
} |
2304 |
} |
2305 |
break;
|
2306 |
|
2307 |
case SOFTWARE_TYPE: |
2308 |
|
2309 |
$tab_pdf["pdf"] = plugin_pdf_add_header($tab_pdf["pdf"],$ID,SOFTWARE_TYPE); |
2310 |
$tab_pdf = plugin_pdf_config_software($tab_pdf,$width,$ID); |
2311 |
|
2312 |
for($i=0;$i<count($tab);$i++) |
2313 |
{ |
2314 |
switch($tab[$i]){ |
2315 |
case 0: |
2316 |
$tab_pdf = plugin_pdf_licenses($tab_pdf,$width,$ID,0,SOFTWARE_TYPE); |
2317 |
break;
|
2318 |
case 1: |
2319 |
$tab_pdf = plugin_pdf_licenses($tab_pdf,$width,$ID,1,SOFTWARE_TYPE); |
2320 |
break;
|
2321 |
case 2: |
2322 |
$tab_pdf = plugin_pdf_financial($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2323 |
$tab_pdf = plugin_pdf_contract($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2324 |
break;
|
2325 |
case 3: |
2326 |
$tab_pdf = plugin_pdf_document($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2327 |
break;
|
2328 |
case 4: |
2329 |
$tab_pdf = plugin_pdf_ticket($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2330 |
$tab_pdf = plugin_pdf_oldticket($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2331 |
break;
|
2332 |
case 5: |
2333 |
$tab_pdf = plugin_pdf_link($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2334 |
break;
|
2335 |
case 6: |
2336 |
$tab_pdf = plugin_pdf_note($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2337 |
break;
|
2338 |
case 7: |
2339 |
$tab_pdf = plugin_pdf_reservation($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2340 |
break;
|
2341 |
case 8: |
2342 |
$tab_pdf = plugin_pdf_history($tab_pdf,$width,$ID,SOFTWARE_TYPE); |
2343 |
break;
|
2344 |
default:
|
2345 |
break;
|
2346 |
} |
2347 |
} |
2348 |
break;
|
2349 |
} |
2350 |
if($nb_id!=$key+1) |
2351 |
{ |
2352 |
$tab_pdf["pdf"] = plugin_pdf_newPage($tab_pdf["pdf"],$ID,-1); |
2353 |
$tab_pdf["start_tab"] = 750; |
2354 |
} |
2355 |
} |
2356 |
|
2357 |
$tab_pdf["pdf"]->ezStream(); |
2358 |
} |
2359 |
|
2360 |
/**
|
2361 |
* Print out an HTML checkbox
|
2362 |
* @param
|
2363 |
*/
|
2364 |
function checkbox($myname,$label,$value,$checked=false) |
2365 |
{ |
2366 |
echo "<td><input type='checkbox' ".($checked==true?"checked='checked'":'')." name='$myname' value='$value'>".$label."</td>"; |
2367 |
} |
2368 |
|
2369 |
?>
|