Пример #1
0
 public function executeResend()
 {
     $param = $this->getAllRequestParameter();
     $sendsCrit = new Criteria();
     $sendsCrit->add(SmsLogRecipientPeer::ID, $param['id'], Criteria::IN);
     $sends = SmsLogRecipientPeer::doSelect($sendsCrit);
     $logs = array();
     foreach ($sends as $send) {
         if (!array_key_exists($send->getSmsLog()->getId(), $logs)) {
             $log = new SmsLog();
             $log->setCreatorUserId($send->getSmsLog()->getCreatorUserId());
             $log->setCreatorType($send->getSmsLog()->getCreatorType());
             $log->setSubject('Resend : ' . $send->getSmsLog()->getSubject());
             $recipients = array(array('type' => $send->getRecipientType(), 'value' => $send->getRecipientId()));
             $log->setRecipient($this->jsonwrapper->json_encode($recipients));
             $log->setMessage($send->getSmsLog()->getMessage());
             $log->setCreated(date('Y-m-d H:i:s'));
             $log->setSenderId($send->getSmsLog()->getSenderId());
             $sendAt = date('Y-m-d H:i:s');
             $log->setSendAt($sendAt);
             $log->setSmsLong($send->getSmsLog()->getSmsLong());
             $log->setSmsCount(1);
             $log->save();
             $logs[$send->getSmsLog()->getId()]['object'] = $log;
             $logs[$send->getSmsLog()->getId()]['sms_count'] = 1;
         } else {
             $log = $logs[$send->getSmsLog()->getId()]['object'];
             $logs[$send->getSmsLog()->getId()]['sms_count']++;
             $recipients = $this->jsonwrapper->json_decode($log->getRecipient);
             $recipients[] = array(array('type' => $send->getRecipientType(), 'value' => $send->getRecipientId()));
             $log->setRecipient($this->jsonwrapper->json_encode($recipients));
             $log->setSmsCount($logs[$send->getSmsLog()->getId()]['sms_count']);
             $log->save();
         }
         $rec = new SmsLogRecipient();
         $rec->setLogId($log->getId());
         $rec->setRecipientId($send->getRecipientId());
         $rec->setRecipientType($send->getRecipientType());
         $rec->setRecipientNumber($send->getRecipientNumber());
         $rec->setStatus('pending');
         $rec->setLog(0);
         $rec->save();
         /* Saving to gammu Database */
         $save = $this->sms->send($rec->getId(), 1, 2, 3, $rec->getRecipientNumber(), $log->getMessage(), $log->getCreated(), $log->getSendAt());
         /* log send status to resend */
         $send->setStatus('resend');
         $send->save();
     }
     $this->jsonwrapper->print_json(array('success' => 1, 'message' => 'success'));
 }
Пример #2
0
 public function sendSmsSppPayment($student, $month, $year)
 {
     $months = array(1 => 'Januari', 2 => 'Februari', 3 => 'Maret', 4 => 'April', 5 => 'Mei', 6 => 'Juni', 7 => 'Juli', 8 => 'Agustus', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Desember');
     $message = 'Pembayaran SPP bulan ' . $months[$month] . ' ' . $year . ' telah kami terima. Terima kasih telah berpartisipasi dalam program kami.';
     $recipients = array(array('type' => 'student', 'value' => $student->getId()));
     $departmentId = $student->getClassGroup()->getDepartmentId();
     $senderId = $this->getSenderID($departmentId);
     $message = $senderId->getText() . ' ' . $message;
     $log = new SmsLog();
     //$log->setCreatorUserId($employeeId);
     $log->setCreatorType('system');
     $log->setSubject('Konfirmasi pembayaran SPP');
     $log->setRecipient($this->jsonwrapper->json_encode($recipients));
     $log->setMessage($message);
     $log->setSenderId($senderId->getId());
     $log->setCreated(date('Y-m-d H:i:s'));
     $sendAt = date('Y-m-d H:i:s');
     $log->setSendAt('now');
     $log->save();
     $recNumber = $student->getStudentDetail()->getCellphone();
     $rec = new SmsLogRecipient();
     $rec->setLogId($log->getId());
     $rec->setRecipientId($student->getId());
     $rec->setRecipientType('student');
     $rec->setRecipientNumber($recNumber);
     $rec->setStatus('pending');
     $rec->setLog(0);
     $rec->save();
     /* Saving to gammu Database */
     $save = $this->smsConn->send($rec->getId(), 1, 2, 3, $recNumber, $log->getMessage(), $log->getCreated(), $log->getSendAt());
 }