Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / plugins / pdf / inc / plugin_pdf.functions.php @ f45ff3b0

Historique | Voir | Annoter | Télécharger (87,2 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=="&nbsp;")
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
        $pdf->filledRectangle(25,$start_tab-5,$length_tab,15);
196
        $pdf->filledRectangle(25+$length_tab+5,$start_tab-5,$length_tab,15);
197
        $pdf->setColor(0.95,0.95,0.95);
198
        
199
        for($i=0;$i<13;$i++)
200
                {
201
                if($i<11)
202
                        {
203
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$length_tab,15);
204
                        $pdf->filledRectangle(25+$length_tab+5,($start_tab-25)-(20*$i),$length_tab,15);
205
                        }
206
                else
207
                        if($i==11)
208
                        {
209
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),2*$length_tab+5,15);        
210
                        }
211
                        else
212
                        {
213
                        $i+=2;
214
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),2*$length_tab+5,55);
215
                        }
216
                }
217
        $pdf->restoreState();
218
                
219
        //erics on simplifie pas besoin de ca
220
        //        $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>'));
221
        $pdf->addText(30,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][16].' :</i></b> '.$computer->fields['name']));
222
        $pdf->addText(30,$start_tab-40,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName('glpi_type_computers',$computer->fields['type'])));
223
        $pdf->addText(30,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][22].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_model',$computer->fields['model'])));
224
        $pdf->addText(30,$start_tab-80,9,utf8_decode('<b><i>'.$LANG["common"][5].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_manufacturer',$computer->fields['FK_glpi_enterprise'])));
225
        $pdf->addText(30,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["computers"][9].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os',$computer->fields['os'])));
226
        $pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["computers"][52].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os_version',$computer->fields['os_version'])));
227
        $pdf->addText(30,$start_tab-140,9,utf8_decode('<b><i>'.$LANG["computers"][53].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os_sp',$computer->fields['os_sp'])));
228
        $pdf->addText(30,$start_tab-160,9,utf8_decode('<b><i>'.$LANG["computers"][10].' :</i></b> '.$computer->fields['os_license_number']));
229
        $pdf->addText(30,$start_tab-180,9,utf8_decode('<b><i>'.$LANG["computers"][11].' :</i></b> '.$computer->fields['os_license_id']));
230
                        
231
        if($computer->fields['ocs_import'])
232
                $pdf->addText(30,$start_tab-200,9,utf8_decode('<b><i>'.$LANG["ocsng"][6].' '.$LANG["Menu"][33].' :</i></b> '.$LANG["choice"][1]));
233
        else
234
                $pdf->addText(30,$start_tab-200,9,utf8_decode('<b><i>'.$LANG["ocsng"][6].' '.$LANG["Menu"][33].' :</i></b> '.$LANG["choice"][0]));
235
        $pdf->addText(30,$start_tab-240,9,utf8_decode('<b><i>'.$LANG["common"][15].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_locations',$computer->fields['location'])));
236
        $pdf->addText(30,$start_tab-260,9,utf8_decode('<b><i>'.$LANG["common"][25].' :</i></b> '));
237
                        
238
        $y=$start_tab-260;
239
        $temp=utf8_decode($computer->fields['comments']);
240
        while($temp = $pdf->addTextWrap(105,$y,2*$length_tab-80,9,$temp))
241
                $y-=9;
242
                        
243
        /*
244
        if(!empty($computer->fields['tplname']))
245
                $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>'));
246
        elseif($computer->fields['ocs_import'])
247
                $pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).' ('.$LANG["ocsng"][7].')</b>'));
248
        else
249
                $pdf->addText($length_tab+80,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).'</b>'));
250
        */
251
                        
252
        $pdf->addText($length_tab+35,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][18].' :</i></b> '.$computer->fields['contact']));
253
        $pdf->addText($length_tab+35,$start_tab-40,9,utf8_decode('<b><i>'.$LANG["common"][21].' :</i></b> '.$computer->fields['contact_num']));
254
        $pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][34].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$computer->fields['FK_users'])));
255
        $pdf->addText($length_tab+35,$start_tab-80,9,utf8_decode('<b><i>'.$LANG["common"][35].' :</i></b> '.plugin_pdf_getDropdownName('glpi_groups',$computer->fields['FK_groups'])));
256
        $pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["common"][10].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$computer->fields['tech_num'])));
257
        $pdf->addText($length_tab+35,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["setup"][88].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_network',$computer->fields['network'])));
258
        $pdf->addText($length_tab+35,$start_tab-140,9,utf8_decode('<b><i>'.$LANG["setup"][89].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_domain',$computer->fields['domain'])));
259
        $pdf->addText($length_tab+35,$start_tab-160,9,utf8_decode('<b><i>'.$LANG["common"][19].' :</i></b> '.$computer->fields['serial']));
260
        $pdf->addText($length_tab+35,$start_tab-180,9,utf8_decode('<b><i>'.$LANG["common"][20].' :</i></b> '.$computer->fields['otherserial']));
261
        $pdf->addText($length_tab+35,$start_tab-200,9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_state',$computer->fields['state'])));
262
        $pdf->addText($length_tab+35,$start_tab-220,9,utf8_decode('<b><i>'.$LANG["computers"][51].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_auto_update',$computer->fields['auto_update'])));
263
        
264
        $start_tab = ($start_tab-20)-(20*$i) - 20;
265
        
266
        $tab["start_tab"] = $start_tab;
267
        $tab["pdf"] = $pdf;
268
        
269
        return $tab;
270
}
271

    
272
function plugin_pdf_config_software($tab,$width,$ID){
273
        
274
        global $LANG;
275
        
276
        $start_tab = $tab["start_tab"];
277
        $pdf = $tab["pdf"];
278
        
279
        $software=new Software();
280
        $software->getFromDB($ID);
281
        
282
        $length_tab = (($width-50)/2)-2.5;
283
        
284
        $pdf->saveState();
285
        $pdf->setColor(0.8,0.8,0.8);
286
        $pdf->filledRectangle(25,$start_tab-5,$length_tab,15);
287
        $pdf->filledRectangle(25+$length_tab+5,$start_tab-5,$length_tab,15);
288
        $pdf->setColor(0.95,0.95,0.95);
289
        
290
        for($i=0;$i<7;$i++)
291
                {
292
                if($i<5)
293
                        {
294
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$length_tab,15);
295
                        $pdf->filledRectangle(25+$length_tab+5,($start_tab-25)-(20*$i),$length_tab,15);
296
                        }
297
                else
298
                        if($i==5)
299
                        {
300
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),2*$length_tab+5,15);        
301
                        }
302
                        else
303
                        {
304
                        $i+=2;
305
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),2*$length_tab+5,55);
306
                        }
307
                }
308
        $pdf->restoreState();
309
        
310
        $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>'));
311
        $pdf->addText(30,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][16].' :</i></b> '.$software->fields['name']));
312
        $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'])));
313
        $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"])));
314
        $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"])));
315
        $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'])));
316
        
317
        if($software->fields['is_update'])
318
                $pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["software"][29].' :</i></b> '.$LANG["choice"][1]));
319
        else
320
                $pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["software"][29].' :</i></b> '.$LANG["choice"][0]));
321
        
322
        if($software->fields["update_software"]!=null)
323
                $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"])));
324
        
325
        $pdf->addText(30,$start_tab-140,9,utf8_decode('<b><i>'.$LANG["common"][25].' :</i></b> '));
326
        
327
        $y=$start_tab-140;
328
        $temp=utf8_decode($software->fields['comments']);
329
        while($temp = $pdf->addTextWrap(105,$y,2*$length_tab-80,9,$temp))
330
                $y-=9;
331
        
332
        if(!empty($software->fields['tplname']))
333
                $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>'));
334
        else
335
                $pdf->addText($length_tab+80,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($software->fields["date_mod"]).'</b>'));
336
        
337
        $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"])));
338
        $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'])));
339
        $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'])));
340
        $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"])));
341
        
342
        if($software->fields['helpdesk_visible'])
343
                $pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["software"][46].' :</i></b> '.$LANG["choice"][1]));
344
        else
345
                $pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["software"][46].' :</i></b> '.$LANG["choice"][0]));
346
        
347
        $start_tab = ($start_tab-20)-(20*$i) - 20;
348
        
349
        $tab["start_tab"] = $start_tab;
350
        $tab["pdf"] = $pdf;
351
        
352
        return $tab;
353
}
354

    
355
function plugin_pdf_device($tab,$width,$ID,$type){
356
        
357
        global $LANG;
358
        
359
        $start_tab = $tab["start_tab"];
360
        $pdf = $tab["pdf"];
361
        
362
        $computer=new Computer();
363
        $computer->getFromDBwithDevices($ID);
364
        
365
        $pdf->saveState();
366
        $pdf->setColor(0.8,0.8,0.8);
367
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
368
        $pdf->restoreState();
369
        $pdf->addText(275,$start_tab,9,'<b>'.utf8_decode($LANG["title"][30].'</b>'));
370
        
371
        $i=0;
372
        
373
        foreach($computer->devices as $key => $val) {
374
                $device = new Device($val["devType"]);
375
                $device->getFromDB($val["devID"]);
376
                
377
                $nb_x = 27        ;
378
                $device_x = 47;
379
                $design_x = 127;
380
                $other_x = 362;
381
                $spec_x = 468;
382
                
383
                $pdf->saveState();
384
                $pdf->setColor(0.95,0.95,0.95);
385
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),15,15);
386
                $pdf->filledRectangle(45,($start_tab-25)-(20*$i),75,15);
387
                $pdf->filledRectangle(125,($start_tab-25)-(20*$i),230,15);
388
                $pdf->filledRectangle(360,($start_tab-25)-(20*$i),101,15);
389
                $pdf->filledRectangle(466,($start_tab-25)-(20*$i),105,15);
390
                $pdf->restoreState();
391
                
392
                switch($device->devtype) {
393
                case HDD_DEVICE :
394
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
395
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][1]));
396
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
397
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_hdd"][4].' :</i></b> '.$val["specificity"]));
398
                        if (!empty($device->fields["rpm"]))        $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["device_hdd"][0].' :</i></b> '.$device->fields["rpm"]));
399
                        else if (!empty($device->fields["interface"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_interface",$device->fields["interface"])));
400
                        else if (!empty($device->fields["cache"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["device_hdd"][1].' :</i></b> '.$device->fields["cache"]));
401
                        break;
402
                case GFX_DEVICE :
403
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
404
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][2]));
405
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
406
                        if (!empty($device->fields["ram"])) $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_gfxcard"][0].' :</i></b> '.$device->fields["ram"]));
407
                        if (!empty($device->fields["interface"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.$device->fields["interface"]));
408
                        break;
409
                case NETWORK_DEVICE :
410
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
411
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][3]));
412
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
413
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["networking"][15].' :</i></b> '.$val["specificity"]));
414
                        if (!empty($device->fields["bandwidth"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["device_iface"][0].' :</i></b> '.$device->fields["bandwidth"]));
415
                        break;
416
                case MOBOARD_DEVICE :
417
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
418
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][5]));
419
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
420
                        if (!empty($device->fields["chipset"])) $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_moboard"][0].' :</i></b> '.$device->fields["chipset"]));
421
                        break;
422
                case PROCESSOR_DEVICE :
423
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
424
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][4]));
425
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
426
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_ram"][1].' :</i></b> '.$val["specificity"]));
427
                        break;
428
                case RAM_DEVICE :
