Code

glpi update
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Jan 2006 08:46:35 +0000 (08:46 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Jan 2006 08:46:35 +0000 (08:46 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2398 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_glpi.inc
plugins/admin/systems/class_glpiAccount.inc
plugins/admin/systems/class_glpiDeviceManagement.inc
plugins/admin/systems/class_glpiManufacturer.inc
plugins/admin/systems/glpi.tpl

index a779d7552ab9029111ff48a44ef7b9beaf781736..6c390cd43f1bd7571d445809b17135501547aeea 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+
 class glpiDB{
 
        var $user               ="";
@@ -12,6 +13,9 @@ class glpiDB{
 
        var $lasterror  ="";
 
+       var $deviceMappingGOsaGlpi;
+       var $deviceMappingTableNameID;
+
        function glpiDB($server,$user,$pwd,$db){
                $this->server   = $server;
                $this->user     = $user;
@@ -24,6 +28,34 @@ class glpiDB{
                        $this->is_connected = true;
                        $this->SelectDB($this->db);
                }       
+               $this->deviceMappingGOsaGlpi = array(
+                               "glpi_device_case"      => "case",
+                               "glpi_device_control"   => "control",
+                               "glpi_device_drive"     => "drive",
+                               "glpi_device_gfxcard"   => "gfxcard",
+                               "glpi_device_hdd"       => "hdd",
+                               "glpi_device_iface"     => "iface",
+                               "glpi_device_moboard"   => "moboard",
+                               "glpi_device_pci"       => "pci",
+                               "glpi_device_power"     => "power",
+                               "glpi_device_processor" => "processor",
+                               "glpi_device_ram"       => "ram",
+                               "glpi_device_sndcard"   => "sndcard");
+
+               $this->deviceMappingTableNameID = array(                "moboard"       => 1,                                                                           
+                               "processor"     => 2,                                                                           
+                               "ram"           => 3,                                                                           
+                               "hdd"           => 4,                                                                           
+                               "iface"         => 5,                                                                           
+                               "drive"         => 6,                                                                           
+                               "control"       => 7,                                                                           
+                               "gfxcard"       => 8,                                                                           
+                               "sndcard"       => 9,                                                                           
+                               "pci"           => 10,                                                                          
+                               "case"          => 11,                                                                          
+                               "power"         => 12);
+
+
        }
 
        function SelectDB()
@@ -33,12 +65,16 @@ class glpiDB{
                }
        }
 
+
+       /* This functions checks if the selected computer/network 
+          device is already available in the db
+        */
        function is_account($dn)
        {
                if(!$this->is_connected){
-            $this->lasterror ="Can't query anything, if we aren't connected.";
-            return(false);
-        }else{
+                       $this->lasterror ="Can't query anything, if we aren't connected.";
+                       return(false);
+               }else{
                        $qry = "SELECT * FROM glpi_computers WHERE name='".$dn."';";
                        $res = $this->query($qry);
                        if(count($res)==0){
@@ -49,6 +85,8 @@ class glpiDB{
                }
        }
 
+       /* this function queries everything 
+        */
        function query($qry)
        {
                if(!$this->is_connected){
@@ -65,7 +103,9 @@ class glpiDB{
                }
        }
 
-       /* System types */
+       /* System types 
+       Returns all defined system types 
+        */
        function getSystemTypes()
        {
                if($this->is_connected){
@@ -81,7 +121,9 @@ class glpiDB{
                }
        }
 
-       /* System types */
+       /* System types 
+          Update a system type         
+       */
        function updateSystemType($name,$id)
        {
 
@@ -99,7 +141,9 @@ class glpiDB{
                }
        }
 
-       /* System types */
+       /* System types 
+       Add one entry to the system types 
+     */
        function addSystemType($name)
        {
                if($this->is_connected){
@@ -116,8 +160,10 @@ class glpiDB{
                }
        }
 
-       /* System types */
-       function removeSystemType_byID($id)
+       /* System types 
+       Remove one entry from the system types (specified by ID=$id)
+     */
+       function removeSystemType($id)
        {
                if($this->is_connected){
                        $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
@@ -133,8 +179,10 @@ class glpiDB{
                }
        }
 
-       /* Manufacturer */      
-       function getEnterprisesTypes()
+       /* Manufacturer 
+          Returns all defined manufacturers
+       */      
+       function getEnterprises()
        {
                if($this->is_connected){
                        $ret = array();
@@ -149,7 +197,9 @@ class glpiDB{
                }
        }
 
-       /* Manufacturer */      
+       /* Manufacturer 
+          Returns single manufacturer
+       */      
        function getEnterprise($id)
        {
                if($this->is_connected){
@@ -162,8 +212,10 @@ class glpiDB{
                }
        }
 
-       /* System types */
-       function updateEnterprisesType($array,$id)
+       /* Manufacturer 
+       Updates already existing manufacturer
+    */
+       function updateEnterprise($array,$id)
        {
                if(!is_array($array)){
                        echo "updateEnterprisesType: first paraeter must be an array";
@@ -195,7 +247,10 @@ class glpiDB{
                }
        }
 
-       function addEnterprisesType($array)
+       /* Manufacturer
+          Add new manufacturer
+        */
+       function addEnterprise($array)
        {
                if(!is_array($array)){
                        echo "addUser: first paraeter must be an array";
@@ -225,9 +280,10 @@ class glpiDB{
 
        }
 
-
-
-       function removeEnterprisesType($id)
+       /*      Manufacturer
+               remove manufacturer
+        */
+       function removeEnterprise($id)
        {
                if($this->is_connected){
                        $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
@@ -243,8 +299,9 @@ class glpiDB{
                }
        }
 
-
-       /* Operating systems */
+       /* Operating systems 
+          Returns all OSs
+        */
        function getOSTypes()
        {
                if($this->is_connected){
@@ -263,8 +320,9 @@ class glpiDB{
                }
        }
 
-
-       /* os */
+       /*  Operating systems
+               Add a new operating system to the dropdown menus   
+        */
     function addOS($name)
     {
         if($this->is_connected){
@@ -281,7 +339,9 @@ class glpiDB{
         }
     }
 
-          /* System types */
+    /* Operating systems 
+       remove one OS entry
+     */
     function removeOS_byID($id)
     {
         if($this->is_connected){
@@ -298,9 +358,9 @@ class glpiDB{
         }
     }
 
-
-       
-       /* System types */
+       /* Operating systems 
+          Update existing OS entry
+       */
        function updateOS($name,$id)
        {
 
@@ -318,8 +378,8 @@ class glpiDB{
                }
        }
 
-
-       /* Technical / Responsible person / glpi users  */
+       /* This returns all available glpi users 
+     */
        function getUsers()
        {
                if($this->is_connected){
@@ -336,7 +396,8 @@ class glpiDB{
                }
        }
 
-       
+       /* this function adds a new glpi user
+     */
        function addUser($array,$dn)
        {
                if(!is_array($array)){
@@ -368,6 +429,9 @@ class glpiDB{
 
        }
 
+       /* This function updates a glpi user 
+       with the given data
+     */
        function updateUser($array,$dn)
        {
                if(!is_array($array)){
@@ -401,29 +465,12 @@ class glpiDB{
 
        }
 
-
+       /* This function returns all available data 
+       from a specified dn
+     */
        function getComputerInformations($name)
        {
                if($this->is_connected){        
-                       /*
-                       $ret                                                    = $this->query( '       
-                                       SELECT
-                                       c.ID,
-                                       c.name      as "Name",
-                                       c.comments  as "Commets",
-                                       d.name      as "OS",
-                                       e.name      as "Manufacturer",
-                                       dc.name     as "Type",
-                                       u.name      as "Technical responsible"
-                                       FROM
-                                       glpi_computers as c
-                                       left join   glpi_dropdown_os    as d    on (c.os                    = d.ID)
-                                       left join   glpi_enterprises    as e    on (c.FK_glpi_enterprise    = e.ID)
-                                       left join   glpi_type_computers as dc   on (c.type                  = dc.ID)
-                                       left join   glpi_users          as u    on (c.tech_num              = u.ID)
-
-                                       WHERE c.Name!="" AND c.ID='.$id.';');
-               */
                        $ret = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
                        return($ret);           
                }else{
@@ -432,6 +479,8 @@ class glpiDB{
                }
        }
 
+       /*  This fucntions updates an already existing entry 
+     */
        function updateComputerInformations($array,$name)
        {
                if(!is_array($array)){
@@ -467,6 +516,8 @@ class glpiDB{
 
        }
 
+       /* This function adds a new inventory device (computer phone etc)
+     */
        function addComputerInformations($array)
        {
                if(!is_array($array)){
@@ -499,21 +550,14 @@ class glpiDB{
 
        }
 
+       /* this functions checks if the given Device 
+     * already exists 
+     */
        function deviceExists($attr)
        {
+               $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
                if($this->is_connected){        
-                       $arr = array_flip(array(        "glpi_device_case"              => "case",
-                                               "glpi_device_control"   => "control",   
-                                               "glpi_device_drive"             => "drive",
-                                               "glpi_device_gfxcard"   => "gfxcard",   
-                                               "glpi_device_hdd"               => "hdd",               
-                                               "glpi_device_iface"             => "iface",
-                                               "glpi_device_moboard"   => "moboard",
-                                               "glpi_device_pci"               => "pci",
-                                               "glpi_device_power"             => "power",
-                                               "glpi_device_processor" => "processor",
-                                               "glpi_device_ram"               => "ram",
-                                               "glpi_device_sndcard"   => "sndcard"));
+                       $arr = array_flip($deviceMappingGOsaGlpi);
 
                        $tbl_name = $arr[$attr['device_type']];
                        if(!isset($attr['ID'])){
@@ -533,21 +577,14 @@ class glpiDB{
                return(false);
        }
 
+       /* This functions deletes a specified entry 
+     * from our device tables 
+     */
        function deleteDevice($attr)
        {
+               $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
                if($this->is_connected){
-                       $arr = array_flip(array(        "glpi_device_case"              => "case",
-                                               "glpi_device_control"   => "control",   
-                                               "glpi_device_drive"             => "drive",
-                                               "glpi_device_gfxcard"   => "gfxcard",   
-                                               "glpi_device_hdd"               => "hdd",               
-                                               "glpi_device_iface"             => "iface",
-                                               "glpi_device_moboard"   => "moboard",
-                                               "glpi_device_pci"               => "pci",
-                                               "glpi_device_power"             => "power",
-                                               "glpi_device_processor" => "processor",
-                                               "glpi_device_ram"               => "ram",
-                                               "glpi_device_sndcard"   => "sndcard"));
+                       $arr = array_flip($deviceMappingGOsaGlpi);
                        
                        $device_type = $attr['device_type'];
                        unset($attr['device_type']);                    
@@ -560,21 +597,14 @@ class glpiDB{
                        return(false);
                }
        }
+
+       /* This funtions updated an already existing device
+     */
        function updateDevices($attr)
        {
+               $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
                if($this->is_connected){
-                       $arr = array_flip(array(        "glpi_device_case"              => "case",
-                                               "glpi_device_control"   => "control",   
-                                               "glpi_device_drive"             => "drive",
-                                               "glpi_device_gfxcard"   => "gfxcard",   
-                                               "glpi_device_hdd"               => "hdd",               
-                                               "glpi_device_iface"             => "iface",
-                                               "glpi_device_moboard"   => "moboard",
-                                               "glpi_device_pci"               => "pci",
-                                               "glpi_device_power"             => "power",
-                                               "glpi_device_processor" => "processor",
-                                               "glpi_device_ram"               => "ram",
-                                               "glpi_device_sndcard"   => "sndcard"));
+                       $arr = array_flip($deviceMappingGOsaGlpi);
                        
                        $device_type = $attr['device_type'];
                        unset($attr['device_type']);                    
@@ -594,6 +624,9 @@ class glpiDB{
                }
        }
 
+       /* Returns all possible RAM types 
+     * like SDRAM , DIMM .....
+     */
        function getRAMTypes()
        {
                if($this->is_connected){
@@ -609,7 +642,9 @@ class glpiDB{
                }
        }
        
-
+       /* Returns all possible HDD connection types 
+     * like IDE SCSI ...
+     */
        function getGlpiDeviceControlTypes()
        {
                if($this->is_connected){
@@ -625,6 +660,9 @@ class glpiDB{
                }
        }
        
+       /* Returns all possible gfx card connection types
+     * like PCI-X PCI AGP ....
+        */
        function getGlpiGfxControlTypes()
        {
                if($this->is_connected){
@@ -640,22 +678,14 @@ class glpiDB{
                }
        }
        
-       
+       /* Devices 
+       Adds a new single device to our db
+    */ 
        function addDevice($attr)
        {
+               $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
                if($this->is_connected){        
-                       $arr = array_flip(array(        "glpi_device_case"              => "case",
-                                               "glpi_device_control"   => "control",   
-                                               "glpi_device_drive"             => "drive",
-                                               "glpi_device_gfxcard"   => "gfxcard",   
-                                               "glpi_device_hdd"               => "hdd",               
-                                               "glpi_device_iface"             => "iface",
-                                               "glpi_device_moboard"   => "moboard",
-                                               "glpi_device_pci"               => "pci",
-                                               "glpi_device_power"             => "power",
-                                               "glpi_device_processor" => "processor",
-                                               "glpi_device_ram"               => "ram",
-                                               "glpi_device_sndcard"   => "sndcard"));
+                       $arr = array_flip($deviceMappingGOsaGlpi);
                        
                        $device_type = $attr['device_type'];
                        unset($attr['device_type']);                    
@@ -682,21 +712,13 @@ class glpiDB{
         }
        }
 
+       /* Return all available devices 
+     */
        function getDevices()
        {
+               $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
                if($this->is_connected){
-                       $arr = array(   "glpi_device_case"              => "case",
-                                                       "glpi_device_control"   => "control",   
-                                                       "glpi_device_drive"             => "drive",
-                                                       "glpi_device_gfxcard"   => "gfxcard",   
-                                                       "glpi_device_hdd"               => "hdd",               
-                                                       "glpi_device_iface"             => "iface",
-                                                       "glpi_device_moboard"   => "moboard",
-                                                       "glpi_device_pci"               => "pci",
-                                                       "glpi_device_power"             => "power",
-                                                       "glpi_device_processor" => "processor",
-                                                       "glpi_device_ram"               => "ram",
-                                                       "glpi_device_sndcard"   => "sndcard");
+                       $arr = $deviceMappingGOsaGlpi; 
                
                        $res = array();
                        foreach($arr as $glpi => $gosa){
@@ -714,6 +736,71 @@ class glpiDB{
                }
        }
 
+       /* This function returns all used devices 
+     */
+       function getUsedDevices($computerID)
+       {
+               $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
+               $deviceMappingTableNameID       = $this->deviceMappingTableNameID;
+       
+               if($this->is_connected){
+                       $qry = "SELECT * FROM glpi_computer_device WHERE FK_computers=".$computerID.";";
+                       $res = $this->query($qry);
+               
+                       $ret = array();
+                       foreach($deviceMappingGOsaGlpi as $GOsa => $glpi){
+                               $ret[$GOsa] = array();
+                       }
+
+                       $tbls = array_flip($deviceMappingTableNameID);
+
+                       foreach($res as $device){
+                               $devtype = $tbls[$device['device_type']];
+                               $tbl_name = $deviceMappingGOsaGlpi[$devtype];
+                               $qry = ("SELECT * FROM ".$tbl_name." WHERE ID=".$device['FK_device'].";");
+                               $res2 = $this->query($qry);
+                               if(count($res2)!=0){
+                                       $ret[$devtype][$res2[0]['designation']]=$res2[0];
+                               }
+                       }
+                       return($ret);
+               }else{
+                       echo "not connected";
+                       return(false);
+               }
+       }
+
+       /* This function removes all given devices from a computer, specified by $id
+       In the next step all devices specified by devices will be added.
+        */
+       function addDevicesToComputer($devices, $id)
+       {
+               $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
+               $deviceMappingTableNameID       = $this->deviceMappingTableNameID;
+       
+               if(($id == "" )||(!is_numeric($id))){
+                       return (false); 
+               }
+               if($this->is_connected){
+                       $qry = "DELETE FROM glpi_computer_device WHERE FK_computers=".$id.";";
+                       $this->query($qry);     
+               
+                       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.");";
+                                       $this->query($str);
+                               }
+                       }
+               
+
+               }else{
+                       echo "not connected";
+                       return(false);
+               }
+
+       }
+
        function removeComputerInformations($id)
        {
 /*             
index a24c3382af4e34bb89133b346fb79e2532574d01..bd0e0eb4027428c63dc36a3af350e790702ac8cc 100644 (file)
@@ -10,12 +10,13 @@ class glpiAccount extends plugin
   /* attribute list for save action */
   var $ignore_account= TRUE;
   var $attributes= array("ID","name","contact",
-      "tech_num","comments","date_mod","os","location","domain","network",
+      "tech_num","comments","date_mod","os","location","domain","network","contact_num",
       "model","type","is_template","FK_glpi_enterprise","deleted");
 
   var $ID                 ;
   var $name               ="";
   var $contact            ="";
+  var $contact_num        ="";
 
   var $tech_num           ="";
   var $comments           ="";
@@ -46,6 +47,9 @@ class glpiAccount extends plugin
 
   var $orig_dn;
   var $ui;
+  
+  var $usedDevices = array();
+
 
   /* Contructor 
      Sets default values and checks if we already have an existing glpi account
@@ -78,6 +82,7 @@ class glpiAccount extends plugin
       foreach(array("tech_num","os","FK_glpi_enterprise","type","comments") as $attr){
         $this->$attr = $tmp[0][$attr];
       }
+      $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']);
 
     }else{
       $this->is_account = false;
@@ -97,9 +102,37 @@ class glpiAccount extends plugin
     $smarty= get_smarty();
     $display= "";
 
-    // #fixme
-    // Check if mysql a.s.o. is available.
+    /* Assign smarty defaults */ 
+    foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
+                  "OSs","TechnicalResponsibles","InstalledDevices","Attachments",
+                  "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
+      $smarty->assign($attr,array());
+      $smarty->assign($attr."ACL"," disabled ");
+    }
+
+    foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num") as $attr){
+      $smarty->assign($attr,"");
+      $smarty->assign($attr."ACL"," disabled ");
+    }
+
+    if(!isset($this->config->data['SERVERS']['GLPI'])){
+      print_red(_("There is no server with valid glpi database service."));
+      return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+    }
+
+    $this->data = $this->config->data['SERVERS']['GLPI'];
+
+    if(!is_callable("mysql_connect")){
+      print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
+      return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+    }
+
+    $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
 
+    if(!$this->handle->is_connected){
+      print_red(_("Can't connect to glpi database, check configuration twice."));
+      return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+    } 
 
     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
     $users = ($this->handle->getUsers());
@@ -108,13 +141,13 @@ class glpiAccount extends plugin
 
     if(isset($_POST['AddDevice'])){
       $this->dialog =true;
-      $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn);
+      $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
     }
 
     /* We have selected some devices and pressed use button */
     if(isset($_POST['SelectDeviceSave'])){
       $this->cur_dialog->save_object();
-      print_a($this->cur_dialog->getSelected());
+      $this->usedDevices= ($this->cur_dialog->getSelected());
       $this->cur_dialog = false;
       $this->dialog = false;
       $this->edit_type=false;
@@ -144,7 +177,7 @@ class glpiAccount extends plugin
     }
 
     if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
-      $this->handle->removeSystemType_byID($_POST['select_type']);  
+      $this->handle->removeSystemType($_POST['select_type']);  
     }
 
     if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))&&(!empty($_POST['type_string']))){
@@ -266,12 +299,12 @@ class glpiAccount extends plugin
     /* Assign smarty defaults */ 
     foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
       $smarty->assign($attr,array());
-      $smarty->assign($attr."ACL"," disabled ");
+      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
     }
 
     foreach(array("type","FK_glpi_enterprise","os","tech_num") as $attr){
       $smarty->assign($attr,"");
-      $smarty->assign($attr."ACL"," disabled ");
+      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
     }
 
     /* Perform some checks
@@ -328,8 +361,12 @@ class glpiAccount extends plugin
     $smarty->assign("OSs",                    $this->handle->getOSTypes());
     $smarty->assign("os",                     $this->os);
 
-    $smarty->assign("ManufacturerKeys",       array_flip($this->handle->getEnterprisesTypes()));
-    $smarty->assign("Manufacturers",          $this->handle->getEnterprisesTypes());
+    $smarty->assign("InstalledDevices"        ,$this->getDevices());
+    $smarty->assign("InstalledDeviceKeys"     ,array_flip($this->getDevices()));
+
+
+    $smarty->assign("ManufacturerKeys",       array_flip($this->handle->getEnterprises()));
+    $smarty->assign("Manufacturers",          $this->handle->getEnterprises());
     $smarty->assign("FK_glpi_enterprise",     $this->FK_glpi_enterprise);
 
     if(isset($users[$this->tech_num])){
@@ -362,6 +399,16 @@ class glpiAccount extends plugin
   {
   }
 
+  function getDevices(){
+    $ret = array();
+    foreach($this->usedDevices as $type => $entries){
+      foreach($entries as $ent){
+        $ret[] = $ent['designation']." [".$type."]";
+      }
+    }
+    return($ret); 
+  }
+
 
   /* Save data to object */
   function save_object()
@@ -390,18 +437,22 @@ class glpiAccount extends plugin
   /* Save to LDAP */
   function save()
   {
-    $attrs = array();
-    $this->date_mod = date("Y-m-d H:i:s");
-    foreach($this->attributes as $attr){
-      $attrs[$attr] = $this->$attr;
-    }
-    $attrs['name'] = $this->dn;
-    unset($attrs['ID']);
-    $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-    if($this->initialy_was_account&&$this->is_account){
-      $this->handle->updateComputerInformations($attrs,$this->dn);
-    }elseif($this->is_account){
-      $this->handle->addComputerInformations($attrs,$this->dn);
+    if($this->is_account){
+        $attrs = array();
+      $this->date_mod = date("Y-m-d H:i:s");
+      foreach($this->attributes as $attr){
+        $attrs[$attr] = $this->$attr;
+      }
+      $attrs['name'] = $this->dn;
+      unset($attrs['ID']);
+      $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+      if($this->initialy_was_account&&$this->is_account){
+        $this->handle->updateComputerInformations($attrs,$this->dn);
+      }elseif($this->is_account){
+        $this->handle->addComputerInformations($attrs,$this->dn);
+      }
+      $tmp = ($this->handle->getComputerInformations($this->dn));
+      $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
     }
   }
 
index f235666999e74839ff1b429fcc41e496f19e6031..79c628ba57da2f21f5e70ceb0637ce377088be4e 100644 (file)
@@ -24,7 +24,7 @@ class glpiDeviceManagement extends plugin
 
   var $Selected = array();
 
-  function glpiDeviceManagement ($config, $dn= NULL)
+  function glpiDeviceManagement ($config, $dn= NULL,$used=NULL)
   {
     plugin::plugin ($config, $dn);
 
@@ -33,6 +33,10 @@ class glpiDeviceManagement extends plugin
       $_SESSION['glpiDeviceRegex'] = $tmp;
     }
     $this->ui = get_userinfo();  
+
+    if(isset($used)){
+    $this->Selected = $used;
+    }
  
     /* Specify which vars are allowed for a sepcific type of device */ 
     $this->DeviceAttrs['case']      = array("designation","format","comment","FK_glpi_enterprise");
@@ -53,6 +57,7 @@ class glpiDeviceManagement extends plugin
 
   function execute()
   {
+    print_a($this->Selected);
     /* Call parent execute */
     plugin::execute();
 
@@ -313,7 +318,7 @@ class glpiDeviceManagement extends plugin
     $smarty->assign("device_type",$entry['device_type']);
 
     $none = array(0 => _("none"));
-    $manufacturer = array_merge($none,$this->parent->handle->getEnterprisesTypes());
+    $manufacturer = array_merge($none,$this->parent->handle->getEnterprises());
 
     $ramtypes = $this->parent->handle->getRAMTypes();
 
index aeedaa4d2ddc07d2098f576214f4c810be8b8359..a29a601c751f9fa6e62ec4d7e31b338700d8ee39 100644 (file)
@@ -40,7 +40,7 @@ class glpiManufacturer extends plugin
     $display = "";
 
     if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
-      $this->parent->handle->removeEnterprisesType($_POST['manufacturer']);
+      $this->parent->handle->removeEnterprise($_POST['manufacturer']);
     }
 
     if(isset($_POST['add_manu'])){
@@ -86,10 +86,10 @@ class glpiManufacturer extends plugin
 
       if($allok){
         if($this->Edit_Add == "add"){
-          $this->parent->handle->addEnterprisesType($tmp);
+          $this->parent->handle->addEnterprise($tmp);
           $this->editMode=false;
         }else{
-          $this->parent->handle->updateEnterprisesType($tmp,$this->ID);
+          $this->parent->handle->updateEnterprise($tmp,$this->ID);
           $this->editMode=false;
         }
       }
@@ -106,8 +106,8 @@ class glpiManufacturer extends plugin
     }
 
 
-    $smarty->assign("Manus",    $this->parent->handle->getEnterprisesTypes());
-    $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprisesTypes()));
+    $smarty->assign("Manus",    $this->parent->handle->getEnterprises());
+    $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
     $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
     return($display);
   }
index fca7e980899f2f540dc4eec91b9b53a79ade0d75..2f960e09b75a4cde2c3a94991b80c9795a963681 100644 (file)
@@ -12,7 +12,7 @@
                                                <select name="type" {$typeACL}>
                                                        {html_options values=$SystemTypeKeys output=$SystemTypes selected=$type}
                                                </select>
-                                               <input type="submit" value="{t}edit{/t}" name="edit_type">      
+                                               <input type="submit" value="{t}edit{/t}" name="edit_type" {$typeACL}>   
                                        </td>
                                </tr>
                                <tr>
@@ -22,7 +22,7 @@
                                                <select name="os" {$osACL}>
                                                        {html_options values=$OSKeys output=$OSs selected=$os}
                                                </select>       
-                                               <input type="submit" value="{t}edit{/t}" name="edit_os"       
+                                               <input type="submit" value="{t}edit{/t}" name="edit_os" {$osACL}>       
                                        </td>
                                </tr>
                                <tr>
                                                <select name="FK_glpi_enterprise" {$FK_glpi_enterpriseACL}>
                                                        {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
                                                </select>       
-                                               <input type="submit" value="{t}edit{/t}" name="edit_manufacturer"     
+                                               <input type="submit" value="{t}edit{/t}" name="edit_manufacturer" {$FK_glpi_enterpriseACL}>     
                                        </td>
                                </tr>
                                <tr>
                                        <td>{t}Technical responsible{/t}&nbsp;
                                        </td>
                                        <td>
-                                               <i>{$tech_num}</i>&nbsp;<input type="submit" value="{t}Choose{/t}" name="SelectTechPerson">
+                                               <i>{$tech_num}&nbsp; </i>&nbsp;
+                                               <input type="submit" value="{t}Choose{/t}" name="SelectTechPerson" {$tech_numACL}>
                                        </td>
                                </tr>
                        </table>
@@ -49,9 +50,9 @@
                                <tr>
                                        <td>
                                                <select name="InstalledDevices" {$InstalledDevicesACL} style="height:120px;width:100%;" multiple>
-                                                       {html_options values=$InstalledDevices output=$InstalledDevices}
+                                                       {html_options values=$InstalledDeviceKeys output=$InstalledDevices}
                                                </select>
-                                               <input name="AddDevice" value="{t}Add{/t}" type="submit">       
+                                               <input name="AddDevice" value="{t}Edit{/t}" type="submit" {$InstalledDevicesACL}>       
                                        </td>
                                </tr>
                        </table>
@@ -69,7 +70,8 @@
                                                {t}Contact person{/t}
                                        </td>
                                        <td>
-                                               contact person sdasd <input type="submit" value="{t}Edit{/t}"><img src="images/mailto.png" class="center" alt="{t}mailto{/t}">  
+                                               <i>{$contact_num}&nbsp; </i>&nbsp;
+                                               <input {$contact_numACL} type="submit" value="{t}Edit{/t}"><img src="images/mailto.png" class="center" alt="{t}mailto{/t}">     
                                        </td>
                                </tr>
                                <tr>
@@ -77,7 +79,7 @@
                                                {t}Comments{/t}
                                        </td>
                                        <td>
-                                               <textarea name="comments" style="width:100%;height:110px;" >{$comments}</textarea>
+                                               <textarea name="comments" style="width:100%;height:110px;" {$commentsACL}>{$comments}</textarea>
                                        </td>
                                </tr>
                        </table>
@@ -89,7 +91,7 @@
                                                <select name="Attachments" {$AttachmentsACL} style="height:120px;width:100%;" multiple>
                                                        {html_options values=$Attachments output=$Attachments}
                                                </select>
-                                               <input name="AddDevice" value="{t}Add{/t}" type="submit">       
+                                               <input name="AddDevice" value="{t}Edit{/t}" type="submit">      
                                        </td>
                                </tr>
                        </table>