public function addMoreContactAction() { if ($this->request->isPost() == true) { $group_id = $this->request->getPost('group_id'); $user_id = $this->request->getPost('user_id'); $groucontact = GroupContact::find("group_id={$group_id}"); $contact_ids = array(); foreach ($groucontact as $contact) { $contact_ids[] = $contact->contact_id; } $contacts = ''; $contacts = implode(',', $contact_ids); if (count($contact_ids) > 0) { $other_contacts = Contacts::find(array('conditions' => 'id NOT IN (' . $contacts . ') AND user_id=' . $user_id . ' AND deleted=0', 'columns' => 'id,name,number,email')); } else { $other_contacts = Contacts::find(array('conditions' => 'user_id=' . $user_id . ' AND deleted=0', 'columns' => 'id,name,number,email')); } $morecontacts = array(); foreach ($other_contacts as $other_contact) { $morecontacts[] = array('id' => $other_contact->id, 'name' => $other_contact->name, 'number' => $other_contact->number, 'email' => $other_contact->email); } $this->response->setContent(json_encode(array('morecontacts' => $morecontacts))); // $this->flash->error($other_contacts->getMessages()); $this->response->send(); } else { } }
/** * deleteAction * Delete a contact of the customer * @return unknown_type */ public function deletecontactAction() { $id = $this->getRequest()->getParam('id'); if (is_numeric($id)) { Contacts::find($id)->delete(); } $this->_helper->redirector('account', 'profile', 'default'); }
public function deleteContactAction() { if ($this->request->isPost() == true) { $this->response->setContentType('application/json'); $user_id = $this->request->getPost('user_id'); $contact_ids = $this->request->getPost('contact_ids'); $contacts = Contacts::find('id IN (' . $contact_ids . ')'); foreach ($contacts as $contact) { $group_contacts = GroupContact::find('contact_id =' . $contact->id); if ($group_contacts != false) { foreach ($group_contacts as $group_contact) { $group_contact->delete(); } } $contact->deleted = 1; $contact->save(); } $data = array('status' => 'success', 'msg' => 'contact deleted', 'code' => 2); $this->response->setContent(json_encode($data)); $this->response->send(); } }
public function sheduleSMSAction() { if ($this->request->isPost() == true) { $this->response->setContentType('application/json'); $type = $this->request->getPost('type'); $user_id = $this->request->getPost('user_id'); $message = $this->request->getPost('message'); $datetime = $this->request->getPost('datetime'); $timezone = 'UTC'; $scheduled_date_user_tz = new DateTime($datetime, new DateTimeZone($timezone)); $scheduled_date_user_tz->setTimezone(new DateTimeZone('UTC')); $scheduled_date_UTC = $scheduled_date_user_tz->format('Y-m-d H:i:s'); $schedule_date = date('Y-m-d H:i:s', strtotime($scheduled_date_UTC)); // $scheduled_date_user_tz = new DateTime($datetime); // $scheduled_date_UTC = $scheduled_date_user_tz->format('Y-m-d H:i:s'); // $schedule_date = date('Y-m-d H:i:s', strtotime($scheduled_date_UTC)); if ($type == "CONTACTID") { $contact_ids = $this->request->getPost('contact_ids'); $contacts_ids = explode(',', $contact_ids); $contacts = Contacts::find('id IN (' . $contact_ids . ')'); $numbers = array(); $contact_id = array(); foreach ($contacts as $contact) { $numbers[] = $contact->number; $contact_id[] = $contact->id; } } if ($type == "GROUPID") { $group_id = $this->request->getPost('group_id'); $groucontact = GroupContact::find("group_id={$group_id}"); $groucontactlist = array(); $contact_id = array(); foreach ($groucontact as $group_data) { $numbers[] = $group_data->contacts->number; } $contact_id = explode(',', $group_id); } $data = $this->sheduleSMSProcessData(array('message' => $message, 'user_id' => $user_id, 'ids' => $contact_id, 'type' => $type, 'contacts' => $numbers, 'schedule_date' => $schedule_date)); $this->response->setContent(json_encode($data)); $this->response->send(); } }