public function toXML() { $xml = parent::toXML(); $cost = 0; $billsec = 0; foreach ($this as $row) { $cost += $row['cost']; $billsec += $row['billsec']; } $xml .= '<Cost>' . round($cost, 2) . '</Cost>' . "\r\n"; $xml .= '<BillSec>' . $billsec . '</BillSec>' . "\r\n"; return $xml; }
} else { // make query for asterisk table $query = "SELECT id,calldate,dcontext,src,clid,dst"; $query .= ",(getDirX(dst)).dir, (getDirX(dst)).dirName"; $query .= ",channel,dstchannel"; $query .= ",lastapp,lastdata,duration,billsec,disposition"; $query .= " FROM ast_cdr WHERE "; switch ($period) { case "month": $query .= "calldate >=date_trunc('month',current_date-interval '1 day')"; $query .= " and calldate < current_date"; break; case "yesterday": $query .= "calldate >= (current_date-interval '1 day')"; $query .= " and calldate < current_date"; break; case "today": $query .= "calldate >= current_date"; break; } $query .= " ORDER BY calldate DESC"; } #-- make objects Stat and CDR_Log ------------------------- $cdrLog = new GMatrix('CDRList', 'CDRListItem', DB::select($query)); #-- print out XML doc header("content-type: text/xml; charset=utf-8"); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\r"; $xml .= "<common>\n\r"; $xml .= $cdrLog->toXML(); $xml .= "</common>\n\r"; echo $xml;
$plan_id = isset($_GET['plan_id']) ? $_GET['plan_id'] : null; $oper = isset($_POST['oper']) ? $_POST['oper'] : null; $dir = isset($_POST['dir']) ? $_POST['dir'] : null; $valid = isset($_POST['valid']) ? $_POST['valid'] : '1970-01-01 00:00:00'; $valid = $valid === '' ? '1970-01-01 00:00:00' : $valid; $cost = isset($_POST['cost']) ? $_POST['cost'] : '0.0'; $rsp = null; $query = null; if ($ss->isAdmin() && isset($plan_id) && isset($dir)) { switch ($oper) { case 'del': $query = 'DELETE FROM plan_attr WHERE id=' . $plan_id . ' AND'; $query .= ' dir=\'' . $dir . '\' AND valid=\'' . $valid . '\''; break; case 'add': $query = 'INSERT INTO plan_attr VALUES(' . $plan_id . ',\'' . $dir; $query .= '\',\'' . $valid . '\',' . $cost . ')'; break; } if (isset($query)) { $num = DB::query($query); $rsp = new GMatrix('PlanEdit', 'PlanEditItem', array(array('affected_rows' => $num))); } } # -- print out XML doc -- header("content-type: text/xml; charset=utf-8"); $xml = '<?xml version="1.0" encoding="utf-8"?>' . "\r\n"; $xml .= "<common>\r\n"; $xml .= isset($rsp) ? $rsp->toXML() : ''; $xml .= "</common>\r\n"; echo $xml;
<?php ####################################################################### # # getDir.php - print out Directions as HTML SELECT TAG # # Parameters: ####################################################################### require_once $_SERVER['ATS0'] . '/classes/DB.php'; require_once $_SERVER['ATS0'] . '/classes/GMatrix.php'; # -- make a query for select appropriate data ---------------------- $query = 'SELECT dir, dir||\': \'||dir_name as dir_name FROM direction ORDER BY dir'; # -- make Directions array -- $dirs = new GMatrix('DirList', 'DirListItem', DB::select($query)); #-- print out html doc -- header('content-type: text/html; charset=utf-8'); $xml = $dirs->toSelect('dir', 'dir_name'); echo $xml;