From d84912b9703faf3e479517ddd6e9152a7fb72ae6 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 6 Jan 2006 13:06:21 +0000 Subject: [PATCH] Now we can create/edit/assign monitors to a glpi acc git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2423 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_glpi.inc | 30 +++++- plugins/admin/systems/class_glpiAccount.inc | 6 +- .../systems/class_glpiDeviceManagement.inc | 53 +++++++++-- plugins/admin/systems/glpi_devices.tpl | 93 ++++++++++++++++++- 4 files changed, 169 insertions(+), 13 deletions(-) diff --git a/include/class_glpi.inc b/include/class_glpi.inc index 0cb4b0009..207a9c388 100644 --- a/include/class_glpi.inc +++ b/include/class_glpi.inc @@ -40,6 +40,7 @@ class glpiDB{ "glpi_device_power" => "power", "glpi_device_processor" => "processor", "glpi_device_ram" => "ram", + "glpi_monitors" => "monitor", "glpi_device_sndcard" => "sndcard"); $this->deviceMappingTableNameID = array( "moboard" => 1, @@ -726,7 +727,12 @@ class glpiDB{ $ret = $this->query($qry); foreach($ret as $id => $entry){ $entry['device_type'] = $gosa; - $res[$entry['designation']."-".$gosa] = $entry; + + if(isset($entry['designation'])){ + $res[$entry['designation']."-".$gosa] = $entry; + }else{ + $res[$entry['name']."-".$gosa] = $entry; + } } } return($res); @@ -762,6 +768,19 @@ class glpiDB{ if(count($res2)!=0){ $ret[$devtype][$res2[0]['designation']]=$res2[0]; } + + $qry = "SELECT * FROM glpi_connect_wire WHERE type=4 AND end2=".$computerID.";"; + $res2 = $this->query($qry); + foreach($res2 as $monitor){ + $qry = "SELECT * FROM glpi_monitors WHERE ID=".$monitor['end1'].";"; + $res3 = $this->query($qry); + foreach($res3 as $moni){ + $ret['monitor'][$moni['name']]=$moni; + } + } + + + } return($ret); }else{ @@ -787,8 +806,13 @@ class glpiDB{ foreach($devices as $type => $entries){ foreach($entries as $entry){ - $str = "INSERT INTO glpi_computer_device (device_type,FK_device,FK_computers) - VALUES (".$deviceMappingTableNameID[$type].",".$entry['ID'].",".$id.");"; + if($type=="monitor"){ + $str = "INSERT INTO glpi_connect_wire (end1,end2,type) + VALUES (".$entry['ID'].",".$id.",4);"; + }else{ + $str = "INSERT INTO glpi_computer_device (device_type,FK_device,FK_computers) + VALUES (".$deviceMappingTableNameID[$type].",".$entry['ID'].",".$id.");"; + } $this->query($str); } } diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc index f1e56d8f8..f07dd853e 100644 --- a/plugins/admin/systems/class_glpiAccount.inc +++ b/plugins/admin/systems/class_glpiAccount.inc @@ -515,7 +515,11 @@ class glpiAccount extends plugin $ret = array(); foreach($this->usedDevices as $type => $entries){ foreach($entries as $ent){ - $ret[] = $ent['designation']." [".$type."]"; + if(isset($ent['designation'])){ + $ret[] = $ent['designation']." [".$type."]"; + }else{ + $ret[] = $ent['name']." [".$type."]"; + } } } return($ret); diff --git a/plugins/admin/systems/class_glpiDeviceManagement.inc b/plugins/admin/systems/class_glpiDeviceManagement.inc index 5c4f223ea..126ac4ad3 100644 --- a/plugins/admin/systems/class_glpiDeviceManagement.inc +++ b/plugins/admin/systems/class_glpiDeviceManagement.inc @@ -51,8 +51,11 @@ class glpiDeviceManagement extends plugin $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default"); $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx"); $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default"); + $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size", + "flags_micro","flags_speaker","flags_subd","flags_bnc", + "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname"); - $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci"); + $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor"); } function execute() @@ -156,14 +159,25 @@ class glpiDeviceManagement extends plugin foreach($this->devices as $key=>$user){ - if(isset($this->Selected[$user['device_type']][$user['designation']])){ + if(isset($user['designation'])){ + $str = "designation"; + }else{ + $str = "name"; + } + + if(isset($this->Selected[$user['device_type']][$user[$str]])){ $use = " checked "; }else{ $use =""; } + /* Dawn databse struckture ....*/ + if(empty($user['comment'])) { + $user['comment'] = $user['comments']; + } + $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'"); - $field2 = array("string" => sprintf($edit,base64_encode($key),$user['designation']." [".$user['comment']."]"), "attach" => "style=''"); + $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''"); $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)), "attach" => "style='width:60px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3)); @@ -171,6 +185,8 @@ class glpiDeviceManagement extends plugin } $listhead = "
". + "  ". "  ". " $value){ + if(preg_match("/wasOnPage_/",$name)){ $dN = base64_decode($value); $device = $this->devices[$dN]; $type = $device['device_type']; + if(isset($device['designation'])){ + $str = "designation"; + }else{ + $str = "name"; + } if(isset($_POST['useDevice_'.$value])){ - $this->Selected[$type][$device['designation']] = $device; + $this->Selected[$type][$device[$str]] = $device; }else{ - if(isset($this->Selected[$type][$device['designation']])){ - unset($this->Selected[$type][$device['designation']]); + if(isset($this->Selected[$type][$device[$str]])){ + unset($this->Selected[$type][$device[$str]]); } } } @@ -278,14 +300,26 @@ class glpiDeviceManagement extends plugin function check($attr) { $message = array(); - if(empty($attr['designation'])){ + + if(isset($attr['designation'])){ + $str2 = "designation"; + }else{ + $str2 = "name"; + } + if(empty($attr[$str2])){ $message[]=(_("You have to specify a valid name for this device.")); } /* Avoid same name twice */ $devices = ($this->parent->handle->getDevices()); foreach($devices as $dev){ - if($dev['designation']==$attr['designation']){ + if(isset($dev['designation'])){ + $str = "designation"; + }else{ + $str = "name"; + } + + if($dev[$str]==$attr[$str2]){ /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */ if(isset($attr['ID'])){ @@ -337,6 +371,9 @@ class glpiDeviceManagement extends plugin $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer)); $smarty->assign("FK_glpi_enterprises", $manufacturer); + $smarty->assign("formats",array("Large","Medium","Micro")); + $smarty->assign("formats",array("Large","Medium","Micro")); + $smarty->assign("formats",array("Large","Medium","Micro")); $smarty->assign("formatKeys",array('Grand','Moyen','Micro')); return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE))); diff --git a/plugins/admin/systems/glpi_devices.tpl b/plugins/admin/systems/glpi_devices.tpl index 90c220368..55687e0d5 100644 --- a/plugins/admin/systems/glpi_devices.tpl +++ b/plugins/admin/systems/glpi_devices.tpl @@ -1,5 +1,96 @@ +{if $device_type=="monitor"} +

{t}Monitor{/t}

+ + + + + +
+ + + + + + + + + + + + + + + + + +
{t}Name{/t} + + +
{t}Comments{/t} + + +
{t}Manufacturer{/t} + + +
{t}Monitor size{/t} + + " +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
{t}Integrated microphone{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Integrated speakers{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Sub-D{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}BNC{/t} + + {t}Yes{/t} + {t}No{/t} +
{t}Serial number{/t} + + +
{t}Additional serial number{/t} + + +
+
+ -{if $device_type=="pci"} +{elseif $device_type=="pci"}

{t}Other devices{/t}

-- 2.30.2