Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

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

Historique | Voir | Annoter | Télécharger (87,7 ko)

1
<?php
2
/*
3
 ----------------------------------------------------------------------
4
 GLPI - Gestionnaire Libre de Parc Informatique
5
 Copyright (C) 2003-2008 by the INDEPNET Development Team.
6

7
 http://indepnet.net/   http://glpi-project.org/
8
 ----------------------------------------------------------------------
9

10
 LICENSE
11

12
        This file is part of GLPI.
13

14
    GLPI is free software; you can redistribute it and/or modify
15
    it under the terms of the GNU General Public License as published by
16
    the Free Software Foundation; either version 2 of the License, or
17
    (at your option) any later version.
18

19
    GLPI is distributed in the hope that it will be useful,
20
    but WITHOUT ANY WARRANTY; without even the implied warranty of
21
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
    GNU General Public License for more details.
23

24
    You should have received a copy of the GNU General Public License
25
    along with GLPI; if not, write to the Free Software
26
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
 ------------------------------------------------------------------------
28
*/
29

    
30
// Original Author of file: BALPE Dévi
31
// Purpose of file:
32
// ----------------------------------------------------------------------
33

    
34
function plugin_pdf_menu_computer($action,$compID,$export=true){
35
        global $LANGPDF,$LANG,$DB;
36
        
37
        echo "<form name='computer' action='$action' target='blank' method='post'><table class='tab_cadre_fixe'>";
38
        $values = array();
39
        $result = $DB->query("select table_num from glpi_plugin_pdf_preference WHERE user_id =" . $_SESSION['glpiID'] . " and cat=" . COMPUTER_TYPE);
40
                                        
41
        while ($data = $DB->fetch_array($result))
42
                $values["check".$data["table_num"]] = $data["table_num"]; 
43

    
44
                echo "<tr><th colspan='6'>" . $LANGPDF["title"][2]. " : ".$LANG["Menu"][0] . "</th></tr>";
45
                echo "<tr class='tab_bg_1'>";
46
                checkbox("check0",$LANG["Menu"][26],0,(isset($values["check0"])?true:false));
47
                checkbox("check2",$LANG["title"][30],2,(isset($values["check2"])?true:false));
48
                checkbox("check4",$LANG["title"][28],4,(isset($values["check4"])?true:false));
49
                checkbox("check6",$LANG["title"][43],6,(isset($values["check6"])?true:false));
50
                checkbox("check8",$LANG["title"][37],8,(isset($values["check8"])?true:false));
51
                checkbox("check10",$LANG["title"][38],10,(isset($values["check10"])?true:false));
52
                echo "</tr>";
53
        
54
                echo "<tr class='tab_bg_1'>";
55
                checkbox("check1",$LANG["title"][27],1,(isset($values["check1"])?true:false));
56
                checkbox("check3",$LANG["Menu"][4],3,(isset($values["check3"])?true:false));
57
                checkbox("check5",$LANG["Menu"][27],5,(isset($values["check5"])?true:false));
58
                checkbox("check7",$LANG["title"][34],7,(isset($values["check7"])?true:false));
59
                checkbox("check9",$LANG["Menu"][17],9,(isset($values["check9"])?true:false));
60
                echo "<td></td>";
61
                echo "</tr>";
62
        
63
                echo "<tr class='tab_bg_2'><td colspan='6' align='center'>";
64
                echo "<input type='hidden' name='plugin_pdf_inventory_type' value='" . COMPUTER_TYPE . "'>";
65
                echo "<input type='hidden' name='indice' value='11'>";
66
                echo "<input type='hidden' name='itemID' value='$compID'>";
67

    
68
                echo "<input type='submit' value='" . (!$export?$LANGPDF["button"][2]:$LANGPDF["button"][1]) . "' name='plugin_pdf_user_preferences_save' class='submit'></td></tr>";
69
                echo "</table></form>";
70
}
71

    
72
function plugin_pdf_menu_software($action,$softID){
73
        global $LANGPDF,$LANG,$DB;
74
        
75
        echo "<form name='software' action='$action' target='blank' method='post'><table class='tab_cadre_fixe'>";
76
        $values = array();
77
        $result = $DB->query("select table_num from glpi_plugin_pdf_preference WHERE user_id =" . $_SESSION['glpiID'] . " and cat=" . SOFTWARE_TYPE);
78
                                                
79
        while ($data = $DB->fetch_array($result))
80
                $values["check".$data["table_num"]] = $data["table_num"]; 
81
                
82
        echo "<tr><th colspan='6'>" . $LANGPDF["title"][2]." : ".$LANG["Menu"][4] . "</th></tr>";
83
        
84
        echo "<tr class='tab_bg_1'>";
85
        checkbox("check0",$LANG["title"][26],0,(isset($values["check0"])?true:false));
86
        checkbox("check2",$LANG["Menu"][26],2,(isset($values["check2"])?true:false));
87
        checkbox("check4",$LANG["title"][28],4,(isset($values["check4"])?true:false));
88
        checkbox("check6",$LANG["title"][37],6,(isset($values["check6"])?true:false));
89
        checkbox("check8",$LANG["title"][38],8,(isset($values["check10"])?true:false));
90
        echo "<td></td>";
91
        echo "</tr>";
92
        
93
        echo "<tr class='tab_bg_1'>";
94
        
95
        checkbox("check1",$LANG["software"][19],1,(isset($values["check1"])?true:false));
96
        checkbox("check3",$LANG["Menu"][27],3,(isset($values["check3"])?true:false));
97
        checkbox("check5",$LANG["title"][34],5,(isset($values["check5"])?true:false));
98
        checkbox("check7",$LANG["Menu"][17],7,(isset($values["check7"])?true:false));
99
        echo "<td></td>";
100
        echo "<td></td>";
101
        echo "</tr>";
102
                                                
103
        echo "<tr class='tab_bg_2'><td colspan='6' align='center'>";
104
        echo "<input type='hidden' name='plugin_pdf_inventory_type' value='" . SOFTWARE_TYPE . "'>";
105
        echo "<input type='hidden' name='indice' value='7'>";
106
        echo "<input type='hidden' name='itemID' value='$softID'>";
107
        
108
        echo "<input type='submit' value='" . $LANGPDF["button"][2] . "' name='plugin_pdf_user_preferences_save' class='submit'></td></tr>";
109
        echo "</table></form>";
110
}
111

    
112
function plugin_pdf_getDropdownName($table,$id){
113
        
114
        $name = getDropdownName($table,$id);
115
        
116
        if($name=="&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

    
196
        //erics deux rectangles pour mettre l'entite et des choses que je vire
197
        /*
198
        $pdf->filledRectangle(25,$start_tab-5,$length_tab,15);
199
        $pdf->filledRectangle(25+$length_tab+5,$start_tab-5,$length_tab,15);
200
        */
201
        //J'en met un seul pour "informations generales"
202
        $pdf->filledRectangle(25,$start_tab-5,$length_tab*2+5,15);
203
        
204
        for($i=0;$i<13;$i++)
205
          {
206
            //erics pour avoir la couleur une ligne sur deux
207
            if($i%2){
208
              $pdf->setColor(0.95,0.95,0.95);
209
            }
210
            else {
211
              $pdf->setColor(1,1,1);
212
            }
213
            
214
                if($i<11)
215
                  {
216
                    //des lignes complètes pour l'arriere plan
217
                    $pdf->filledRectangle(25,($start_tab-20)-(15*$i),2*$length_tab+5,15);
218
                    //$pdf->filledRectangle(25+$length_tab+5,($start_tab-25)-(20*$i),$length_tab,15);
219
                  }
220
                else
221
                  if($i==11)
222
                    {
223
                      $pdf->filledRectangle(25,($start_tab-20)-(15*$i),2*$length_tab+5,15);        
224
                    }
225
                /*
226
                  else
227
                    {
228
                      $i+=2;
229
                      $pdf->filledRectangle(25,($start_tab-20)-(15*$i),2*$length_tab+5,30);
230
                    }
231
                */
232
                }
233
        $pdf->restoreState();
234
                
235
        //erics on simplifie pas besoin de ca
236
        //        $pdf->addText(100,$start_tab,9,utf8_decode('<b>'.$LANG["common"][2].' '.$computer->fields['ID'].' ('.plugin_pdf_getDropdownName('glpi_entities',$computer->fields['FK_entities']).')</b>'));
237
        $pdf->addText(275,$start_tab,9,utf8_decode('<b>Généralités</b>'));
238

    
239
        $pdf->addText(30,$start_tab-15,9,utf8_decode('<b><i>'.$LANG["common"][16].' :</i></b> '.$computer->fields['name']));
240
        $pdf->addText(30,$start_tab-30,9,utf8_decode('<b><i>'.$LANG["common"][17].' :</i></b> '.plugin_pdf_getDropdownName('glpi_type_computers',$computer->fields['type'])));
241
        $pdf->addText(30,$start_tab-45,9,utf8_decode('<b><i>'.$LANG["common"][22].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_model',$computer->fields['model'])));
242
        $pdf->addText(30,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][5].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_manufacturer',$computer->fields['FK_glpi_enterprise'])));
243
        $pdf->addText(30,$start_tab-75,9,utf8_decode('<b><i>'.$LANG["computers"][9].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os',$computer->fields['os'])));
244
        $pdf->addText(30,$start_tab-90,9,utf8_decode('<b><i>'.$LANG["computers"][52].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os_version',$computer->fields['os_version'])));
245
        $pdf->addText(30,$start_tab-105,9,utf8_decode('<b><i>'.$LANG["computers"][53].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os_sp',$computer->fields['os_sp'])));
246
        $pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["computers"][10].' :</i></b> '.$computer->fields['os_license_number']));
247
        $pdf->addText(30,$start_tab-135,9,utf8_decode('<b><i>'.$LANG["computers"][11].' :</i></b> '.$computer->fields['os_license_id']));
248
                        
249
        if($computer->fields['ocs_import'])
250
                $pdf->addText(30,$start_tab-150,9,utf8_decode('<b><i>'.$LANG["ocsng"][6].' '.$LANG["Menu"][33].' :</i></b> '.$LANG["choice"][1]));
251
        else
252
                $pdf->addText(30,$start_tab-150,9,utf8_decode('<b><i>'.$LANG["ocsng"][6].' '.$LANG["Menu"][33].' :</i></b> '.$LANG["choice"][0]));
253
        $pdf->addText(30,$start_tab-165,9,utf8_decode('<b><i>'.$LANG["common"][15].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_locations',$computer->fields['location'])));
254
        $pdf->addText(30,$start_tab-180,9,utf8_decode('<b><i>'.$LANG["common"][25].' :</i></b> '));
255
                        
256
        $y=$start_tab-195;
257
        $temp=utf8_decode($computer->fields['comments']);
258
        while($temp = $pdf->addTextWrap(105,$y,2*$length_tab-80,9,$temp))
259
                $y-=9;
260
                        
261
        //seconde colone                        
262
        /*
263
        if(!empty($computer->fields['tplname']))
264
                $pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).' ('.$LANG["common"][13].' : '.$computer->fields['tplname'].')</b>'));
265
        elseif($computer->fields['ocs_import'])
266
                $pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).' ('.$LANG["ocsng"][7].')</b>'));
267
        else
268
                $pdf->addText($length_tab+80,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($computer->fields["date_mod"]).'</b>'));
269
        */
270

    
271
        $pdf->addText($length_tab+35,$start_tab-15,9,utf8_decode('<b><i>'.$LANG["common"][18].' :</i></b> '.$computer->fields['contact']));
272
        $pdf->addText($length_tab+35,$start_tab-30,9,utf8_decode('<b><i>'.$LANG["common"][21].' :</i></b> '.$computer->fields['contact_num']));
273
        $pdf->addText($length_tab+35,$start_tab-45,9,utf8_decode('<b><i>'.$LANG["common"][34].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$computer->fields['FK_users'])));
274
        $pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][35].' :</i></b> '.plugin_pdf_getDropdownName('glpi_groups',$computer->fields['FK_groups'])));
275
        $pdf->addText($length_tab+35,$start_tab-75,9,utf8_decode('<b><i>'.$LANG["common"][10].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$computer->fields['tech_num'])));
276
        $pdf->addText($length_tab+35,$start_tab-90,9,utf8_decode('<b><i>'.$LANG["setup"][88].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_network',$computer->fields['network'])));
277
        $pdf->addText($length_tab+35,$start_tab-105,9,utf8_decode('<b><i>'.$LANG["setup"][89].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_domain',$computer->fields['domain'])));
278
        $pdf->addText($length_tab+35,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["common"][19].' :</i></b> '.$computer->fields['serial']));
279
        $pdf->addText($length_tab+35,$start_tab-135,9,utf8_decode('<b><i>'.$LANG["common"][20].' :</i></b> '.$computer->fields['otherserial']));
280
        $pdf->addText($length_tab+35,$start_tab-150,9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_state',$computer->fields['state'])));
281
        $pdf->addText($length_tab+35,$start_tab-165,9,utf8_decode('<b><i>'.$LANG["computers"][51].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_auto_update',$computer->fields['auto_update'])));
282
        
283
        $start_tab = ($start_tab-20)-(20*$i) - 20;
284
        
285
        $tab["start_tab"] = $start_tab;
286
        $tab["pdf"] = $pdf;
287
        
288
        return $tab;
289
}
290

    
291
function plugin_pdf_config_software($tab,$width,$ID){
292
        
293
        global $LANG;
294
        
295
        $start_tab = $tab["start_tab"];
296
        $pdf = $tab["pdf"];
297
        
298
        $software=new Software();
299
        $software->getFromDB($ID);
300
        
301
        $length_tab = (($width-50)/2)-2.5;
302
        
303
        $pdf->saveState();
304
        $pdf->setColor(0.8,0.8,0.8);
305
        $pdf->filledRectangle(25,$start_tab-5,$length_tab,15);
306
        $pdf->filledRectangle(25+$length_tab+5,$start_tab-5,$length_tab,15);
307
        $pdf->setColor(0.95,0.95,0.95);
308
        
309
        for($i=0;$i<7;$i++)
310
                {
311
                if($i<5)
312
                        {
313
                        $pdf->filledRectangle(25,($start_tab-20)-(20*$i),$length_tab,15);
314
                        $pdf->filledRectangle(25+$length_tab+5,($start_tab-20)-(20*$i),$length_tab,15);
315
                        }
316
                else
317
                        if($i==5)
318
                        {
319
                        $pdf->filledRectangle(25,($start_tab-20)-(20*$i),2*$length_tab+5,15);        
320
                        }
321
                        else
322
                        {
323
                        $i+=2;
324
                        $pdf->filledRectangle(25,($start_tab-20)-(20*$i),2*$length_tab+5,55);
325
                        }
326
                }
327
        $pdf->restoreState();
328
        
329
        $pdf->addText(100,$start_tab,9,utf8_decode('<b>'.$LANG["common"][2].' '.$software->fields['ID'].' ('.plugin_pdf_getDropdownName('glpi_entities',$software->fields['FK_entities']).')</b>'));
330
        $pdf->addText(30,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][16].' :</i></b> '.$software->fields['name']));
331
        $pdf->addText(30,$start_tab-40,9,utf8_decode('<b><i>'.$LANG["software"][3].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_os',$software->fields['platform'])));
332
        $pdf->addText(30,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][34].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$software->fields["FK_users"])));
333
        $pdf->addText(30,$start_tab-80,9,utf8_decode('<b><i>'.$LANG["common"][10].' :</i></b> '.plugin_pdf_getDropdownName('glpi_users',$software->fields["tech_num"])));
334
        $pdf->addText(30,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["common"][15].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_locations',$software->fields['location'])));
335
        
336
        if($software->fields['is_update'])
337
                $pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["software"][29].' :</i></b> '.$LANG["choice"][1]));
338
        else
339
                $pdf->addText(30,$start_tab-120,9,utf8_decode('<b><i>'.$LANG["software"][29].' :</i></b> '.$LANG["choice"][0]));
340
        
341
        if($software->fields["update_software"]!=null)
342
                $pdf->addText(100,$start_tab-120,9,utf8_decode('<b><i> '.$LANG["pager"][2].' </i></b> '.plugin_pdf_getDropdownName('glpi_software',$software->fields["update_software"])));
343
        
344
        $pdf->addText(30,$start_tab-140,9,utf8_decode('<b><i>'.$LANG["common"][25].' :</i></b> '));
345
        
346
        $y=$start_tab-140;
347
        $temp=utf8_decode($software->fields['comments']);
348
        while($temp = $pdf->addTextWrap(105,$y,2*$length_tab-80,9,$temp))
349
                $y-=9;
350
        
351
        if(!empty($software->fields['tplname']))
352
                $pdf->addText($length_tab+35,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($software->fields["date_mod"]).' ('.$LANG["common"][13].' : '.$software->fields['tplname'].')</b>'));
353
        else
354
                $pdf->addText($length_tab+80,$start_tab,9,utf8_decode('<b>'.$LANG["common"][26].' : '.convDateTime($software->fields["date_mod"]).'</b>'));
355
        
356
        $pdf->addText($length_tab+35,$start_tab-20,9,utf8_decode('<b><i>'.$LANG["common"][36].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_software_category',$software->fields["category"])));
357
        $pdf->addText($length_tab+35,$start_tab-40,9,utf8_decode('<b><i>'.$LANG["common"][5].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_manufacturer',$software->fields['FK_glpi_enterprise'])));
358
        $pdf->addText($length_tab+35,$start_tab-60,9,utf8_decode('<b><i>'.$LANG["common"][35].' :</i></b> '.plugin_pdf_getDropdownName('glpi_groups',$software->fields['FK_groups'])));
359
        $pdf->addText($length_tab+35,$start_tab-80,9,utf8_decode('<b><i>'.$LANG["state"][0].' :</i></b> '.plugin_pdf_getDropdownName('glpi_dropdown_state',$software->fields["state"])));
360
        
361
        if($software->fields['helpdesk_visible'])
362
                $pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["software"][46].' :</i></b> '.$LANG["choice"][1]));
363
        else
364
                $pdf->addText($length_tab+35,$start_tab-100,9,utf8_decode('<b><i>'.$LANG["software"][46].' :</i></b> '.$LANG["choice"][0]));
365
        
366
        $start_tab = ($start_tab-20)-(20*$i) - 20;
367
        
368
        $tab["start_tab"] = $start_tab;
369
        $tab["pdf"] = $pdf;
370
        
371
        return $tab;
372
}
373

    
374
function plugin_pdf_device($tab,$width,$ID,$type){
375
        
376
        global $LANG;
377
        
378
        $start_tab = $tab["start_tab"];
379
        $pdf = $tab["pdf"];
380
        
381
        $computer=new Computer();
382
        $computer->getFromDBwithDevices($ID);
383
        
384
        $pdf->saveState();
385
        $pdf->setColor(0.8,0.8,0.8);
386
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
387
        $pdf->restoreState();
388
        $pdf->addText(275,$start_tab,9,'<b>'.utf8_decode($LANG["title"][30].'</b>'));
389
        
390
        $i=0;
391
        
392
        foreach($computer->devices as $key => $val) {
393
                $device = new Device($val["devType"]);
394
                $device->getFromDB($val["devID"]);
395
                
396
                $nb_x = 27        ;
397
                $device_x = 47;
398
                $design_x = 127;
399
                $other_x = 362;
400
                $spec_x = 468;
401
                
402
                $pdf->saveState();
403
                $pdf->setColor(0.95,0.95,0.95);
404
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),15,15);
405
                $pdf->filledRectangle(45,($start_tab-25)-(20*$i),75,15);
406
                $pdf->filledRectangle(125,($start_tab-25)-(20*$i),230,15);
407
                $pdf->filledRectangle(360,($start_tab-25)-(20*$i),101,15);
408
                $pdf->filledRectangle(466,($start_tab-25)-(20*$i),105,15);
409
                $pdf->restoreState();
410
                
411
                switch($device->devtype) {
412
                case HDD_DEVICE :
413
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
414
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][1]));
415
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
416
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_hdd"][4].' :</i></b> '.$val["specificity"]));
417
                        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"]));
418
                        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"])));
419
                        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"]));
420
                        break;
421
                case GFX_DEVICE :
422
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
423
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][2]));
424
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
425
                        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"]));
426
                        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"]));
427
                        break;
428
                case NETWORK_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"][3]));
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["networking"][15].' :</i></b> '.$val["specificity"]));
433
                        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"]));
