Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / computer.class.php @ b67d8923

Historique | Voir | Annoter | Télécharger (24,3 ko)

1
<?php
2
/*
3
 * @version $Id: computer.class.php 7763 2009-01-06 18:44:50Z moyo $
4
 -------------------------------------------------------------------------
5
 GLPI - Gestionnaire Libre de Parc Informatique
6
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
7

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

11
 LICENSE
12

13
 This file is part of GLPI.
14

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

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

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

    
31
// ----------------------------------------------------------------------
32
// Original Author of file:
33
// Purpose of file:
34
// ----------------------------------------------------------------------
35

    
36
if (!defined('GLPI_ROOT')){
37
        die("Sorry. You can't access directly to this file");
38
        }
39

    
40
/// Computer class
41
class Computer extends CommonDBTM {
42

    
43

    
44
        ///Device container - format $device = array(ID,"device type","ID in device table","specificity value")
45
        var $devices        = array();
46

    
47
        /**
48
         * Constructor
49
        **/
50
        function Computer () {
51
                $this->table="glpi_computers";
52
                $this->type=COMPUTER_TYPE;
53
                $this->dohistory=true;
54
        }
55

    
56
        function defineOnglets($withtemplate){
57
                global $LANG,$CFG_GLPI;
58

    
59
                $ong[1]=$LANG["title"][26];
60
                if (haveRight("software","r"))        {
61
                        $ong[2]=$LANG["Menu"][4];
62
                }
63
                if (haveRight("networking","r")||haveRight("printer","r")||haveRight("monitor","r")||haveRight("peripheral","r")||haveRight("phone","r")){        
64
                        $ong[3]=$LANG["title"][27];
65
                }
66
                if (haveRight("contract_infocom","r")){
67
                        $ong[4]=$LANG["Menu"][26];
68
                }
69
                if (haveRight("document","r")){
70
                        $ong[5]=$LANG["Menu"][27];
71
                }
72

    
73
                if(empty($withtemplate)){
74
                        if ($CFG_GLPI["ocs_mode"]){
75
                                $ong[14]=$LANG["title"][43];
76
                        }
77
                        if (haveRight("show_all_ticket","1")){
78
                                $ong[6]=$LANG["title"][28];
79
                        }
80
                        if (haveRight("link","r")){
81
                                $ong[7]=$LANG["title"][34];
82
                        }
83
                        if (haveRight("notes","r")){
84
                                $ong[10]=$LANG["title"][37];
85
                        }
86
                        if (haveRight("reservation_central","r")){
87
                                $ong[11]=$LANG["Menu"][17];
88
                        }
89
                                
90
                        $ong[12]=$LANG["title"][38];
91

    
92
                        if ($CFG_GLPI["ocs_mode"]&&(haveRight("sync_ocsng","w")||haveRight("computer","w"))){
93
                                $ong[13]=$LANG["Menu"][33];
94
                        }
95
                }        
96
                return $ong;
97
        }
98
        /**
99
         * Retrieve an item from the database with device associated
100
         *
101
         *@param $ID ID of the item to get
102
         *@return true if succeed else false
103
        **/
104
        function getFromDBwithDevices ($ID) {
105

    
106
                global $DB;
107

    
108
                if ($this->getFromDB($ID)){
109
                        $query = "SELECT count(*) AS NB, ID, device_type, FK_device, specificity FROM glpi_computer_device WHERE FK_computers = '$ID' GROUP BY device_type, FK_device, specificity ORDER BY device_type, ID";
110
                        if ($result = $DB->query($query)) {
111
                                if ($DB->numrows($result)>0) {
112
                                        $i = 0;
113
                                        while($data = $DB->fetch_array($result)) {
114
                                                $this->devices[$i] = array("compDevID"=>$data["ID"],"devType"=>$data["device_type"],"devID"=>$data["FK_device"],"specificity"=>$data["specificity"],"quantity"=>$data["NB"]);
115
                                                $i++;
116
                                        }
117
                                }
118
                                return true;
119
                        } 
120
                }
121
                return false;
122
        }
