Esempio n. 1
0
 public function executeReport2()
 {
     $monthName = array(0 => '', 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
     $param = $this->getAllRequestParameter();
     if (empty($param['type'])) {
         $this->jsonwrapper->show_json_error('#report-type', 'Report Type Not Found');
     }
     if ($param['type'] != 'monthly' && $param['type'] != 'daily') {
         $this->jsonwrapper->show_json_error('#report-type', 'Report Type Not Found');
     }
     if (empty($param['year'])) {
         $this->jsonwrapper->show_json_error('#report-type', 'Year Not Found');
     }
     if (empty($param['month'])) {
         $this->jsonwrapper->show_json_error('#report-type', 'Month Not Found');
     }
     if (empty($param['sender_id'])) {
         $this->jsonwrapper->show_json_error('#report-type', 'Sender Id Not Found');
     }
     $senderId = SmsSenderIdPeer::retrieveByPK($param['sender_id']);
     if (!$senderId) {
         $this->jsonwrapper->show_json_error('not found', 'Sender Id Not Found');
     }
     $report = array();
     if ($param['type'] == 'monthly') {
         for ($i = 1; $i <= 12; $i++) {
             $month = $i;
             if (strlen($i) < 2) {
                 $month = '0' . $i;
             }
             $date = $param['year'] . '-' . $month . '-%';
             /* Sent */
             $connection = Propel::getConnection();
             $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as send \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tsend_at LIKE '{$date}'";
             $statement = $connection->prepareStatement($query);
             $resultset = $statement->executeQuery();
             $resultset->next();
             $send = $resultset->getInt('send');
             /* Error */
             $connection = Propel::getConnection();
             $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as error \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.send_at LIKE '{$date}'\n\t\t\t\t\tAND\n\t\t\t\t\t\trec.status = 'failed'";
             $statement = $connection->prepareStatement($query);
             $resultset = $statement->executeQuery();
             $resultset->next();
             $error = $resultset->getInt('error');
             /* Success */
             $connection = Propel::getConnection();
             $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as success \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.send_at LIKE '{$date}'\n\t\t\t\t\tAND\n\t\t\t\t\t\trec.status = 'sent'";
             $statement = $connection->prepareStatement($query);
             $resultset = $statement->executeQuery();
             $resultset->next();
             $success = $resultset->getInt('success');
             /* Pending */
             $connection = Propel::getConnection();
             $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as pending \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.send_at LIKE '{$date}'\n\t\t\t\t\tAND\n\t\t\t\t\t\trec.status = 'pending'";
             $statement = $connection->prepareStatement($query);
             $resultset = $statement->executeQuery();
             $resultset->next();
             $pending = $resultset->getInt('pending');
             /*
             $query = 'SELECT COUNT(*) as count_ FROM sentitems WHERE SenderId = "' . $senderId->getInitial() .'" AND SendingDateTime LIKE "'.$date.'"';
             $sent = $this->sms->conn->get_row($query);
             
             $query = 'SELECT COUNT(*) as count_ FROM sentitems WHERE SenderId = "' . $senderId->getInitial() .'" AND Status = "SendingError" AND SendingDateTime LIKE "'.$date.'"';
             $error = $this->sms->conn->get_row($query);
             
             $query = 'SELECT COUNT(*) as count_ FROM sentitems WHERE SenderId = "' . $senderId->getInitial() .'" AND Status = "SendingOk" AND SendingDateTime LIKE "'.$date.'"';
             $success = $this->sms->conn->get_row($query);
             */
             $report[] = array('sent' => $send ? $send : 0, 'error' => $error ? $error : 0, 'success' => $success ? $success : 0, 'pending' => $pending ? $pending : 0, 'date' => $monthName[$i] . ' ' . $param['year']);
         }
     } else {
         if ($param['type'] == 'daily') {
             $days = cal_days_in_month(CAL_GREGORIAN, $param['month'], $param['year']);
             $month = $param['month'];
             if (strlen($month) < 2) {
                 $month = '0' . $month;
             }
             for ($i = 1; $i <= $days; $i++) {
                 $day = $i;
                 if (strlen($i) < 2) {
                     $day = '0' . $i;
                 }
                 $date = $param['year'] . '-' . $month . '-' . $day . '%';
                 /* Sent */
                 $connection = Propel::getConnection();
                 $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as send \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tsend_at LIKE '{$date}'";
                 $statement = $connection->prepareStatement($query);
                 $resultset = $statement->executeQuery();
                 $resultset->next();
                 $send = $resultset->getInt('send');
                 echo $query;
                 echo '<hr />';
                 var_dump($send);
                 echo '<hr />';
                 echo '<hr />';
                 /* Error */
                 $connection = Propel::getConnection();
                 $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as error \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.send_at LIKE '{$date}'\n\t\t\t\t\tAND\n\t\t\t\t\t\trec.status = 'failed'";
                 $statement = $connection->prepareStatement($query);
                 $resultset = $statement->executeQuery();
                 $resultset->next();
                 $error = $resultset->getInt('error');
                 /* Success */
                 $connection = Propel::getConnection();
                 $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as success \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.send_at LIKE '{$date}'\n\t\t\t\t\tAND\n\t\t\t\t\t\trec.status = 'sent'";
                 $statement = $connection->prepareStatement($query);
                 $resultset = $statement->executeQuery();
                 $resultset->next();
                 $success = $resultset->getInt('success');
                 /* Pending */
                 $connection = Propel::getConnection();
                 $query = "\n\t\t\t\t\tSELECT \n\t\t\t\t\t\tsum(log.sms_long) as pending \n\t\t\t\t\tFROM \n\t\t\t\t\t\tsms_log_recipient as rec, \n\t\t\t\t\t\tsms_log as log \n\t\t\t\t\tWHERE \n\t\t\t\t\t\trec.log_id = log.id \n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.sender_id = '{$senderId->getId()}'\n\t\t\t\t\tAND\n\t\t\t\t\t\tlog.send_at LIKE '{$date}'\n\t\t\t\t\tAND\n\t\t\t\t\t\trec.status = 'pending'";
                 $statement = $connection->prepareStatement($query);
                 $resultset = $statement->executeQuery();
                 $resultset->next();
                 $pending = $resultset->getInt('pending');
                 /*
                 $query = 'SELECT COUNT(*) as count_ FROM sentitems WHERE SenderId = "' . $senderId->getInitial() .'" AND SendingDateTime LIKE "'.$date.'"';
                 $sent = $this->sms->conn->get_row($query);
                 
                 $query = 'SELECT COUNT(*) as count_ FROM sentitems WHERE SenderId = "' . $senderId->getInitial() .'" AND Status = "SendingError" AND SendingDateTime LIKE "'.$date.'"';
                 $error = $this->sms->conn->get_row($query);
                 
                 $query = 'SELECT COUNT(*) as count_ FROM sentitems WHERE SenderId = "' . $senderId->getInitial() .'" AND Status = "SendingOk" AND SendingDateTime LIKE "'.$date.'"';
                 $success = $this->sms->conn->get_row($query);
                 */
                 $report[] = array('sent' => $send ? $send : 0, 'error' => $error ? $error : 0, 'success' => $success ? $success : 0, 'pending' => $pending ? $pending : 0, 'date' => $i . ' ' . $monthName[$param['month']] . ' ' . $param['year']);
             }
         }
     }
     /*
     $output = array(
     	'success' => 1,
     	'data' => $report
     );
     $this->jsonwrapper->print_json($output);
     */
     die;
 }
Esempio n. 2
0
 public function getSmsSenderId($con = null)
 {
     include_once 'lib/model/om/BaseSmsSenderIdPeer.php';
     if ($this->aSmsSenderId === null && $this->sender_id !== null) {
         $this->aSmsSenderId = SmsSenderIdPeer::retrieveByPK($this->sender_id, $con);
     }
     return $this->aSmsSenderId;
 }