434
                        break;
435
                case MOBOARD_DEVICE :
436
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
437
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][5]));
438
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
439
                        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"]));
440
                        break;
441
                case PROCESSOR_DEVICE :
442
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
443
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][4]));
444
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
445
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["device_ram"][1].' :</i></b> '.$val["specificity"]));
446
                        break;
447
                case RAM_DEVICE :
448
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
449
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][6]));
450
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
451
                        $pdf->addTextWrap($spec_x,($start_tab-20)-(20*$i),99,9,utf8_decode('<b><i>'.$LANG["monitors"][21].' :</i></b> '.$val["specificity"]));
452
                        if (empty($device->fields["frequence"])) {
453
                                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"])));
454
                        } else {
455
                                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"])));
456
                                $pdf->addTextWrap($other_x+75,($start_tab-20)-(20*$i),28,9,utf8_decode($device->fields["frequence"]));
457
                        }        
458
                        break;
459
                case SND_DEVICE :
460
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
461
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][7]));
462
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
463
                        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"]));
464
                        break;
465
                case DRIVE_DEVICE : 
466
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
467
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][19]));
468
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
469
                        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"])));
470
                        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"]));
471
                        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"]));
472
                        break;
473
                case CONTROL_DEVICE :;
474
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(25*$i),13,9,utf8_decode($val["quantity"].'x'));
475
                        $pdf->addTextWrap($device_x,($start_tab-20)-(25*$i),73,9,utf8_decode($LANG["devices"][20]));