123

    
124
        function post_updateItem($input,$updates,$history=1) {
125
                global $DB,$LANG,$CFG_GLPI;
126
                
127
                // Manage changes for OCS if more than 1 element (date_mod)
128
                // Need dohistory==1 if dohistory==2 no locking fields
129
                if ($this->fields["ocs_import"]&&$history==1&&count($updates)>1){
130
                        mergeOcsArray($this->fields["ID"],$updates,"computer_update");
131
                }
132

    
133
                if (isset($input["_auto_update_ocs"])){
134
                        $query="UPDATE glpi_ocs_link SET auto_update='".$input["_auto_update_ocs"]."'         WHERE glpi_id='".$input["ID"]."'";
135
                        $DB->query($query);
136
                }
137

    
138
                for ($i=0; $i < count($updates); $i++) {
139

    
140
                        // Update contact of attached items
141
                        
142
                        if (($updates[$i]=="contact" ||$updates[$i]=="contact_num")&&$CFG_GLPI["autoupdate_link_contact"]){
143
                                $items=array(PRINTER_TYPE,MONITOR_TYPE,PERIPHERAL_TYPE,PHONE_TYPE);
144
                                $ci=new CommonItem();
145
                                $update_done=false;
146
                                $updates3[0]="contact";
147
                                $updates3[1]="contact_num";
148

    
149
                                foreach ($items as $t){
150
                                        $query = "SELECT * from glpi_connect_wire WHERE end2='".$this->fields["ID"]."' AND type='".$t."'";
151
                                        if ($result=$DB->query($query)) {
152
                                                $resultnum = $DB->numrows($result);
153
                                                if ($resultnum>0) {
154
                                                        for ($j=0; $j < $resultnum; $j++) {
155
                                                                $tID = $DB->result($result, $j, "end1");
156
                                                                $ci->getFromDB($t,$tID);
157
                                                                if (!$ci->getField('is_global')){
158
                                                                        if ($ci->getField('contact')!=$this->fields['contact']||$ci->getField('contact_num')!=$this->fields['contact_num']){
159
                                                                                $tmp["ID"]=$ci->getField('ID');
160
                                                                                $tmp['contact']=$this->fields['contact'];
161
                                                                                $tmp['contact_num']=$this->fields['contact_num'];
162
                                                                                $ci->obj->update($tmp);
163
                                                                                $update_done=true;
164
                                                                        }
165
                                                                }
166
                                                        }
167
                                                }
168
                                        }
169
                                }
170

    
171
                                if ($update_done) {
172
                                        addMessageAfterRedirect($LANG["computers"][49],true);
173
                                }
174

    
175
                        }
176

    
177
                        // Update users and groups of attached items
178
                        if (($updates[$i]=="FK_users" && $this->fields["FK_users"]!=0 && $CFG_GLPI["autoupdate_link_user"])||($updates[$i]=="FK_groups" && $this->fields["FK_groups"]!=0 && $CFG_GLPI["autoupdate_link_group"])){
179
                                $items=array(PRINTER_TYPE,MONITOR_TYPE,PERIPHERAL_TYPE,PHONE_TYPE);
180
                                $ci=new CommonItem();
181
                                $update_done=false;
182
                                $updates4[0]="FK_users";
183
                                $updates4[1]="FK_groups";
184

    
185
                                foreach ($items as $t){
186
                                        $query = "SELECT * from glpi_connect_wire WHERE end2='".$this->fields["ID"]."' AND type='".$t."'";
187

    
188
                                        if ($result=$DB->query($query)) {
189
                                                $resultnum = $DB->numrows($result);
190

    
191
                                                if ($resultnum>0) {
192
                                                        for ($j=0; $j < $resultnum; $j++) {
193
                                                                $tID = $DB->result($result, $j, "end1");
194

    
195
                                                                $ci->getFromDB($t,$tID);
196
                                                                if (!$ci->getField('is_global')){
197
                                                                        if ($ci->getField('FK_users')!=$this->fields["FK_users"]||$ci->getField('FK_groups')!=$this->fields["FK_groups"]){
198
                                                                                $tmp["ID"]=$ci->getField('ID');
199
                                                                                if ($CFG_GLPI["autoupdate_link_user"]){
200
                                                                                        $tmp["FK_users"]=$this->fields["FK_users"];
201
                                                                                }
202
                                                                                if ($CFG_GLPI["autoupdate_link_group"]){
203
                                                                                        $tmp["FK_groups"]=$this->fields["FK_groups"];
204
                                                                                }
205
                                                                                $ci->obj->update($tmp);
206
                                                                                $update_done=true;
207
                                                                        }
208
                                                                }
209
                                                        }
210
                                                }
211
                                        }
212
                                }
213
                                if ($update_done) {
214
                                        addMessageAfterRedirect($LANG["computers"][50],true);
215
                                }
216

    
217
                        }
218

    
219
                        // Update state of attached items
220
                        if ($updates[$i]=="state" && $CFG_GLPI["autoupdate_link_state"]<0){
221
                                $items=array(PRINTER_TYPE,MONITOR_TYPE,PERIPHERAL_TYPE,PHONE_TYPE);
222
                                $ci=new CommonItem();
223
                                $update_done=false;
224

    
225
                                foreach ($items as $t){
226
                                        $query = "SELECT * from glpi_connect_wire WHERE end2='".$this->fields["ID"]."' AND type='".$t."'";
227

    
228
                                        if ($result=$DB->query($query)) {
229
                                                $resultnum = $DB->numrows($result);
230

    
231
                                                if ($resultnum>0) {
232
                                                        for ($j=0; $j < $resultnum; $j++) {
233
                                                                $tID = $DB->result($result, $j, "end1");
234

    
235
                                                                $ci->getFromDB($t,$tID);
236
                                                                if (!$ci->getField('is_global')){
237
                                                                        if ($ci->getField('state')!=$this->fields["state"]){
238
                                                                                $tmp["ID"]=$ci->getField('ID');
239
                                                                                $tmp["state"]=$this->fields["state"];
240
                                                                                $ci->obj->update($tmp);
241
                                                                                $update_done=true;
242
                                                                        }
243
                                                                }
244
                                                        }
245
                                                }
246
                                        }
247
                                }
248
                                if ($update_done) {
249
                                        addMessageAfterRedirect($LANG["computers"][56],true);
250
                                }
251

    
252
                        }
253

    
254

    
255
                        // Update loction of attached items
256
                        if ($updates[$i]=="location" && $this->fields["location"]!=0 && $CFG_GLPI["autoupdate_link_location"]){
257
                                $items=array(PRINTER_TYPE,MONITOR_TYPE,PERIPHERAL_TYPE,PHONE_TYPE);
258
                                $ci=new CommonItem();
259
                                $update_done=false;
260
                                $updates2[0]="location";
261

    
262
                                foreach ($items as $t){
263
                                        $query = "SELECT * from glpi_connect_wire WHERE end2='".$this->fields["ID"]."' AND type='".$t."'";
264

    
265
                                        if ($result=$DB->query($query)) {
266
                                                $resultnum = $DB->numrows($result);
267

    
268
                                                if ($resultnum>0) {
269
                                                        for ($j=0; $j < $resultnum; $j++) {
270
                                                                $tID = $DB->result($result, $j, "end1");
271

    
272
                                                                $ci->getFromDB($t,$tID);
273
                                                                if (!$ci->getField('is_global')){
274
                                                                        if ($ci->getField('location')!=$this->fields["location"]){
275
                                                                                $tmp["ID"]=$ci->getField('ID');
276
                                                                                $tmp["location"]=$this->fields["location"];
277
                                                                                $ci->obj->update($tmp);
278
                                                                                $update_done=true;
279
                                                                        }
280
                                                                }
281
                                                        }
282
                                                }
283
                                        }
284
                                }
285
                                if ($update_done) {
286
                                        addMessageAfterRedirect($LANG["computers"][48],true);
287
                                }
288

    
289
                        }
290

    
291
                }
292

    
293

    
294

    
295
        }
