Esempio n. 1
0
 public function send()
 {
     $sendMany = false;
     if ($this->sendingOptions == self::SEND_OPT_MULTI) {
         $contacts = Pbk::findAll(explode(',', $this->number));
         $sendMany = true;
     }
     if ($this->sendingOptions == self::SEND_OPT_GROUP) {
         $contacts = Pbk::find()->where(['GroupID' => $this->number])->all();
         $sendMany = true;
     }
     if ($this->timeOptions == self::TIME_OPT_NOW) {
         $time = new Expression('NOW()');
     } elseif ($this->timeOptions == self::TIME_OPT_DATETIME) {
         $time = $this->sendingDateTime;
     } else {
         $timeParts = explode(':', $this->sendingTime);
         $hours = intval($timeParts[0]);
         $minutes = intval($timeParts[1]);
         $now = new \DateTime();
         $now->add(new \DateInterval("PT{$hours}H{$minutes}M"));
         $time = $now->format('Y-m-d H:i:s');
     }
     if ($sendMany) {
         foreach ($contacts as $contact) {
             $this->insertIntoOutbox($contact->Number, $this->text, $time);
         }
     } else {
         $this->insertIntoOutbox(trim($this->number), $this->text, $time);
     }
 }
Esempio n. 2
0
 /**
  * Finds the Pbk model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Pbk the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Pbk::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pbk::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'GroupID' => $this->GroupID]);
     $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'Number', $this->Number]);
     return $dataProvider;
 }
Esempio n. 4
0
 public function getPbk()
 {
     //return $this->hasOne(Pbk::className(), ['Number' => 'SenderNumber']);
     $number = $this->SenderNumber;
     if (strpos($number, '+') !== false) {
         $number = str_replace('+62', '0', $number);
     }
     $pbk = Pbk::find(['Number' => $number])->one();
     if ($pbk !== null) {
         return $pbk->Name;
     }
     return '(not set)';
 }
Esempio n. 5
0
 public function getPbk()
 {
     return $this->hasOne(Pbk::className(), ['Number' => 'DestinationNumber']);
 }