476
                        $pdf->addTextWrap($design_x,($start_tab-20)-(25*$i),228,9,utf8_decode($device->fields["designation"]));
477
                        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"])));
478
                        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"])));
479
                        break;
480
                case PCI_DEVICE :
481
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
482
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][21]));
483
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
484
                        break;
485
                case POWER_DEVICE :
486
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
487
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][23]));
488
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
489
                        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"]));
490
                        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"])));
491
                        break;
492
                case CASE_DEVICE :
493
                        $pdf->addTextWrap($nb_x,($start_tab-20)-(20*$i),13,9,utf8_decode($val["quantity"].'x'));
494
                        $pdf->addTextWrap($device_x,($start_tab-20)-(20*$i),73,9,utf8_decode($LANG["devices"][22]));
495
                        $pdf->addTextWrap($design_x,($start_tab-20)-(20*$i),228,9,utf8_decode($device->fields["designation"]));
496
                        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"])));
497
                        break;
498
                }
499
        $i++;
500
        
501
        if(($start_tab-20)-(20*$i)<50){
502
                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
503
                $i=0;
504
                $start_tab = 750;
505
                }
506
        }
507
        
508
        $start_tab = ($start_tab-20)-(20*$i) - 20;
509
        
510
        $tab["start_tab"] = $start_tab;
511
        $tab["pdf"] = $pdf;
512
        
513
        return $tab;                
514
}
515

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

    
690
function plugin_pdf_software($tab,$width,$ID,$type){
691
        
692
        global $DB,$LANG,$LANGPDF;
693
        
694
        $start_tab = $tab["start_tab"];
695
        $pdf = $tab["pdf"];
696
        
697
        $comp=new Computer();
698
        $comp->getFromDB($ID);
699
        $FK_entities=$comp->fields["FK_entities"];
700

    
701
        $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 )
702
        LEFT JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID) 