296

    
297
        function prepareInputForAdd($input) {
298

    
299
                if (isset($input["ID"])&&$input["ID"]>0){
300
                        $input["_oldID"]=$input["ID"];
301
                }
302
                unset($input['ID']);
303
                unset($input['withtemplate']);
304

    
305
                return $input;
306
        }
307

    
308
        function post_addItem($newID,$input) {
309
                global $DB;
310

    
311
                // Manage add from template
312
                if (isset($input["_oldID"])){
313
                        // ADD Devices
314
                        $this->getFromDBwithDevices($input["_oldID"]);
315
                        foreach($this->devices as $key => $val) {
316
                                for ($i=0;$i<$val["quantity"];$i++){
317
                                        compdevice_add($newID,$val["devType"],$val["devID"],$val["specificity"],0);
318
                                }
319
                        }
320
        
321
                        // ADD Infocoms
322
                        $ic= new Infocom();
323
                        if ($ic->getFromDBforDevice(COMPUTER_TYPE,$input["_oldID"])){
324
                                $ic->fields["FK_device"]=$newID;
325
                                unset ($ic->fields["ID"]);
326
                                if (isset($ic->fields["num_immo"])) {
327
                                        $ic->fields["num_immo"] = autoName($ic->fields["num_immo"], "num_immo", 1, INFOCOM_TYPE,$input['FK_entities']);
328
                                }
329
                                $ic->addToDB();
330
                        }
331
        
332
                        // ADD software
333
                        $query="SELECT license from glpi_inst_software WHERE cID='".$input["_oldID"]."'";
334
                        $result=$DB->query($query);
335
                        if ($DB->numrows($result)>0){
336
                                while ($data=$DB->fetch_array($result))
337
                                        installSoftware($newID,$data['license']);
338
                        }
339
        
340
                        // ADD Contract                                
341
                        $query="SELECT FK_contract from glpi_contract_device WHERE FK_device='".$input["_oldID"]."' AND device_type='".COMPUTER_TYPE."';";
342
                        $result=$DB->query($query);
343
                        if ($DB->numrows($result)>0){
344
                                while ($data=$DB->fetch_array($result))
345
                                        addDeviceContract($data["FK_contract"],COMPUTER_TYPE,$newID);
346
                        }
347
        
348
                        // ADD Documents                        
349
                        $query="SELECT FK_doc from glpi_doc_device WHERE FK_device='".$input["_oldID"]."' AND device_type='".COMPUTER_TYPE."';";
350
                        $result=$DB->query($query);
351
                        if ($DB->numrows($result)>0){
352
                                while ($data=$DB->fetch_array($result))
353
                                        addDeviceDocument($data["FK_doc"],COMPUTER_TYPE,$newID);
354
                        }
355
        
356
                        // ADD Ports
357
                        $query="SELECT ID from glpi_networking_ports WHERE on_device='".$input["_oldID"]."' AND device_type='".COMPUTER_TYPE."';";
358
                        $result=$DB->query($query);
359
                        if ($DB->numrows($result)>0){
360
                                while ($data=$DB->fetch_array($result)){
361
                                        $np= new Netport();
362
                                        $np->getFromDB($data["ID"]);
363
                                        unset($np->fields["ID"]);
364
                                        unset($np->fields["ifaddr"]);
365
                                        unset($np->fields["ifmac"]);
366
                                        unset($np->fields["netpoint"]);
367
                                        $np->fields["on_device"]=$newID;
368
                                        $np->addToDB();
369
                                }
370
                        }
371
        
372
                        // Add connected devices
373
                        $query="SELECT * from glpi_connect_wire WHERE end2='".$input["_oldID"]."';";
374
        
375
                        $result=$DB->query($query);
376
                        if ($DB->numrows($result)>0){
377
                                while ($data=$DB->fetch_array($result)){
378
                                        Connect($data["end1"],$newID,$data["type"]);
379
                                }
380
                        }
381
                }
382

    
383
        }
