Code

Renamed fon and fax reports folder
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 29 Nov 2005 07:44:22 +0000 (07:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 29 Nov 2005 07:44:22 +0000 (07:44 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2110 594d385d-05f5-0310-b6e9-bd551577e9d8

15 files changed:
contrib/gosa.conf
plugins/gofax/faxreports/class_faxreport.inc [new file with mode: 0644]
plugins/gofax/faxreports/contents.tpl [new file with mode: 0644]
plugins/gofax/faxreports/detail.tpl [new file with mode: 0644]
plugins/gofax/faxreports/main.inc [new file with mode: 0644]
plugins/gofax/reports/class_faxreport.inc [deleted file]
plugins/gofax/reports/contents.tpl [deleted file]
plugins/gofax/reports/detail.tpl [deleted file]
plugins/gofax/reports/main.inc [deleted file]
plugins/gofon/fonreports/class_fonreport.inc [new file with mode: 0644]
plugins/gofon/fonreports/contents.tpl [new file with mode: 0644]
plugins/gofon/fonreports/main.inc [new file with mode: 0644]
plugins/gofon/reports/class_fonreport.inc [deleted file]
plugins/gofon/reports/contents.tpl [deleted file]
plugins/gofon/reports/main.inc [deleted file]

index a310eb5dae87249cdc32075e2c1f91ae4af01281..19b362871d0815551763cb2872bffc290bc5a35e 100644 (file)
@@ -52,9 +52,9 @@
                        <plugin acl="default" class="addressbook" icon="addressbook.png"
                                path="plugins/addons/addressbook" />
                        <plugin acl="default" class="faxreport" icon="reports.png"
-                               path="plugins/gofax/reports" />
+                               path="plugins/gofax/faxreports" />
                        <plugin acl="default" class="fonreport" icon="phonereport.png"
-                               path="plugins/gofon/reports" />
+                               path="plugins/gofon/fonreports" />
                        <plugin acl="logs" class="logview" icon="logview.png"
                                path="plugins/addons/logview" />
                        <plugin acl="mailqueue" class="mailqueue" icon="mailqueue.png"
diff --git a/plugins/gofax/faxreports/class_faxreport.inc b/plugins/gofax/faxreports/class_faxreport.inc
new file mode 100644 (file)
index 0000000..dbae32e
--- /dev/null
@@ -0,0 +1,328 @@
+<?php
+
+class faxreport extends plugin
+{
+  /* Definitions */
+  var $plHeadline= "FAX Reports";
+  var $plDescription= "This does something";
+
+  /* For internal use */
+  var $start= 0;
+  var $search_for= "*";
+  var $search_base= "";
+  var $year= "";
+  var $month= "";
+  var $sort= 1;
+  var $sort_direction= "down";
+  var $report_list= array();
+  var $userfilter= "";
+  var $ui= NULL;
+
+  var $range = 20;
+
+  /* Constant stuff */
+  var $status= array( "SENT", "MAILED", "SERROR", "RERROR", "SBLOCK", "RBLOCK",
+                       "DELETED", "REQUEUED", "DISABLED", "PRINTED", "DIVERTED",
+                       "UNDEFINED", "UNDEFINED", "UNDEFINED", "UNDEFINED",
+                       "UNDEFINED");
+  var $fields= array("uid", "queuing_time", "status", "sender_id", "receiver_id", "pages");
+
+  /* attribute list for save action */
+  var $attributes= array();
+  var $objectclasses= array();
+
+  function faxreport ($config, $ui)
+  {
+       /* Include config object */
+       $this->config= $config;
+       $this->ui= $ui;
+
+       /* Try to get matching search base for user provided
+          by 'dn' */
+       $tmp= preg_replace ("/^[^,]+,[^,]+,/", "", $ui->dn);
+       $sb= array_search($tmp, $this->config->departments);
+       if ($sb === FALSE){
+               $sb= "/";
+       }
+       $this->search_base= $sb;
+
+        /* Get global filter config */
+        if (!is_global("faxreportfilter")){
+                $ui= get_userinfo();
+                $base= get_base_from_people($ui->dn);
+                $faxfilter= array("year" => date("Y"),
+                                "month" => date("m"),
+                               "search_base" => $base,
+                               "search_for" => "*");
+                register_global("faxreportfilter", $faxfilter);
+        }
+  }
+
+  function execute()
+  {
+       /* Call parent execute */
+       plugin::execute();
+
+       if(isset($_POST['EntriesPerPage'])){
+               $this->range = $_POST['EntriesPerPage'];
+       }
+
+       /* Get template engine */
+       $smarty= get_smarty();
+       $faxfilter= get_global("faxreportfilter");
+        foreach( array("year", "month", "search_for", "search_base") as $type){
+                if (isset($_POST[$type])){
+                        $faxfilter[$type]= $_POST[$type];
+                }
+               $this->$type= $faxfilter[$type];
+        }
+       register_global("faxreportfilter", $faxfilter);
+  
+       /* Adapt sorting */
+       if (isset($_GET['sort'])){
+               if ($this->sort == (int)$_GET['sort']){
+                       if ($this->sort_direction == "down"){
+                               $this->sort_direction= "up";
+                       } else {
+                               $this->sort_direction= "down";
+                       }
+               }
+               $this->sort= (int)$_GET['sort'];
+               if ($this->sort < 0 || $this->sort > 5){
+                       $this->sort= 0;
+               }
+       }
+
+       /* Do detail view? */
+       if (isset($_GET['detail'])){
+               $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,sender_msn,receiver_id,".
+                       "receiver_msn,pages,status_message,transfer_time FROM faxlog ".
+                       "WHERE id=".$_GET['detail'].";";
+
+               /* Connecting, selecting database */
+               $cfg= $this->config->data['SERVERS']['FAX'];
+
+               if(!is_callable("mysql_connect")){
+                       print_red(_("There is no mysql extension available, please check your php setup."));    
+                       return; 
+               }               
+
+               $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
+               if ($link === FALSE){
+                       print_red(_("Can't connect to fax database, no reports can be shown!"));
+                       return;
+               }
+               if (! @mysql_select_db("gofax")){
+                       print_red(_("Can't select fax database for report generation!"));
+                       return;
+               }
+
+               @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,
+                       $query, "Database query");
+               $result = @mysql_query($query);
+               if ($result === false){
+                       print_red(_("Query for fax database failed!"));
+                       return;
+               }
+
+               $line = mysql_fetch_array($result, MYSQL_ASSOC);
+               mysql_close($link);
+
+               if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){
+                       print_red (_("You have no permission to retrieve informations about this fax id!"));
+                       return;
+               }
+
+               $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn",
+                       "receiver_id", "receiver_msn", "pages", "status_message", "transfer_time" );
+               foreach ($parts as $vname) {
+                       $final="fax_$vname";
+                       if ($line[$vname] != ""){
+                               $smarty->assign("$final", $line[$vname]);
+                       } else {
+                               $smarty->assign("$final", "-");
+                       }
+               }
+               $queuing_time= $line['queuing_time'];
+
+               $_SESSION['fuserfilter']= $this->userfilter;
+           $smarty->assign("plug", "?plug=".validate($_GET['plug']));
+           $smarty->assign("detail", validate($_GET['detail']));
+
+               $format= _("Y-M-D");
+               $date= preg_replace("/Y/", substr($queuing_time,0,4), $format);
+               $date= preg_replace("/M/", substr($queuing_time,4,2), $date);
+               $date= preg_replace("/D/", substr($queuing_time,6,2), $date);
+               $smarty->assign("date", $date);
+               $smarty->assign("time", substr($queuing_time,8,2).":".
+                                       substr($queuing_time,10,2).":".
+                                       substr($queuing_time,12,2));
+               return($smarty->fetch(get_template_path('detail.tpl', TRUE)));
+       }
+
+       /* Search button has been pressed */
+       if ($this->search_for != ""){
+               $this->start= 0;
+
+               if (is_integer (strpos($this->search_for, "*"))){
+                       $s= $this->search_for;
+               } else {
+                       $s= "*".$this->search_for."*";
+               }
+               $ldap= $this->config->get_ldap_link();
+               $ldap->cd ($this->search_base);
+
+               /* Perform ldap search for potential users */
+               $ldap->search ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))".
+                       "(objectClass=goFaxAccount)".
+                       "(|(uid=$s)(l=$s)(homePhone=$s)".
+                       "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)".
+                       "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)".
+                       "(title=$s)))");
+
+               $fax_users= array();
+               while ($attrs= $ldap->fetch()){
+                       $acl= get_permissions ($ldap->getDN(), $this->ui->subtreeACL);
+                       $acl= get_module_permission($acl, "fax", $ldap->getDN());
+
+                       if (chkacl ($acl, "faxReport") == ""){
+                               $fax_users[]= $attrs["uid"][0];
+                       }
+               }
+
+               /* Prepare SQL query */
+               $this->userfilter= "";
+               foreach ($fax_users as $user){
+                       $this->userfilter.= "uid = '$user' OR ";
+               }
+               $this->userfilter= preg_replace("/OR $/", "", $this->userfilter);
+       }
+
+
+       /* Perform SQL query */
+       if ($this->userfilter){
+               if ($this->sort_direction == "down"){
+                       $desc= "DESC";
+               } else {
+                       $desc= "";
+               }
+               $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year));
+               $end=   date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year));
+               $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,receiver_id,pages FROM faxlog ".
+                       "WHERE ( ".$this->userfilter." ) AND queuing_time <= $end AND ".
+                       "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;";
+
+               if(!is_callable("mysql_connect")){
+                       print_red("There is no mysql extension configured in your php setup.");
+                       return;
+               }
+
+               /* Connecting, selecting database */
+               $cfg= $this->config->data['SERVERS']['FAX'];
+               $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
+               if ($link === FALSE){
+                       print_red(_("Can't connect to fax database, no reports can be shown!"));
+                       return;
+               }
+               if (! @mysql_select_db("gofax")){
+                       print_red(_("Can't select fax database for report generation!"));
+                       return;
+               }
+
+               @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,
+                       $query, "Database query");
+               $result = @mysql_query($query);
+               if ($result === false){
+                       print_red(_("Query for fax database failed!"));
+                       return;
+               }
+
+               $report_list= array();
+               while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
+                       $hour=  substr($line["queuing_time"], 8, 2);
+                       $minute=substr($line["queuing_time"], 10, 2);
+                       $format= _("Y-M-D");
+                       $date= preg_replace("/Y/", substr($line["queuing_time"], 0, 4), $format);
+                       $date= preg_replace("/M/", substr($line["queuing_time"], 4, 2), $date);
+                       $date= preg_replace("/D/", substr($line["queuing_time"], 6, 2), $date);
+
+
+                       $report_list[]= "<td class=\"phonelist\"><a href=\"main.php?plug=".validate($_GET['plug'])."&amp;detail=".
+                               $line["id"]."\"><img alt=\"\" align=\"middle\" border=0 src=\"".get_template_path('images/info_small.png')."\">&nbsp;".$line["uid"]."</a></td>".
+                               "<td>$date $hour:$minute</td>".
+                               "<td>".$this->status[$line["status"]]."</td>".
+                               "<td>".$line["sender_id"]."</td>".
+                               "<td>".$line["receiver_id"]."</td>".
+                               "<td>".$line["pages"]."</td>";
+               }
+
+               $this->report_list= $report_list;
+               mysql_close($link);
+       }
+
+       /* Generate output */
+       $mod= 0;
+       if (isset($_GET['start'])){
+               $this->start= (int)$_GET['start'];
+       }
+
+       $output= "";
+       foreach ($this->report_list as $val){
+               if ($mod < $this->start) {
+                       $mod++;
+                       continue;
+               }
+               if ($mod >= ($this->start + $this->range)){
+                       $mod++;
+                       break;
+               }
+               if ( ($mod++) & 1){
+                       $col= "background-color: #ECECEC;";
+               } else {
+                       $col= "background-color: #F5F5F5;";
+               }
+               $output.= "<tr style=\"height:22px; $col\">$val</tr>";
+       }
+
+       /* Prepare template */
+       $smarty->assign("search_for", $this->search_for);
+        $smarty->assign("bases", $this->config->idepartments);
+        $smarty->assign("base_select", $this->search_base);
+       $months= array();
+       $months[1]= _("January"); $months[2]= _("February"); $months[3]= _("March"); $months[4]= _("April");
+       $months[5]= _("May"); $months[6]= _("June"); $months[7]= _("July"); $months[8]= _("August");
+       $months[9]= _("September"); $months[10]= _("October"); $months[11]= _("November"); $months[12]= _("December");
+        $smarty->assign("months", $months);
+       $smarty->assign("month_select", $this->month);
+       $current= date("Y");
+       $years= array();
+       for ($y= $current - 5; $y<=$current; $y++){
+               $years[]= $y;
+       }
+        $smarty->assign("years", $years);
+       $smarty->assign("year_select", $this->year);
+
+       if (isset($fax_users) && count($fax_users)){
+               $smarty->assign("search_result", $output);
+               $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start, $this->range,"EntriesPerPage"));
+       }else{
+               $smarty->assign("search_result", "");
+       }
+
+       
+
+       /* Show main page */
+    $smarty->assign("plug", "?plug=".validate($_GET['plug']));
+       $smarty->assign("launchimage", get_template_path('images/launch.png'));
+       $smarty->assign("search_image", get_template_path('images/search.png'));
+       for($i= 0; $i<7; $i++){
+               $smarty->assign("mode$i", "");
+       }
+       $smarty->assign("mode".$this->sort, "<img alt=\"\" src=\"images/sort_".$this->sort_direction.
+                       ".png\" border=0 align=middle>");
+        return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
+  }
+
+}
+
+?>
diff --git a/plugins/gofax/faxreports/contents.tpl b/plugins/gofax/faxreports/contents.tpl
new file mode 100644 (file)
index 0000000..eef9011
--- /dev/null
@@ -0,0 +1,59 @@
+<div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
+</div>
+<div class="contentboxb">
+ <p class="contentboxb" style="border-top:1px solid #B0B0B0; padding-top:5px;">
+ <img alt="" align="middle" border=0 src="{$search_image}">&nbsp;{t}Search for{/t}
+ <input name="search_for" size=25 maxlength=60 value="{$search_for}" title="{t}Enter user name to search for{/t}" onChange="mainform.submit()">
+ {t}in{/t}
+ <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}during{/t}
+ <select size="1" name="month" onChange="mainform.submit()">
+  {html_options options=$months selected=$month_select}
+ </select>
+ {t}in{/t} 
+ <select size="1" name="year" onChange="mainform.submit()">
+  {html_options values=$years output=$years selected=$year_select}
+ </select>
+ &nbsp;
+ <input type=submit name="search" value="{t}Search{/t}">
+</p>
+</div>
+
+<br>
+
+{if $search_result ne ""}
+ <table summary="" style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 border=0 rules="cols">
+  <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
+   <td><a href="main.php{$plug}&amp;sort=0">{t}User{/t} {$mode0}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=1">{t}Date{/t} {$mode1}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=2">{t}Status{/t} {$mode2}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=3">{t}Sender{/t} {$mode3}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=4">{t}Receiver{/t} {$mode4}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=5">{t}# pages{/t} {$mode5}</a></td>
+  </tr>
+  {$search_result}
+ </table>
+
+ <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
+  <tr>
+   <td>{$range_selector}</td>
+  </tr>
+ </table>
+<p class="plugbottom">
+ &nbsp;
+</p>
+
+{else}
+  <b>{t}Search returned no results...{/t}</b>
+{/if}
+
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+  document.mainform.search_for.focus();
+  -->
+</script>
diff --git a/plugins/gofax/faxreports/detail.tpl b/plugins/gofax/faxreports/detail.tpl
new file mode 100644 (file)
index 0000000..1cd45f5
--- /dev/null
@@ -0,0 +1,70 @@
+<table summary="">
+ <tr>
+  <td> 
+   <a href="getfax.php?id={$detail}&amp;download=1">
+     <img  align="bottom" width="420" height="594" src="getfax.php?id={$detail}"
+          alt="{t}FAX preview - please wait{/t}" border=1>
+   </a>
+   <p style="margin-top-width:0px; text-align:center;">
+    {t}Click on fax to download{/t}
+   </p>
+  </td>
+  <td style="width:20px;">
+    &nbsp;
+  </td>
+  <td style="vertical-align:top">
+    <table summary="" border=0 cellspacing=5>
+     <tr>
+      <td><b>{t}FAX ID{/t}</b></td>
+      <td>{$fax_id}</td>
+     </tr>
+     <tr>
+      <td><b>{t}User{/t}</b></td>
+      <td>{$fax_uid}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Date / Time{/t}</b></td>
+      <td>{$date} / {$time}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Sender MSN{/t}</b></td>
+      <td>{$fax_sender_msn}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Sender ID{/t}</b></td>
+      <td>{$fax_sender_id}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Receiver MSN{/t}</b></td>
+      <td>{$fax_receiver_msn}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Receiver ID{/t}</b></td>
+      <td>{$fax_receiver_id}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Status{/t}</b></td>
+      <td>{$fax_status}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Status message{/t}</b></td>
+      <td>{$fax_status_message}</td>
+     </tr>
+     <tr>
+      <td><b>{t}Transfer time{/t}</b></td>
+      <td>{$fax_transfer_time}</td>
+     </tr>
+     <tr>
+      <td><b>{t}# pages{/t}</b></td>
+      <td>{$fax_pages}</td>
+     </tr>
+    </table>
+
+  </td>
+ </tr>
+</table>
+
+<p class="plugbottom">
+  <input type=submit name="bck_to_list" value="{t}Back{/t}">
+</p>
+
diff --git a/plugins/gofax/faxreports/main.inc b/plugins/gofax/faxreports/main.inc
new file mode 100644 (file)
index 0000000..cfa7de0
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+if (!$remove_lock){
+       /* Page header*/
+        $display= print_header(get_template_path('images/reports.png'), _("FAX reports"));
+
+        /* Create faxreport object on demand */
+        if (!isset($_SESSION['faxreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+                $_SESSION['faxreport']= new faxreport ($config, $ui);
+        }
+        $faxreport= $_SESSION['faxreport'];
+
+        /* Execute formular */
+       $display.= $faxreport->execute ();
+       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+       /* Store changes  in session */
+       $_SESSION['faxreport']= $faxreport;
+}
+?>
diff --git a/plugins/gofax/reports/class_faxreport.inc b/plugins/gofax/reports/class_faxreport.inc
deleted file mode 100644 (file)
index dbae32e..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-<?php
-
-class faxreport extends plugin
-{
-  /* Definitions */
-  var $plHeadline= "FAX Reports";
-  var $plDescription= "This does something";
-
-  /* For internal use */
-  var $start= 0;
-  var $search_for= "*";
-  var $search_base= "";
-  var $year= "";
-  var $month= "";
-  var $sort= 1;
-  var $sort_direction= "down";
-  var $report_list= array();
-  var $userfilter= "";
-  var $ui= NULL;
-
-  var $range = 20;
-
-  /* Constant stuff */
-  var $status= array( "SENT", "MAILED", "SERROR", "RERROR", "SBLOCK", "RBLOCK",
-                       "DELETED", "REQUEUED", "DISABLED", "PRINTED", "DIVERTED",
-                       "UNDEFINED", "UNDEFINED", "UNDEFINED", "UNDEFINED",
-                       "UNDEFINED");
-  var $fields= array("uid", "queuing_time", "status", "sender_id", "receiver_id", "pages");
-
-  /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
-
-  function faxreport ($config, $ui)
-  {
-       /* Include config object */
-       $this->config= $config;
-       $this->ui= $ui;
-
-       /* Try to get matching search base for user provided
-          by 'dn' */
-       $tmp= preg_replace ("/^[^,]+,[^,]+,/", "", $ui->dn);
-       $sb= array_search($tmp, $this->config->departments);
-       if ($sb === FALSE){
-               $sb= "/";
-       }
-       $this->search_base= $sb;
-
-        /* Get global filter config */
-        if (!is_global("faxreportfilter")){
-                $ui= get_userinfo();
-                $base= get_base_from_people($ui->dn);
-                $faxfilter= array("year" => date("Y"),
-                                "month" => date("m"),
-                               "search_base" => $base,
-                               "search_for" => "*");
-                register_global("faxreportfilter", $faxfilter);
-        }
-  }
-
-  function execute()
-  {
-       /* Call parent execute */
-       plugin::execute();
-
-       if(isset($_POST['EntriesPerPage'])){
-               $this->range = $_POST['EntriesPerPage'];
-       }
-
-       /* Get template engine */
-       $smarty= get_smarty();
-       $faxfilter= get_global("faxreportfilter");
-        foreach( array("year", "month", "search_for", "search_base") as $type){
-                if (isset($_POST[$type])){
-                        $faxfilter[$type]= $_POST[$type];
-                }
-               $this->$type= $faxfilter[$type];
-        }
-       register_global("faxreportfilter", $faxfilter);
-  
-       /* Adapt sorting */
-       if (isset($_GET['sort'])){
-               if ($this->sort == (int)$_GET['sort']){
-                       if ($this->sort_direction == "down"){
-                               $this->sort_direction= "up";
-                       } else {
-                               $this->sort_direction= "down";
-                       }
-               }
-               $this->sort= (int)$_GET['sort'];
-               if ($this->sort < 0 || $this->sort > 5){
-                       $this->sort= 0;
-               }
-       }
-
-       /* Do detail view? */
-       if (isset($_GET['detail'])){
-               $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,sender_msn,receiver_id,".
-                       "receiver_msn,pages,status_message,transfer_time FROM faxlog ".
-                       "WHERE id=".$_GET['detail'].";";
-
-               /* Connecting, selecting database */
-               $cfg= $this->config->data['SERVERS']['FAX'];
-
-               if(!is_callable("mysql_connect")){
-                       print_red(_("There is no mysql extension available, please check your php setup."));    
-                       return; 
-               }               
-
-               $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
-               if ($link === FALSE){
-                       print_red(_("Can't connect to fax database, no reports can be shown!"));
-                       return;
-               }
-               if (! @mysql_select_db("gofax")){
-                       print_red(_("Can't select fax database for report generation!"));
-                       return;
-               }
-
-               @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,
-                       $query, "Database query");
-               $result = @mysql_query($query);
-               if ($result === false){
-                       print_red(_("Query for fax database failed!"));
-                       return;
-               }
-
-               $line = mysql_fetch_array($result, MYSQL_ASSOC);
-               mysql_close($link);
-
-               if (!preg_match ("/'".$line["uid"]."'/", $this->userfilter)){
-                       print_red (_("You have no permission to retrieve informations about this fax id!"));
-                       return;
-               }
-
-               $parts= array( "id", "uid", "queuing_time", "status", "sender_id", "sender_msn",
-                       "receiver_id", "receiver_msn", "pages", "status_message", "transfer_time" );
-               foreach ($parts as $vname) {
-                       $final="fax_$vname";
-                       if ($line[$vname] != ""){
-                               $smarty->assign("$final", $line[$vname]);
-                       } else {
-                               $smarty->assign("$final", "-");
-                       }
-               }
-               $queuing_time= $line['queuing_time'];
-
-               $_SESSION['fuserfilter']= $this->userfilter;
-           $smarty->assign("plug", "?plug=".validate($_GET['plug']));
-           $smarty->assign("detail", validate($_GET['detail']));
-
-               $format= _("Y-M-D");
-               $date= preg_replace("/Y/", substr($queuing_time,0,4), $format);
-               $date= preg_replace("/M/", substr($queuing_time,4,2), $date);
-               $date= preg_replace("/D/", substr($queuing_time,6,2), $date);
-               $smarty->assign("date", $date);
-               $smarty->assign("time", substr($queuing_time,8,2).":".
-                                       substr($queuing_time,10,2).":".
-                                       substr($queuing_time,12,2));
-               return($smarty->fetch(get_template_path('detail.tpl', TRUE)));
-       }
-
-       /* Search button has been pressed */
-       if ($this->search_for != ""){
-               $this->start= 0;
-
-               if (is_integer (strpos($this->search_for, "*"))){
-                       $s= $this->search_for;
-               } else {
-                       $s= "*".$this->search_for."*";
-               }
-               $ldap= $this->config->get_ldap_link();
-               $ldap->cd ($this->search_base);
-
-               /* Perform ldap search for potential users */
-               $ldap->search ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))".
-                       "(objectClass=goFaxAccount)".
-                       "(|(uid=$s)(l=$s)(homePhone=$s)".
-                       "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)".
-                       "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)".
-                       "(title=$s)))");
-
-               $fax_users= array();
-               while ($attrs= $ldap->fetch()){
-                       $acl= get_permissions ($ldap->getDN(), $this->ui->subtreeACL);
-                       $acl= get_module_permission($acl, "fax", $ldap->getDN());
-
-                       if (chkacl ($acl, "faxReport") == ""){
-                               $fax_users[]= $attrs["uid"][0];
-                       }
-               }
-
-               /* Prepare SQL query */
-               $this->userfilter= "";
-               foreach ($fax_users as $user){
-                       $this->userfilter.= "uid = '$user' OR ";
-               }
-               $this->userfilter= preg_replace("/OR $/", "", $this->userfilter);
-       }
-
-
-       /* Perform SQL query */
-       if ($this->userfilter){
-               if ($this->sort_direction == "down"){
-                       $desc= "DESC";
-               } else {
-                       $desc= "";
-               }
-               $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year));
-               $end=   date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year));
-               $query = "SELECT id,uid,date_format(queuing_time, '%Y%m%d%H%i%s') as queuing_time,status,sender_id,receiver_id,pages FROM faxlog ".
-                       "WHERE ( ".$this->userfilter." ) AND queuing_time <= $end AND ".
-                       "queuing_time >= $start ORDER BY ".$this->fields[$this->sort]." $desc;";
-
-               if(!is_callable("mysql_connect")){
-                       print_red("There is no mysql extension configured in your php setup.");
-                       return;
-               }
-
-               /* Connecting, selecting database */
-               $cfg= $this->config->data['SERVERS']['FAX'];
-               $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
-               if ($link === FALSE){
-                       print_red(_("Can't connect to fax database, no reports can be shown!"));
-                       return;
-               }
-               if (! @mysql_select_db("gofax")){
-                       print_red(_("Can't select fax database for report generation!"));
-                       return;
-               }
-
-               @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,
-                       $query, "Database query");
-               $result = @mysql_query($query);
-               if ($result === false){
-                       print_red(_("Query for fax database failed!"));
-                       return;
-               }
-
-               $report_list= array();
-               while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
-                       $hour=  substr($line["queuing_time"], 8, 2);
-                       $minute=substr($line["queuing_time"], 10, 2);
-                       $format= _("Y-M-D");
-                       $date= preg_replace("/Y/", substr($line["queuing_time"], 0, 4), $format);
-                       $date= preg_replace("/M/", substr($line["queuing_time"], 4, 2), $date);
-                       $date= preg_replace("/D/", substr($line["queuing_time"], 6, 2), $date);
-
-
-                       $report_list[]= "<td class=\"phonelist\"><a href=\"main.php?plug=".validate($_GET['plug'])."&amp;detail=".
-                               $line["id"]."\"><img alt=\"\" align=\"middle\" border=0 src=\"".get_template_path('images/info_small.png')."\">&nbsp;".$line["uid"]."</a></td>".
-                               "<td>$date $hour:$minute</td>".
-                               "<td>".$this->status[$line["status"]]."</td>".
-                               "<td>".$line["sender_id"]."</td>".
-                               "<td>".$line["receiver_id"]."</td>".
-                               "<td>".$line["pages"]."</td>";
-               }
-
-               $this->report_list= $report_list;
-               mysql_close($link);
-       }
-
-       /* Generate output */
-       $mod= 0;
-       if (isset($_GET['start'])){
-               $this->start= (int)$_GET['start'];
-       }
-
-       $output= "";
-       foreach ($this->report_list as $val){
-               if ($mod < $this->start) {
-                       $mod++;
-                       continue;
-               }
-               if ($mod >= ($this->start + $this->range)){
-                       $mod++;
-                       break;
-               }
-               if ( ($mod++) & 1){
-                       $col= "background-color: #ECECEC;";
-               } else {
-                       $col= "background-color: #F5F5F5;";
-               }
-               $output.= "<tr style=\"height:22px; $col\">$val</tr>";
-       }
-
-       /* Prepare template */
-       $smarty->assign("search_for", $this->search_for);
-        $smarty->assign("bases", $this->config->idepartments);
-        $smarty->assign("base_select", $this->search_base);
-       $months= array();
-       $months[1]= _("January"); $months[2]= _("February"); $months[3]= _("March"); $months[4]= _("April");
-       $months[5]= _("May"); $months[6]= _("June"); $months[7]= _("July"); $months[8]= _("August");
-       $months[9]= _("September"); $months[10]= _("October"); $months[11]= _("November"); $months[12]= _("December");
-        $smarty->assign("months", $months);
-       $smarty->assign("month_select", $this->month);
-       $current= date("Y");
-       $years= array();
-       for ($y= $current - 5; $y<=$current; $y++){
-               $years[]= $y;
-       }
-        $smarty->assign("years", $years);
-       $smarty->assign("year_select", $this->year);
-
-       if (isset($fax_users) && count($fax_users)){
-               $smarty->assign("search_result", $output);
-               $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start, $this->range,"EntriesPerPage"));
-       }else{
-               $smarty->assign("search_result", "");
-       }
-
-       
-
-       /* Show main page */
-    $smarty->assign("plug", "?plug=".validate($_GET['plug']));
-       $smarty->assign("launchimage", get_template_path('images/launch.png'));
-       $smarty->assign("search_image", get_template_path('images/search.png'));
-       for($i= 0; $i<7; $i++){
-               $smarty->assign("mode$i", "");
-       }
-       $smarty->assign("mode".$this->sort, "<img alt=\"\" src=\"images/sort_".$this->sort_direction.
-                       ".png\" border=0 align=middle>");
-        return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
-  }
-
-}
-
-?>
diff --git a/plugins/gofax/reports/contents.tpl b/plugins/gofax/reports/contents.tpl
deleted file mode 100644 (file)
index eef9011..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<div class="contentboxh">
- <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
-</div>
-<div class="contentboxb">
- <p class="contentboxb" style="border-top:1px solid #B0B0B0; padding-top:5px;">
- <img alt="" align="middle" border=0 src="{$search_image}">&nbsp;{t}Search for{/t}
- <input name="search_for" size=25 maxlength=60 value="{$search_for}" title="{t}Enter user name to search for{/t}" onChange="mainform.submit()">
- {t}in{/t}
- <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}during{/t}
- <select size="1" name="month" onChange="mainform.submit()">
-  {html_options options=$months selected=$month_select}
- </select>
- {t}in{/t} 
- <select size="1" name="year" onChange="mainform.submit()">
-  {html_options values=$years output=$years selected=$year_select}
- </select>
- &nbsp;
- <input type=submit name="search" value="{t}Search{/t}">
-</p>
-</div>
-
-<br>
-
-{if $search_result ne ""}
- <table summary="" style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 border=0 rules="cols">
-  <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
-   <td><a href="main.php{$plug}&amp;sort=0">{t}User{/t} {$mode0}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=1">{t}Date{/t} {$mode1}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=2">{t}Status{/t} {$mode2}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=3">{t}Sender{/t} {$mode3}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=4">{t}Receiver{/t} {$mode4}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=5">{t}# pages{/t} {$mode5}</a></td>
-  </tr>
-  {$search_result}
- </table>
-
- <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
-  <tr>
-   <td>{$range_selector}</td>
-  </tr>
- </table>
-<p class="plugbottom">
- &nbsp;
-</p>
-
-{else}
-  <b>{t}Search returned no results...{/t}</b>
-{/if}
-
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
-  <!-- // First input field on page
-  document.mainform.search_for.focus();
-  -->
-</script>
diff --git a/plugins/gofax/reports/detail.tpl b/plugins/gofax/reports/detail.tpl
deleted file mode 100644 (file)
index 1cd45f5..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<table summary="">
- <tr>
-  <td> 
-   <a href="getfax.php?id={$detail}&amp;download=1">
-     <img  align="bottom" width="420" height="594" src="getfax.php?id={$detail}"
-          alt="{t}FAX preview - please wait{/t}" border=1>
-   </a>
-   <p style="margin-top-width:0px; text-align:center;">
-    {t}Click on fax to download{/t}
-   </p>
-  </td>
-  <td style="width:20px;">
-    &nbsp;
-  </td>
-  <td style="vertical-align:top">
-    <table summary="" border=0 cellspacing=5>
-     <tr>
-      <td><b>{t}FAX ID{/t}</b></td>
-      <td>{$fax_id}</td>
-     </tr>
-     <tr>
-      <td><b>{t}User{/t}</b></td>
-      <td>{$fax_uid}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Date / Time{/t}</b></td>
-      <td>{$date} / {$time}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Sender MSN{/t}</b></td>
-      <td>{$fax_sender_msn}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Sender ID{/t}</b></td>
-      <td>{$fax_sender_id}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Receiver MSN{/t}</b></td>
-      <td>{$fax_receiver_msn}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Receiver ID{/t}</b></td>
-      <td>{$fax_receiver_id}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Status{/t}</b></td>
-      <td>{$fax_status}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Status message{/t}</b></td>
-      <td>{$fax_status_message}</td>
-     </tr>
-     <tr>
-      <td><b>{t}Transfer time{/t}</b></td>
-      <td>{$fax_transfer_time}</td>
-     </tr>
-     <tr>
-      <td><b>{t}# pages{/t}</b></td>
-      <td>{$fax_pages}</td>
-     </tr>
-    </table>
-
-  </td>
- </tr>
-</table>
-
-<p class="plugbottom">
-  <input type=submit name="bck_to_list" value="{t}Back{/t}">
-</p>
-
diff --git a/plugins/gofax/reports/main.inc b/plugins/gofax/reports/main.inc
deleted file mode 100644 (file)
index cfa7de0..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-if (!$remove_lock){
-       /* Page header*/
-        $display= print_header(get_template_path('images/reports.png'), _("FAX reports"));
-
-        /* Create faxreport object on demand */
-        if (!isset($_SESSION['faxreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
-                $_SESSION['faxreport']= new faxreport ($config, $ui);
-        }
-        $faxreport= $_SESSION['faxreport'];
-
-        /* Execute formular */
-       $display.= $faxreport->execute ();
-       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
-
-       /* Store changes  in session */
-       $_SESSION['faxreport']= $faxreport;
-}
-?>
diff --git a/plugins/gofon/fonreports/class_fonreport.inc b/plugins/gofon/fonreports/class_fonreport.inc
new file mode 100644 (file)
index 0000000..4a08c04
--- /dev/null
@@ -0,0 +1,267 @@
+<?php
+
+class fonreport extends plugin
+{
+  /* Definitions */
+  var $plHeadline= "Phone Reports";
+  var $plDescription= "This does something";
+
+  /* For internal use */
+  var $start= 0;
+  var $search_for= "*";
+  var $search_base= "";
+  var $year= "";
+  var $month= "";
+  var $sort= 0;
+  var $sort_direction= "down";
+  var $report_list= array();
+  var $userfilter= "";
+  var $ui= NULL;
+  var $fields= array("calldate", "src", "dst", "channel", "lastapp", "disposition", "duration");
+  var $range = 20;
+
+  /* attribute list for save action */
+  var $attributes= array();
+  var $objectclasses= array();
+
+  function fonreport ($config, $ui)
+  {
+         /* Include config object */
+         $this->config= $config;
+         $this->ui= $ui;
+
+         /* Try to get matching search base for user provided
+                by 'dn' */
+         $tmp= preg_replace ("/^[^,]+,[^,]+,/", "", $ui->dn);
+         $sb= array_search($tmp, $this->config->departments);
+         if ($sb === FALSE){
+                 $sb= "/";
+         }
+         $this->search_base= $sb;
+
+         /* Get global filter config */
+         if (!is_global("fonfilter")){
+                 $ui= get_userinfo();
+                 $base= get_base_from_people($ui->dn);
+                 $fonfilter= array("year" => date("Y"),
+                                 "month" => date("m"),
+                                 "search_base" => $base,
+                                 "search_for" => "*");
+                 register_global("fonfilter", $fonfilter);
+         }
+  }
+
+  function execute()
+  {
+       /* Call parent execute */
+       plugin::execute();
+
+       if(isset($_POST['EntryPerPage'])){
+               $this->range = $_POST['EntryPerPage'];
+       }
+
+         /* Get template engine */
+         $smarty= get_smarty();
+         $fonfilter= get_global("fonfilter");
+         foreach( array("year", "month", "search_for", "search_base") as $type){
+                 if (isset($_POST[$type])){
+                         $fonfilter[$type]= $_POST[$type];
+                 }
+                 $this->$type= $fonfilter[$type];
+         }
+         register_global("fonfilter", $fonfilter);
+
+         /* Adapt sorting */
+         if (isset($_GET['sort'])){
+                 if ($this->sort == (int)$_GET['sort']){
+                         if ($this->sort_direction == "down"){
+                                 $this->sort_direction= "up";
+                         } else {
+                                 $this->sort_direction= "down";
+                         }
+                 }
+                 $this->sort= (int)$_GET['sort'];
+                 if ($this->sort < 0 || $this->sort > 6){
+                         $this->sort= 0;
+                 }
+         }
+
+         /* Search button has been pressed */
+         if ($this->search_for != ""){
+                 $this->start= 0;
+
+                 if (is_integer (strpos($this->search_for, "*"))){
+                         $s= $this->search_for;
+                 } else {
+                         $s= "*".$this->search_for."*";
+                 }
+                 $ldap= $this->config->get_ldap_link();
+                 $ldap->cd ($this->search_base);
+
+                 /* Perform ldap search for potential users */
+                 $ldap->search ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))".
+                                 "(objectClass=gofonAccount)".
+                                 "(|(uid=$s)(l=$s)(homePhone=$s)".
+                                 "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)".
+                                 "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)".
+                                 "(title=$s)))");
+
+                 $fon_users= array();
+                 while ($attrs= $ldap->fetch()){
+                         $acl= get_permissions ($ldap->getDN(), $this->ui->subtreeACL);
+                         $acl= get_module_permission($acl, "fax", $ldap->getDN());
+
+                         if (chkacl ($acl, "faxReport") == ""){
+                                 $fax_users[]= $attrs["uid"][0];
+                         }
+                 }
+
+                 /* Prepare SQL query */
+                 $this->userfilter= "";
+                 foreach ($fon_users as $user){
+                         $this->userfilter.= "uid = '$user' OR ";
+                 }
+                 $this->userfilter= preg_replace("/OR $/", "", $this->userfilter);
+         }
+
+         /* Perform SQL query */
+##### FIXME ACL, FILTER ######
+#        if ($this->userfilter){
+       if ($this->sort_direction == "down"){
+               $desc= "DESC";
+       } else {
+               $desc= "";
+       }
+       $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year));
+       $end=   date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year));
+       $query = "SELECT calldate, channel, src, clid, lastapp, lastdata, dst, ".
+               "disposition, duration FROM cdr ".
+               "WHERE calldate <= $end AND ".
+               "calldate >= $start ORDER BY ".$this->fields[$this->sort]." $desc;";
+
+       /* Connecting, selecting database */
+       if (!isset($this->config->data['SERVERS']['FON'])){
+               return ("");
+       }
+
+       if(!is_callable("mysql_connect")){
+               print_red("There is no mysql extension available.");
+               return;
+       }
+
+       $cfg= $this->config->data['SERVERS']['FON'];
+       $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!"));
+               return;
+       }
+       if (! @mysql_select_db("gophone")){
+               print_red(_("Can't select phone database for report generation!"));
+               return;
+       }
+
+       @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,
+                       $query, "Database query");
+
+       $result = @mysql_query($query);
+       if ($result === false){
+               print_red(_("Query for phone database failed!"));
+               return;
+       }
+       $report_list= array();
+       while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
+               $hour=  substr($line["calldate"], 11, 2);
+               $minute=substr($line["calldate"], 14, 2);
+               $format= _("Y-M-D");
+               $date= preg_replace("/Y/", substr($line["calldate"], 0, 4), $format);
+               $date= preg_replace("/M/", substr($line["calldate"], 5, 2), $date);
+               $date= preg_replace("/D/", substr($line["calldate"], 8, 2), $date);
+
+               $report_list[]= "<td>$date $hour:$minute</td>".
+                       "<td>".$line["src"]."</td>".
+                       "<td>".$line["dst"]."</td>".
+                       "<td>".$line["channel"]."</td>".
+                       "<td>".$line["lastapp"]."</td>".
+                       "<td>".$line["disposition"]."</td>".
+                       "<td>".$this->gen_duration($line["duration"])."</td>";
+       }
+
+       $this->report_list= $report_list;
+       mysql_close($link);
+#        }
+
+       /* Generate output */
+       $mod= 0;
+       if (isset($_GET['start'])){
+               $this->start= (int)$_GET['start'];
+       }
+
+       $output= "";
+       foreach ($this->report_list as $val){
+               if ($mod < $this->start) {
+                       $mod++;
+                       continue;
+               }
+               if ($mod >= ($this->start + $this->range)){
+                       $mod++;
+                       break;
+               }
+               if ( ($mod++) & 1){
+                       $col= "background-color: #ECECEC;";
+               } else {
+                       $col= "background-color: #F5F5F5;";
+               }
+               $output.= "<tr style=\"height:22px; $col\">$val</tr>";
+       }
+
+       /* Prepare template */
+       $smarty->assign("search_for", $this->search_for);
+       $smarty->assign("bases", $this->config->idepartments);
+       $smarty->assign("base_select", $this->search_base);
+       $months= array();
+       $months[1]= _("January"); $months[2]= _("February"); $months[3]= _("March"); $months[4]= _("April");
+       $months[5]= _("May"); $months[6]= _("June"); $months[7]= _("July"); $months[8]= _("August");
+       $months[9]= _("September"); $months[10]= _("October"); $months[11]= _("November"); $months[12]= _("December");
+       $smarty->assign("months", $months);
+       $smarty->assign("month_select", $this->month);
+       $current= date("Y");
+       $years= array();
+       for ($y= $current - 5; $y<=$current; $y++){
+               $years[]= $y;
+       }
+       $smarty->assign("years", $years);
+       $smarty->assign("year_select", $this->year);
+
+       if ($output != ""){
+               $smarty->assign("search_result", $output);
+               $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start,$this->range,"EntryPerPage"));
+       } else {
+               $smarty->assign("search_result", "");
+       }
+
+       /* Show main page */
+       $smarty->assign("plug", "?plug=".validate($_GET['plug']));
+       $smarty->assign("launchimage", get_template_path('images/launch.png'));
+       $smarty->assign("search_image", get_template_path('images/search.png'));
+        for($i= 0; $i<7; $i++){
+                $smarty->assign("mode$i", "");
+        }
+       $smarty->assign("mode".$this->sort, "<img alt=\"\" src=\"images/sort_".$this->sort_direction.
+                       ".png\" border=0 align=middle>");
+       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
+  }
+
+  function gen_duration($seconds)
+  {
+       if ($seconds / 60 > 1){
+               $minutes= (int)($seconds / 60);
+               $seconds= $seconds % 60;
+               return ("$minutes&rsquo;$seconds&rdquo;");
+       }
+       
+       return ("$seconds&rdquo;");
+  }
+
+}
+
+?>
diff --git a/plugins/gofon/fonreports/contents.tpl b/plugins/gofon/fonreports/contents.tpl
new file mode 100644 (file)
index 0000000..3a780ca
--- /dev/null
@@ -0,0 +1,59 @@
+<div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
+</div>
+<div class="contentboxb">
+ <p class="contentboxb" style="border-top:1px solid #B0B0B0; padding-top:5px;">
+ <img alt="" align="middle" border=0 src="{$search_image}">&nbsp;{t}Search for{/t}
+ <input name="search_for" size=25 maxlength=60 value="{$search_for}" title="{t}Enter user name to search for{/t}" onChange="mainform.submit()">
+ {t}in{/t}
+ <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}during{/t}
+ <select size="1" name="month" onChange="mainform.submit()">
+  {html_options options=$months selected=$month_select}
+ </select>
+ {t}in{/t} 
+ <select size="1" name="year" onChange="mainform.submit()">
+  {html_options values=$years output=$years selected=$year_select}
+ </select>
+ &nbsp;
+ <input type=submit name="search" value="{t}Search{/t}">
+</p>
+</div>
+
+<br>
+
+{if $search_result ne ""}
+ <table style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 border=0 rules="cols" summary="">
+  <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
+   <td><a href="main.php{$plug}&amp;sort=0">{t}Date{/t} {$mode0}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=1">{t}Source{/t} {$mode1}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=2">{t}Destination{/t} {$mode2}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=3">{t}Channel{/t} {$mode3}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=4">{t}Application{/t} {$mode4}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=5">{t}Status{/t} {$mode5}</a></td>
+   <td><a href="main.php{$plug}&amp;sort=6">{t}Duration{/t} {$mode6}</a></td>
+  </tr>
+  {$search_result}
+ </table>
+
+ <table style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0 summary="">
+  <tr>
+   <td>{$range_selector}</td>
+  </tr>
+ </table>
+
+<p class="plugbottom">
+ &nbsp;
+</p>
+{else}
+  <b>{t}Search returned no results...{/t}</b>
+{/if}
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+  document.mainform.search_for.focus();
+  -->
+</script>
diff --git a/plugins/gofon/fonreports/main.inc b/plugins/gofon/fonreports/main.inc
new file mode 100644 (file)
index 0000000..f79641b
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+if (!$remove_lock){
+       /* Page header*/
+        $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports"));
+
+        /* Create fonreport object on demand */
+        if (!isset($_SESSION['fonreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+                $_SESSION['fonreport']= new fonreport ($config, $ui);
+        }
+        $fonreport= $_SESSION['fonreport'];
+
+        /* Execute formular */
+       $display.= $fonreport->execute ();
+       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+       /* Store changes  in session */
+       $_SESSION['fonreport']= $fonreport;
+}
+?>
diff --git a/plugins/gofon/reports/class_fonreport.inc b/plugins/gofon/reports/class_fonreport.inc
deleted file mode 100644 (file)
index 4a08c04..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-<?php
-
-class fonreport extends plugin
-{
-  /* Definitions */
-  var $plHeadline= "Phone Reports";
-  var $plDescription= "This does something";
-
-  /* For internal use */
-  var $start= 0;
-  var $search_for= "*";
-  var $search_base= "";
-  var $year= "";
-  var $month= "";
-  var $sort= 0;
-  var $sort_direction= "down";
-  var $report_list= array();
-  var $userfilter= "";
-  var $ui= NULL;
-  var $fields= array("calldate", "src", "dst", "channel", "lastapp", "disposition", "duration");
-  var $range = 20;
-
-  /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
-
-  function fonreport ($config, $ui)
-  {
-         /* Include config object */
-         $this->config= $config;
-         $this->ui= $ui;
-
-         /* Try to get matching search base for user provided
-                by 'dn' */
-         $tmp= preg_replace ("/^[^,]+,[^,]+,/", "", $ui->dn);
-         $sb= array_search($tmp, $this->config->departments);
-         if ($sb === FALSE){
-                 $sb= "/";
-         }
-         $this->search_base= $sb;
-
-         /* Get global filter config */
-         if (!is_global("fonfilter")){
-                 $ui= get_userinfo();
-                 $base= get_base_from_people($ui->dn);
-                 $fonfilter= array("year" => date("Y"),
-                                 "month" => date("m"),
-                                 "search_base" => $base,
-                                 "search_for" => "*");
-                 register_global("fonfilter", $fonfilter);
-         }
-  }
-
-  function execute()
-  {
-       /* Call parent execute */
-       plugin::execute();
-
-       if(isset($_POST['EntryPerPage'])){
-               $this->range = $_POST['EntryPerPage'];
-       }
-
-         /* Get template engine */
-         $smarty= get_smarty();
-         $fonfilter= get_global("fonfilter");
-         foreach( array("year", "month", "search_for", "search_base") as $type){
-                 if (isset($_POST[$type])){
-                         $fonfilter[$type]= $_POST[$type];
-                 }
-                 $this->$type= $fonfilter[$type];
-         }
-         register_global("fonfilter", $fonfilter);
-
-         /* Adapt sorting */
-         if (isset($_GET['sort'])){
-                 if ($this->sort == (int)$_GET['sort']){
-                         if ($this->sort_direction == "down"){
-                                 $this->sort_direction= "up";
-                         } else {
-                                 $this->sort_direction= "down";
-                         }
-                 }
-                 $this->sort= (int)$_GET['sort'];
-                 if ($this->sort < 0 || $this->sort > 6){
-                         $this->sort= 0;
-                 }
-         }
-
-         /* Search button has been pressed */
-         if ($this->search_for != ""){
-                 $this->start= 0;
-
-                 if (is_integer (strpos($this->search_for, "*"))){
-                         $s= $this->search_for;
-                 } else {
-                         $s= "*".$this->search_for."*";
-                 }
-                 $ldap= $this->config->get_ldap_link();
-                 $ldap->cd ($this->search_base);
-
-                 /* Perform ldap search for potential users */
-                 $ldap->search ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))".
-                                 "(objectClass=gofonAccount)".
-                                 "(|(uid=$s)(l=$s)(homePhone=$s)".
-                                 "(telephoneNumber=$s)(facsimileTelephoneNumber=$s)(mobile=$s)".
-                                 "(pager=$s)(cn=$s)(givenName=$s)(sn=$s)(personalTitle=$s)".
-                                 "(title=$s)))");
-
-                 $fon_users= array();
-                 while ($attrs= $ldap->fetch()){
-                         $acl= get_permissions ($ldap->getDN(), $this->ui->subtreeACL);
-                         $acl= get_module_permission($acl, "fax", $ldap->getDN());
-
-                         if (chkacl ($acl, "faxReport") == ""){
-                                 $fax_users[]= $attrs["uid"][0];
-                         }
-                 }
-
-                 /* Prepare SQL query */
-                 $this->userfilter= "";
-                 foreach ($fon_users as $user){
-                         $this->userfilter.= "uid = '$user' OR ";
-                 }
-                 $this->userfilter= preg_replace("/OR $/", "", $this->userfilter);
-         }
-
-         /* Perform SQL query */
-##### FIXME ACL, FILTER ######
-#        if ($this->userfilter){
-       if ($this->sort_direction == "down"){
-               $desc= "DESC";
-       } else {
-               $desc= "";
-       }
-       $start= date ("YmdHis", mktime(0,0,0,$this->month,1,$this->year));
-       $end=   date ("YmdHis", mktime(23,59,59,$this->month+1,0,$this->year));
-       $query = "SELECT calldate, channel, src, clid, lastapp, lastdata, dst, ".
-               "disposition, duration FROM cdr ".
-               "WHERE calldate <= $end AND ".
-               "calldate >= $start ORDER BY ".$this->fields[$this->sort]." $desc;";
-
-       /* Connecting, selecting database */
-       if (!isset($this->config->data['SERVERS']['FON'])){
-               return ("");
-       }
-
-       if(!is_callable("mysql_connect")){
-               print_red("There is no mysql extension available.");
-               return;
-       }
-
-       $cfg= $this->config->data['SERVERS']['FON'];
-       $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!"));
-               return;
-       }
-       if (! @mysql_select_db("gophone")){
-               print_red(_("Can't select phone database for report generation!"));
-               return;
-       }
-
-       @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,
-                       $query, "Database query");
-
-       $result = @mysql_query($query);
-       if ($result === false){
-               print_red(_("Query for phone database failed!"));
-               return;
-       }
-       $report_list= array();
-       while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
-               $hour=  substr($line["calldate"], 11, 2);
-               $minute=substr($line["calldate"], 14, 2);
-               $format= _("Y-M-D");
-               $date= preg_replace("/Y/", substr($line["calldate"], 0, 4), $format);
-               $date= preg_replace("/M/", substr($line["calldate"], 5, 2), $date);
-               $date= preg_replace("/D/", substr($line["calldate"], 8, 2), $date);
-
-               $report_list[]= "<td>$date $hour:$minute</td>".
-                       "<td>".$line["src"]."</td>".
-                       "<td>".$line["dst"]."</td>".
-                       "<td>".$line["channel"]."</td>".
-                       "<td>".$line["lastapp"]."</td>".
-                       "<td>".$line["disposition"]."</td>".
-                       "<td>".$this->gen_duration($line["duration"])."</td>";
-       }
-
-       $this->report_list= $report_list;
-       mysql_close($link);
-#        }
-
-       /* Generate output */
-       $mod= 0;
-       if (isset($_GET['start'])){
-               $this->start= (int)$_GET['start'];
-       }
-
-       $output= "";
-       foreach ($this->report_list as $val){
-               if ($mod < $this->start) {
-                       $mod++;
-                       continue;
-               }
-               if ($mod >= ($this->start + $this->range)){
-                       $mod++;
-                       break;
-               }
-               if ( ($mod++) & 1){
-                       $col= "background-color: #ECECEC;";
-               } else {
-                       $col= "background-color: #F5F5F5;";
-               }
-               $output.= "<tr style=\"height:22px; $col\">$val</tr>";
-       }
-
-       /* Prepare template */
-       $smarty->assign("search_for", $this->search_for);
-       $smarty->assign("bases", $this->config->idepartments);
-       $smarty->assign("base_select", $this->search_base);
-       $months= array();
-       $months[1]= _("January"); $months[2]= _("February"); $months[3]= _("March"); $months[4]= _("April");
-       $months[5]= _("May"); $months[6]= _("June"); $months[7]= _("July"); $months[8]= _("August");
-       $months[9]= _("September"); $months[10]= _("October"); $months[11]= _("November"); $months[12]= _("December");
-       $smarty->assign("months", $months);
-       $smarty->assign("month_select", $this->month);
-       $current= date("Y");
-       $years= array();
-       for ($y= $current - 5; $y<=$current; $y++){
-               $years[]= $y;
-       }
-       $smarty->assign("years", $years);
-       $smarty->assign("year_select", $this->year);
-
-       if ($output != ""){
-               $smarty->assign("search_result", $output);
-               $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start,$this->range,"EntryPerPage"));
-       } else {
-               $smarty->assign("search_result", "");
-       }
-
-       /* Show main page */
-       $smarty->assign("plug", "?plug=".validate($_GET['plug']));
-       $smarty->assign("launchimage", get_template_path('images/launch.png'));
-       $smarty->assign("search_image", get_template_path('images/search.png'));
-        for($i= 0; $i<7; $i++){
-                $smarty->assign("mode$i", "");
-        }
-       $smarty->assign("mode".$this->sort, "<img alt=\"\" src=\"images/sort_".$this->sort_direction.
-                       ".png\" border=0 align=middle>");
-       return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
-  }
-
-  function gen_duration($seconds)
-  {
-       if ($seconds / 60 > 1){
-               $minutes= (int)($seconds / 60);
-               $seconds= $seconds % 60;
-               return ("$minutes&rsquo;$seconds&rdquo;");
-       }
-       
-       return ("$seconds&rdquo;");
-  }
-
-}
-
-?>
diff --git a/plugins/gofon/reports/contents.tpl b/plugins/gofon/reports/contents.tpl
deleted file mode 100644 (file)
index 3a780ca..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-<div class="contentboxh">
- <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
-</div>
-<div class="contentboxb">
- <p class="contentboxb" style="border-top:1px solid #B0B0B0; padding-top:5px;">
- <img alt="" align="middle" border=0 src="{$search_image}">&nbsp;{t}Search for{/t}
- <input name="search_for" size=25 maxlength=60 value="{$search_for}" title="{t}Enter user name to search for{/t}" onChange="mainform.submit()">
- {t}in{/t}
- <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}during{/t}
- <select size="1" name="month" onChange="mainform.submit()">
-  {html_options options=$months selected=$month_select}
- </select>
- {t}in{/t} 
- <select size="1" name="year" onChange="mainform.submit()">
-  {html_options values=$years output=$years selected=$year_select}
- </select>
- &nbsp;
- <input type=submit name="search" value="{t}Search{/t}">
-</p>
-</div>
-
-<br>
-
-{if $search_result ne ""}
- <table style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 border=0 rules="cols" summary="">
-  <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
-   <td><a href="main.php{$plug}&amp;sort=0">{t}Date{/t} {$mode0}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=1">{t}Source{/t} {$mode1}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=2">{t}Destination{/t} {$mode2}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=3">{t}Channel{/t} {$mode3}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=4">{t}Application{/t} {$mode4}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=5">{t}Status{/t} {$mode5}</a></td>
-   <td><a href="main.php{$plug}&amp;sort=6">{t}Duration{/t} {$mode6}</a></td>
-  </tr>
-  {$search_result}
- </table>
-
- <table style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0 summary="">
-  <tr>
-   <td>{$range_selector}</td>
-  </tr>
- </table>
-
-<p class="plugbottom">
- &nbsp;
-</p>
-{else}
-  <b>{t}Search returned no results...{/t}</b>
-{/if}
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
-  <!-- // First input field on page
-  document.mainform.search_for.focus();
-  -->
-</script>
diff --git a/plugins/gofon/reports/main.inc b/plugins/gofon/reports/main.inc
deleted file mode 100644 (file)
index f79641b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-if (!$remove_lock){
-       /* Page header*/
-        $display= print_header(get_template_path('images/phonereport.png'), _("Phone reports"));
-
-        /* Create fonreport object on demand */
-        if (!isset($_SESSION['fonreport']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
-                $_SESSION['fonreport']= new fonreport ($config, $ui);
-        }
-        $fonreport= $_SESSION['fonreport'];
-
-        /* Execute formular */
-       $display.= $fonreport->execute ();
-       $display.= "<input type=\"hidden\" name=\"ignore\">\n";
-
-       /* Store changes  in session */
-       $_SESSION['fonreport']= $fonreport;
-}
-?>