Code

Added server selection to fonreport plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 2 Nov 2009 12:40:22 +0000 (12:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 2 Nov 2009 12:40:22 +0000 (12:40 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@14723 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/fonreports/class_fonreport.inc
plugins/gofon/fonreports/contents.tpl

index aaefaab6c392f2c44f9e3cf4d46a86b608f52e57..de59274e28b33ef58b041023df2dd1b6009345db 100644 (file)
@@ -20,6 +20,7 @@ class fonreport extends plugin
   var $ui                                          = NULL;
   var $range                             = 20;
   var $EntryPerPage   = 20;
+  var $selected_server = "";
 
   /* attribute list for save action */
   var $attributes_SO  = array("start","search_for","search_base","range","month","sort_direction","sort","year");
@@ -64,7 +65,7 @@ class fonreport extends plugin
     if (isset($_GET['start'])){
       $this->start= (int)$_GET['start'];
     }
-    foreach( array("year", "month", "search_for", "search_base") as $type){
+    foreach( array("year", "month", "search_for", "search_base","selected_server") as $type){
       if (isset($_POST[$type])){
         $this->$type= $_POST[$type];
       }
@@ -152,6 +153,15 @@ class fonreport extends plugin
       Check Database , Table , Connection 
      *****************/
 
+    // Collect servers and allow to select the server in the ui.
+    $servers = array();
+    foreach($this->config->data['SERVERS']['FON'] as $key => $server){
+      $servers[$server['SERVER']] = $server['SERVER'];
+    }
+    $smarty->assign("servers",  $servers);
+    $smarty->assign("selected_server",  $this->selected_server);
+
+
     /* Connecting, selecting database */
     if (!isset($this->config->data['SERVERS']['FON'][0])){
       print_red(_("Can't connect to phone database, no reports can be shown!"));
@@ -161,7 +171,18 @@ class fonreport extends plugin
       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
     }else{
 
-      $cfg= $this->config->data['SERVERS']['FON'][0];
+      // Get CFG for the selected server, if empty use first.
+      if($this->selected_server == ""){
+        $cfg= $this->config->data['SERVERS']['FON'][0];
+      }else{
+        foreach($this->config->data['SERVERS']['FON'] as $server){
+          if($server['SERVER'] == $this->selected_server){
+            $cfg = $server; 
+          }
+        }
+      }
+      
+      // Try to connect 
       $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
       if ($link === FALSE){
         print_red(_("Can't connect to phone database, no reports can be shown!"));
@@ -179,7 +200,6 @@ class fonreport extends plugin
      *****************/
 
     $query  = $this->CreateQuerySyntax();
-    $cfg    = $this->config->data['SERVERS']['FON'][0];
     $link   = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
 
     @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query");
index bd8f503fdd74b5f94d73cf121e43eabc1309c2db..67e5e1c53e170ba3075c6489e49108b999a871db 100644 (file)
@@ -9,6 +9,10 @@
  <select size="1" name="search_base" title="{t}Select subtree to base search on{/t}" onChange="mainform.submit()">
   {html_options options=$bases selected=$base_select}
  </select>
+ {t}on{/t}
+ <select size="1" name="selected_server" title="{t}Select server to search on{/t}" onChange="mainform.submit()">
+  {html_options options=$servers selected=$selected_server}
+ </select>
  {t}during{/t}
  <select size="1" name="month" onChange="mainform.submit()">
   {html_options options=$months selected=$month_select}