703
        LEFT JOIN glpi_dropdown_software_category ON (glpi_dropdown_software_category.ID = glpi_software.category)";
704

    
705
        $query_cat.=" WHERE glpi_inst_software.cID = '$ID' AND glpi_software.category > 0 "; 
706
    $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  
707
        FROM glpi_inst_software LEFT JOIN glpi_licenses ON ( glpi_inst_software.license = glpi_licenses.ID ) 
708
        LEFT JOIN glpi_software ON (glpi_licenses.sID = glpi_software.ID)  
709
        LEFT JOIN glpi_dropdown_software_category ON (glpi_dropdown_software_category.ID = glpi_software.category)"; 
710
    $query_nocat.= " WHERE glpi_inst_software.cID = '$ID' AND (glpi_software.category <= 0 OR glpi_software.category IS NULL ) "; 
711
    $query="( $query_cat ) UNION ($query_nocat) ORDER BY TYPE, category, softname, version";
712

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

    
821
function plugin_pdf_connection($tab,$width,$ID,$type){
822
        
823
        global $DB,$LANG;
824
        
825
        $start_tab = $tab["start_tab"];
826
        $pdf = $tab["pdf"];
827
        
828
        $items=array(PRINTER_TYPE=>$LANG["computers"][39],MONITOR_TYPE=>$LANG["computers"][40],PERIPHERAL_TYPE=>$LANG["computers"][46],PHONE_TYPE=>$LANG["computers"][55]);
829
        
830
        $ci=new CommonItem();
831
        $comp=new Computer();
832
        $info=new InfoCom();
833
        $comp->getFromDB($ID);
834
        
835
        $i=0;
836
        
837
        $pdf->saveState();
838
        $pdf->setColor(0.8,0.8,0.8);
839
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
840
        $pdf->restoreState();
841
        $pdf->addText(250,$start_tab,9,utf8_decode('<b>'.$LANG["connect"][0].' :</b>'));
842
        
843
        foreach ($items as $type=>$title){
844
                $query = "SELECT * from glpi_connect_wire WHERE end2='$ID' AND type='".$type."'";
845
                
846
                if ($result=$DB->query($query)) {
847
                        $resultnum = $DB->numrows($result);
848
                        if ($resultnum>0) {
849
                                
850
                                for ($j=0; $j < $resultnum; $j++, $i++) {
851
                                        $tID = $DB->result($result, $j, "end1");
852
                                        $connID = $DB->result($result, $j, "ID");
853
                                        $ci->getFromDB($type,$tID);
854
                                        $info->getFromDBforDevice($type,$tID) || $info->getEmpty();
855

    
856
                                        $pdf->saveState();
857
                                        $pdf->setColor(0.95,0.95,0.95);
858
                                        if ($ci->getField("otherserial")!=null || $info->fields["num_immo"]) {
859
                                                $pdf->filledRectangle(25,($start_tab-45)-(20*$i),$width-50, 35);
860
                                        } else {
861
                                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50, 15);
862
                                        }
863
                                        $pdf->restoreState();
864
                                        if ($j==0) {
865
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode('<b><i>'.$ci->getType().' :</i></b>'));                                                
866
                                        }
867

    
868
                                        $tempo=$ci->getName()." - ";
869
                                        if($ci->getField("serial")!=null) {
870
                                                $tempo .=$LANG["common"][19] . " : " .$ci->getField("serial")." - ";
871
                                        }
872
                                        $pdf->addText(120,($start_tab-20)-(20*$i),9,utf8_decode($tempo . plugin_pdf_getDropdownName("glpi_dropdown_state",$ci->getField('state'))));
873

    
874
                                        $tempo="";
875
                                        if($ci->getField("otherserial")!=null) {
876
                                                $tempo .=$LANG["common"][20] . " : " . $ci->getField("otherserial");
877
                                        }
878
                                        if ($info->fields["num_immo"]) {
879
                                                if ($tempo) $tempo .= " - ";
880
                                                $tempo .=$LANG["financial"][20] . " : " . $info->fields["num_immo"];
881
                                        }
882
                                        if ($tempo) {
883
                                                $i++;
884
                                                $pdf->addText(200,($start_tab-20)-(20*$i),9,utf8_decode($tempo));
885
                                        }
886
                                }// each device        of current type
887
                                                
888
                        } else { // No row        
889
                                        
890
                                $pdf->saveState();
891
                                $pdf->setColor(0.95,0.95,0.95);
892
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
893
                                $pdf->restoreState();
894

    
895
                                switch ($type){
896
                                        case PRINTER_TYPE:
897
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][38]));
898
                                        break;
899
                                        case MONITOR_TYPE:
900
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][37]));
901
                                        break;
902
                                        case PERIPHERAL_TYPE:
903
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][47]));
904
                                        break;
905
                                        case PHONE_TYPE:
906
                                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($LANG["computers"][54]));
907
                                        break;
908
                                        }
909
                                $i++;
910
                        } // No row
911
                } // Result
912
                        
913
                if(($start_tab-20)-(20*$i)<50){
914
                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
915
                        $i=0;
916
                        $start_tab = 750;
917
                }
918
        } // each type
919
        
920
        $start_tab = ($start_tab-20)-(20*$i) - 20;
921
                
922
        $tab["start_tab"] = $start_tab;
923
        $tab["pdf"] = $pdf;
924
        
925
        return $tab;
926
        
927
}
928

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

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

    
1122
        }
1123
        else
1124
                {
1125
                if(($start_tab-20)-(20*$i)<50){
1126
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1127
                                $i=0;
1128
                                $start_tab = 750;
1129
                                }
1130
                $pdf->saveState();
1131
                $pdf->setColor(0.8,0.8,0.8);
1132
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1133
                $pdf->restoreState();
1134
                $pdf->addText(245,$start_tab,9,utf8_decode("<b>".$LANGPDF["financial"][1]."</b>"));
1135
                }
1136
        
1137

    
1138
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1139
        
1140
        $tab["start_tab"] = $start_tab;
1141
        $tab["pdf"] = $pdf;
1142
        
1143
        return $tab;
1144
}
1145

    
1146
function plugin_pdf_contract($tab,$width,$ID,$type){
1147
        
1148
        global $DB,$CFG_GLPI,$LANG,$LANGPDF;
1149
        
1150
        $start_tab = $tab["start_tab"];
1151
        $pdf = $tab["pdf"];
1152
        
1153
        $ci=new CommonItem();
1154
        $ci->getFromDB($type,$ID);
1155

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

    
1158
        $result = $DB->query($query);
1159
        $number = $DB->numrows($result);
1160
        
1161
        $i=$j=0;
1162
        
1163
        if($number>0){
1164
                
1165
        $pdf->saveState();
1166
        $pdf->setColor(0.8,0.8,0.8);
1167
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1168
        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15);
1169
        $pdf->filledRectangle(130,($start_tab-25)-(20*$i),100,15);
1170
        $pdf->filledRectangle(235,($start_tab-25)-(20*$i),100,15);
1171
        $pdf->filledRectangle(340,($start_tab-25)-(20*$i),80,15);
1172
        $pdf->filledRectangle(425,($start_tab-25)-(20*$i),60,15);
1173
        $pdf->filledRectangle(490,($start_tab-25)-(20*$i),80,15);
1174
        $pdf->restoreState();
1175
        $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["financial"][66]).' :</b>');
1176
        $pdf->addText(65,$start_tab-20,9,'<b>'.utf8_decode($LANG["common"][16]).'</b>');
1177
        $pdf->addText(138,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][4]).'</b>');
1178
        $pdf->addText(255,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][6]).'</b>');
1179
        $pdf->addText(355,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][26]).'</b>');
1180
        $pdf->addText(428,$start_tab-20,9,'<b>'.utf8_decode($LANG["search"][8]).'</b>');
1181
        $pdf->addText(515,$start_tab-20,9,'<b>'.utf8_decode($LANG["financial"][8]).'</b>');
1182
        
1183
        $i++;
1184
                
