Пример #1
0
 public function quicksmsAction()
 {
     if ($this->request->isPost() == true) {
         $this->response->setContentType('application/json');
         $contact_number = $this->request->getPost('contact_number');
         $contact_number = explode(',', $contact_number);
         $message = $this->request->getPost('message');
         $user_id = $this->request->getPost('user_id');
         $contact_ids = array();
         foreach ($contact_number as $number) {
             $con_data = Contacts::findFirst("number LIKE '%{$number}%' AND user_id={$user_id} AND deleted=0");
             if ($con_data) {
                 $contact_ids[] = $con_data->id;
                 $type = "CONTACTID";
             } else {
                 $contact_ids[] = $number;
                 $type = "NUMBER";
             }
         }
         $data = $this->sendSmsProcessData(array('message' => $message, 'user_id' => $user_id, 'ids' => $contact_ids, 'type' => $type, 'contacts' => $contact_ids));
         $this->response->setContent(json_encode($data));
         $this->response->send();
     }
 }
Пример #2
0
 private function updateContact($contact_data)
 {
     $number = $contact_data['number'];
     $user_id = $contact_data['user_id'];
     $contact = Contacts::findFirst("user_id={$user_id} AND number LIKE '%{$number}%'");
     if ($contact->deleted == 1) {
         $contact->name = $contact_data['contact_name'];
         $contact->address = $contact_data['address'];
         $contact->email = $contact_data['email'];
         $contact->deleted = 0;
         $contact->save();
         $data = array('status' => 'success', 'msg' => $contact_data['msg'], 'code' => 2);
     } else {
         $data = array('status' => 'error', 'msg' => 'Already Exist', 'code' => 1);
     }
     return $data;
 }
Пример #3
0
 public static function getNumbers($contact_ids)
 {
     $numbers = array();
     foreach ($contact_ids as $contact_id) {
         $result = Contacts::findFirst("id= '{$contact_id}'");
         $numbers[] = $result->number;
     }
     return implode(',', $numbers);
 }