Ejemplo n.º 1
0
 public function create($content, $user = null, $cuser = 0, $stime = 0)
 {
     $model = new Sms();
     $model->year = date('Y', time());
     $model->month = date('m', time());
     $model->day = date('d', time());
     $model->message = $content;
     $model->ctime = time();
     $model->stime = $stime;
     $model->user_id = $cuser;
     if (empty($user)) {
         $model->send_all = 1;
         $model->save();
     } else {
         $model->save();
         if (is_array($user)) {
             foreach ($user as $u) {
                 $sms_user = new SmsToUser();
                 $sms_user->sms_id = $model->id;
                 $sms_user->user_id = $u;
                 $sms_user->save();
             }
         } else {
             $sms_user = new SmsToUser();
             $sms_user->sms_id = $model->id;
             $sms_user->user_id = $user;
             $sms_user->save();
         }
     }
     if (empty($stime)) {
         Task::add('sms');
     } else {
         Task::add('sms,' . $stime);
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionSendtogroup()
 {
     $model = new Sms();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Sms'])) {
         $model->attributes = $_POST['Sms'];
         if ($model->validate()) {
             if ($model->uid == 'parent') {
                 $userlist = Guardians::model()->findAll();
             }
             if ($model->uid == 'teacher') {
                 $userlist = Employees::model()->findAll();
             }
             if ($userlist != NULL) {
                 foreach ($userlist as $user) {
                     if ($user->mobile_phone) {
                         // $status = SmsSettings::model()->sendSms($user->mobile_phone,0,$model->message) ;
                         $mobile_phone = $user->mobile_phone;
                     } else {
                         $status = 0;
                         $mobile_phone = 0;
                     }
                     $Sms = new Sms();
                     $Sms->uid = $user->uid;
                     $Sms->phone_number = $mobile_phone;
                     $Sms->message = $model->message;
                     $Sms->status = $status;
                     $Sms->save();
                 }
             }
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 3
0
 public function actionIndex()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $response = array('status' => 'failed');
         if (isset($_POST['sms']) && 0) {
             if (isset($_POST['message']) and $_POST['message'] != "") {
                 $message = $_POST['message'];
                 if (isset($_POST['recipients']) and $_POST['recipients'] != "") {
                     $recipients = $_POST['recipients'];
                     $recipients_data = explode(',', $recipients);
                     foreach ($recipients_data as $recipient_data) {
                         $parts = explode(':', $recipient_data);
                         if (count($parts) > 0) {
                             $name = count($parts) > 1 ? $parts[0] : NULL;
                             $phone_number = end($parts);
                             $hello = '';
                             $hello .= $name == NULL ? "Hi," : "Hi " . $name . ",";
                             // $status 			= SmsSettings::model()->sendSms($phone_number, 0, $hello.$message);
                             $Sms = new Sms();
                             $Sms->phone_number = $phone_number;
                             $Sms->message = $hello . $message;
                             $Sms->status = $status;
                             $Sms->save();
                         }
                     }
                     $response['status'] = 'success';
                     $response['message'] = 'Message sent';
                 } else {
                     $response['message'] = 'Enter numbers to send SMS';
                 }
             } else {
                 $response['message'] = 'Enter message to send SMS';
             }
         } else {
             $response['message'] = 'Invalid request';
         }
         echo json_encode($response);
         Yii::app()->end();
     } else {
         //registering js files
         Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.modules.sms.assets') . '/js/ajaxupload/ajaxupload.js'));
         Yii::app()->clientScript->registerScript('browseActionPath', 'var browseActionPath="' . $this->createUrl('/sms/send/browse') . '"', CClientScript::POS_BEGIN);
         Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.modules.sms.assets') . '/js/ajaxupload/download.js'));
         $this->render('send');
     }
 }
Ejemplo n.º 4
0
 function actionIndex($oid)
 {
     $ri = $_COOKIE['ri'];
     $log = $_COOKIE['login'];
     if (!isset($ri)) {
         header('Location: /' . SITE_DIR . '/auth/showAuth');
     }
     $zagol = array('Просчет', 'Материал', 'Распил', 'ЧПУ', 'Кромка', 'Присадка', 'Гнутье', 'Эмаль', 'ПВХ', 'Фотопечать', 'Пескоструй', 'Витраж', 'oracal', 'Фасады', 'Упакован', 'Отгружен');
     $db = array("tech_end", "mater", "raspil", "cpu", "kromka", "pris_end", "gnutje", "emal", "pvh", "photo", "pesok", "vitrag", "oracal", "fas", "upak_end", "otgruz_end");
     $order = Order::getOrderById($oid);
     $order_stan = OrderStan::getOrdersByPole('oid', $oid);
     $stan = $order_stan[$oid];
     $us_dis = Users::getUserById($order['designer']);
     $dis = $us_dis['name'];
     $us_tech = Users::getUserById($order['technologist']);
     $tech = $us_tech['name'];
     //сборщик
     $mount = Mounting::getMountingLast($oid);
     if (!$mount) {
         $coll = '';
         $date_mount = '';
         $m_phone = '';
     } else {
         $coll_id = $mount['uid'];
         $user = Users::getUserById($coll_id);
         $coll = $user['name'];
         $m_phone = $user['tel'];
         $date_mount = date("d.m.y", strtotime($mount['m_date']));
     }
     //шаблоны смс
     $sample = Sms::getSamples();
     $search = array('%name%', '%con%', '%date%', '%m_date%', '%collector%', '%phone%');
     $replace = array($order['name'], $order['contract'], date("d.m.y", strtotime($stan['plan'])), $date_mount, $coll, $m_phone);
     foreach ($sample as $key => $sampleone) {
         $str = $sampleone['text_sms'];
         $newstr = str_replace($search, $replace, $str);
         $sample[$key]['text_sms'] = $newstr;
     }
     $notes = Notes::getNotesByOid($oid);
     if (isset($_POST['sendsms'])) {
         $phone = $_POST['phone'];
         $message = $_POST['message'];
         $sms = Sms::send($phone, $message);
         $errorsms = array();
         switch ($sms) {
             case 100:
                 $errorsms[] = 'Сообщение отправлено';
                 Sms::save($oid, $message);
                 break;
             case 201:
                 $errorsms[] = 'Не хватает средств на лицевом счету';
                 break;
             case 202:
                 $errorsms[] = 'Неправильно указан получатель';
                 break;
             case 203:
                 $errorsms[] = 'Нет текста сообщения';
                 break;
             case 205:
                 $errorsms[] = 'Сообщение слишком длинное (превышает 8 СМС)';
                 break;
             case 206:
                 $errorsms[] = 'Будет превышен или уже превышен дневной лимит на отправку сообщений';
                 break;
             case 207:
                 $errorsms[] = 'На этот номер (или один из номеров) нельзя отправлять сообщения';
                 break;
             case 220:
                 $errorsms[] = 'Сервис временно недоступен, попробуйте чуть позже';
                 break;
             default:
                 $errorsms[] = 'Сообщение не отправлено, обратитесь к администратору';
         }
     }
     $page = SITE_PATH . 'views/order.php';
     include SITE_PATH . 'views/layout.php';
     return true;
 }