1185
        while ($j < $number) {
1186
                $cID=$DB->result($result, $j, "FK_contract");
1187
                $assocID=$DB->result($result, $j, "ID");
1188
                $con=new Contract;
1189
                $con->getFromDB($cID);
1190
                
1191
                $pdf->saveState();
1192
                $pdf->setColor(0.95,0.95,0.95);
1193
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),100,15);
1194
                $pdf->filledRectangle(130,($start_tab-25)-(20*$i),100,15);
1195
                $pdf->filledRectangle(235,($start_tab-25)-(20*$i),100,15);
1196
                $pdf->filledRectangle(340,($start_tab-25)-(20*$i),80,15);
1197
                $pdf->filledRectangle(425,($start_tab-25)-(20*$i),60,15);
1198
                $pdf->filledRectangle(490,($start_tab-25)-(20*$i),80,15);
1199
                $pdf->restoreState();
1200
                
1201
                if (empty($con->fields["name"]))
1202
                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["ID"]));
1203
                else
1204
                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["name"]));
1205
                
1206
                $pdf->addText(135,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["num"]));
1207
                $pdf->addText(240,($start_tab-20)-(20*$i),9,utf8_decode(plugin_pdf_getDropdownName("glpi_dropdown_contract_type",$con->fields["contract_type"])));
1208
                
1209
                $temp = str_replace("<br>", "", getContractEnterprises($cID));
1210
                
1211
                if(strlen($temp)<14)
1212
                        $pdf->addText(345,($start_tab-20)-(20*$i),9,utf8_decode($temp));
1213
                else
1214
                {
1215
                        $temp=$pdf->addTextWrap(345,($start_tab-20)-(20*$i)+4,70,8,utf8_decode($temp));
1216
                        $pdf->addTextWrap(345,($start_tab-20)-(20*$i)-4,70,8,utf8_decode($temp));
1217
                }
1218
                
1219
                $pdf->addText(430,($start_tab-20)-(20*$i),9,utf8_decode(convDate($con->fields["begin_date"])));
1220
                
1221
                if ($con->fields["begin_date"]!='' && $con->fields["begin_date"]!="0000-00-00")
1222
                        {
1223
                        $pdf->addText(515,($start_tab-20)-(20*$i)+4,7,utf8_decode($con->fields["duration"]." ".$LANG["financial"][57])); 
1224
                        $pdf->addText(505,($start_tab-20)-(20*$i)-4,7,"-> ".utf8_decode(getWarrantyExpir($con->fields["begin_date"],$con->fields["duration"]))); 
1225
                        }
1226
                else
1227
                        $pdf->addText(510,($start_tab-20)-(20*$i),9,utf8_decode($con->fields["duration"]." ".$LANG["financial"][57])); 
1228
                
1229
                $i++;
1230
                $j++;
1231
                
1232
                if(($start_tab-20)-(20*$i)<50){
1233
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1234
                                $i=0;
1235
                                $start_tab = 750;
1236
                                }
1237
                }
1238
        }
1239
        else
1240
                {
1241
                if(($start_tab-20)-(20*$i)<50){
1242
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1243
                                $i=0;
1244
                                $start_tab = 750;
1245
                                }
1246
                $pdf->saveState();
1247
                $pdf->setColor(0.8,0.8,0.8);
1248
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1249
                $pdf->restoreState();
1250
                $pdf->addText(260,$start_tab,9,utf8_decode('<b>'.$LANGPDF["financial"][2].'</b>'));
1251
                }
1252
        
1253
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1254
                
1255
        $tab["start_tab"] = $start_tab;
1256
        $tab["pdf"] = $pdf;
1257
        
1258
        return $tab;
1259
}
1260

    
1261
function plugin_pdf_document($tab,$width,$ID,$type){
1262
        
1263
        global $DB,$LANG,$LANGPDF;
1264
        
1265
        $start_tab = $tab["start_tab"];
1266
        $pdf = $tab["pdf"];
1267
        
1268
        $query = "SELECT glpi_doc_device.ID as assocID, glpi_docs.* FROM glpi_doc_device "; 
1269
        $query .= "LEFT JOIN glpi_docs ON (glpi_doc_device.FK_doc=glpi_docs.ID)"; 
1270
        $query .= "WHERE glpi_doc_device.FK_device = ".$ID." AND glpi_doc_device.device_type = ".$type;
1271
        
1272
        $result = $DB->query($query);
1273
        $number = $DB->numrows($result);
1274
        
1275
        $i=0;
1276
        
1277
        if($number>0){
1278
        
1279
        $pdf->saveState();
1280
        $pdf->setColor(0.8,0.8,0.8);
1281
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
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
        $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANG["document"][21]).' :</b>');
1289
        $pdf->addText(80,$start_tab-20,9,'<b>'.utf8_decode($LANG["common"][16]).'</b>');
1290
        $pdf->addText(195,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][2]).'</b>');
1291
        $pdf->addText(315,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][33]).'</b>');
1292
        $pdf->addText(425,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][3]).'</b>');
1293
        $pdf->addText(510,$start_tab-20,9,'<b>'.utf8_decode($LANG["document"][4]).'</b>');
1294
        
1295
        $i++;
1296
                
1297
        while ($data=$DB->fetch_assoc($result)) {
1298
                
1299
                $pdf->saveState();
1300
                $pdf->setColor(0.95,0.95,0.95);
1301
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),125,15);
1302
                $pdf->filledRectangle(155,($start_tab-25)-(20*$i),120,15);
1303
                $pdf->filledRectangle(280,($start_tab-25)-(20*$i),110,15);
1304
                $pdf->filledRectangle(395,($start_tab-25)-(20*$i),100,15);
1305
                $pdf->filledRectangle(500,($start_tab-25)-(20*$i),70,15);
1306
                $pdf->restoreState();
1307
                
1308
                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($data["name"]));
1309
                $pdf->addText(160,($start_tab-20)-(20*$i),9,utf8_decode($data["filename"]));
1310
                $pdf->addText(285,($start_tab-20)-(20*$i),9,utf8_decode($data["link"]));
1311
                $pdf->addText(400,($start_tab-20)-(20*$i),9,utf8_decode(plugin_pdf_getDropdownName("glpi_dropdown_rubdocs",$data["rubrique"])));
1312
                $pdf->addText(505,($start_tab-20)-(20*$i),9,utf8_decode($data["mime"]));
1313
                
1314
                $i++;
1315
                
1316
                if(($start_tab-20)-(20*$i)<50){
1317
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1318
                                $i=0;
1319
                                $start_tab = 750;
1320
                                }
1321
        }
1322
        }
1323
        else
1324
                {
1325
                if(($start_tab-20)-(20*$i)<50){
1326
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1327
                                $i=0;
1328
                                $start_tab = 750;
1329
                                }
1330
                $pdf->saveState();
1331
                $pdf->setColor(0.8,0.8,0.8);
1332
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1333
                $pdf->restoreState();
1334
                $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANGPDF["document"][1]).'</b>');
1335
                }
1336
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1337
        
1338
        $tab["start_tab"] = $start_tab;
1339
        $tab["pdf"] = $pdf;
1340
        
1341
        return $tab;
1342
}
1343

    
1344
function plugin_pdf_registry($tab,$width,$ID,$type){
1345
        
1346
        global $DB,$LANG;
1347
        
1348
        $start_tab = $tab["start_tab"];
1349
        $pdf = $tab["pdf"];
1350
        
1351
        $REGISTRY_HIVE=array("HKEY_CLASSES_ROOT",
1352
        "HKEY_CURRENT_USER",
1353
        "HKEY_LOCAL_MACHINE",
1354
        "HKEY_USERS",
1355
        "HKEY_CURRENT_CONFIG",
1356
        "HKEY_DYN_DATA");
1357
        
1358
        $query = "SELECT ID FROM glpi_registry WHERE computer_id='".$ID."'";
1359
        
1360
        $i=0;
1361
        
1362
        if ($result = $DB->query($query)) {
1363
                if ($DB->numrows($result)!=0) {
1364
                        
1365
                        $pdf->saveState();
1366
                        $pdf->setColor(0.8,0.8,0.8);
1367
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
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
                        $pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($DB->numrows($result)." ".$LANG["registry"][4]).' :</b>');
1374
                        $pdf->addText(65,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][6]).'</b>');
