Code

Now we can create/edit/assign monitors to a glpi acc
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 6 Jan 2006 13:06:21 +0000 (13:06 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 6 Jan 2006 13:06:21 +0000 (13:06 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2423 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_glpi.inc
plugins/admin/systems/class_glpiAccount.inc
plugins/admin/systems/class_glpiDeviceManagement.inc
plugins/admin/systems/glpi_devices.tpl

index 0cb4b00090dc68cf6b5db28e98475398668b5a49..207a9c388ed218d41faafe52f0d77bdf0b31ecf7 100644 (file)
@@ -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);
                                }
                        }
index f1e56d8f8bf3835a2a7961a7d9b039a8526df81b..f07dd853ef822b9e926b899dc3923de9eec320df 100644 (file)
@@ -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); 
index 5c4f223ea54d78101283e63eb9a47dda8e979fbe..126ac4ad3c0d79a9cb81f26092bb14af184c7cd0 100644 (file)
@@ -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']."&nbsp;[".$user['comment']."]"), "attach" => "style=''");
+      $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]."&nbsp;[".$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 = "<div style='background:#F0F0F9;padding:5px;'>".
+      " <input class='center' type='image' align='middle' 
+      src='images/monitor.png'  title='"._("New monitor")."' alt='"._("M")."' name='new_monitor'>&nbsp;".
       " <input class='center' type='image' align='middle' 
       src='images/keyboard.png' title='"._("New mainbord")."' alt='"._("MB")."' name='new_moboard'>&nbsp;".
       " <input class='center' type='image' align='middle' 
@@ -239,18 +255,24 @@ class glpiDeviceManagement extends plugin
   function save_object()
   {
     foreach($_POST as $name => $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)));
index 90c220368f06f8f47682fedc6682ab3c3b83886a..55687e0d5242f01b7be2ee4a86d9e984a03676c0 100644 (file)
@@ -1,5 +1,96 @@
+{if $device_type=="monitor"}
+       <h2>{t}Monitor{/t}</h2>
+       <table summary="" width="100%">
+               <tr>
+                       <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+                               <table summary="" width="100%">
+                                       <tr>
+                                               <td>{t}Name{/t}
+                                               </td>   
+                                               <td>    
+                                                       <input name="name" value="{$name}">
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td style="vertical-align:top;">{t}Comments{/t}
+                                               </td>   
+                                               <td>    
+                                                       <textarea name="comments">{$comments}</textarea>
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>{t}Manufacturer{/t}
+                                               </td>   
+                                               <td>    
+                                                       <select name="FK_glpi_enterprise">
+                                                               {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+                                                       </select>
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td style="vertical-align:top;">{t}Monitor size{/t}
+                                               </td>   
+                                               <td>    
+                                                       <input name="size" value="{$size}">"
+                                               </td>
+                                       </tr>
+                               </table>
+                       </td>
+                       <td>
+                               <table summary="" width="100%">
+                                       <tr>
+                        <td>{t}Integrated microphone{/t}
+                        </td>
+                        <td>
+                            <input type="radio" name="flags_micro" value="1" {if $flags_micro == "1"}checked {/if}>{t}Yes{/t}
+                            <input type="radio" name="flags_micro" value="0" {if ($flags_micro == "0")||($flags_micro=="")}checked {/if}>{t}No{/t}
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}Integrated speakers{/t}
+                        </td>
+                        <td>
+                            <input type="radio" name="flags_speaker" value="1" {if $flags_speaker == "1"}checked {/if}>{t}Yes{/t}
+                            <input type="radio" name="flags_speaker" value="0" {if ($flags_speaker == "0")||($flags_speaker=="")}checked {/if}>{t}No{/t}
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}Sub-D{/t}
+                        </td>
+                        <td>
+                            <input type="radio" name="flags_subd" value="1" {if $flags_subd == "1"}checked {/if}>{t}Yes{/t}
+                            <input type="radio" name="flags_subd" value="0" {if ($flags_subd == "0")||($flags_subd=="")}checked {/if}>{t}No{/t}
+                        </td>
+                    </tr>
+                    <tr>
+                        <td>{t}BNC{/t}
+                        </td>
+                        <td>
+                            <input type="radio" name="flags_bnc" value="1" {if $flags_bnc == "1"}checked {/if}>{t}Yes{/t}
+                            <input type="radio" name="flags_bnc" value="0" {if ($flags_bnc == "0")||($flags_bnc=="")}checked {/if}>{t}No{/t}
+                        </td>
+                    </tr>
+                                       <tr>
+                                               <td style="vertical-align:top;">{t}Serial number{/t}
+                                               </td>   
+                                               <td>    
+                                                       <input name="serial" value="{$serial}">
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td style="vertical-align:top;">{t}Additional serial number{/t}
+                                               </td>   
+                                               <td>    
+                                                       <input name="otherserial" value="{$otherserial}">
+                                               </td>
+                                       </tr>
+                               </table>
+                       </td>
+               </tr>
+       </table>
+
 
-{if $device_type=="pci"}
+{elseif $device_type=="pci"}
 
        <h2>{t}Other devices{/t}</h2>
        <table summary="" width="100%">