Code

Updated usage dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 25 Sep 2009 13:03:49 +0000 (13:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 25 Sep 2009 13:03:49 +0000 (13:03 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14352 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc
gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc

index 60a94f6db9081b9c3d935257a1b0a4d6dcab788a..866d6f28d6665b7fdf925165237f3bad73c54d97 100644 (file)
@@ -53,6 +53,7 @@ class licenseUsageByHost extends plugin
   function init()
   {
     $this->licenseUses = array();
+    $this->reservedLicenses = array();
     if(!$this->initially_was_account){
       $this->init_successfull = TRUE;
     }else{
@@ -62,8 +63,13 @@ class licenseUsageByHost extends plugin
         $this->init_successfull = FALSE;
         return;
       }
-
       $this->licenseUses = $res;
+
+      $res = $this->si->getReservedLicensesForHost($this->cn);
+      if($this->si->is_error()){
+        $this->init_successfull = FALSE;
+        return;
+      }
       $this->reservedLicenses = $res;
       $this->init_reservedLicenses = $res;
       $this->init_successfull = TRUE;
@@ -100,11 +106,12 @@ class licenseUsageByHost extends plugin
       $action = "<input class='center' type='image' src='images/lists/trash.png' 
         name='removeReservation_{$key}'>";
       $f1 = array("string" => $license['licensePoolId'][0]);
-      $f2 = array("string" => $license['licenseKey'][0]);
+#      $f2 = array("string" => $license['licenseKey'][0]);
       $f3 = array("string" => $license['softwareLicenseId'][0]);
       $f4 = array("string" => $action,
                   "attach" => "style='border-right:0px;'");
-      $list2->addEntry(array($f1,$f2,$f3, $f4));
+#      $list2->addEntry(array($f1,$f2,$f3, $f4));
+      $list2->addEntry(array($f1,$f3, $f4));
     } 
 
     $smarty = get_smarty();
index 3b855423217e01de616682d33767be54826870cc..c900136981fa841a4f2990557f04c2608444f010 100644 (file)
@@ -206,6 +206,38 @@ class opsiLicenceHandler extends opsi  {
   }
 
 
+  function getReservedLicensesForHost($hostId)
+  {
+    $data= array();
+    if(!empty($hostId)){
+      $data['hostId'] = htmlentities($hostId);
+    }
+    $res = $this->send_data("gosa_opsi_getReservedLicenses",$this->target,$data,TRUE);
+    if(isset($res['XML'][0]['ANSWER_OPSI_GETRESERVEDLICENSES'])){
+
+      $items = array();
+      foreach($res['XML'][0]['LICENSES'][0]['HIT'] as $entry){
+        $item = array();
+        foreach(array(
+              "LICENSEPOOLIDS"      => "licensePoolId",
+              "SOFTWARELICENSEID"   => "softwareLicenseId") as $source => $target){
+          if(isset($entry[$source])){
+
+            $item[$target] = array('count' => 0);
+            foreach($entry[$source] as $data){
+              $item[$target][] = $data['VALUE'];
+            }
+            $item[$target]['count'] = count($item[$target]) -1 ;
+          }
+        }
+        $items[]  = $item;
+      }
+      return($items);
+    }
+    return(FALSE);
+  }
+
+
   /* 
    * @brief Returns softwareLicenseId, notes, licenseKey, hostId and licensePoolId for optional given licensePoolId and hostId
    * @param hostid Something like client_1.intranet.mydomain.de (optional).