Code

Made asterisk server selectable in phonereports.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 3 Nov 2009 14:29:30 +0000 (14:29 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 3 Nov 2009 14:29:30 +0000 (14:29 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14734 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index a5e932a3dbffd05b912196a6f0909774eb8e6d3a..926355a19819d00246a872652d6b88c99e671a18 100644 (file)
@@ -22,6 +22,8 @@ class fonreport extends plugin
   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");
   var $objectclasses  = array();
@@ -65,7 +67,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];
       }
@@ -161,6 +163,14 @@ 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])){
       msg_dialog::display(_("Configuration error"), msgPool::noserver(_("GOfon")), WARNING_DIALOG);
@@ -170,7 +180,17 @@ 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;
+          }
+        }
+      }
+
       $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
       if ($link === FALSE){
         msg_dialog::display(_("Error"), msgPool::dbconnect(_("GOfon"),@mysql_error(),$cfg['SERVER']),ERROR_DIALOG);
@@ -188,7 +208,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 d8cf0a47fc68ce113514a9d86dff20c070d1324b..ce2ae650832eb2a9c415b5d0078664d5ad324d4d 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}