Code

Updated manufacturer handling
[gosa.git] / plugins / admin / systems / class_glpiPrinterAccount.inc
index 7c86816893efac3be2284de5e8a6efe33a4732b8..2fbffd147c576f7b3b8ebf3862c14208c693cae2 100644 (file)
@@ -39,6 +39,8 @@ class glpiPrinterAccount extends plugin
   var $contact            = "";    // Empty
   var $deleted            = "N";   // Deleted entries should have this set to Y
 
+  var $editManufacturer   = false;
+
   /* Not necessary, cause we use mysql databse */
   var $objectclasses= array("whatever");
 
@@ -258,13 +260,15 @@ class glpiPrinterAccount extends plugin
     if(isset($_POST['edit_manufacturer'])){
       $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
       $this->dialog = true;
+      $this->editManufacturer =true;
     }
 
     /* Close manufacturer editing dialog
      */
-    if(isset($_POST['close_edit_manufacturer'])){
+    if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
       $this->dialog = false;
       $this->cur_dialog = false;
+      $this->editManufacturer=false;
     }
 
 
@@ -279,18 +283,19 @@ class glpiPrinterAccount extends plugin
      */
     if(isset($_POST['SelectContactPerson'])){
       $this->addUser = "contact";
-      $this->cur_dialog= new glpiSelectUser($this->config,$this->dn);
+      $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
     }
 
     /* Selecte technical responsible person
      */
     if(isset($_POST['SelectTechPerson'])){
       $this->addUser ="tech";
-      $this->cur_dialog= new glpiSelectUser($this->config,$this->dn);
+      $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
     }
 
     /* Abort user selection
      */
+    $smarty->assign("AbortSelectUser","SelectUserCancel");
     if(isset($_POST['SelectUserCancel'])){
       $this->dialog = false;
       $this->addUser ="";
@@ -410,11 +415,15 @@ class glpiPrinterAccount extends plugin
     /* Remove cartridge  
      */
     if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges']))){
-      if(isset($this->usedCartridges[$_POST['Cartridges']])){
-        if($this->usedCartridges[$_POST['Cartridges']]['status'] == "exists"){
-          $this->usedCartridges[$_POST['Cartridges']]['status'] = "deleted";
-        }else{
-          unset($this->usedCartridges[$_POST['Cartridges']]);
+
+      foreach($_POST['Cartridges'] as $cartID){
+
+        if(isset($this->usedCartridges[$cartID])){
+          if($this->usedCartridges[$cartID]['status'] == "exists"){
+            $this->usedCartridges[$cartID]['status'] = "deleted";
+          }else{
+            unset($this->usedCartridges[$cartID]);
+          }
         }
       }
     }
@@ -520,6 +529,19 @@ class glpiPrinterAccount extends plugin
       $smarty->assign("tech_num",               _("N/A"));
     }
 
+    /* If theres a cartridge selected, you can't change the printer type.
+     */ 
+    $disp = true;
+
+    foreach($this->usedCartridges as $cart){
+      if($cart['status'] != "deleted"){
+        $disp = false;
+      }
+    }
+    if($disp==false){
+      $smarty->assign("typeACL","disabled");
+    }
+
     $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
     return($display);
   }
@@ -536,14 +558,14 @@ class glpiPrinterAccount extends plugin
   /* Save data to object */
   function save_object()
   {
-    plugin::save_object();
-    foreach($this->attributes as $attrs){
-      if(isset($_POST[$attrs])){
-        $this->$attrs = $_POST[$attrs];
+    if(isset($_POST['glpiPrinterFlagsPosted'])){
+      plugin::save_object();
+      foreach($this->attributes as $attrs){
+        if(isset($_POST[$attrs])){
+          $this->$attrs = $_POST[$attrs];
+        }
       }
-    }
 
-    if(isset($_POST['glpiPrinterFlagsPosted'])){
       foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
         if(isset($_POST[$checkboxes])){
           $this->$checkboxes = 1;