429
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
430
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][6]));
431
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
432
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["monitors"][21].' :</i></b> '.$val["specificity"]));
433
                        if (empty($device->fields["frequence"])) {
434
                                if (!empty($device->fields["type"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_ram_type",$device->fields["type"])));
435
                        } else {
436
                                if (!empty($device->fields["type"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),73,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_ram_type",$device->fields["type"])));
437
                                $pdf->addTextWrap($other_x+75,($start_tab-20)-(20*$i),28,9,utf8_decode($device->fields["frequence"]));
438
                        }        
439
                        break;
440
                case SND_DEVICE :
441
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
442
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][7]));
443
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
444
                        if (!empty($device->fields["type"])) $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.$device->fields["type"]));
445
                        break;
446
                case DRIVE_DEVICE : 
447
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
448
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][19]));
449
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
450
                        if (!empty($device->fields["is_writer"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["profiles"][11].' :</i></b> '.getYesNo($device->fields["is_writer"])));
451
                        else if (!empty($device->fields["speed"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_drive"][1].' :</i></b> '.$device->fields["speed"]));
452
                        else if (!empty($device->fields["frequence"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_ram"][1].' :</i></b> '.$device->fields["frequence"]));
453
                        break;
454
                case CONTROL_DEVICE :;
455
                        $pdf->addTextWrap($nb_x,($start_tab-25)-(25*$i),13,9,utf8_decode($val["quantity"].'x'));
456
                        $pdf->addTextWrap($device_x,($start_tab-25)-(25*$i),73,9,utf8_decode($LANG["devices"][20]));
457
                        $pdf->addTextWrap($design_x,($start_tab-25)-(25*$i),228,9,utf8_decode($device->fields["designation"]));
458
                        if (!empty($device->fields["interface"])) $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["common"][65].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_interface",$device->fields["interface"])));
459
                        if (!empty($device->fields["raid"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["device_control"][0].' :</i></b> '.getYesNo($device->fields["raid"])));
460
                        break;
461
                case PCI_DEVICE :
462
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
463
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][21]));
464
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
465
                        break;
466
                case POWER_DEVICE :
467
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
468
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][23]));
469
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
470
                        if (!empty($device->fields["power"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["device_power"][0].' :</i></b> '.$device->fields["power"]));
471
                        else if (!empty($device->fields["atx"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["device_power"][1].' :</i></b> '.getYesNo($device->fields["atx"])));
472
                        break;
473
                case CASE_DEVICE :
474
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
475
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][22]));
476
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
477
                        if (!empty($device->fields["type"])) $pdf->addTextWrap($other_x,($start_tab-20)-(20*$i),103,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName("glpi_dropdown_case_type",$device->fields["type"])));
478
                        break;
479
                }
480
        $i++;
481
        
482
        if(($start_tab-20)-(20*$i)<50){
483
                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
484
                $i=0;
485
                $start_tab = 750;
486
                }
487
        }
488
        
489
        $start_tab = ($start_tab-20)-(20*$i) - 20;
490
        
491
        $tab["start_tab"] = $start_tab;
492
        $tab["pdf"] = $pdf;
493
        
494
        return $tab;                
495
}
496

    
497
function plugin_pdf_licenses($tab,$width,$ID,$show_computers,$type){
498
        
499
        global $DB,$LANG,$LANGPDF;
500
        
501
        $start_tab = $tab["start_tab"];
502
        $pdf = $tab["pdf"];
503
        
504
        $ci=new CommonItem();
505
        $query = "SELECT count(*) AS COUNT  FROM glpi_licenses WHERE (sID = '$ID')";
506
        $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')";
507
        
508
        $i=0;
509
        
510
        if ($result = $DB->query($query)) {
511
                if ($DB->result($result,0,0)!=0) {
512
                        $nb_licences=$DB->result($result, 0, "COUNT");
513
                        $result_update = $DB->query($query_update);
514
                        $nb_updates=$DB->result($result_update, 0, "COUNT");
515
                        $installed = getInstalledLicence($ID);
516
                        $tobuy=getLicenceToBuy($ID);
517
                        $isfreeorglobal=isFreeSoftware($ID)||isGlobalSoftware($ID);
518
                        
519
                        $pdf->saveState();
520
                        $pdf->setColor(0.8,0.8,0.8);
521
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
522
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15);
523
                        $pdf->filledRectangle(130,($start_tab-25)-(20*$i),90,15);
524
                        $pdf->filledRectangle(225,($start_tab-25)-(20*$i),30,15);
525
                        $pdf->filledRectangle(260,($start_tab-25)-(20*$i),80,15);
526
                        $pdf->filledRectangle(345,($start_tab-25)-(20*$i),30,15);
527
                        $pdf->filledRectangle(380,($start_tab-25)-(20*$i),30,15);
528
                        $pdf->filledRectangle(415,($start_tab-25)-(20*$i),155,15);
529
                        $pdf->restoreState();
530
                        $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>'));
531
                        $pdf->addText(60,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][5].'</b>'));
532
                        $pdf->addText(145,$start_tab-20,9,utf8_decode('<b>'.$LANG["common"][19].'</b>'));
533
                        $pdf->addText(230,$start_tab-20,9,utf8_decode('<b>'.$LANG["common"][33].'</b>'));
534
                        $pdf->addText(280,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][32].'</b>'));
535
                        $pdf->addText(350,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][28].'</b>'));
536
                        $pdf->addText(382,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][35].'</b>'));
537
                        $pdf->addText(470,$start_tab-20,9,utf8_decode('<b>'.$LANG["software"][19].'</b>'));
538
                        
539
                        $i++;
540
                        }
541
                else
542
                        {
543
                        $pdf->saveState();
544
                        $pdf->setColor(0.8,0.8,0.8);
545
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
546
                        $pdf->restoreState();
547
                        $pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($LANG["software"][14]).'</b>');
548
                        }
549
                }
550
                        
551
                $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";
552
                        
553
                if ($result = $DB->query($query)) {                        
554
                        while ($data=$DB->fetch_array($result)) {
555
                                $version=$data["VERSION"];
556
                                $serial=$data["SERIAL"];
557
                                $num_tot=$data["COUNT"];
558
                                $expire=$data["EXPIRE"];
559
                                $oem=$data["OEM"];
560
                                $oem_computer=$data["OEM_COMPUTER"];
561
                                $buy=$data["BUY"];
562
                                        
563
                                $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' ";
564
                                if ($expire=="")
565
                                        $SEARCH_LICENCE.=" AND glpi_licenses.expire IS NULL";
566
                                else $SEARCH_LICENCE.=" AND glpi_licenses.expire = '$expire'";
567
                
568
                                if ($version=="")
569
                                        $SEARCH_LICENCE.=" AND glpi_licenses.version='')";
570
                                else $SEARCH_LICENCE.=" AND glpi_licenses.version = '$version')";
571
                
572
                                $today=date("Y-m-d"); 
573
                                $expirer=0;
574
                                if ($expire!=NULL&&$today>$expire)
575
                                        $expirer=1;
576
                                        
577
                                $query_inst = "SELECT glpi_inst_software.ID AS ID, glpi_inst_software.license AS lID, glpi_computers.deleted as deleted, ";
578
                                $query_inst .= " glpi_infocoms.ID as infocoms, glpi_licenses.comments AS COMMENT, ";
579
                                $query_inst .= " glpi_computers.ID AS cID, glpi_computers.name AS cname FROM glpi_licenses";
580
                                $query_inst .= " INNER JOIN glpi_inst_software ";
581
                                $query_inst .= " ON ( glpi_inst_software.license = glpi_licenses.ID )";
582
                                $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) ";
583
                                $query_inst .= " LEFT JOIN glpi_infocoms ON (glpi_infocoms.device_type='".LICENSE_TYPE."' AND glpi_infocoms.FK_device=glpi_licenses.ID) ";
584
                                $query_inst .= " WHERE $SEARCH_LICENCE ORDER BY cname";
585
                                        
586
                                $result_inst = $DB->query($query_inst);
587
                                $num_inst=$DB->numrows($result_inst);
588
                                
589
                                $pdf->saveState();
590
                                $pdf->setColor(0.95,0.95,0.95);
591
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15);
592
                                $pdf->filledRectangle(130,($start_tab-25)-(20*$i),90,15);
593
                                $pdf->filledRectangle(225,($start_tab-25)-(20*$i),30,15);
594
                                $pdf->filledRectangle(260,($start_tab-25)-(20*$i),80,15);
595
                                $pdf->filledRectangle(345,($start_tab-25)-(20*$i),30,15);
596
                                $pdf->filledRectangle(380,($start_tab-25)-(20*$i),30,15);
597
                                $pdf->filledRectangle(415,($start_tab-25)-(20*$i),155,15);
598
                                $pdf->restoreState();
599
                                
600
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($version));
601
                                $pdf->addText(135,($start_tab-20)-(20*$i),9,utf8_decode($serial));
602
                                $pdf->addText(235,($start_tab-20)-(20*$i),9,utf8_decode($num_tot));
603
                                
604
                                if ($expire==NULL)
605
                                        $pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][26]));
606
                                else{
607
                                        if ($expirer) 
608
                                                $pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][27]));
609
                                        else 
610
                                                $pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][25].' '.convDate($expire)));
611
                                        }
612
                                
613
                                if($oem)
614
                                        $pdf->addText(350,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1]));
615
                                else
616
                                        $pdf->addText(350,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0]));
617
                                
618
                                if ($serial!="free"){
619
                                        if($buy)
620
                                                $pdf->addText(385,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1]));
621
                                        else
622
                                                $pdf->addText(385,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0]));
623
                                }
624
                                
625
                                if (!$show_computers)
626
                                        $pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][19].' '.$num_inst));
627
                                else
628
                                        {
629
                                        while ($data_inst=$DB->fetch_array($result_inst))
630
                                                {
631
                                
632
                                                $ci->getFromDB(COMPUTER_TYPE,$data_inst["cID"]);
633
                                                $name=$ci->getNameID();
634
                                                $computer = new Computer();
635
                                                $computer->getFromDB($data_inst["cID"]);
636
                                        
637
                                                $pdf->saveState();
638
                                                $pdf->setColor(0.95,0.95,0.95);
639
                                                $pdf->filledRectangle(415,($start_tab-25)-(20*$i),155,15);
640
                                                $pdf->restoreState();
641
                                                $pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($name.' ('.$computer->fields['serial'].')'));
642
                                                
643
                                                $i++;
644
                
645
                                                if(($start_tab-20)-(20*$i)<50){
646
                                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
647
                                                        $i=0;
648
                                                        $start_tab = 750;
649
                                                        }
650
                                                }
651
                                                $i--;
652
                                        }
653
                                $i++;
654
        
655
                                if(($start_tab-20)-(20*$i)<50){
656
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
657
                                        $i=0;
658
                                        $start_tab = 750;
659
                                        }
660
                                }
661
                        }
662
        
663
        $start_tab = ($start_tab-20)-(20*$i) - 20;
664
        
665
        $tab["start_tab"] = $start_tab;
666
        $tab["pdf"] = $pdf;
667
        
668
        return $tab;
669
}
670

    
671
function plugin_pdf_software($tab,$width,$ID,$type){
672
        
673
        global $DB,$LANG,$LANGPDF;
674
        
675
        $start_tab = $tab["start_tab"];
676
        $pdf = $tab["pdf"];
677
        
678
        $comp=new Computer();
679
        $comp->getFromDB($ID);
680
        $FK_entities=$comp->fields["FK_entities"];
681

    
682
        $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 )
683
        LEFT JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID) 
