From 285f7ad7d0aed48cd5cb13a2437e80d26fffc254 Mon Sep 17 00:00:00 2001
From: Lennart Poettering
Date: Wed, 3 Mar 2004 01:25:46 +0000
Subject: commit initial release
git-svn-id: file:///home/lennart/svn/public/pgets/trunk@3 768266df-afd4-0310-94a7-d396c829e022
---
php/pgets.php | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 119 insertions(+)
create mode 100644 php/pgets.php
(limited to 'php/pgets.php')
diff --git a/php/pgets.php b/php/pgets.php
new file mode 100644
index 0000000..d1e8036
--- /dev/null
+++ b/php/pgets.php
@@ -0,0 +1,119 @@
+' ?>
+
+
+
+
+pgETS
+
+
+
+
+ETS Call Accounting - Query Results
+";
+
+ if ($edate != "" && $sdate != "") {
+ echo "Showing entries between $sdate (incl) and $edate (excl).";
+ } else if ($edate != "") {
+ echo "Showing entries before $edate (excl).";
+ } else if ($sdate != "") {
+ echo "Showing entries after $sdate (incl).";
+ }
+
+ echo "
";
+}
+
+$db = pg_pconnect($dbspec);
+
+$where = "WHERE 1=1";
+if ($n_direction == 1) $where = $where." AND incoming='f'";
+if ($n_direction == 2) $where = $where." AND incoming='t'";
+if ($sdate != "") $where = $where." AND _timestamp >= '$sdate'";
+if ($edate != "") $where = $where." AND _timestamp < '$edate'";
+
+$q = pg_query($db, "SELECT CASE WHEN SUBSTRING(remote_msn FROM 1 FOR 3)='".$local_prefix."' THEN SUBSTRING(TRIM(remote_msn) FROM 4) ELSE TRIM(remote_msn) END, CASE WHEN incoming='t' THEN 'Incoming' ELSE 'Outgoing' END, participant, TO_CHAR(_timestamp, 'DD.MM.YYYY HH24:MI'), CASE WHEN duration > 60 THEN duration/60||'m '||duration%60||'s' ELSE duration||'s' END FROM pgets_accounting ".$where." ORDER BY _timestamp ".$order);
+
+$num = pg_numrows($q);
+
+if ($num == 0) {
+ echo "No entries found.
\n";
+} else {
+ echo "\n\n";
+
+ $c = 0;
+
+ for ($i = 0; $i < $num; $i++) {
+ $r = pg_fetch_row($q, $i);
+
+
+ $c = 1-$c;
+
+ echo "";
+
+ for ($j=0; $j < count($r); $j++) {
+ echo " $r[$j] | ";
+ }
+
+ echo "
\n";
+ }
+
+ echo "
\n";
+
+ $q = pg_query($db, "SELECT COUNT(*),SUM(duration) FROM pgets_accounting $where");
+ $r = pg_fetch_row($q, 0);
+
+ if ($r[1] > 3600) {
+ $sum = (int) ($r[1]/3600)."h ".(int)($r[1] % 3600 / 60)."m ".(int)($r[1] % 60)."s";
+ } else if ($r[1] > 60) {
+ $sum = (int)($r[1]/60)."m ".(int)($r[1] % 60)."s";
+ } else {
+ $sum = $r[1]."s";
+ }
+
+ echo "$r[0] items, $sum total duration.
";
+}
+
+?>
+
+
+Generated:
+
+
\ No newline at end of file
--
cgit