1375
                        $pdf->addText(215,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][1]).'</b>');
1376
                        $pdf->addText(345,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][2]).'</b>');
1377
                        $pdf->addText(490,$start_tab-20,9,'<b>'.utf8_decode($LANG["registry"][3]).'</b>');
1378
                        
1379
                        $i++;
1380
                        
1381
                        while ($regid=$DB->fetch_row($result)) {
1382
                                $reg = new Registry;
1383
                                $reg->getfromDB(current($regid));
1384
                                
1385
                                $pdf->saveState();
1386
                                $pdf->setColor(0.95,0.95,0.95);
1387
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),130,15);
1388
                                $pdf->filledRectangle(160,($start_tab-25)-(20*$i),130,15);
1389
                                $pdf->filledRectangle(295,($start_tab-25)-(20*$i),140,15);
1390
                                $pdf->filledRectangle(440,($start_tab-25)-(20*$i),130,15);
1391
                                $pdf->restoreState();
1392
                                                                                                        
1393
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_ocs_name"]));
1394
                                $pdf->addText(165,($start_tab-20)-(20*$i),9,utf8_decode($REGISTRY_HIVE[$reg->fields["registry_hive"]]));
1395
                                $pdf->addText(300,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_path"]));
1396
                                $pdf->addText(445,($start_tab-20)-(20*$i),9,utf8_decode($reg->fields["registry_value"]));
1397
                                
1398
                                $i++;
1399
                
1400
                                if(($start_tab-20)-(20*$i)<50){
1401
                                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1402
                                                $i=0;
1403
                                                $start_tab = 750;
1404
                                                }
1405
                        }
1406
                }
1407
                else
1408
                        {
1409
                        if(($start_tab-20)-(20*$i)<50){
1410
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1411
                                $i=0;
1412
                                $start_tab = 750;
1413
                                }
1414
                        $pdf->saveState();
1415
                        $pdf->setColor(0.8,0.8,0.8);
1416
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1417
                        $pdf->restoreState();
1418
                        $pdf->addText(230,$start_tab,9,'<b>'.utf8_decode($LANG["registry"][5]).'</b>');
1419
                        }
1420
        }
1421
        
1422
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1423
        
1424
        $tab["start_tab"] = $start_tab;
1425
        $tab["pdf"] = $pdf;
1426
        
1427
        return $tab;
1428
}
1429

    
1430
function plugin_pdf_ticket($tab,$width,$ID,$type){
1431
        
1432
        global $DB,$CFG_GLPI, $LANG;
1433
        
1434
        $start_tab = $tab["start_tab"];
1435
        $pdf = $tab["pdf"];
1436
        
1437
        $sort="glpi_tracking.date";
1438
        $order=getTrackingOrderPrefs($_SESSION["glpiID"]);
1439

    
1440
        $where = "(status = 'new' OR status= 'assign' OR status='plan' OR status='waiting')";        
1441

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

    
1444
        $result = $DB->query($query);
1445

    
1446
        $i = 0;
1447
        
1448
        $number = $DB->numrows($result);
1449

    
1450
        if ($number > 0)
1451
        {
1452
                $pdf->saveState();
1453
                $pdf->setColor(0.8,0.8,0.8);
1454
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1455
                $pdf->restoreState();
1456
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($number.' '.$LANG["job"][17].' '.$LANG["job"][16]).' :</b>');
1457

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

    
1538
function plugin_pdf_oldticket($tab,$width,$ID,$type){
1539
        
1540
        global $DB,$CFG_GLPI, $LANG;
1541
        
1542
        $start_tab = $tab["start_tab"];
1543
        $pdf = $tab["pdf"];
1544
        
1545
        $sort="glpi_tracking.date";
1546
        $order=getTrackingOrderPrefs($_SESSION["glpiID"]);
1547

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

    
1551
        $result = $DB->query($query);
1552

    
1553
        $i = 0;
1554
        
1555
        $number = $DB->numrows($result);
1556

    
1557
        if ($number > 0)
1558
        {
1559
                $pdf->saveState();
1560
                $pdf->setColor(0.8,0.8,0.8);
1561
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1562
                $pdf->restoreState();
1563
                $pdf->addText(240,$start_tab,9,'<b>'.utf8_decode($number.' '.$LANG["job"][18].' '.$LANG["job"][17].' '.$LANG["job"][16]).' :</b>');
1564

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

    
1645
function plugin_pdf_link($tab,$width,$ID,$type){
1646
        
1647
        global $DB,$LANG;
1648
        
1649
        $start_tab = $tab["start_tab"];
1650
        $pdf = $tab["pdf"];
1651
        
1652
        $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";
1653

    
1654
        $result=$DB->query($query);
1655
        
1656
        $pdf->ezSetMargins(100,0,200,0);
1657
        
1658
        $i=0;
1659
        
1660
        $ci=new CommonItem;
1661
        if ($DB->numrows($result)>0){
1662
                
1663
                $pdf->saveState();
1664
                $pdf->setColor(0.8,0.8,0.8);
1665
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1666
                $pdf->restoreState();
1667
                $pdf->addText(230,$start_tab,9,'<b>'.utf8_decode($LANG["title"][33]).'</b>');                
1668
                
1669
                while ($data=$DB->fetch_assoc($result)){
1670

    
1671
                        $pdf->saveState();
1672
                        $pdf->setColor(0.95,0.95,0.95);
1673
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1674
                        $pdf->restoreState();
1675
                        
1676
                        $name=$data["name"];
1677
                        if (empty($name))
1678
                                $name=$data["link"];
1679

    
1680
                        $link=$data["link"];
1681
                        $file=trim($data["data"]);
1682
                        if (empty($file)){
1683

    
1684
                                $ci->getFromDB($type,$ID);
1685
                                if (ereg("\[NAME\]",$link)){
1686
                                        $link=ereg_replace("\[NAME\]",$ci->getName(),$link);
1687
                                }
1688
                                if (ereg("\[ID\]",$link)){
1689
                                        $link=ereg_replace("\[ID\]",$ID,$link);
1690
                                }
1691

    
1692
                                if (ereg("\[SERIAL\]",$link)){
1693
                                        if ($tmp=$ci->getField('serial')){
1694
                                                $link=ereg_replace("\[SERIAL\]",$tmp,$link);
1695
                                        }
1696
                                }
1697
                                if (ereg("\[OTHERSERIAL\]",$link)){
1698
                                        if ($tmp=$ci->getField('otherserial')){
1699
                                                $link=ereg_replace("\[OTHERSERIAL\]",$tmp,$link);
1700
                                        }
1701
                                }
1702

    
1703
                                if (ereg("\[LOCATIONID\]",$link)){
1704
                                        if ($tmp=$ci->getField('location')){
1705
                                                $link=ereg_replace("\[LOCATIONID\]",$tmp,$link);
1706
                                        }
1707
                                }
1708

    
1709
                                if (ereg("\[LOCATION\]",$link)){
1710
                                        if ($tmp=$ci->getField('location')){
1711
                                                $link=ereg_replace("\[LOCATION\]",plugin_pdf_getDropdownName("glpi_dropdown_locations",$tmp),$link);
1712
                                        }
1713
                                }
1714
                                if (ereg("\[NETWORK\]",$link)){
1715
                                        if ($tmp=$ci->getField('network')){
1716
                                                $link=ereg_replace("\[NETWORK\]",plugin_pdf_getDropdownName("glpi_dropdown_network",$tmp),$link);
1717
                                        }
1718
                                }
1719
                                if (ereg("\[DOMAIN\]",$link)){
1720
                                        if ($tmp=$ci->getField('domain'))
1721
                                                $link=ereg_replace("\[DOMAIN\]",plugin_pdf_getDropdownName("glpi_dropdown_domain",$tmp),$link);
1722
                                }
1723
                                $ipmac=array();
1724
                                $j=0;
1725
                                if (ereg("\[IP\]",$link)||ereg("\[MAC\]",$link)){
1726
                                        $query2 = "SELECT ifaddr,ifmac FROM glpi_networking_ports WHERE (on_device = $ID AND device_type = ".$type.") ORDER BY logical_number";
1727
                                        $result2=$DB->query($query2);
1728
                                        if ($DB->numrows($result2)>0)
1729
                                                while ($data2=$DB->fetch_array($result2)){
1730
                                                        $ipmac[$j]['ifaddr']=$data2["ifaddr"];
1731
                                                        $ipmac[$j]['ifmac']=$data2["ifmac"];
1732
                                                        $j++;
1733
                                                }
1734
                                }
1735

    
1736
                                if (ereg("\[IP\]",$link)||ereg("\[MAC\]",$link)){
1737
                                        if (count($ipmac)>0){
1738
                                                foreach ($ipmac as $key => $val){
1739
                                                        $tmplink=$link;
1740
                                                        $tmplink=ereg_replace("\[IP\]",$val['ifaddr'],$tmplink);
1741
                                                        $tmplink=ereg_replace("\[MAC\]",$val['ifmac'],$tmplink);
1742
                                                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($tmplink));
1743
                                                }
1744
                                        }
1745
                                } else 
1746
                                        $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($name));
1747
                        } else {
1748
                                $link=$data['name'];                
1749
                                $ci->getFromDB($type,$ID);
1750

    
1751
                                if (ereg("\[NAME\]",$link)){
1752
                                        $link=ereg_replace("\[NAME\]",$ci->getName(),$link);
1753
                                }
1754

    
1755
                                if (ereg("\[ID\]",$link)){
1756
                                        $link=ereg_replace("\[ID\]",$_GET["ID"],$link);
1757
                                }
1758
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode($name));
1759
                        }
1760
                }
1761
                $i++;
1762
                        
1763
                if(($start_tab-20)-(20*$i)<50){
1764
                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1765
                        $i=0;
1766
                        $start_tab = 750;
1767
                        }
1768
        }
1769
        else
1770
                {
1771
                if(($start_tab-20)-(20*$i)<50){
1772
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1773
                                $i=0;
1774
                                $start_tab = 750;
1775
                                }
1776
                $pdf->saveState();
1777
                $pdf->setColor(0.8,0.8,0.8);
1778
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1779
                $pdf->restoreState();
1780
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANG["links"][7]).'</b>');
1781
                }