684
        LEFT JOIN glpi_dropdown_software_category ON (glpi_dropdown_software_category.ID = glpi_software.category)";
685

    
686
        $query_cat.=" WHERE glpi_inst_software.cID = '$ID' AND glpi_software.category > 0 "; 
687
    $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  
688
        FROM glpi_inst_software LEFT JOIN glpi_licenses ON ( glpi_inst_software.license = glpi_licenses.ID ) 
689
        LEFT JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID)  
690
        LEFT JOIN glpi_dropdown_software_category ON (glpi_dropdown_software_category.ID = glpi_software.category)"; 
691
    $query_nocat.= " WHERE glpi_inst_software.cID = '$ID' AND (glpi_software.category <= 0 OR glpi_software.category IS NULL ) "; 
692
    $query="( $query_cat ) UNION ($query_nocat) ORDER BY TYPE, category, softname, version";
693

    
694
        $result = $DB->query($query);
695
        $i = 0;
696
        
697
        $pdf->saveState();
698
        $pdf->setColor(0.8,0.8,0.8);
699
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
700
        $pdf->restoreState();
701
        $pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$LANG["software"][17].'</b>'));
702
        
703
        $cat=-1;
704
        
705
        if ($DB->numrows($result))
706
                while ($data=$DB->fetch_array($result)) {
707
                        
708
                        if($data["category_id"] != $cat)
709
                                {
710
                                $cat = $data["category_id"];
711
                                $catname=$data["category"];
712
                                
713
                                if (!$cat)
714
                                        $catname=$LANG["softwarecategories"][3];
715
                                
716
                                $pdf->saveState();
717
                                $pdf->setColor(0.8,0.8,0.8);
718
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
719
                                $pdf->restoreState();
720
                                $pdf->addText(240,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$catname.'</b>'));
721
                                
722
                                $i++;
723
                                
724
                                $pdf->saveState();
725
                                $pdf->setColor(0.8,0.8,0.8);
726
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),385,15);
727
                                $pdf->filledRectangle(415,($start_tab-25)-(20*$i),65,15);
728
                                $pdf->filledRectangle(485,($start_tab-25)-(20*$i),40,15);
729
                                $pdf->filledRectangle(530,($start_tab-25)-(20*$i),40,15);
730
                                $pdf->restoreState();
731
                                $pdf->addText(180,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["common"][16].'</b>'));
732
                                $pdf->addText(425,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["financial"][98].'</b>'));
733
                                $pdf->addText(493,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["software"][28].'</b>'));
734
                                $pdf->addText(536,($start_tab-20)-(20*$i),9,utf8_decode('<b>'.$LANG["software"][35].'</b>'));
735
                                
736
                                $i++;
737
                                }
738
                        
739
                        $sw = new Software();
740
                        $sw->getFromDB($data['sID']);
741
                        
742
                        $pdf->saveState();
743
                        $pdf->setColor(0.95,0.95,0.95);
744
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),385,15);
745
                        $pdf->filledRectangle(415,($start_tab-25)-(20*$i),65,15);
746
                        $pdf->filledRectangle(485,($start_tab-25)-(20*$i),40,15);
747
                        $pdf->filledRectangle(530,($start_tab-25)-(20*$i),40,15);
748
                        $pdf->restoreState();
749
                        
750
                        $pdf->addText(27,($start_tab-20)-(20*$i),8,utf8_decode($sw->fields["name"].' ( '.$data["version"].' ) - '.$data['serial']));
751
                        
752
                        if($data['expire']==null)
753
                                $pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][26]));
754
                        else{
755
                                if($data['deleted'])
756
                                        $pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($LANG["software"][27]));
757
                                else
758
                                        $pdf->addText(420,($start_tab-20)-(20*$i),9,utf8_decode($data["expire"]));
759
                        }
760
                        
761
                        if($data['serial']!="free" && $data['serial']!="global")
762
                                {
763
                                if($data["oem"])
764
                                        $pdf->addText(495,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1]));
765
                                else
766
                                        $pdf->addText(495,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0]));
767
                                
768
                                if($data["buy"])
769
                                        $pdf->addText(543,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][1]));
770
                                else
771
                                        $pdf->addText(543,($start_tab-20)-(20*$i),9,utf8_decode($LANG["choice"][0]));
772
                                }
773
                        $i++;
774
        
775
                        if(($start_tab-20)-(20*$i)<50){
776
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
777
                                $i=0;
778
                                $start_tab = 750;
779
                                }
780
                }
781
        else
782
                {
783
                if(($start_tab-20)-(20*$i)<50){
784
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
785
                                $i=0;
786
                                $start_tab = 750;
787
                                }
788
                $pdf->saveState();
789
                $pdf->setColor(0.8,0.8,0.8);
790
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
791
                $pdf->restoreState();
792
                $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANGPDF["software"][1]).'</b>');
793
                }
794
        $start_tab = ($start_tab-20)-(20*$i) - 20;
795
                
796
        $tab["start_tab"] = $start_tab;
797
        $tab["pdf"] = $pdf;
798
        
799
        return $tab;
800
}
801

    
802
function plugin_pdf_connection($tab,$width,$ID,$type){
803
        
804
        global $DB,$LANG;
805
        
806
        $start_tab = $tab["start_tab"];
807
        $pdf = $tab["pdf"];
808
        
809
        $items=array(PRINTER_TYPE=>$LANG["computers"][39],MONITOR_TYPE=>$LANG["computers"][40],PERIPHERAL_TYPE=>$LANG["computers"][46],PHONE_TYPE=>$LANG["computers"][55]);
810
        
811
        $ci=new CommonItem();
812
        $comp=new Computer();
813
        $info=new InfoCom();
814
        $comp->getFromDB($ID);
815
        
816
        $i=0;
817
        
818
        $pdf->saveState();
819
        $pdf->setColor(0.8,0.8,0.8);
820
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
821
        $pdf->restoreState();
822
        $pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$LANG["connect"][0].' :</b>'));
823
        
824
        foreach ($items as $type=>$title){
825
                $query = "SELECT * from glpi_connect_wire WHERE end2='$ID' AND type='".$type."'";
826
                
827
                if ($result=$DB->query($query)) {
828
                        $resultnum = $DB->numrows($result);
829
                        if ($resultnum>0) {
830
                                
831
                                for ($j=0; $j < $resultnum; $j++, $i++) {
832
                                        $tID = $DB->result($result, $j, "end1");
833
                                        $connID = $DB->result($result, $j, "ID");
834
                                        $ci->getFromDB($type,$tID);
835
                                        $info->getFromDBforDevice($type,$tID) || $info->getEmpty();
836

    
837
                                        $pdf->saveState();
838
                                        $pdf->setColor(0.95,0.95,0.95);
839
                                        if ($ci->getField("otherserial")!=null || $info->fields["num_immo"]) {
840
                                                $pdf->filledRectangle(25,($start_tab-45)-(20*$i),$width-50, 35);
841
                                        } else {
842
                                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50, 15);
843
                                        }
844
                                        $pdf->restoreState();
845
                                        if ($j==0) {
846
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode('<b><i>'.$ci->getType().' :</i></b>'));                                                
847
                                        }
848

    
849
                                        $tempo=$ci->getName()." - ";
850
                                        if($ci->getField("serial")!=null) {
851
                                                $tempo .=$LANG["common"][19] . " : " .$ci->getField("serial")." - ";
852
                                        }
853
                                        $pdf->addText(120,($start_tab-20)-(20*$i),9,utf8_decode($tempo . plugin_pdf_getDropdownName("glpi_dropdown_state",$ci->getField('state'))));
854

    
855
                                        $tempo="";
856
                                        if($ci->getField("otherserial")!=null) {
857
                                                $tempo .=$LANG["common"][20] . " : " . $ci->getField("otherserial");
858
                                        }
859
                                        if ($info->fields["num_immo"]) {
860
                                                if ($tempo) $tempo .= " - ";
861
                                                $tempo .=$LANG["financial"][20] . " : " . $info->fields["num_immo"];
862
                                        }
863
                                        if ($tempo) {
864
                                                $i++;
865
                                                $pdf->addText(200,($start_tab-20)-(20*$i),9,utf8_decode($tempo));
866
                                        }
867
                                }// each device        of current type
868
                                                
869
                        } else { // No row        
870
                                        
871
                                $pdf->saveState();
872
                                $pdf->setColor(0.95,0.95,0.95);
873
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
874
                                $pdf->restoreState();
875

    
876
                                switch ($type){
877
                                        case PRINTER_TYPE:
878
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][38]));
879
                                        break;
880
                                        case MONITOR_TYPE:
881
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][37]));
882
                                        break;
883
                                        case PERIPHERAL_TYPE:
884
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][47]));
885
                                        break;
886
                                        case PHONE_TYPE:
887
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][54]));
888
                                        break;
889
                                        }
890
                                $i++;
891
                        } // No row
892
                } // Result
893
                        
894
                if(($start_tab-20)-(20*$i)<50){
895
                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
896
                        $i=0;
897
                        $start_tab = 750;
898
                }
899
        } // each type
900
        
901
        $start_tab = ($start_tab-20)-(20*$i) - 20;
902
                
903
        $tab["start_tab"] = $start_tab;
904
        $tab["pdf"] = $pdf;
905
        
906
        return $tab;
907
        
908
}
909

    
910
function plugin_pdf_port($tab,$width,$ID,$type){
911
        
912
        global $DB,$LANG;
913
        
914
        $start_tab = $tab["start_tab"];
915
        $pdf = $tab["pdf"];
916
        
917
        $query = "SELECT ID FROM glpi_networking_ports WHERE (on_device = ".$ID." AND device_type = ".COMPUTER_TYPE.") ORDER BY name, logical_number";
918
        
919
        $i=0;
920
        
921
        if ($result = $DB->query($query)) 
922
                {
923
                
924
                $nb_connect = $DB->numrows($result);
925
                        
926
                if ($nb_connect!=0) 
927
                        {
928
        
929
                        $pdf->saveState();
930
                        $pdf->setColor(0.8,0.8,0.8);
931
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
932
                        $pdf->restoreState();
933
                        
934
                        $pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$nb_connect.' '.$LANG["networking"][13].' :</b>'));
935
                                
936
                        while ($devid=$DB->fetch_row($result)) 
937
                                {
938
                                
939
                                $netport = new Netport;
940
                                $netport->getfromDB(current($devid));
941
                                
942
                                for($j=0,$deb=0;$j<8;$j++,$deb++){
943
                                        
944
                                        if(($start_tab-20)-(20*($i+$j))<50){
945
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
946
                                        $i=0;
947
                                        $start_tab = 750;
948
                                        $deb=0;
949
                                        }
950
                                        
951
                                        if(!($nb_connect==1 && $j==7)){
952
                                        $pdf->saveState();
953
                                        if($j<7)
954
                                                $pdf->setColor(0.95,0.95,0.95);
955
                                        else
956
                                                $pdf->setColor(0.8,0.8,0.8);
957
                                        $pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15);
958
                                        $pdf->restoreState();
959
                                        }
960
                                        
961
                                        switch($j){
962
                                                case 0:
963
                                                $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"]));
964
                                                break;
965
                                                case 1:
966
                                                $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"])));
967
                                                break;
968
                                                case 2:
969
                                                $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"]));
970
                                                break;
971
                                                case 3:
972
                                                $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"]));
973
                                                break;
974
                                                case 4:
975
                                                $query="SELECT * from glpi_networking_vlan WHERE FK_port='$ID'";
976
                                                $result2=$DB->query($query);
977
                                                if ($DB->numrows($result2)>0)
978
                                                        while ($line=$DB->fetch_array($result2))
979
                                                                $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"])));
980
                                                else
981
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][56].' :</i></b> '));
982
                                                break;
