<?php
 class OpActions2DB extends ADO { public function __construct( $app, $dburi, $debug=false, $tmode=true, $dformat='') { $this->owner = $app; if ( !empty($dburi)) $this->dburi = $dburi; return parent::__construct( $this->dburi, $debug, $tmode, $dformat); } public function get_records($lines_per_page, $page=0, $id='', $date='', $edate='', $callfrom='') { $ext = ''; $need_and = false; if ( $id != '') { $ext .= "actions.Username LIKE'%" . $id . "%' "; $need_and = true; } if ( $date != '' && $date != '1970-01-01') { if ( $need_and) $ext .= ' AND '; $ext .= 'substr(actions.Start_Time::text,0,10)=\'' . $date . '\''; $need_and = true; } if ( $edate != '' && $edate != '1970-01-01') { if ( $need_and) $ext .= ' AND '; $ext .= 'substr(actions.Stop_Time::text,0,10)=\'' . $edate . '\''; $need_and = true; } if ( $callfrom != '') { if ( $need_and) $ext .= ' AND '; $ext .= 'actions.Call_From LIKE \'%' . $callfrom . '%\''; } if ( !$need_and) $ext .= ' 1'; $ext .= ' ORDER BY actions.Start_Time DESC'; $res = $this->GetAll("SELECT count(*), time_show(sum(actions.time_on)::int8) FROM actions,group_tracker WHERE actions.gid=group_tracker.gid AND group_tracker.obj_id='".$GLOBALS['SSXID']."' AND ".$ext); $limits = false; if ( $page >= 0) { $low = $page*$lines_per_page; $high = $lines_per_page; $limits = true; } $query = "SELECT actions.Username,ts_show(actions.Start_Time::int8),ts_show(actions.Stop_Time),actions.Call_From,actions.Call_To,actions.Ip,time_show(actions.Time_On),actions.In_Bytes,actions.Out_Bytes,actions.Billing_Minus,actions.Terminate_Cause,actions.Port FROM actions,group_tracker WHERE actions.gid=group_tracker.gid AND group_tracker.obj_id='".$GLOBALS['SSXID']."' AND "; if ( $limits) { $ext .= ' OFFSET '.$low.' LIMIT '.$high; } $allRecs = $this->GetAll($query.$ext); return array((isset($res[0]) ? $res[0] : 0), $allRecs); } } ?>
