From: hickert Date: Thu, 1 Apr 2010 07:42:13 +0000 (+0000) Subject: Updated Phone reports X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c281eb02d5377557adcc9e755046f0a64cd6a59b;p=gosa.git Updated Phone reports -Increased performance, only request entries in range. -Fixed style -Fixed w3c errors git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17447 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/gofon/gofon/fonreports/class_fonreport.inc b/gosa-plugins/gofon/gofon/fonreports/class_fonreport.inc index bbb6f98ea..1ed3ecfa7 100644 --- a/gosa-plugins/gofon/gofon/fonreports/class_fonreport.inc +++ b/gosa-plugins/gofon/gofon/fonreports/class_fonreport.inc @@ -207,11 +207,25 @@ class fonreport extends plugin Get Query String && Search *****************/ - $query = $this->CreateQuerySyntax(); $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']); @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + // Get all matching entries to be able to fill the pager + $query = $this->CreateQuerySyntax($limit = FALSE); + $count = @mysql_query($query); + if ($count === false){ + msg_dialog::display(_("Error"), msgPool::dbquery(_("GOfon"),@mysql_error(),$cfg['SERVER']),ERROR_DIALOG); + return($smarty->fetch(get_template_path('contents.tpl', TRUE))); + } + $tmp = mysql_fetch_array($count, MYSQL_ASSOC); + $res_count = $tmp['count']; + if($res_count < $this->start){ + $this->start = 0; + } + + // Get entries for the selected range only. + $query = $this->CreateQuerySyntax($limit = TRUE); $result = @mysql_query($query); if ($result === false){ msg_dialog::display(_("Error"), msgPool::dbquery(_("GOfon"),@mysql_error(),$cfg['SERVER']),ERROR_DIALOG); @@ -232,16 +246,16 @@ class fonreport extends plugin while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { + // Check attribute permissions foreach($line as $attr => $value){ - if($attr == "duration") continue; - $acl = $this->ui->get_permissions($this->search_base,"fonreport/fonreport",$attr); if(!preg_match("/r/",$acl)){ $line[$attr] = $no_acl; } } + // Check date permissions if($this->ui->get_permissions($this->search_base,"fonreport/fonreport","calldate")){ $hour= substr($line["calldate"], 11, 2); $minute=substr($line["calldate"], 14, 2); @@ -254,19 +268,16 @@ class fonreport extends plugin $date_str = $no_acl; } - $append_str = ""; - $append_str .= "".$date_str.""; - + $append_str = "".$date_str.""; foreach(array("src","dst","channel","lastapp","disposition") as $atr){ if(isset($line[$atr])){ - $append_str .= "".$line[$atr].""; + $append_str .= "".$line[$atr].""; } } - if($this->ui->get_permissions($this->search_base,"fonreport/fonreport","duration")){ - $append_str .= "".$this->gen_duration($line["duration"]).""; + $append_str .= "".$this->gen_duration($line["duration"]).""; }else{ - $append_str .= "".$no_acl.""; + $append_str .= "".$no_acl.""; } $report_list[] = $append_str; } @@ -282,24 +293,8 @@ class fonreport extends plugin /* Generate output */ $mod = 0; $output = ""; - if(count($this->report_list) < $this->start){ - $this->start = 0; - } 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.= "$val"; + $output.= "$val"; } /***************** @@ -308,7 +303,7 @@ class fonreport extends plugin if ($output != ""){ $smarty->assign("search_result", $output); - $smarty->assign("range_selector", range_selector(count($this->report_list), $this->start,$this->range,"EntryPerPage")); + $smarty->assign("range_selector", range_selector($res_count, $this->start,$this->range,"EntryPerPage")); } else { $smarty->assign("search_result", ""); } @@ -372,7 +367,7 @@ class fonreport extends plugin /* Create query string */ - function CreateQuerySyntax() + function CreateQuerySyntax($limit = TRUE) { /* Get extended search filter which contain uids and so on */ $uidstring = $this->GetUidMatchingFilter(); @@ -396,13 +391,34 @@ class fonreport extends plugin /* Create times */ $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 ".$fields_str.",calldate FROM cdr ". + + if(!$limit){ + $fieldset = "count(dst) as `count`"; + }else{ + + /* Create string with all fields seperated by ,*/ + $fields_str =""; + foreach($this->fields as $field){ + if($field == "calldate") continue; + $fields_str .= $field.", "; + } + $fields_str = preg_replace("/, $/","",$fields_str); + $fieldset = $fields_str.",calldate"; + } + + $query = "SELECT {$fieldset} FROM cdr ". "WHERE calldate <= $end AND calldate >= $start ". $uidstring." - ORDER BY ".$this->fields[$this->sort]." $desc;"; + ORDER BY ".$this->fields[$this->sort]." $desc"; + + // Set limitations + if($limit){ + $query.=" LIMIT ".($this->start).", ".$this->range; + } + $query.=";"; return($query); } diff --git a/gosa-plugins/gofon/gofon/fonreports/contents.tpl b/gosa-plugins/gofon/gofon/fonreports/contents.tpl index 86797c96a..94cebf826 100644 --- a/gosa-plugins/gofon/gofon/fonreports/contents.tpl +++ b/gosa-plugins/gofon/gofon/fonreports/contents.tpl @@ -1,57 +1,79 @@ -
-

{image path="{$launchimage}" align="right"}{t}Filter{/t} -

-
-
-

- {image path="{$search_image}"} {t}Search for{/t} - - - {t}in{/t} - - {t}on{/t} - - {t}during{/t} - - {t}in{/t} - -   - - -

+
+
+

{t}System logs{/t}

+ +
+ + + + + + + +
{t}Server{/t} + + {t}Date{/t} + + + {t}Search for{/t} + + + +
+ +
+

{if $search_result} - - - - - - - - - - {$search_result} -
{t}Date{/t} {$mode0}{t}Source{/t} {$mode1}{t}Destination{/t} {$mode2}{t}Channel{/t} {$mode3}{t}Application{/t} {$mode4}{t}Status{/t} {$mode5}{t}Duration{/t} {$mode6}
- - - - -
{$range_selector}
- -
+ + +
+
+ {$range_selector} +
+
+ {else} - {t}Search returned no results...{/t} +
+ {t}Search returned no results...{/t} {/if} diff --git a/gosa-plugins/gofon/gofon/fonreports/main.inc b/gosa-plugins/gofon/gofon/fonreports/main.inc index cbd957edd..21660c85c 100644 --- a/gosa-plugins/gofon/gofon/fonreports/main.inc +++ b/gosa-plugins/gofon/gofon/fonreports/main.inc @@ -18,9 +18,6 @@ if ( $cleanup ){ $display= $fonreport->execute (); $display.= "\n"; - /* Page header*/ - $display= print_header(get_template_path('plugins/gofon/images/phonereport.png'), _("Phone reports")).$display; - /* Store changes in session */ session::set('fonreport',$fonreport); }