983
                                                case 5:
984
                                                $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"])));
985
                                                break;
986
                                                case 6:
987
                                                $contact = new Netport;
988
                                                $netport2 = new Netport;
989
                                        
990
                                                if ($contact->getContact($netport->fields["ID"]))
991
                                                        {
992
                                                        $netport2->getfromDB($contact->contact_id);
993
                                                        $netport2->getDeviceData($netport2->fields["on_device"],$netport2->fields["device_type"]);
994
                                        
995
                                                        if($netport2->device_name!=null)        
996
                                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][17].' :</i></b> '.$netport2->device_name));
997
                                                        else
998
                                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][17].' :</i></b>'.$LANG["connect"][1]));
999
                                                        }
1000
                                                else
1001
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["networking"][17].' :</i></b>'.$LANG["connect"][1]));
1002
                                                break;
1003
                                                case 7:
1004
                                                        $i+=$deb+1;
1005
                                                break;
1006
                                        }
1007
                                }
1008
                                }
1009
                                if($nb_connect==1)
1010
                                        $i--;
1011
                                $start_tab = ($start_tab-20)-(20*$i) - 20;
1012
                        }
1013
                }
1014
        else
1015
                {
1016
                if(($start_tab-20)-(20*$i)<50){
1017
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1018
                                $i=0;
1019
                                $start_tab = 750;
1020
                                }
1021
                $pdf->saveState();
1022
                $pdf->setColor(0.8,0.8,0.8);
1023
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1024
                $pdf->restoreState();
1025
                $pdf->addText(250,$start_tab,9,utf8_decode('<b>0 '.$LANG["networking"][37].'</b>'));                
1026
                }
1027
        
1028
        $tab["start_tab"] = $start_tab;
1029
        $tab["pdf"] = $pdf;
1030
        
1031
        return $tab;
1032
}
1033

    
1034
function plugin_pdf_financial($tab,$width,$ID,$type){
1035
        
1036
        global $CFG_GLPI,$LANG,$LANGPDF;
1037
        
1038
        $start_tab = $tab["start_tab"];
1039
        $pdf = $tab["pdf"];
1040
        
1041
        $ic = new Infocom();
1042
        $ci=new CommonItem();
1043
        
1044
        $i=0;
1045
        
1046
        if ($ci->getFromDB($type,$ID))
1047
        if ($ic->getFromDBforDevice($type,$ID)){
1048
        
1049
        $length_tab = (($width-50)/2)-2.5;
1050
        
1051
        $pdf->saveState();
1052
        $pdf->setColor(0.8,0.8,0.8);
1053
        $pdf->filledRectangle(25,$start_tab-5,2*$length_tab+5,15);
1054
        $pdf->setColor(0.95,0.95,0.95);
1055
        
1056
        for($i=0;$i<11;$i++)
1057
                {
1058
                if($i<10)
1059
                        {
1060
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$length_tab,15);
1061
                        $pdf->filledRectangle(25+$length_tab+5,($start_tab-25)-(20*$i),$length_tab,15);
1062
                        }
1063
                else
1064
                        {
1065
                        $i+=2;
1066
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),2*$length_tab+5,55);
1067
                        }
1068
                }
1069
        $pdf->restoreState();
1070
        
1071
        $pdf->addText(250,$start_tab,9,"<b>".utf8_decode($LANG["financial"][3])."</b>");
1072
        
1073
        $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"])));
1074
        $pdf->addText(30,$start_tab-40,9,utf8_decode("<b><i>".$LANG["financial"][18]." :</i></b> ".$ic->fields["num_commande"]));
1075
        $pdf->addText(30,$start_tab-60,9,utf8_decode("<b><i>".$LANG["financial"][14]." :</i></b> ".convDate($ic->fields["buy_date"])));
1076
        $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"])));
1077
        $pdf->addText(30,$start_tab-100,9,utf8_decode("<b><i>".$LANG["financial"][78]." :</i></b> ".formatNumber($ic->fields["warranty_value"])));
1078
        $pdf->addText(30,$start_tab-120,9,utf8_decode("<b><i>".$LANG["rulesengine"][13]." :</i></b> ".formatNumber($ic->fields["value"])));
1079
        $pdf->addText(30,$start_tab-140,9,utf8_decode("<b><i>".$LANG["financial"][20]." :</i></b>         ".$ic->fields["num_immo"]));
1080
        $pdf->addText(30,$start_tab-160,9,utf8_decode("<b><i>".$LANG["financial"][23]." :</i></b> ".$ic->fields["amort_time"]." an(s)"));
1081
        $pdf->addText(30,$start_tab-180,9,utf8_decode("<b><i>".$LANG["financial"][89]." :</i></b> ".showTco($ci->getField('ticket_tco'),$ic->fields["value"])));
1082
        if($ic->fields["alert"]==0)
1083
                $pdf->addText(30,$start_tab-200,9,utf8_decode("<b><i>".$LANG["setup"][247]." :</i></b> "));
1084
        elseif($ic->fields["alert"]==4)
1085
                $pdf->addText(30,$start_tab-200,9,utf8_decode("<b><i>".$LANG["setup"][247]." :</i></b> ".$LANG["financial"][80]));
1086
        $pdf->addText(30,$start_tab-220,9,utf8_decode("<b><i>".$LANG["common"][25]." :</i></b> "));
1087
                        
1088
        $y=$start_tab-220;
1089
        $mytext=$ic->fields["comments"];
1090
        while($mytext = $pdf->addTextWrap(105,$y,2*$length_tab-80,10,utf8_decode($mytext)))
1091
                $y-=10;
1092
        
1093
        $pdf->addText($length_tab+35,$start_tab-20,9,utf8_decode("<b><i>".$LANG["financial"][82]." :</i></b> ".$ic->fields["facture"]));
1094
        $pdf->addText($length_tab+35,$start_tab-40,9,utf8_decode("<b><i>".$LANG["financial"][19]." :</i></b> ".$ic->fields["bon_livraison"]));
1095
        $pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode("<b><i>".$LANG["financial"][76]." :</i></b> ".convDate($ic->fields["use_date"])));
1096
        $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"]))); 
1097
        $pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode("<b><i>".$LANG["financial"][16]." :</i></b> ".$ic->fields["warranty_info"]));
1098
        $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")));
1099
        $pdf->addText($length_tab+35,$start_tab-140,9,utf8_decode("<b><i>".$LANG["financial"][22]." :</i></b> ".getAmortTypeName($ic->fields["amort_type"])));
1100
        $pdf->addText($length_tab+35,$start_tab-160,9,utf8_decode("<b><i>".$LANG["financial"][77]." :</i></b> ".$ic->fields["amort_coeff"]));
1101
        $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"])));
1102

    
1103
        }
1104
        else
1105
                {
1106
                if(($start_tab-20)-(20*$i)<50){
1107
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1108
                                $i=0;
1109
                                $start_tab = 750;
1110
                                }
1111
                $pdf->saveState();
1112
                $pdf->setColor(0.8,0.8,0.8);
1113
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1114
                $pdf->restoreState();
1115
                $pdf->addText(245,$start_tab,9,utf8_decode("<b>".$LANGPDF["financial"][1]."</b>"));
1116
                }
1117
        
1118

    
1119
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1120
        
1121
        $tab["start_tab"] = $start_tab;
1122
        $tab["pdf"] = $pdf;
1123
        
1124
        return $tab;
1125
}
1126

    
1127
function plugin_pdf_contract($tab,$width,$ID,$type){
1128
        
1129
        global $DB,$CFG_GLPI,$LANG,$LANGPDF;
1130
        
1131
        $start_tab = $tab["start_tab"];
1132
        $pdf = $tab["pdf"];
1133
        
1134
        $ci=new CommonItem();
1135
        $ci->getFromDB($type,$ID);
1136

    
1137
        $query = "SELECT * FROM glpi_contract_device WHERE glpi_contract_device.FK_device = ".$ID." AND glpi_contract_device.device_type = ".$type;
1138

    
1139
        $result = $DB->query($query);
1140
        $number = $DB->numrows($result);
1141
        
1142
        $i=$j=0;
1143
        
1144
        if($number>0){
1145
                
1146
        $pdf->saveState();
1147
        $pdf->setColor(0.8,0.8,0.8);
1148
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1149
        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15);
1150
        $pdf->filledRectangle(130,($start_tab-25)-(20*$i),100,15);
1151
        $pdf->filledRectangle(235,($start_tab-25)-(20*$i),100,15);
1152
        $pdf->filledRectangle(340,($start_tab-25)-(20*$i),80,15);
1153
        $pdf->filledRectangle(425,($start_tab-25)-(20*$i),60,15);
1154
        $pdf->filledRectangle(490,($start_tab-25)-(20*$i),80,15);
1155
        $pdf->restoreState();
1156
        $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["financial"][66]).' :</b>');
1157
        $pdf->addText(65,$start_tab-20,9,'<b>'.utf8_decode($LANG["common"][16]).'</b>');
1158
        $pdf->addText(138,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][4]).'</b>');
1159
        $pdf->addText(255,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][6]).'</b>');
1160
        $pdf->addText(355,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][26]).'</b>');
1161
        $pdf->addText(428,$start_tab-20,9,'<b>'.utf8_decode($LANG["search"][8]).'</b>');
1162
        $pdf->addText(515,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][8]).'</b>');
1163
        
1164
        $i++;
1165
                
1166
        while ($j < $number) {
1167
                $cID=$DB->result($result, $j, "FK_contract");
1168
                $assocID=$DB->result($result, $j, "ID");
1169
                $con=new Contract;
1170
                $con->getFromDB($cID);
1171
                
1172
                $pdf->saveState();
1173
                $pdf->setColor(0.95,0.95,0.95);
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
                
1182
                if (empty($con->fields["name"]))
1183
                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["ID"]));
1184
                else
1185
                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["name"]));
1186
                
1187
                $pdf->addText(135,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["num"]));
1188
                $pdf->addText(240,($start_tab-20)-(20*$i),9,utf8_decode(plugin_pdf_getDropdownName("glpi_dropdown_contract_type",$con->fields["contract_type"])));
1189
                
1190
                $temp = str_replace("<br>", "", getContractEnterprises($cID));
1191
                
1192
                if(strlen($temp)<14)
1193
                        $pdf->addText(345,($start_tab-20)-(20*$i),9,utf8_decode($temp));
1194
                else
1195
                {
1196
                        $temp=$pdf->addTextWrap(345,($start_tab-20)-(20*$i)+4,70,8,utf8_decode($temp));
1197
                        $pdf->addTextWrap(345,($start_tab-20)-(20*$i)-4,70,8,utf8_decode($temp));
1198
                }
1199
                
1200
                $pdf->addText(430,($start_tab-20)-(20*$i),9,utf8_decode(convDate($con->fields["begin_date"])));
1201
                
1202
                if ($con->fields["begin_date"]!='' && $con->fields["begin_date"]!="0000-00-00")
1203
                        {
1204
                        $pdf->addText(515,($start_tab-20)-(20*$i)+4,7,utf8_decode($con->fields["duration"]." ".$LANG["financial"][57])); 
1205
                        $pdf->addText(505,($start_tab-20)-(20*$i)-4,7,"-> ".utf8_decode(getWarrantyExpir($con->fields["begin_date"],$con->fields["duration"]))); 
1206
                        }