1782
        
1783
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1784
                
1785
        $tab["start_tab"] = $start_tab;
1786
        $tab["pdf"] = $pdf;
1787
        
1788
        return $tab;
1789
}
1790

    
1791
function plugin_pdf_note($tab,$width,$ID,$type){
1792
        
1793
        global $LANGPDF,$LANG;
1794
        
1795
        $start_tab = $tab["start_tab"];
1796
        $pdf = $tab["pdf"];
1797
        
1798
        $ci =new CommonItem;
1799
        $ci->getfromDB ($type,$ID);
1800
        
1801
        $length = strlen($ci->getField('notes'));
1802
        
1803
        $i=0;
1804
        
1805
        if($length>0)
1806
                {
1807
                        
1808
                $pdf->saveState();
1809
                $pdf->setColor(0.8,0.8,0.8);
1810
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1811
                $pdf->restoreState();
1812
                $pdf->addText(280,$start_tab,9,'<b>'.utf8_decode($LANG["title"][37]).'</b>');
1813
                        
1814
                $nbline = $length/140;
1815
                $temp=utf8_decode($ci->getField('notes'));
1816
                $i=$j=0;
1817
                while($j<$nbline)
1818
                        {
1819
                        $pdf->saveState();
1820
                        $pdf->setColor(0.95,0.95,0.95);
1821
                        if($j==0)
1822
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1823
                        else
1824
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,20);
1825
                        $pdf->restoreState();        
1826
                        
1827
                        $temp = $pdf->addTextWrap(40,($start_tab-20)-(20*$i),$width-80,9,$temp);
1828
                        $i++;
1829
                        $j++;
1830
                        
1831
                        if(($start_tab-20)-(20*$i)<50){
1832
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1833
                                $i=0;
1834
                                $start_tab = 750;
1835
                                }
1836
                        }
1837
                }
1838
        else
1839
                {
1840
                if(($start_tab-20)-(20*$i)<50){
1841
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1842
                                $i=0;
1843
                                $start_tab = 750;
1844
                                }
1845
                $pdf->saveState();
1846
                $pdf->setColor(0.8,0.8,0.8);
1847
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1848
                $pdf->restoreState();
1849
                $pdf->addText(260,$start_tab,9,'<b>'.utf8_decode($LANGPDF["note"][1]).'</b>');
1850
                }
1851
        
1852
        $start_tab = ($start_tab-20)-(20*$i) - 20;
1853
                
1854
        $tab["start_tab"] = $start_tab;
1855
        $tab["pdf"] = $pdf;
1856
        
1857
        return $tab;
1858
}
1859

    
1860
function plugin_pdf_reservation($tab,$width,$ID,$type){
1861
        
1862
        global $DB,$LANG,$CFG_GLPI;
1863
        
1864
        $start_tab = $tab["start_tab"];
1865
        $pdf = $tab["pdf"];
1866
        
1867
        $resaID=0;
1868
        
1869
        $i=0;
1870
        
1871
        $pdf->ezSetMargins(200,0,200,0);
1872

    
1873
        if ($resaID=isReservable($type,$ID))
1874
                {
1875
                $ri=new ReservationItem;
1876
                $ri->getFromDB($resaID);
1877

    
1878
                $now=$_SESSION["glpi_currenttime"];
1879
                $query = "SELECT * FROM glpi_reservation_resa WHERE end > '".$now."' AND id_item='$resaID' ORDER BY begin";
1880
                $result=$DB->query($query);
1881
                
1882
                $pdf->saveState();
1883
                $pdf->setColor(0.8,0.8,0.8);
1884
                $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
1885
                $pdf->restoreState();
1886
                $pdf->addText(245,$start_tab,9,'<b>'.utf8_decode($LANG["reservation"][35]).'</b>');
1887
                
1888
                if(($start_tab-20)-(20*$i)<50){
1889
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1890
                                        $i=0;
1891
                                        $start_tab = 750;
1892
                                        }
1893
                
1894
                if ($DB->numrows($result)==0)
1895
                        {        
1896
                        $pdf->saveState();
1897
                        $pdf->setColor(0.95,0.95,0.95);
1898
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1899
                        $pdf->restoreState();
1900
                        $pdf->addText(265,($start_tab-20)-(20*$i),9,utf8_decode($LANG["reservation"][37]));
1901
                        $i++;
1902
                        
1903
                        if(($start_tab-20)-(20*$i)<50){
1904
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1905
                                        $i=0;
1906
                                        $start_tab = 750;
1907
                                        }
1908
                        } 
1909
                else 
1910
                        {
1911
                        $pdf->saveState();
1912
                        $pdf->setColor(0.8,0.8,0.8);
1913
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1914
                        $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
1915
                        $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
1916
                        $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
1917
                        $pdf->restoreState();
1918

    
1919
                        $pdf->addText(45,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][8]).'</b>');
1920
                        $pdf->addText(150,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][9]).'</b>');
1921
                        $pdf->addText(280,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][31]).'</b>');
1922
                        $pdf->addText(435,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["common"][25]).'</b>');
1923
                        
1924
                        $i++;
1925
                        
1926
                        if(($start_tab-20)-(20*$i)<50){
1927
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1928
                                        $i=0;
1929
                                        $start_tab = 750;
1930
                                        }
1931
                        
1932
                        while ($data=$DB->fetch_assoc($result))
1933
                                {
1934
                                $pdf->saveState();
1935
                                $pdf->setColor(0.95,0.95,0.95);
1936
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1937
                                $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
1938
                                $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
1939
                                $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
1940
                                $pdf->restoreState();        
1941
                                
1942
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode(convDateTime($data["begin"])));
1943
                                $pdf->addText(125,($start_tab-20)-(20*$i),9,utf8_decode($data["end"]));
