function callTest($order_id) { $service = get_twilio_service(); $data['order_id'] = $order_id; $data['order_details'] = $this->Cp_menu_model->get_order($order_id)[0]; $data['menu_details'] = $this->Cp_menu_model->get_menu_details($data['order_details']->menu_id); //var_dump($data); $service->account->calls->create('4694163485', $data['menu_details']->phone_to_notify, site_url('twiml/call/' . $order_id), array("Method" => "GET", "StatusCallbackMethod" => "GET", "StatusCallback" => site_url('twiml/handleCallCompleteResponse/' . $order_id))); }
function placeorder() { $localtime_assoc = localtime(time(), true); $business_hours = true; //inmotionhosting server's times are PST if ($localtime_assoc['tm_hour'] > 19 || $localtime_assoc['tm_hour'] < 8) { $business_hours = false; } if ($this->session->userdata('testmode')) { $business_hours = true; } if (!$business_hours) { redirect('/clickpick', 'refresh'); } /*$this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div>', '</div>'); $this->form_validation->set_rules('contact_phone', 'Merchant Phone', 'trim|required|is_numeric|exact_length[10]'); $this->form_validation->set_rules('email_id', 'Merchant Email', 'trim|required|valid_email|max_length[128]|callback_check_email'); //$this->form_validation->set_rules('recaptcha_response_field', 'Captcha field', 'trim|required|callback_checkCaptcha'); if ($this->form_validation->run() == FALSE) { $item_ids = $this->input->post('item_ids'); for($i=0;$i<count($item_ids);$i++) { $item_ids_for_review[$i] = array('item_id' => $item_ids[$i]); } //if they have submitted the form already and it has returned with errors, reset the redirect /*if ($this->input->post('submitted')) { $data['redirect'] = $this->input->post('redirect'); }*/ /*$this->load->helper('directory'); $data['error'] = validation_errors(); $this->load->view('register', $data); } else //validation successfull {*/ $order_id = strtoupper(random_string('alnum', 6)); $order['code'] = $order_id; $order['first_name'] = $this->input->post('first_name'); $order['last_name'] = $this->input->post('last_name'); $order['email_id'] = $this->input->post('email_id'); $order['phone_number'] = $this->input->post('phone_number'); $order['subtotal'] = $this->input->post('subtotal'); $order['discount_value'] = $this->input->post('discount_value'); $order['discount_text'] = $this->input->post('discount_text'); $order['total_before_tax'] = $this->input->post('total_before_tax'); $order['tax_amount'] = $this->input->post('tax_amount'); $order['total'] = $this->input->post('grand_total'); $order['savings'] = $this->input->post('discount_value'); $order['menu_id'] = $this->input->post('menu_id'); $order['discount_id'] = $this->input->post('discount_id'); $order['business_name'] = $this->input->post('business_name'); $order['merchant_id'] = $this->input->post('merchant_id'); $this->Cp_menu_model->insert_order_record($order); $order_items[] = ''; $item_names = $this->input->post('item_names'); $item_prices = $this->input->post('item_prices'); $item_ids = $this->input->post('item_ids'); $quantity = $this->input->post('quantity'); for ($i = 0; $i < count($item_names); $i++) { $order_items[$i] = array('item_id' => $item_ids[$i], 'order_id' => $order_id, 'item_name' => $item_names[$i], 'item_order_price' => $item_prices[$i] * $quantity[$i], 'item_list_price' => $item_prices[$i], 'quantity' => $quantity[$i]); } $this->Cp_menu_model->insert_order_items($order_items); //$this->session->set_flashdata('message', 'Your Coupon has been emailed.'); //send all notifications. $data['order_id'] = $order_id; $data['order_details'] = $this->Cp_menu_model->get_order($order_id)[0]; $data['order_items'] = $this->Cp_menu_model->get_order_items($order_id); $data['menu_details'] = $this->Cp_menu_model->get_menu_details($data['order_details']->menu_id); $this->sendNotificationsForOrder($data); $service = get_twilio_service(); $number_to_text_array = explode("_", $data['menu_details']->phone_to_text); foreach ($number_to_text_array as $number_to_text) { $service->account->messages->create(array('To' => $number_to_text, 'From' => "+14694163485", 'Body' => "There is a new Click-Pick order for " . $data['order_details']->business_name . ". Please go to " . site_url('order/' . $order_id) . " to get order details.")); } $service->account->calls->create('4694163485', $data['menu_details']->phone_to_notify, site_url('twiml/call/' . $order_id), array("Method" => "GET", "StatusCallback" => site_url('twiml/handleCallCompleteResponse/' . $order_id))); //test code if ($this->input->post('text_confirmation')) { $service->account->messages->create(array('To' => $data['order_details']->phone_number, 'From' => "+14694163485", 'Body' => "Hi " . $data['order_details']->first_name . ", Thanks for your click-pick.com order. Click here for your order details : " . site_url('order/' . $order_id))); log_message('warning', ' text message sent to user for order id ' . $order_id . ' at phone number: ' . $data['order_details']->phone_number); } //test code end if (!isset($_SESSION)) { session_start(); } $_SESSION["data"] = $data; redirect('/order/' . $order_id, 'refresh'); }