1207
                else
1208
                        $pdf->addText(510,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["duration"]." ".$LANG["financial"][57])); 
1209
                
1210
                $i++;
1211
                $j++;
1212
                
1213
                if(($start_tab-20)-(20*$i)<50){
1214
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1215
                                $i=0;
1216
                                $start_tab = 750;
1217
                                }
1218
                }
1219
        }
1220
        else
1221
                {
1222
                if(($start_tab-20)-(20*$i)<50){
1223
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1224
                                $i=0;
1225
                                $start_tab = 750;
1226
                                }
1227
                $pdf->saveState();
1228
                $pdf->setColor(0.8,0.8,0.8);
1229
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1230
                $pdf->restoreState();
1231
                $pdf->addText(260,$start_tab,9,utf8_decode('<b>'.$LANGPDF["financial"][2].'</b>'));
1232
                }
1233
        
1234
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1235
                
1236
        $tab["start_tab"] = $start_tab;
1237
        $tab["pdf"] = $pdf;
1238
        
1239
        return $tab;
1240
}
1241

    
1242
function plugin_pdf_document($tab,$width,$ID,$type){
1243
        
1244
        global $DB,$LANG,$LANGPDF;
1245
        
1246
        $start_tab = $tab["start_tab"];
1247
        $pdf = $tab["pdf"];
1248
        
1249
        $query = "SELECT glpi_doc_device.ID as assocID, glpi_docs.* FROM glpi_doc_device "; 
1250
        $query .= "LEFT JOIN glpi_docs ON (glpi_doc_device.FK_doc=glpi_docs.ID)"; 
1251
        $query .= "WHERE glpi_doc_device.FK_device = ".$ID." AND glpi_doc_device.device_type = ".$type;
1252
        
1253
        $result = $DB->query($query);
1254
        $number = $DB->numrows($result);
1255
        
1256
        $i=0;
1257
        
1258
        if($number>0){
1259
        
1260
        $pdf->saveState();
1261
        $pdf->setColor(0.8,0.8,0.8);
1262
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1263
        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),125,15);
1264
        $pdf->filledRectangle(155,($start_tab-25)-(20*$i),120,15);
1265
        $pdf->filledRectangle(280,($start_tab-25)-(20*$i),110,15);
1266
        $pdf->filledRectangle(395,($start_tab-25)-(20*$i),100,15);
1267
        $pdf->filledRectangle(500,($start_tab-25)-(20*$i),70,15);
1268
        $pdf->restoreState();
1269
        $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANG["document"][21]).' :</b>');
1270
        $pdf->addText(80,$start_tab-20,9,'<b>'.utf8_decode($LANG["common"][16]).'</b>');
1271
        $pdf->addText(195,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][2]).'</b>');
1272
        $pdf->addText(315,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][33]).'</b>');
1273
        $pdf->addText(425,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][3]).'</b>');
1274
        $pdf->addText(510,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][4]).'</b>');
1275
        
1276
        $i++;
1277
                
1278
        while ($data=$DB->fetch_assoc($result)) {
1279
                
1280
                $pdf->saveState();
1281
                $pdf->setColor(0.95,0.95,0.95);
1282
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),125,15);
1283
                $pdf->filledRectangle(155,($start_tab-25)-(20*$i),120,15);
1284
                $pdf->filledRectangle(280,($start_tab-25)-(20*$i),110,15);
1285
                $pdf->filledRectangle(395,($start_tab-25)-(20*$i),100,15);
1286
                $pdf->filledRectangle(500,($start_tab-25)-(20*$i),70,15);
1287
                $pdf->restoreState();
1288
                
1289
                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($data["name"]));
1290
                $pdf->addText(160,($start_tab-20)-(20*$i),9,utf8_decode($data["filename"]));
1291
                $pdf->addText(285,($start_tab-20)-(20*$i),9,utf8_decode($data["link"]));
1292
                $pdf->addText(400,($start_tab-20)-(20*$i),9,utf8_decode(plugin_pdf_getDropdownName("glpi_dropdown_rubdocs",$data["rubrique"])));
1293
                $pdf->addText(505,($start_tab-20)-(20*$i),9,utf8_decode($data["mime"]));
1294
                
1295
                $i++;
1296
                
1297
                if(($start_tab-20)-(20*$i)<50){
1298
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1299
                                $i=0;
1300
                                $start_tab = 750;
1301
                                }
1302
        }
1303
        }
1304
        else
1305
                {
1306
                if(($start_tab-20)-(20*$i)<50){
1307
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1308
                                $i=0;
1309
                                $start_tab = 750;
1310
                                }
1311
                $pdf->saveState();
1312
                $pdf->setColor(0.8,0.8,0.8);
1313
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1314
                $pdf->restoreState();
1315
                $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANGPDF["document"][1]).'</b>');
1316
                }
1317
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1318
        
1319
        $tab["start_tab"] = $start_tab;
1320
        $tab["pdf"] = $pdf;
1321
        
1322
        return $tab;
1323
}
1324

    
1325
function plugin_pdf_registry($tab,$width,$ID,$type){
1326
        
1327
        global $DB,$LANG;
1328
        
1329
        $start_tab = $tab["start_tab"];
1330
        $pdf = $tab["pdf"];
1331
        
1332
        $REGISTRY_HIVE=array("HKEY_CLASSES_ROOT",
1333
        "HKEY_CURRENT_USER",
1334
        "HKEY_LOCAL_MACHINE",
1335
        "HKEY_USERS",
1336
        "HKEY_CURRENT_CONFIG",
1337
        "HKEY_DYN_DATA");
1338
        
1339
        $query = "SELECT ID FROM glpi_registry WHERE computer_id='".$ID."'";
1340
        
1341
        $i=0;
1342
        
1343
        if ($result = $DB->query($query)) {
1344
                if ($DB->numrows($result)!=0) {
1345
                        
1346
                        $pdf->saveState();
1347
                        $pdf->setColor(0.8,0.8,0.8);
1348
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1349
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),130,15);
1350
                        $pdf->filledRectangle(160,($start_tab-25)-(20*$i),130,15);
1351
                        $pdf->filledRectangle(295,($start_tab-25)-(20*$i),140,15);
1352
                        $pdf->filledRectangle(440,($start_tab-25)-(20*$i),130,15);
1353
                        $pdf->restoreState();
1354
                        $pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($DB->numrows($result)." ".$LANG["registry"][4]).' :</b>');
1355
                        $pdf->addText(65,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][6]).'</b>');
1356
                        $pdf->addText(215,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][1]).'</b>');
1357
                        $pdf->addText(345,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][2]).'</b>');
1358
                        $pdf->addText(490,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][3]).'</b>');
1359
                        
1360
                        $i++;
1361
                        
1362
                        while ($regid=$DB->fetch_row($result)) {
1363
                                $reg = new Registry;
1364
                                $reg->getfromDB(current($regid));
1365
                                
1366
                                $pdf->saveState();
1367
                                $pdf->setColor(0.95,0.95,0.95);
1368
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),130,15);
1369
                                $pdf->filledRectangle(160,($start_tab-25)-(20*$i),130,15);
1370
                                $pdf->filledRectangle(295,($start_tab-25)-(20*$i),140,15);
1371
                                $pdf->filledRectangle(440,($start_tab-25)-(20*$i),130,15);
1372
                                $pdf->restoreState();
1373
                                                                                                        
1374
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_ocs_name"]));
1375
                                $pdf->addText(165,($start_tab-20)-(20*$i),9,utf8_decode($REGISTRY_HIVE[$reg->fields["registry_hive"]]));
1376
                                $pdf->addText(300,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_path"]));
1377
                                $pdf->addText(445,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_value"]));
1378
                                
1379
                                $i++;
1380
                
1381
                                if(($start_tab-20)-(20*$i)<50){
1382
                                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1383
                                                $i=0;
1384
                                                $start_tab = 750;
1385
                                                }
1386
                        }
1387
                }
1388
                else
1389
                        {
1390
                        if(($start_tab-20)-(20*$i)<50){
1391
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1392
                                $i=0;
1393
                                $start_tab = 750;
1394
                                }
1395
                        $pdf->saveState();
1396
                        $pdf->setColor(0.8,0.8,0.8);
1397
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1398
                        $pdf->restoreState();
1399
                        $pdf->addText(230,$start_tab,9,'<b>'.utf8_decode($LANG["registry"][5]).'</b>');
1400
                        }
1401
        }
1402
        
1403
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1404
        
1405
        $tab["start_tab"] = $start_tab;
1406
        $tab["pdf"] = $pdf;
1407
        
1408
        return $tab;
1409
}
1410

    
1411
function plugin_pdf_ticket($tab,$width,$ID,$type){
1412
        
1413
        global $DB,$CFG_GLPI, $LANG;
1414
        
1415
        $start_tab = $tab["start_tab"];
1416
        $pdf = $tab["pdf"];
1417
        
1418
        $sort="glpi_tracking.date";
1419
        $order=getTrackingOrderPrefs($_SESSION["glpiID"]);
1420

    
1421
        $where = "(status = 'new' OR status= 'assign' OR status='plan' OR status='waiting')";        
1422

    
1423
        $query = "SELECT ".getCommonSelectForTrackingSearch()." FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch()." WHERE $where and (computer = '$ID' and device_type= ".$type.") ORDER BY $sort $order";
1424

    
1425
        $result = $DB->query($query);
1426

    
1427
        $i = 0;
1428
        
1429
        $number = $DB->numrows($result);
1430

    
1431
        if ($number > 0)
1432
        {
1433
                $pdf->saveState();
1434
                $pdf->setColor(0.8,0.8,0.8);
1435
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1436
                $pdf->restoreState();
1437
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($number.' '.$LANG["job"][17].' '.$LANG["job"][16]).' :</b>');
1438

    
1439
                while ($data=$DB->fetch_assoc($result))
1440
                {
1441
                        for($j=0,$deb=0;$j<9;$j++,$deb++){
1442
                                        
1443
                                        if(($start_tab-20)-(20*($i+$j))<50){
1444
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1445
                                        $i=0;
1446
                                        $start_tab = 750;
1447
                                        $deb=0;
1448
                                        }
1449
                                        
1450
                                        if(!($number==1 && $j==8)){
1451
                                        $pdf->saveState();
1452
                                        if($j<8)
1453
                                                $pdf->setColor(0.95,0.95,0.95);
1454
                                        else
1455
                                                $pdf->setColor(0.8,0.8,0.8);
1456
                                        $pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15);
1457
                                        $pdf->restoreState();
1458
                                        }
1459
                        
1460
                        switch($j){
1461
                                                case 0:
1462
                                                        $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"])));
1463
                                                break;
1464
                                                case 1:
1465
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][27].' :</i></b>       '.$LANG["joblist"][11].' : '.$data["date"]));
1466
                                                break;
1467
                                                case 2:
1468
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["joblist"][2].' :</i></b> '.getPriorityName($data["priority"])));
1469
                                                break;
1470
                                                case 3:
1471
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][4].' :</i></b> '.getUserName($data["author"])));
1472
                                                break;
1473
                                                case 4:
1474
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][5].' :</i></b> '.getUserName($data["assign"])));
1475
                                                break;
1476
                                                case 5:
1477
                                                        $ci=new CommonItem();
1478
                                                        $ci->getFromDB($data["device_type"],$data["computer"]);
1479
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][1].' :</i></b> '.$ci->getType()));
1480
                                                break;
1481
                                                case 6:
