db = $db; } /** * Funcion para recuperar la base de datos * @return type */ public function getDb() { return $this->db; } /** * Constructor de la Clase */ public function __construct() { } function get_calls(){ $sql= "SELECT a.*, c.restoid as restoid, r.name as restoname from callsacount as c inner join calls as a on c.numbertwilio=a.CallTo inner join restaurants as r on r.id=c.restoid ORDER BY a.DateCreated DESC"; //$x = $this->db->Execute($sql); $x = $this->db->Execute($sql); $calls=array(); if (!$x) { echo "no entro el recorset"; } else { //$this->total_registros = $x->RecordCount(); foreach ($x as $row) { $call['CallSid'] = $row['CallSid']; $call['CallFrom'] = $row['CallFrom']; $call['restoid'] = $row['restoid']; $call['restoname'] = $row['restoname']; $call['CallTo'] = $row['CallTo']; $call['FromCity'] = $row['FromCity']; $call['FromState'] = $row['FromState']; $call['FromZip'] = $row['FromZip']; $call['DialCallDuration'] = $row['DialCallDuration']; $call['DialCallStatus'] = $row['CallStatus']; $call['RecordingUrl'] = $row['RecordingUrl']; $call['DateCreated'] = $row['DateCreated']; $calls[] = $call; } } return $calls; } function get_calls_count(){ $sql='SELECT count(*) as cnt, CallTo FROM calls GROUP BY CallTo ORDER BY cnt DESC'; $x = $this->db->Execute($sql); $this->total_registros = $x->RecordCount(); $calls=array(); foreach ($x as $row) { $call['cnt'] = $row['cnt']; $call['CallTo'] = $row['CallTo']; $calls[] = $call; } return $calls; } function get_calls_totals(){ $sql='select count(c.numbertwilio) as total,c.restoid as restoid, r.name as restoname, sum(a.DialCallDuration) as mints from callsacount as c inner join calls as a on c.numbertwilio=a.CallTo inner join restaurants as r on r.id=c.restoid group by c.restoid,r.name,a.CallTo order by 1 desc'; $x = $this->db->Execute($sql); $this->total_registros = $x->RecordCount(); $calls=array(); foreach ($x as $row) { $call['restoid'] = $row['restoid']; $call['restoname'] = $row['restoname']; $call['total'] = $row['total']; $call['mints'] = $row['mints']; $calls[] = $call; } return $calls; } } ?>