384

    
385
        function cleanDBonPurge($ID) {
386
                global $DB,$CFG_GLPI;
387

    
388
                $job=new Job;
389

    
390
                $query = "SELECT * FROM glpi_tracking WHERE (computer = '$ID'  AND device_type='".COMPUTER_TYPE."')";
391
                $result = $DB->query($query);
392

    
393
                if ($DB->numrows($result))
394
                        while ($data=$DB->fetch_array($result)) {
395
                                if ($CFG_GLPI["keep_tracking_on_delete"]==1){
396
                                        $query = "UPDATE glpi_tracking SET computer = '0', device_type='0' WHERE ID='".$data["ID"]."';";
397
                                        $DB->query($query);
398
                                } else $job->delete(array("ID"=>$data["ID"]));
399
                        }
400

    
401
                $query = "DELETE FROM glpi_inst_software WHERE (cID = '$ID')";
402
                $result = $DB->query($query);                
403

    
404
                $query = "DELETE FROM glpi_contract_device WHERE (FK_device = '$ID' AND device_type='".COMPUTER_TYPE."')";
405
                $result = $DB->query($query);
406

    
407
                $query = "DELETE FROM glpi_infocoms WHERE (FK_device = '$ID' AND device_type='".COMPUTER_TYPE."')";
408
                $result = $DB->query($query);
409

    
410
                $query = "SELECT ID FROM glpi_networking_ports WHERE (on_device = '$ID' AND device_type = '".COMPUTER_TYPE."')";
411
                $result = $DB->query($query);
412
                while ($data = $DB->fetch_array($result)){
413
                        $q = "DELETE FROM glpi_networking_wire WHERE (end1 = '".$data["ID"]."' OR end2 = '".$data["ID"]."')";
414
                        $result2 = $DB->query($q);                                        
415
                }        
416

    
417
                $query = "DELETE FROM glpi_networking_ports WHERE (on_device = '$ID' AND device_type = '".COMPUTER_TYPE."')";
418
                $result = $DB->query($query);
419

    
420

    
421
                $query="SELECT * FROM glpi_connect_wire WHERE (end2='$ID')";
422
                if ($result = $DB->query($query)) {
423
                        if ($DB->numrows($result)>0) {
424
                                while ($data = $DB->fetch_array($result)){
425
                                        // Disconnect without auto actions
426
                                        Disconnect($data["ID"],1,false);
427
                                }
428
                        }
429
                }
430

    
431

    
432
                $query = "DELETE FROM glpi_registry WHERE (computer_id = '$ID')";
433
                $result = $DB->query($query);
434

    
435
                $query="select * from glpi_reservation_item where (device_type='".COMPUTER_TYPE."' and id_device='$ID')";
436
                if ($result = $DB->query($query)) {
437
                        if ($DB->numrows($result)>0) {
438
                                $rr=new ReservationItem();
439
                                $rr->delete(array("ID"=>$DB->result($result,0,"ID")));
440
                        }
441
                }
442

    
443
                $query = "DELETE FROM glpi_computer_device WHERE (FK_computers = '$ID')";
444
                $result = $DB->query($query);
445

    
446
                $query = "DELETE FROM glpi_ocs_link WHERE (glpi_id = '$ID')";
447
                $result = $DB->query($query);
448
        }