1482
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][36].' :</i></b> '.$data["catname"]));
1483
                                                break;
1484
                                                case 7:
1485
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][57].' :</i></b> '.$data["name"]));
1486
                                                break;
1487
                                                case 8:
1488
                                                        $i+=$deb+1;
1489
                                                break;
1490
                                        }
1491
                                }
1492
                                if($number==1)
1493
                                        $i--;
1494
                }
1495
        } 
1496
        else
1497
                {
1498
                if(($start_tab-20)-(20*$i)<50){
1499
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1500
                                $i=0;
1501
                                $start_tab = 750;
1502
                                }
1503
                $pdf->saveState();
1504
                $pdf->setColor(0.8,0.8,0.8);
1505
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1506
                $pdf->restoreState();
1507
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["joblist"][8]).'</b>');
1508
                }
1509
        
1510
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1511
        
1512
        $tab["start_tab"] = $start_tab;
1513
        $tab["pdf"] = $pdf;
1514
        
1515
        return $tab;
1516
        
1517
}
1518

    
1519
function plugin_pdf_oldticket($tab,$width,$ID,$type){
1520
        
1521
        global $DB,$CFG_GLPI, $LANG;
1522
        
1523
        $start_tab = $tab["start_tab"];
1524
        $pdf = $tab["pdf"];
1525
        
1526
        $sort="glpi_tracking.date";
1527
        $order=getTrackingOrderPrefs($_SESSION["glpiID"]);
1528

    
1529
        $where = "(status = 'old_done' OR status = 'old_notdone')";        
1530
        $query = "SELECT ".getCommonSelectForTrackingSearch()." FROM glpi_tracking ".getCommonLeftJoinForTrackingSearch()." WHERE $where and (device_type = ".$type." and computer = '$ID') ORDER BY $sort $order";
1531

    
1532
        $result = $DB->query($query);
1533

    
1534
        $i = 0;
1535
        
1536
        $number = $DB->numrows($result);
1537

    
1538
        if ($number > 0)
1539
        {
1540
                $pdf->saveState();
1541
                $pdf->setColor(0.8,0.8,0.8);
1542
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1543
                $pdf->restoreState();
1544
                $pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($number.' '.$LANG["job"][18].' '.$LANG["job"][17].' '.$LANG["job"][16]).' :</b>');
1545

    
1546
                while ($data=$DB->fetch_assoc($result))
1547
                {
1548
                        for($j=0,$deb=0;$j<9;$j++,$deb++){
1549
                                        
1550
                                        if(($start_tab-20)-(20*($i+$j))<50 && !($number==1 && $j==8)){
1551
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1552
                                        $i=0;
1553
                                        $start_tab = 750;
1554
                                        $deb=0;
1555
                                        }
1556
                                        
1557
                                        if(!($number==1 && $j==8)){
1558
                                        $pdf->saveState();
1559
                                        if($j<8)
1560
                                                $pdf->setColor(0.95,0.95,0.95);
1561
                                        else
1562
                                                $pdf->setColor(0.8,0.8,0.8);
1563
                                        $pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15);
1564
                                        $pdf->restoreState();
1565
                                        }
1566
                        
1567
                        switch($j){
1568
                                                case 0:
1569
                                                        $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"])));
1570
                                                break;
1571
                                                case 1:
1572
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][27].' :</i></b>       '.$LANG["joblist"][11].' : '.$data["date"]));
1573
                                                break;
1574
                                                case 2:
1575
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["joblist"][2].' :</i></b> '.getPriorityName($data["priority"])));
1576
                                                break;
1577
                                                case 3:
1578
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][4].' :</i></b> '.getUserName($data["author"])));
1579
                                                break;
1580
                                                case 4:
1581
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["job"][5].' :</i></b> '.getUserName($data["assign"])));
1582
                                                break;
1583
                                                case 5:
1584
                                                        $ci=new CommonItem();
1585
                                                        $ci->getFromDB($data["device_type"],$data["computer"]);
1586
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][1].' :</i></b> '.$ci->getType()));
1587
                                                break;
1588
                                                case 6:
1589
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][36].' :</i></b> '.$data["catname"]));
1590
                                                break;
1591
                                                case 7:
1592
                                                        $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,utf8_decode('<b><i>'.$LANG["common"][57].' :</i></b> '.$data["name"]));
1593
                                                break;
1594
                                                case 8:
1595
                                                        $i+=$deb+1;
1596
                                                break;
1597
                                        }
1598
                                }
1599
                                if($number==1)
1600
                                        $i--;
1601
                }
1602
        } 
1603
        else
1604
                {
1605
                if(($start_tab-20)-(20*$i)<50){
1606
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1607
                                $i=0;
1608
                                $start_tab = 750;
1609
                                }
1610
                $pdf->saveState();
1611
                $pdf->setColor(0.8,0.8,0.8);
1612
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1613
                $pdf->restoreState();
1614
                $pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($LANG["joblist"][22]).'</b>');
1615
                }
1616
        
1617
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1618
        
1619
        $tab["start_tab"] = $start_tab;
1620
        $tab["pdf"] = $pdf;
1621
        
1622
        return $tab;
1623
        
1624
}
1625

    
1626
function plugin_pdf_link($tab,$width,$ID,$type){
1627
        
1628
        global $DB,$LANG;
1629
        
1630
        $start_tab = $tab["start_tab"];
1631
        $pdf = $tab["pdf"];
1632
        
1633
        $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";
1634

    
1635
        $result=$DB->query($query);
1636
        
1637
        $pdf->ezSetMargins(100,0,200,0);
1638
        
1639
        $i=0;
1640
        
1641
        $ci=new CommonItem;
1642
        if ($DB->numrows($result)>0){
1643
                
1644
                $pdf->saveState();
1645
                $pdf->setColor(0.8,0.8,0.8);
1646
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1647
                $pdf->restoreState();
1648
                $pdf->addText(230,$start_tab,9,'<b>'.utf8_decode($LANG["title"][33]).'</b>');                
1649
                
1650
                while ($data=$DB->fetch_assoc($result)){
1651

    
1652
                        $pdf->saveState();
1653
                        $pdf->setColor(0.95,0.95,0.95);
1654
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1655
                        $pdf->restoreState();
1656
                        
1657
                        $name=$data["name"];
1658
                        if (empty($name))
1659
                                $name=$data["link"];
1660

    
1661
                        $link=$data["link"];
1662
                        $file=trim($data["data"]);
1663
                        if (empty($file)){
1664

    
1665
                                $ci->getFromDB($type,$ID);
1666
                                if (ereg("\[NAME\]",$link)){
1667
                                        $link=ereg_replace("\[NAME\]",$ci->getName(),$link);
1668
                                }
1669
                                if (ereg("\[ID\]",$link)){
1670
                                        $link=ereg_replace("\[ID\]",$ID,$link);
1671
                                }
1672

    
1673
                                if (ereg("\[SERIAL\]",$link)){
1674
                                        if ($tmp=$ci->getField('serial')){
1675
                                                $link=ereg_replace("\[SERIAL\]",$tmp,$link);
1676
                                        }
1677
                                }
1678
                                if (ereg("\[OTHERSERIAL\]",$link)){
1679
                                        if ($tmp=$ci->getField('otherserial')){
1680
                                                $link=ereg_replace("\[OTHERSERIAL\]",$tmp,$link);
1681
                                        }
1682
                                }
1683

    
1684
                                if (ereg("\[LOCATIONID\]",$link)){
1685
                                        if ($tmp=$ci->getField('location')){
1686
                                                $link=ereg_replace("\[LOCATIONID\]",$tmp,$link);
1687
                                        }
1688
                                }
1689

    
1690
                                if (ereg("\[LOCATION\]",$link)){
1691
                                        if ($tmp=$ci->getField('location')){
1692
                                                $link=ereg_replace("\[LOCATION\]",plugin_pdf_getDropdownName("glpi_dropdown_locations",$tmp),$link);
1693
                                        }
1694
                                }
1695
                                if (ereg("\[NETWORK\]",$link)){
1696
                                        if ($tmp=$ci->getField('network')){
1697
                                                $link=ereg_replace("\[NETWORK\]",plugin_pdf_getDropdownName("glpi_dropdown_network",$tmp),$link);
1698
                                        }
1699
                                }
1700
                                if (ereg("\[DOMAIN\]",$link)){
1701
                                        if ($tmp=$ci->getField('domain'))
1702
                                                $link=ereg_replace("\[DOMAIN\]",plugin_pdf_getDropdownName("glpi_dropdown_domain",$tmp),$link);
1703
                                }
1704
                                $ipmac=array();
1705
                                $j=0;
1706
                                if (ereg("\[IP\]",$link)||ereg("\[MAC\]",$link)){
1707
                                        $query2 = "SELECT ifaddr,ifmac FROM glpi_networking_ports WHERE (on_device = $ID AND device_type = ".$type.") ORDER BY logical_number";
1708
                                        $result2=$DB->query($query2);
1709
                                        if ($DB->numrows($result2)>0)
1710
                                                while ($data2=$DB->fetch_array($result2)){
1711
                                                        $ipmac[$j]['ifaddr']=$data2["ifaddr"];
1712
                                                        $ipmac[$j]['ifmac']=$data2["ifmac"];
1713
                                                        $j++;
1714
                                                }
1715
                                }
1716

    
1717
                                if (ereg("\[IP\]",$link)||ereg("\[MAC\]",$link)){
1718
                                        if (count($ipmac)>0){
1719
                                                foreach ($ipmac as $key => $val){
1720
                                                        $tmplink=$link;
1721
                                                        $tmplink=ereg_replace("\[IP\]",$val['ifaddr'],$tmplink);
1722
                                                        $tmplink=ereg_replace("\[MAC\]",$val['ifmac'],$tmplink);
1723
                                                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($tmplink));
1724
                                                }
1725
                                        }
1726
                                } else 
1727
                                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($name));
1728
                        } else {
1729
                                $link=$data['name'];                
1730
                                $ci->getFromDB($type,$ID);
1731

    
1732
                                if (ereg("\[NAME\]",$link)){
1733
                                        $link=ereg_replace("\[NAME\]",$ci->getName(),$link);
1734
                                }
1735

    
1736
                                if (ereg("\[ID\]",$link)){
1737
                                        $link=ereg_replace("\[ID\]",$_GET["ID"],$link);
1738
                                }
1739
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($name));
1740
                        }
1741
                }
1742
                $i++;
1743
                        
1744
                if(($start_tab-20)-(20*$i)<50){
1745
                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1746
                        $i=0;
1747
                        $start_tab = 750;
1748
                        }
1749
        }
1750
        else
1751
                {
1752
                if(($start_tab-20)-(20*$i)<50){
1753
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1754
                                $i=0;
1755
                                $start_tab = 750;
1756
                                }
1757
                $pdf->saveState();
1758
                $pdf->setColor(0.8,0.8,0.8);
1759
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1760
                $pdf->restoreState();
1761
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["links"][7]).'</b>');
1762
                }
1763
        
1764
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1765
                
1766
        $tab["start_tab"] = $start_tab;
1767
        $tab["pdf"] = $pdf;
1768
        
1769
        return $tab;