1944
                                $pdf->addText(220,($start_tab-20)-(20*$i),9,utf8_decode($data["id_user"]));
1945
                                $pdf->addText(365,($start_tab-20)-(20*$i),9,utf8_decode($data["comment"]));
1946
                                
1947
                                $i++;
1948
                                
1949
                                if(($start_tab-20)-(20*$i)<50){
1950
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1951
                                        $i=0;
1952
                                        $start_tab = 750;
1953
                                        }
1954
                                }
1955
                        }
1956
                
1957
                $i++;
1958
                
1959
                if(($start_tab-20)-(20*$i)<50){
1960
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1961
                                        $i=0;
1962
                                        $start_tab = 750;
1963
                }
1964
                
1965
                $query = "SELECT * FROM glpi_reservation_resa WHERE end <= '".$now."' AND id_item='$resaID' ORDER BY begin DESC";
1966
                $result=$DB->query($query);
1967

    
1968
                $pdf->saveState();
1969
                $pdf->setColor(0.8,0.8,0.8);
1970
                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1971
                $pdf->restoreState();
1972
                $pdf->addText(260,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][36]).'</b>');
1973

    
1974
                $i++;
1975
                
1976
                if(($start_tab-20)-(20*$i)<50){
1977
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
1978
                                        $i=0;
1979
                                        $start_tab = 750;
1980
                                        }
1981

    
1982
                if ($DB->numrows($result)==0)
1983
                        {        
1984
                        $pdf->saveState();
1985
                        $pdf->setColor(0.95,0.95,0.95);
1986
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),$width-50,15);
1987
                        $pdf->restoreState();
1988
                        $pdf->addText(265,$start_tab,9,utf8_decode($LANG["reservation"][37]));
1989
                        } 
1990
                else 
1991
                        {
1992
                        $pdf->saveState();
1993
                        $pdf->setColor(0.8,0.8,0.8);
1994
                        $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
1995
                        $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
1996
                        $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
1997
                        $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
1998
                        $pdf->restoreState();
1999

    
2000
                        $pdf->addText(45,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][8]).'</b>');
2001
                        $pdf->addText(150,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["search"][9]).'</b>');
2002
                        $pdf->addText(280,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["reservation"][31]).'</b>');
2003
                        $pdf->addText(435,($start_tab-20)-(20*$i),9,'<b>'.utf8_decode($LANG["common"][25]).'</b>');
2004
                        
2005
                        $i++;
2006
                        
2007
                        if(($start_tab-20)-(20*$i)<50){
2008
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2009
                                        $i=0;
2010
                                        $start_tab = 750;
2011
                                        }
2012
                        
2013
                        while ($data=$DB->fetch_assoc($result))
2014
                                {
2015
                                $pdf->saveState();
2016
                                $pdf->setColor(0.95,0.95,0.95);
2017
                                $pdf->filledRectangle(25,($start_tab-25)-(20*$i),90,15);
2018
                                $pdf->filledRectangle(120,($start_tab-25)-(20*$i),90,15);
2019
                                $pdf->filledRectangle(215,($start_tab-25)-(20*$i),140,15);
2020
                                $pdf->filledRectangle(360,($start_tab-25)-(20*$i),210,15);
2021
                                $pdf->restoreState();        
2022
                                
2023
                                $pdf->addText(30,($start_tab-20)-(20*$i),9,utf8_decode(convDateTime($data["begin"])));
2024
                                $pdf->addText(125,($start_tab-20)-(20*$i),9,utf8_decode($data["end"]));
2025
                                $pdf->addText(220,($start_tab-20)-(20*$i),9,utf8_decode($data["id_user"]));
2026
                                $pdf->addText(365,($start_tab-20)-(20*$i),9,utf8_decode($data["comment"]));
2027
                                
2028
                                $i++;
2029
                                
2030
                                if(($start_tab-20)-(20*$i)<50){
2031
                                        $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2032
                                        $i=0;
2033
                                        $start_tab = 750;
2034
                                        }
2035
                                }
2036
                        }
2037

    
2038
                } 
2039
        else
2040
                        {
2041
                        if(($start_tab-20)-(20*$i)<50){
2042
                                $pdf = plugin_pdf_newPage($pdf,$ID,$type);
2043
                                $i=0;
2044
                                $start_tab = 750;
2045
                                }
2046
                        $pdf->saveState();
2047
                        $pdf->setColor(0.8,0.8,0.8);
2048
                        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
2049
                        $pdf->restoreState();
2050
                        $pdf->addText(250,$start_tab,9,'<b>'.utf8_decode($LANG["reservation"][34]).'</b>');
2051
                        }
2052
                
2053
        $start_tab = ($start_tab-20)-(20*$i) - 20;
2054
                
2055
        $tab["start_tab"] = $start_tab;
2056
        $tab["pdf"] = $pdf;
2057
        
2058
        return $tab;        
2059
}
2060

    
2061
function plugin_pdf_history($tab,$width,$ID,$type){
2062
        
2063
        global $DB,$LANG;
2064
        
2065
        $start_tab = $tab["start_tab"];
2066
        $pdf = $tab["pdf"];
2067
        
2068
        $SEARCH_OPTION=getSearchOptions();
2069
        
2070
        $query="SELECT * FROM glpi_history WHERE FK_glpi_device='".$ID."' AND device_type='".$type."' ORDER BY  ID DESC;";
2071
        
2072
        $result = $DB->query($query);
2073
        $number = $DB->numrows($result);
2074
        
2075
        $pdf->saveState();
2076
        $pdf->setColor(0.8,0.8,0.8);
2077
        $pdf->filledRectangle(25,$start_tab-5,$width-50,15);
2078
        $pdf->restoreState();
2079
        $pdf->addText(280,$start_tab,9,'<b>'.utf8_decode($LANG["title"][38]).'</b>');
2080
        
2081
        $i=0;
2082
        
2083
        if($number!=0){
2084
        while ($data =$DB->fetch_array($result)){
2085
                $field="";
2086
                if($data["linked_action"]){
2087
                        switch ($data["linked_action"]){
2088

    
2089
                                case HISTORY_ADD_DEVICE :
2090
                                        $field = getDeviceTypeLabel($data["device_internal_type"]);
2091
                                        $change = $LANG["devices"][25]." ".$data[ "new_value"];        
2092
                                        break;
2093

    
2094
                                case HISTORY_UPDATE_DEVICE :
2095
                                        $field = getDeviceTypeLabel($data["device_internal_type"]);
2096
                                        $change = getDeviceSpecifityLabel($data["device_internal_type"]).$data[ "old_value"].$data[ "new_value"];        
2097
                                        break;
2098

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

    
2225
function plugin_pdf_newPage($pdf,$ID,$type){
2226
        $pdf->ezText("",1000);
2227
        $pdf->ezText("",9);
2228
        if($type!=-1)
2229
                $pdf = plugin_pdf_add_header($pdf,$ID,$type);
2230
        return $pdf;
2231
}
2232

    
2233
function plugin_pdf_general($type,$tab_id,$tab){
2234

    
2235
$pdf= new Cezpdf('a4','portrait');
2236
$width = $pdf->ez['pageWidth'];
2237
$pdf->openHere('Fit');
2238
$start_tab = 750;
2239
$tab_pdf = array("pdf"=>$pdf,"start_tab"=>$start_tab);
2240

    
2241
$nb_id = count($tab_id);
2242

    
2243
$tab_pdf = plugin_pdf_background($tab_pdf,$width);
2244

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

    
2353
/**
2354
 * Print out an HTML checkbox
2355
 * @param 
2356
 */
2357
function checkbox($myname,$label,$value,$checked=false)
2358
{
2359
        echo "<td><input type='checkbox' ".($checked==true?"checked='checked'":'')." name='$myname' value='$value'>".$label."</td>";
2360
}
2361

    
2362
?>
Redmine Appliance - Powered by TurnKey Linux