Example #1
0
 public function sendsmsAction()
 {
     $model = new WsServiceImport();
     $messageModel = new WsServiceImportMessage();
     $importToSend = $model->getImportToSend();
     $servicesModel = new WsServiceSms();
     $cfg = Zend_Registry::get('config');
     while ($current = $importToSend->current()) {
         $services = Zend_Json::decode($current->services);
         $service = $servicesModel->getService($services[0]);
         $config = array('throwExceptions' => true, 'clientHash' => $cfg['services']['mrdebug']['hash'], 'serviceHash' => $service->service_hash);
         $http = new Zend_Controller_Request_Http();
         $host = 'http://' . $http->getServer('HTTP_HOST') . '/ws/';
         $config['wsdl'] = $host . 'sms/?wsdl';
         $sms = new SmsSoapClient($config);
         if (!$model->checkStatus($current->id)) {
             $importToSend->next();
             $current = $importToSend->current();
         }
         if ($importToSend->valid()) {
             switch ($current->file_type) {
                 case 1:
                     $sms->registerNumber($current->phone_number)->registerContent($current->sms_text);
                     $response = $sms->send();
                     break;
                 case 2:
                     $tags = Zend_Json::decode($current->tags);
                     $msg = $current->sms_text;
                     if (!empty($tags)) {
                         foreach ($tags as $key => $tag) {
                             $msg = preg_replace("/<" . $key . ">/", $tag, $msg);
                         }
                     }
                     $sms->registerNumber($current->phone_number)->registerContent($msg);
                     $response = $sms->send();
                     break;
                 case 3:
                     $sms->registerNumber($current->phone_number)->registerContent($current->sms_text);
                     $response = $sms->send();
                     break;
             }
             if (isset($response->errorCode)) {
                 $messageModel->changeStatus($current->msg_id, $response->errorCode, Zend_Json::encode($response->smsId));
             } else {
                 $messageModel->changeStatus($current->msg_id, $response->faultcode, NULL, $response->faultstring);
             }
             $importToSend->next();
         }
     }
 }
Example #2
0
 public function checkstatusAction()
 {
     $request = $this->getRequest();
     $id = $this->_helper->IdConvert->hexToStr($request->getParam('id'));
     $data = array();
     if (!empty($id)) {
         try {
             $model = new SmsStorageStatus();
             $lastStatus = $model->getSmsBySmsStorage($id, true);
             if (isset($lastStatus[0])) {
                 if ($lastStatus[0]['status_dict'] < 4 || $lastStatus[0]['status_dict'] == 8 || $lastStatus[0]['status_dict'] == 9) {
                     $http = new Zend_Controller_Request_Http();
                     $ip = $http->getServer('SERVER_ADDR');
                     $serviceModel = new WsServiceSms();
                     $service = $serviceModel->getService($lastStatus[0]['ws_service_sms_id']);
                     $sms = new Logic_Sms($service, $ip);
                     if ($lastStatus[0]['ws_package_sms_id'] === NULL) {
                         $sms->info($lastStatus[0]['smsid']);
                     } else {
                         $sms->packageinfo($lastStatus[0]['smsid']);
                     }
                 }
             }
             $data = $model->getSmsBySmsStorage($id);
             $paginator = new Base_Paginator(new Base_Paginator_Adapter_Array($data, array('RowClass' => 'Row_SmsStorageStatus')));
             $this->view->paginator = $paginator;
             if ($lastStatus[0]['ws_package_sms_id'] === NULL) {
                 $this->view->headers = array('smsid', 'status_dict', 'messagePriority', 'idProt', 'conectorId', 'encoding', 'smsType', 'validTo', 'delivNotifRequest', 'sendDate', 'lastStatusChange', 'created_at');
             } else {
                 $this->view->headers = array('smsid', 'status_dict', 'numberOfMessages', 'numberOfMessagesLeftToSent', 'created_at');
             }
         } catch (Logic_Service_Exception $ex) {
             $this->_helper->redirector('index');
             $this->_helper->messenger('error', 'Nie udało się pobrać statusu');
             return;
         }
     } else {
         $this->_helper->messenger('error', 'Brak ID!');
         $this->_helper->redirector('index');
         return;
     }
 }