graph date filter
[scannr.git] / viewcalls.php
blob:a/viewcalls.php -> blob:b/viewcalls.php
--- a/viewcalls.php
+++ b/viewcalls.php
@@ -1,7 +1,16 @@
 <?php
 include('common.inc.php');
 $tgid = 44028;
+$from = (isset($_REQUEST['from']) ? $_REQUEST['from'] : strtotime("2012-09-12"));
+$to = (isset($_REQUEST['to']) ? $_REQUEST['to'] : strtotime("2012-12-12"));
 include_header("fdds");
+    $sth = $conn->prepare('select distinct date_trunc(\'day\', call_timestamp) as rdate from recordings order by rdate');
+
+    $sth->execute();
+    foreach( $sth->fetchAll() as $row) {
+echo '<a href="?from='.strtotime($row['rdate']).'&amp;to='.strtotime($row['rdate'].' +1 day').'">'.$row['rdate'].'</a> <br>';
+}
+
 ?>
 <div class="span12">
 
@@ -48,7 +57,7 @@
             Flotr.EventAdapter.observe(placeholder, 'flotr:click', function () { drawGraph(); });
 
                
-        getData('<?php echo $tgid; ?>','<?php echo strtotime("10/09/2012") ?>','<?php echo strtotime("10/11/2012") ?>');
+        getData('<?php echo $tgid; ?>','<?php echo $from ?>','<?php echo $to ?>');
         
     });
 
@@ -91,3 +100,4 @@
 <?php
 include_footer();
 ?>
+