Code

Added license usage dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Sep 2009 09:16:21 +0000 (09:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Sep 2009 09:16:21 +0000 (09:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14328 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsiLicenses/class_licenceUsage.inc
gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc
gosa-plugins/opsi/admin/opsiLicenses/licenseUsage.tpl

index 76776725db6c21bfce4c3521002dc02c3ec4355c..c4fde8e6920edd2bc08f5bcb3f5862f76628ab62 100644 (file)
@@ -25,7 +25,7 @@ class licenseUsage extends plugin
 {
 
   var $cn = "";
-
+  var $licenseUses = array();
   var $init_successfull = FALSE;
 
 
@@ -50,7 +50,20 @@ class licenseUsage extends plugin
   
   function init()
   {
-    $this->init_successfull = TRUE;
+    $this->licenseUses = array();
+    if(!$this->initially_was_account){
+      $this->init_successfull = TRUE;
+    }else{
+
+      $res = $this->si->getLicenseUsage("", $this->cn);
+      if($this->si->is_error()){
+        $this->init_successfull = FALSE;
+        return;
+      }
+
+      $this->licenseUses = $res;
+      $this->init_successfull = TRUE;
+    }
   }
 
 
@@ -63,6 +76,18 @@ class licenseUsage extends plugin
       $smarty->assign("init_successfull", $this->init_successfull);
       return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
     }
+    
+    // Create usage list
+    $list = new divSelectBox("licenseUsage");
+    foreach($this->licenseUses as $license){
+
+      $f1 = array("string" => $license['hostId'][0]);
+      $f2 = array("string" => $license['licenseKey'][0]);
+      $f3 = array("string" => $license['licensePoolId'][0]);
+      $f4 = array("string" => $license['softwareLicenseId'][0],
+                  "attach" => "style='border-right:0px;'");
+      $list->addEntry(array($f1,$f2,$f3,$f4));
+    } 
 
     $smarty = get_smarty();
 
@@ -75,6 +100,7 @@ class licenseUsage extends plugin
       $smarty->assign($attr,$this->$attr);
     }
 
+    $smarty->assign("licenseUses", $list->DrawList());
     $smarty->assign("init_successfull", $this->init_successfull);
     $smarty->assign("initially_was_account", $this->initially_was_account);
     return($smarty->fetch(get_template_path('licenseUsage.tpl',TRUE,dirname(__FILE__))));
index fa75d84a1be3783b36758b082f6f6c62414676d3..d7055cd55275481b609ccfd8a59e73b4a7b2f4ef 100644 (file)
@@ -214,7 +214,28 @@ class opsiLicenceHandler extends opsi  {
 
     $res = $this->send_data("gosa_opsi_getSoftwareLicenseUsages_listOfHashes",$this->target,$data,TRUE);
     if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSEUSAGES_LISTOFHASHES'])){
-      return($res['XML'][0]['RESULT']);
+
+      $items = array();
+      foreach($res['XML'][0]['RESULT'][0]['HIT'] as $entry){
+        $item = array();
+        foreach(array(
+              "HOSTID"              => "hostId",
+              "LICENSEKEY"          => "licenseKey",
+              "LICENSEPOOLID"       => "licensePoolId",
+              "NOTES"               => "notes",
+              "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);
   }
index 3790766d78a036ba2bc180d839344a4b8e96e64f..443d2f4f4f55fb328a5d82c6cef095528bbfe7fa 100644 (file)
@@ -7,24 +7,10 @@
 <br>
 {else}
 
+<!-- GENERIC -->
+<h2>{t}License usage{/t}</h2>
 
-<table width="100%">
-  <tr> 
-    <td style='vertical-align:top;'>
+{$licenseUses}
 
-        <!-- GENERIC -->
-        <h2>{t}Generic{/t}</h2>
-        <table>
-          <tr> 
-            <td>{t}Name{/t}</td>
-            <td>
-              TESTER
-            </td>
-          </tr>
-        </table>
-
-    </td>
-  </tr>
-</table>
 <input name='opsiLicenseUsagePosted' value='1' type='hidden'>
 {/if}