<?php
 class ProvActions2DB 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 = "sk_actions.gid=sk_packets.gid AND sk_packets.service_set_id=sk_service_set.service_set_id AND sk_service_set.service_id=1 AND sk_service_set.provider_id='".$GLOBALS['PROVIDER']."' AND "; $need_and = false; if ( $id != '') { $ext .= "sk_actions.Username LIKE'%" . $id . "%' "; $need_and = true; } if ( $date != '' && $date != '1970-01-01') { if ( $need_and) $ext .= ' AND '; $ext .= 'substr(sk_actions.Start_Time::text,0,10)=\'' . $date . '\''; $need_and = true; } if ( $edate != '' && $edate != '1970-01-01') { if ( $need_and) $ext .= ' AND '; $ext .= 'substr(sk_actions.Stop_Time::text,0,10)=\'' . $edate . '\''; $need_and = true; } if ( $callfrom != '') { if ( $need_and) $ext .= ' AND '; $ext .= 'sk_actions.Call_From LIKE \'%' . $callfrom . '%\''; } if ( !$need_and) $ext .= ' 1'; $ext .= ' ORDER BY sk_actions.Start_Time DESC'; $res = $this->GetAll("SELECT count(*), time_show(sum(sk_actions.time_on)::int8) FROM sk_actions,sk_packets WHERE ".$ext); $limits = false; if ( $page >= 0) { $low = $page*$lines_per_page; $high = $lines_per_page; $limits = true; } $query = 'SELECT sk_actions.Username,ts_show(sk_actions.Start_Time),ts_show(sk_actions.Stop_Time),sk_actions.Call_From,sk_actions.Call_To,sk_actions.Ip,time_show(sk_actions.Time_On::int8),sk_actions.In_Bytes,sk_actions.Out_Bytes,sk_actions.Billing_Minus,sk_actions.Terminate_Cause,sk_actions.Port FROM sk_actions,sk_packets WHERE '; if ( $limits) { $ext .= ' LIMIT '.$low.','.$high; } $allRecs = $this->GetAll($query.$ext); return array($res[0], $allRecs); } } ?>