1770
}
1771

    
1772
function plugin_pdf_note($tab,$width,$ID,$type){
1773
        
1774
        global $LANGPDF,$LANG;
1775
        
1776
        $start_tab = $tab["start_tab"];
1777
        $pdf = $tab["pdf"];
1778
        
1779
        $ci =new CommonItem;
1780
        $ci->getfromDB ($type,$ID);
1781
        
1782
        $length = strlen($ci->getField('notes'));
1783
        
1784
        $i=0;
1785
        
1786
        if($length>0)
1787
                {
1788
                        
1789
                $pdf->saveState();
1790
                $pdf->setColor(0.8,0.8,0.8);
1791
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1792
                $pdf->restoreState();
1793
                $pdf->addText(280,$start_tab,9,'<b>'.utf8_decode($LANG["title"][37]).'</b>');
1794
                        
1795
                $nbline = $length/140;
1796
                $temp=utf8_decode($ci->getField('notes'));
1797
                $i=$j=0;
1798
                while($j<$nbline)
1799
                        {
1800
                        $pdf->saveState();
1801
                        $pdf->setColor(0.95,0.95,0.95);
1802
                        if($j==0)
1803
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1804
                        else
1805
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,20);
1806
                        $pdf->restoreState();        
1807
                        
1808
                        $temp = $pdf->addTextWrap(40,($start_tab-20)-(20*$i),$width-80,9,$temp);
1809
                        $i++;
1810
                        $j++;
1811
                        
1812
                        if(($start_tab-20)-(20*$i)<50){
1813
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1814
                                $i=0;
1815
                                $start_tab = 750;
1816
                                }
1817
                        }
1818
                }
1819
        else
1820
                {
1821
                if(($start_tab-20)-(20*$i)<50){
1822
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1823
                                $i=0;
1824
                                $start_tab = 750;
1825
                                }
1826
                $pdf->saveState();
1827
                $pdf->setColor(0.8,0.8,0.8);
1828
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1829
                $pdf->restoreState();
1830
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANGPDF["note"][1]).'</b>');
1831
                }
1832
        
1833
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1834
                
1835
        $tab["start_tab"] = $start_tab;
1836
        $tab["pdf"] = $pdf;
1837
        
1838
        return $tab;
1839
}
1840

    
1841
function plugin_pdf_reservation($tab,$width,$ID,$type){
1842
        
1843
        global $DB,$LANG,$CFG_GLPI;
1844
        
1845
        $start_tab = $tab["start_tab"];
1846
        $pdf = $tab["pdf"];
1847
        
1848
        $resaID=0;
1849
        
1850
        $i=0;
1851
        
1852
        $pdf->ezSetMargins(200,0,200,0);
1853

    
1854
        if ($resaID=isReservable($type,$ID))
1855
                {
1856
                $ri=new ReservationItem;
1857
                $ri->getFromDB($resaID);
1858

    
1859
                $now=$_SESSION["glpi_currenttime"];
1860
                $query = "SELECT * FROM glpi_reservation_resa WHERE end > '".$now."' AND id_item='$resaID' ORDER BY begin";
1861
                $result=$DB->query($query);
1862
                
1863
                $pdf->saveState();
1864
                $pdf->setColor(0.8,0.8,0.8);
1865
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1866
                $pdf->restoreState();
1867
                $pdf->addText(245,$start_tab,9,'<b>'.utf8_decode($LANG["reservation"][35]).'</b>');
1868
                
1869
                if(($start_tab-20)-(20*$i)<50){
1870
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1871
                                        $i=0;
1872
                                        $start_tab = 750;
1873
                                        }
1874
                
1875
                if ($DB->numrows($result)==0)
1876
                        {        
1877
                        $pdf->saveState();
1878
                        $pdf->setColor(0.95,0.95,0.95);
1879
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1880
                        $pdf->restoreState();
1881
                        $pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["reservation"][37]));
1882
                        $i++;
1883
                        
1884
                        if(($start_tab-20)-(20*$i)<50){
1885
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1886
                                        $i=0;
1887
                                        $start_tab = 750;
1888
                                        }
1889
                        } 
1890
                else 
1891
                        {
1892
                        $pdf->saveState();
1893
                        $pdf->setColor(0.8,0.8,0.8);
1894
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1895
                        $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
1896
                        $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
1897
                        $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
1898
                        $pdf->restoreState();
1899

    
1900
                        $pdf->addText(45,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][8]).'</b>');
1901
                        $pdf->addText(150,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][9]).'</b>');
1902
                        $pdf->addText(280,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][31]).'</b>');
1903
                        $pdf->addText(435,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["common"][25]).'</b>');
1904
                        
1905
                        $i++;
1906
                        
1907
                        if(($start_tab-20)-(20*$i)<50){
1908
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1909
                                        $i=0;
1910
                                        $start_tab = 750;
1911
                                        }
1912
                        
1913
                        while ($data=$DB->fetch_assoc($result))
1914
                                {
1915
                                $pdf->saveState();
1916
                                $pdf->setColor(0.95,0.95,0.95);
1917
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1918
                                $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
1919
                                $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
1920
                                $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
1921
                                $pdf->restoreState();        
1922
                                
1923
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode(convDateTime($data["begin"])));
1924
                                $pdf->addText(125,($start_tab-20)-(20*$i),9,utf8_decode($data["end"]));
1925
                                $pdf->addText(220,($start_tab-20)-(20*$i),9,utf8_decode($data["id_user"]));
1926
                                $pdf->addText(365,($start_tab-20)-(20*$i),9,utf8_decode($data["comment"]));
1927
                                
1928
                                $i++;
1929
                                
1930
                                if(($start_tab-20)-(20*$i)<50){
1931
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1932
                                        $i=0;
1933
                                        $start_tab = 750;
1934
                                        }
1935
                                }
1936
                        }
1937
                
1938
                $i++;
1939
                
1940
                if(($start_tab-20)-(20*$i)<50){
1941
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1942
                                        $i=0;
1943
                                        $start_tab = 750;
1944
                }
1945
                
1946
                $query = "SELECT * FROM glpi_reservation_resa WHERE end <= '".$now."' AND id_item='$resaID' ORDER BY begin DESC";
1947
                $result=$DB->query($query);
1948

    
1949
                $pdf->saveState();
1950
                $pdf->setColor(0.8,0.8,0.8);
1951
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1952
                $pdf->restoreState();
1953
                $pdf->addText(260,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][36]).'</b>');
1954

    
1955
                $i++;
1956
                
1957
                if(($start_tab-20)-(20*$i)<50){
1958
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1959
                                        $i=0;
1960
                                        $start_tab = 750;
1961
                                        }
1962

    
1963
                if ($DB->numrows($result)==0)
1964
                        {        
1965
                        $pdf->saveState();
1966
                        $pdf->setColor(0.95,0.95,0.95);
1967
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1968
                        $pdf->restoreState();
1969
                        $pdf->addText(265,$start_tab,9,utf8_decode($LANG["reservation"][37]));
1970
                        } 
1971
                else 
1972
                        {
1973
                        $pdf->saveState();
1974
                        $pdf->setColor(0.8,0.8,0.8);
1975
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1976
                        $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
1977
                        $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
1978
                        $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
1979
                        $pdf->restoreState();
1980

    
1981
                        $pdf->addText(45,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][8]).'</b>');
1982
                        $pdf->addText(150,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][9]).'</b>');
1983
                        $pdf->addText(280,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][31]).'</b>');
1984
                        $pdf->addText(435,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["common"][25]).'</b>');
1985
                        
1986
                        $i++;
1987
                        
1988
                        if(($start_tab-20)-(20*$i)<50){
1989
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1990
                                        $i=0;
1991
                                        $start_tab = 750;
1992
                                        }
1993
                        
1994
                        while ($data=$DB->fetch_assoc($result))
1995
                                {
1996
                                $pdf->saveState();
1997
                                $pdf->setColor(0.95,0.95,0.95);
1998
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1999
                                $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
2000
                                $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
2001
                                $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
2002
                                $pdf->restoreState();        
2003
                                
2004
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode(convDateTime($data["begin"])));
2005
                                $pdf->addText(125,($start_tab-20)-(20*$i),9,utf8_decode($data["end"]));
2006
                                $pdf->addText(220,($start_tab-20)-(20*$i),9,utf8_decode($data["id_user"]));
2007
                                $pdf->addText(365,($start_tab-20)-(20*$i),9,utf8_decode($data["comment"]));
2008
                                
2009
                                $i++;
2010
                                
2011
                                if(($start_tab-20)-(20*$i)<50){
2012
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2013
                                        $i=0;
2014
                                        $start_tab = 750;
2015
                                        }
2016
                                }
2017
                        }
2018

    
2019
                } 
2020
        else
2021
                        {
2022
                        if(($start_tab-20)-(20*$i)<50){
2023
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2024
                                $i=0;
2025
                                $start_tab = 750;
2026
                                }
2027
                        $pdf->saveState();
2028
                        $pdf->setColor(0.8,0.8,0.8);
2029
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
2030
                        $pdf->restoreState();
2031
                        $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANG["reservation"][34]).'</b>');
2032
                        }
2033
                
2034
        $start_tab = ($start_tab-20)-(20*$i) - 20;
2035
                
2036
        $tab["start_tab"] = $start_tab;
2037
        $tab["pdf"] = $pdf;
2038
        
2039
        return $tab;        