449

    
450
        /**
451
         * Print the computer form
452
         *
453
         * Print general computer form
454
         *
455
         *@param $target form target
456
         *@param $ID Integer : Id of the computer or the template to print
457
         *@param $withtemplate template or basic computer
458
         *
459
         *@return Nothing (display)
460
         *
461
         **/
462
        function showForm($target,$ID,$withtemplate='') {
463
                global $LANG,$CFG_GLPI,$DB;
464

    
465
                if (!haveRight("computer","r")) return false;
466

    
467
                $computer_spotted = false;
468
                $use_cache=true;
469
                if((empty($ID) && $withtemplate == 1)||$ID==-1) {
470
                        $use_cache=false;
471
                        if($this->getEmpty()) $computer_spotted = true;
472
                } else {
473
                        if($this->getFromDB($ID)&&haveAccessToEntity($this->fields["FK_entities"])) $computer_spotted = true;
474
                }
475
                
476
                if($computer_spotted) {
477

    
478
                        $this->showOnglets($ID, $withtemplate,$_SESSION['glpi_onglet']);
479

    
480
                        if(!empty($withtemplate) && $withtemplate == 2) {
481
                                $use_cache=false;
482
                                $template = "newcomp";
483
                                $datestring = $LANG["computers"][14].": ";
484
                                $date = convDateTime($_SESSION["glpi_currenttime"]);
485
                        } elseif(!empty($withtemplate) && $withtemplate == 1) { 
486
                                $use_cache=false;
487
                                $template = "newtemplate";
488
                                $datestring = $LANG["computers"][14].": ";
489
                                $date = convDateTime($_SESSION["glpi_currenttime"]);
490
                        } else {
491
                                $datestring = $LANG["common"][26].": ";
492
                                $date = convDateTime($this->fields["date_mod"]);
493
                                $template = false;
494
                        }
495

    
496
                        echo "<form name='form' method='post' action=\"$target\">";
497
                        if(strcmp($template,"newtemplate") === 0) {
498
                                echo "<input type=\"hidden\" name=\"is_template\" value=\"1\">";
499
                        }
500

    
501
                        echo "<input type='hidden' name='FK_entities' value='".$this->fields["FK_entities"]."'>";
502

    
503
                        echo "<div class='center'>";
504
                        echo "<table class='tab_cadre_fixe' >";
505

    
506

    
507
                        echo "<tr><th colspan ='2' align='center' >";
508
                        if(!$template) {
509
                                echo $LANG["common"][2]." ".$this->fields["ID"];
510
                        }elseif (strcmp($template,"newcomp") === 0) {
511
                                echo $LANG["computers"][12].": ".$this->fields["tplname"];
512
                                echo "<input type='hidden' name='tplname' value='".$this->fields["tplname"]."'>";
513
                        }elseif (strcmp($template,"newtemplate") === 0) {
514
                                echo $LANG["common"][6].": ";
515
                                autocompletionTextField("tplname","glpi_computers","tplname",$this->fields["tplname"],20,$this->fields["FK_entities"]);        
516
                        }
517
                        if (isMultiEntitiesMode()){
518
                                echo "&nbsp;(".getDropdownName("glpi_entities",$this->fields["FK_entities"]).")";
519
                        }
520

    
521
                        if (!$use_cache||!($CFG_GLPI["cache"]->start($ID."_".$_SESSION["glpilanguage"],"GLPI_".$this->type))) {
522

    
523
                                echo "</th><th  colspan ='2' align='center'>".$datestring.$date;
524
                                if (!$template&&!empty($this->fields['tplname']))
525
                                        echo "&nbsp;&nbsp;&nbsp;(".$LANG["common"][13].": ".$this->fields['tplname'].")";
526
                                if ($this->fields["ocs_import"])
527
                                        echo "&nbsp;&nbsp;&nbsp;(".$LANG["ocsng"][7].")";
528
        
529
                                echo "</th></tr>";
530

    
531

    
532
                                echo "<tr class='tab_bg_1'><td>".$LANG["common"][16].($template?"*":"").":                </td>";
533
        
534
                                echo "<td>";
535
        
536
                                $objectName = autoName($this->fields["name"], "name", ($template === "newcomp"), COMPUTER_TYPE,$this->fields["FK_entities"]);
537
                                autocompletionTextField("name","glpi_computers","name",$objectName,20,$this->fields["FK_entities"]);
538

    
539
                                echo "</td>";
540
        
541
                                echo "<td>".$LANG["common"][18].":        </td><td>";
542
                                autocompletionTextField("contact","glpi_computers","contact",$this->fields["contact"],20,$this->fields["FK_entities"]);
543
        
544
                                echo "</td></tr>";
545
        
546
                                echo "<tr class='tab_bg_1'>";
547
                                echo "<td >".$LANG["common"][17].":         </td>";
548
                                echo "<td >";
549
                                dropdownValue("glpi_type_computers", "type", $this->fields["type"]);
550
                                echo "</td>";
551
        
552
        
553
                                echo "<td>".$LANG["common"][21].":                </td><td>";
554
                                autocompletionTextField("contact_num","glpi_computers","contact_num",$this->fields["contact_num"],20,$this->fields["FK_entities"]);
555
                                echo "</td></tr>";
556
        
557
                                echo "<tr class='tab_bg_1'>";
558
                                echo "<td >".$LANG["common"][22].":         </td>";
559
                                echo "<td >";
560
                                dropdownValue("glpi_dropdown_model", "model", $this->fields["model"]);
561
                                echo "</td>";
562
                                
563
                                echo "<td >".$LANG["common"][34].":         </td>";
564
                                echo "<td >";
565
                                dropdownAllUsers("FK_users", $this->fields["FK_users"],1,$this->fields["FK_entities"]);
566
                                echo "</td></tr>";
567
        
568
                                echo "<tr class='tab_bg_1'>";
569
                                echo "<td >".$LANG["common"][15].":         </td>";
570
                                echo "<td >";
571
                                dropdownValue("glpi_dropdown_locations", "location", $this->fields["location"],1,$this->fields["FK_entities"]);
572
                                echo "</td>";
573
                                
574
                                echo "<td>".$LANG["common"][35].":</td><td>";
575
                                dropdownValue("glpi_groups", "FK_groups", $this->fields["FK_groups"],1,$this->fields["FK_entities"]);
576
                                echo "</td></tr>";
577
        
578
                                echo "<tr class='tab_bg_1'>";
579
                                echo "<td>".$LANG["common"][5].":         </td><td>";
580
                                dropdownValue("glpi_dropdown_manufacturer","FK_glpi_enterprise",$this->fields["FK_glpi_enterprise"]);
581
                                echo "</td>";
582
        
583
                                echo "<td >".$LANG["common"][10].":         </td>";
584
                                echo "<td >";
585
                                dropdownUsersID("tech_num",$this->fields["tech_num"],"interface",1,$this->fields["FK_entities"]);
586
                                echo "</td></tr>";
587
                                
588
                                echo "<tr class='tab_bg_1'>";
589
                                echo "<td>".$LANG["computers"][9].":</td><td>";
590
                                dropdownValue("glpi_dropdown_os", "os", $this->fields["os"]);
591
                                echo "</td>";
592
                                
593
                                echo "<td>".$LANG["setup"][88].":</td><td>";
594
                                dropdownValue("glpi_dropdown_network", "network", $this->fields["network"]);
595
                                echo "</td></tr>";
596
        
597
                                echo "<tr class='tab_bg_1'>";
598
                                echo "<td>".$LANG["computers"][52].":</td><td>";
599
                                dropdownValue("glpi_dropdown_os_version", "os_version", $this->fields["os_version"]);
600
                                echo "</td>";
601
        
602
        
603
                                echo "<td>".$LANG["setup"][89].":</td><td>";
604
                                dropdownValue("glpi_dropdown_domain", "domain", $this->fields["domain"]);
605
                                echo "</td></tr>";
606
        
607
        
608
                                echo "<tr class='tab_bg_1'>";
609
                                echo "<td>".$LANG["computers"][53].":</td><td>";
610
                                dropdownValue("glpi_dropdown_os_sp", "os_sp", $this->fields["os_sp"]);
611
                                echo "</td>";
612
        
613
                                echo "<td>".$LANG["common"][19].":        </td><td>";
614
                                autocompletionTextField("serial","glpi_computers","serial",$this->fields["serial"],20,$this->fields["FK_entities"]);
615
                                echo "</td></tr>";
616
        
617
                                echo "<tr class='tab_bg_1'>";
618
                                echo "<td>".$LANG["computers"][10]."</td><td>";
619
                                autocompletionTextField("os_license_number","glpi_computers","os_license_number",$this->fields["os_license_number"],35,$this->fields["FK_entities"]);
620
                                echo"</td>";
621
        
622
                                echo "<td>".$LANG["common"][20].($template?"*":"").":        </td><td>";
623
                                $objectName = autoName($this->fields["otherserial"], "otherserial", ($template === "newcomp"), COMPUTER_TYPE,$this->fields["FK_entities"]);
624
                                autocompletionTextField("otherserial","glpi_computers","otherserial",$objectName,20,$this->fields["FK_entities"]);
625

    
626
                                echo "</td></tr>";
627
        
628
                                echo "<tr class='tab_bg_1'>";
629
                                echo "<td>".$LANG["computers"][11]."</td><td>";
630
                                autocompletionTextField("os_license_id","glpi_computers","os_license_id",$this->fields["os_license_id"],35,$this->fields["FK_entities"]);
631
                                echo"</td>";
632
                                
633
                                echo "<td>".$LANG["state"][0].":</td><td>";
634
                                dropdownValue("glpi_dropdown_state", "state",$this->fields["state"]);
635
                                echo "</td>";
636

    
637
                                // Get OCS Datas :
638
                                $dataocs=array();
639
                                if (!empty($ID)&&$this->fields["ocs_import"]&&haveRight("view_ocsng","r")){
640
                                        $query="SELECT * 
641
                                                FROM glpi_ocs_link 
642
                                                WHERE glpi_id='$ID'";
643
        
644
                                        $result=$DB->query($query);
645
                                        if ($DB->numrows($result)==1){
646
                                                $dataocs=$DB->fetch_array($result);
647
                                        }
648

    
649
                                }
650

    
651
                                echo "<tr class='tab_bg_1'>";
652
                                if (!empty($ID)&&$this->fields["ocs_import"]&&haveRight("view_ocsng","r")&&haveRight("sync_ocsng","w")&&count($dataocs)){
653
                                        echo "<td >".$LANG["ocsng"][6]." ".$LANG["Menu"][33].":</td>";
654
                                        echo "<td >";
655
                                        dropdownYesNo("_auto_update_ocs",$dataocs["auto_update"]);
656
                                        echo "</td>";
657
                                } else        {
658
                                        echo "<td colspan=2></td>";
659
                                }
660
                                echo "<td>".$LANG["computers"][51].":</td><td>";
661
                                dropdownValue("glpi_dropdown_auto_update", "auto_update", $this->fields["auto_update"]);
662
                                echo "</td>";
663

    
664
                                echo "</tr>";
665
                                
666
                                echo "<tr class='tab_bg_1'>";
667
                                
668
                                if (!empty($ID)&&$this->fields["ocs_import"]&&haveRight("view_ocsng","r")&&count($dataocs)){
669
                                        echo "<td colspan='2' align='center'>";
670
                                        echo $LANG["ocsng"][14].": ".convDateTime($dataocs["last_ocs_update"]);
671
                                        echo "<br>";
672
                                        echo $LANG["ocsng"][13].": ".convDateTime($dataocs["last_update"]);
673
                                        echo "<br>";
674
                                        if (haveRight("ocsng","r")){
675
                                                echo $LANG["common"][52]." <a href='".$CFG_GLPI["root_doc"]."/front/ocsng.form.php?ID=".getOCSServerByMachineID($ID)."'>".getOCSServerNameByID($ID)."</a>";
676
                                                $query = "SELECT ocs_agent_version FROM glpi_ocs_link WHERE (glpi_id = '$ID')";
677
                                                $result_agent_version = $DB->query($query);
678
                                                $data_version = $DB->fetch_array($result_agent_version);
679
                                                if ($data_version["ocs_agent_version"] != NULL)
680
                                                        echo " , ".$LANG["ocsng"][49]." : ".$data_version["ocs_agent_version"];
681
                                        } else {
682
                                                echo $LANG["common"][52]." ".getOCSServerNameByID($ID);        
683
                                                echo "</td>";
684
                                        }
685
                                        
686
                                } else        {
687
                                        echo "<td colspan=2></td>";        
688
                                }
689
                                echo "<td valign='middle'>".$LANG["common"][25].":</td><td valign='middle'><textarea  cols='50' rows='3' name='comments' >".$this->fields["comments"]."</textarea></td>";
690
                                echo "</tr>";
691
                                if ($use_cache){
692
                                        $CFG_GLPI["cache"]->end();
693
                                }
694
                        }
695
                        
696

    
697
                        if (haveRight("computer","w")) {
698
                                echo "<tr>\n";
699
                                if ($template) {
700
                                        if (empty($ID)||$withtemplate==2){
701
                                                echo "<td class='tab_bg_2' align='center' colspan='4'>\n";
702
                                                echo "<input type='hidden' name='ID' value=$ID>";
703
                                                echo "<input type='submit' name='add' value=\"".$LANG["buttons"][8]."\" class='submit'>";
704
                                                echo "</td>\n";
705
                                        } else {
706
                                                echo "<td class='tab_bg_2' align='center' colspan='4'>\n";
707
                                                echo "<input type='hidden' name='ID' value=$ID>";
708
                                                echo "<input type='submit' name='update' value=\"".$LANG["buttons"][7]."\" class='submit'>";
709
                                                echo "</td>\n";
710
                                        }
711
                                } else {
712
                                        echo "<td class='tab_bg_2' colspan='2' align='center' valign='top'>\n";
713
                                        echo "<input type='submit' name='update' value=\"".$LANG["buttons"][7]."\" class='submit'>";
714
                                        echo "</td>\n";
715
                                        echo "<td class='tab_bg_2' colspan='2'  align='center'>\n";
716
                                        echo "<input type='hidden' name='ID' value=$ID>";
717
                                        echo "<div class='center'>";
718
                                        if (!$this->fields["deleted"]){
719
                                                echo "<input type='submit' name='delete' value=\"".$LANG["buttons"][6]."\" class='submit'>";
720
                                         }else {
721
                                                echo "<input type='submit' name='restore' value=\"".$LANG["buttons"][21]."\" class='submit'>";
722

    
723
                                                echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"".$LANG["buttons"][22]."\" class='submit'>";
724
                                        }
725
                                        echo "</div>";
726
                                        echo "</td>";
727
                                }
728
                                echo "</tr>\n";
729
                        }
730

    
731

    
732
                        echo "</table>";
733
                        echo "</div>";
734
                        echo "</form>";
735

    
736

    
737
                        return true;
738
                }
739
                else {
740
                        echo "<div class='center'><strong>".$LANG["common"][54]."</strong></div>";
741
                        return false;
742
                }
743
        }
744

    
745
}
746

    
747

    
748
?>
Redmine Appliance - Powered by TurnKey Linux