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