2040
}
2041

    
2042
function plugin_pdf_history($tab,$width,$ID,$type){
2043
        
2044
        global $DB,$LANG;
2045
        
2046
        $start_tab = $tab["start_tab"];
2047
        $pdf = $tab["pdf"];
2048
        
2049
        $SEARCH_OPTION=getSearchOptions();
2050
        
2051
        $query="SELECT * FROM glpi_history WHERE FK_glpi_device='".$ID."' AND device_type='".$type."' ORDER BY  ID DESC;";
2052
        
2053
        $result = $DB->query($query);
2054
        $number = $DB->numrows($result);
2055
        
2056
        $pdf->saveState();
2057
        $pdf->setColor(0.8,0.8,0.8);
2058
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
2059
        $pdf->restoreState();
2060
        $pdf->addText(280,$start_tab,9,'<b>'.utf8_decode($LANG["title"][38]).'</b>');
2061
        
2062
        $i=0;
2063
        
2064
        if($number!=0){
2065
        while ($data =$DB->fetch_array($result)){
2066
                $field="";
2067
                if($data["linked_action"]){
2068
                        switch ($data["linked_action"]){
2069

    
2070
                                case HISTORY_ADD_DEVICE :
2071
                                        $field = getDeviceTypeLabel($data["device_internal_type"]);
2072
                                        $change = $LANG["devices"][25]." ".$data[ "new_value"];        
2073
                                        break;
2074

    
2075
                                case HISTORY_UPDATE_DEVICE :
2076
                                        $field = getDeviceTypeLabel($data["device_internal_type"]);
2077
                                        $change = getDeviceSpecifityLabel($data["device_internal_type"]).$data[ "old_value"].$data[ "new_value"];        
2078
                                        break;
2079

    
2080
                                case HISTORY_DELETE_DEVICE :
2081
                                        $field = getDeviceTypeLabel($data["device_internal_type"]);
2082
                                        $change = $LANG["devices"][26]." ".$data["old_value"];        
2083
                                        break;
2084
                                case HISTORY_INSTALL_SOFTWARE :
2085
                                        $field = $LANG["help"][31];
2086
                                        $change = $LANG["software"][44]." ".$data["new_value"];        
2087
                                        break;                                
2088
                                case HISTORY_UNINSTALL_SOFTWARE :
2089
                                        $field = $LANG["help"][31];
2090
                                        $change = $LANG["software"][45]." ".$data["old_value"];        
2091
                                        break;        
2092
                                case HISTORY_DISCONNECT_DEVICE:
2093
                                        $ci = new CommonItem();
2094
                                        $ci->setType($data["device_internal_type"]);
2095
                                        $field = $ci->getType();
2096
                                        $change = $LANG["central"][6]." ".$data["old_value"];        
2097
                                        break;        
2098
                                case HISTORY_CONNECT_DEVICE:
2099
                                        $ci = new CommonItem();
2100
                                        $ci->setType($data["device_internal_type"]);
2101
                                        $field = $ci->getType();
2102
                                        $change = $LANG["log"][55]." ".$data["new_value"];        
2103
                                        break;        
2104
                                case HISTORY_OCS_IMPORT:
2105
                                        $ci = new CommonItem();
2106
                                        $ci->setType($data["device_internal_type"]);
2107
                                        $field = $ci->getType();
2108
                                        $change = $LANG["ocsng"][7]." ".$LANG["ocsng"][45]." : ".$data["new_value"];        
2109
                                        break;        
2110
                                case HISTORY_OCS_DELETE:
2111
                                        $ci = new CommonItem();
2112
                                        $ci->setType($data["device_internal_type"]);
2113
                                        $field = $ci->getType();
2114
                                        $change = $LANG["ocsng"][46]." ".$LANG["ocsng"][45]." : ".$data["old_value"];        
2115
                                        break;        
2116
                                case HISTORY_OCS_LINK:
2117
                                        $ci = new CommonItem();
2118
                                        $ci->setType($data["device_internal_type"]);
2119
                                        $field = $ci->getType();
2120
                                        $change = $LANG["ocsng"][47]." ".$LANG["ocsng"][45]." : ".$data["new_value"];        
2121
                                        break;        
2122
                                case HISTORY_OCS_IDCHANGED:
2123
                                        $ci = new CommonItem();
2124
                                        $ci->setType($data["device_internal_type"]);
2125
                                        $field = $ci->getType();
2126
                                        $change = $LANG["ocsng"][48].$data["old_value"].$data["new_value"];        
2127
                                        break;        
2128
                        }
2129
                }
2130
                else{
2131
                        $fieldname="";
2132
                        foreach($SEARCH_OPTION[COMPUTER_TYPE] as $key2 => $val2)
2133
                                if($key2==$data["id_search_option"]){
2134
                                        $field = $val2["name"];
2135
                                        $fieldname = $val2["field"];
2136
                                }
2137
                                
2138
                        if ($fieldname=="comments")
2139
                                $change = $LANG["log"][64];
2140
                        else
2141
                                $change = $data[ "old_value"].$data[ "new_value"];
2142
                        }
2143
                
2144
                for($j=0,$deb=0;$j<6;$j++,$deb++){
2145
                                        
2146
                        if(($start_tab-20)-(20*($i+$j))<50){
2147
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2148
                                $i=0;
2149
                                $start_tab = 750;
2150
                                $deb=0;
2151
                                }
2152
                                        
2153
                        $pdf->saveState();
2154
                        if($j<5)
2155
                                $pdf->setColor(0.95,0.95,0.95);
2156
                        else
2157
                                $pdf->setColor(0.8,0.8,0.8);
2158
                        $pdf->filledRectangle(25,($start_tab-25)-(20*($deb+$i)),$width-50,15);
2159
                        $pdf->restoreState();
2160
                
2161
                        switch($j){
2162
                                                case 0:
2163
                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["common"][2].' : </i></b> '.$data["ID"]));
2164
                                                break;
2165
                                                case 1:
2166
                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["common"][27].' : </i></b> '.convDateTime($data["date_mod"])));
2167
                                                break;
2168
                                                case 2:
2169
                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["common"][34].' : </i></b> '.$data["user_name"]));
2170
                                                break;
2171
                                                case 3:
2172
                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["event"][18].' : </i></b> '.$field));
2173
                                                break;
2174
                                                case 4:
2175
                                                $pdf->addText(27,($start_tab-20)-(20*($i+$deb)),9,'<b><i>'.utf8_decode($LANG["event"][19].' : </i></b> '.$change));
2176
                                                break;
2177
                                                case 5:
2178
                                                        $i+=$deb+1;
2179
                                                break;
2180
                                        }
2181
                                }        
2182
        }
2183
        }
2184
        else
2185
                {
2186
                if(($start_tab-20)-(20*$i)<50){
2187
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2188
                                $i=0;
2189
                                $start_tab = 750;
2190
                                }
2191
                $pdf->saveState();
2192
                $pdf->setColor(0.8,0.8,0.8);
2193
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
2194
                $pdf->restoreState();
2195
                $pdf->addText(260,$start_tab,9,"<b>".utf8_decode($LANG["event"][20])."</b>");
2196
                }
2197
                
2198
        $start_tab = ($start_tab-20)-(20*$i) - 20;
2199
        
2200
        $tab["start_tab"] = $start_tab;
2201
        $tab["pdf"] = $pdf;
2202
        
2203
        return $tab;
2204
}
2205

    
2206
function plugin_pdf_newPage($pdf,$ID,$type){
2207
        $pdf->ezText("",1000);
2208
        $pdf->ezText("",9);
2209
        if($type!=-1)
2210
                $pdf = plugin_pdf_add_header($pdf,$ID,$type);
2211
        return $pdf;
2212
}
2213

    
2214
function plugin_pdf_general($type,$tab_id,$tab){
2215

    
2216
$pdf= new Cezpdf('a4','portrait');
2217
$width = $pdf->ez['pageWidth'];
2218
$pdf->openHere('Fit');
2219
$start_tab = 750;
2220
$tab_pdf = array("pdf"=>$pdf,"start_tab"=>$start_tab);
2221

    
2222
$nb_id = count($tab_id);
2223

    
2224
$tab_pdf = plugin_pdf_background($tab_pdf,$width);
2225

    
2226
foreach($tab_id as $key => $ID)
2227
        {
2228
        switch($type){
2229
                case COMPUTER_TYPE:
2230
                        
2231
                        $tab_pdf["pdf"] = plugin_pdf_add_header($tab_pdf["pdf"],$ID,COMPUTER_TYPE);
2232
                        $tab_pdf = plugin_pdf_config_computer($tab_pdf,$width,$ID);
2233
                        //erics, on ajoute systematiquement le contenu materiel ...
2234
                        $tab_pdf = plugin_pdf_device($tab_pdf,$width,$ID,COMPUTER_TYPE);
2235
                        
2236
                        for($i=0;$i<count($tab);$i++)
2237
                        {
2238
                                switch($tab[$i]){
2239
                                        case 0:
2240
                                                $tab_pdf = plugin_pdf_financial($tab_pdf,$width,$ID,COMPUTER_TYPE);
2241
                                                $tab_pdf = plugin_pdf_contract($tab_pdf,$width,$ID,COMPUTER_TYPE);
2242
                                        break;
2243
                                        case 1:
2244
                                                $tab_pdf = plugin_pdf_connection($tab_pdf,$width,$ID,COMPUTER_TYPE);
2245
                                                $tab_pdf = plugin_pdf_port($tab_pdf,$width,$ID,COMPUTER_TYPE);
2246
                                        break;
2247
                                        case 2:
2248
                                                $tab_pdf = plugin_pdf_device($tab_pdf,$width,$ID,COMPUTER_TYPE);
2249
                                        break;
2250
                                        case 3:
2251
                                                $tab_pdf = plugin_pdf_software($tab_pdf,$width,$ID,COMPUTER_TYPE);
2252
                                        break;
2253
                                        case 4:
2254
                                                $tab_pdf = plugin_pdf_ticket($tab_pdf,$width,$ID,COMPUTER_TYPE);
2255
                                                $tab_pdf = plugin_pdf_oldticket($tab_pdf,$width,$ID,COMPUTER_TYPE);
2256
                                        break;
2257
                                        case 5:
2258
                                                $tab_pdf = plugin_pdf_document($tab_pdf,$width,$ID,COMPUTER_TYPE);
2259
                                        break;
2260
                                        case 6:
2261
                                                $tab_pdf = plugin_pdf_registry($tab_pdf,$width,$ID,COMPUTER_TYPE);
2262
                                        break;
2263
                                        case 7:
2264
                                                $tab_pdf = plugin_pdf_link($tab_pdf,$width,$ID,COMPUTER_TYPE);
2265
                                        break;
2266
                                        case 8:
2267
                                                $tab_pdf = plugin_pdf_note($tab_pdf,$width,$ID,COMPUTER_TYPE);
2268
                                        break;
2269
                                        case 9:
2270
                                                $tab_pdf = plugin_pdf_reservation($tab_pdf,$width,$ID,COMPUTER_TYPE);
2271
                                        break;
2272
                                        case 10:
2273
                                                $tab_pdf = plugin_pdf_history($tab_pdf,$width,$ID,COMPUTER_TYPE);
2274
                                        break;
2275
                                        default:
2276
                                        break;
2277
                                }
2278
                        }
2279
                break;
2280
                
2281
                case SOFTWARE_TYPE:
2282
                
2283
                        $tab_pdf["pdf"] = plugin_pdf_add_header($tab_pdf["pdf"],$ID,SOFTWARE_TYPE);
2284
                        $tab_pdf = plugin_pdf_config_software($tab_pdf,$width,$ID);
2285
                        
2286
                        for($i=0;$i<count($tab);$i++)
2287
                        {
2288
                                switch($tab[$i]){
2289
                                        case 0:
2290
                                                $tab_pdf = plugin_pdf_licenses($tab_pdf,$width,$ID,0,SOFTWARE_TYPE);
2291
                                        break;
2292
                                        case 1:
2293
                                                $tab_pdf = plugin_pdf_licenses($tab_pdf,$width,$ID,1,SOFTWARE_TYPE);
2294
                                        break;
2295
                                        case 2:
2296
                                                $tab_pdf = plugin_pdf_financial($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2297
                                                $tab_pdf = plugin_pdf_contract($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2298
                                        break;
2299
                                        case 3:
2300
                                                $tab_pdf = plugin_pdf_document($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2301
                                        break;
2302
                                        case 4:
2303
                                                $tab_pdf = plugin_pdf_ticket($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2304
                                                $tab_pdf = plugin_pdf_oldticket($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2305
                                        break;
2306
                                        case 5:
2307
                                                $tab_pdf = plugin_pdf_link($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2308
                                        break;
2309
                                        case 6:
2310
                                                $tab_pdf = plugin_pdf_note($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2311
                                        break;
2312
                                        case 7:
2313
                                                $tab_pdf = plugin_pdf_reservation($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2314
                                        break;
2315
                                        case 8:
2316
                                                $tab_pdf = plugin_pdf_history($tab_pdf,$width,$ID,SOFTWARE_TYPE);
2317
                                        break;
2318
                                        default:
2319
                                        break;
2320
                                }
2321
                        }
2322
                break;
2323
                }
2324
        if($nb_id!=$key+1)
2325
                {
2326
                $tab_pdf["pdf"] = plugin_pdf_newPage($tab_pdf["pdf"],$ID,-1);
2327
                $tab_pdf["start_tab"] = 750;
2328
                }
2329
        }
2330
        
2331
$tab_pdf["pdf"]->ezStream();
2332
}
2333

    
2334
/**
2335
 * Print out an HTML checkbox
2336
 * @param 
2337
 */
2338
function checkbox($myname,$label,$value,$checked=false)
2339
{
2340
        echo "<td><input type='checkbox' ".($checked==true?"checked='checked'":'')." name='$myname' value='$value'>".$label."</td>";
2341
}
2342

    
2343
?>
Redmine Appliance - Powered by TurnKey Linux