示例#1
0
 private function flows()
 {
     $max = $this->input->get_post('max');
     $offset = $this->input->get_post('offset');
     if (empty($max)) {
         $max = $this->flows_per_page;
     }
     $this->template->add_js('assets/j/flows.js');
     $data = $this->init_view_data();
     $flows = VBX_Flow::search(array(), $max, $offset);
     if (empty($flows)) {
         set_banner('flows', $this->load->view('banners/flows-start', array(), true));
     }
     $flows_with_numbers = array();
     foreach ($flows as $flow) {
         $flows_with_numbers[] = array('id' => $flow->id, 'name' => trim($flow->name), 'numbers' => $flow->numbers, 'voice_data' => $flow->data, 'sms_data' => $flow->sms_data);
     }
     $data['items'] = $flows_with_numbers;
     $data['highlighted_flows'] = array($this->session->flashdata('flow-first-save', 0));
     // pagination
     $total_items = VBX_Flow::count();
     $page_config = array('base_url' => site_url('flows/'), 'total_rows' => $total_items, 'per_page' => $max);
     $this->pagination->initialize($page_config);
     $data['pagination'] = CI_Template::literal($this->pagination->create_links());
     $this->respond('Call Flows', 'flows', $data);
 }
示例#2
0
 private function flows()
 {
     $this->template->add_js('assets/j/flows.js');
     $data = $this->init_view_data();
     $flows = VBX_Flow::search(array(), 100, 0);
     if (empty($flows)) {
         set_banner('flows', 'Customize what happens when someone calls into your Twilio numbers.', 'Add or modify a flow below.');
     }
     $flows_with_numbers = array();
     foreach ($flows as $flow) {
         $flows_with_numbers[] = array('id' => $flow->id, 'name' => trim($flow->name), 'numbers' => $flow->numbers, 'voice_data' => $flow->data, 'sms_data' => $flow->sms_data);
     }
     $data['items'] = $flows_with_numbers;
     $data['highlighted_flows'] = array($this->session->flashdata('flow-first-save', 0));
     $this->respond('Call Flows', 'flows', $data);
 }
示例#3
0
 function index()
 {
     $this->admin_only($this->section);
     $this->template->add_js('assets/j/numbers.js');
     $data = $this->init_view_data();
     $numbers = array();
     try {
         $numbers = $this->vbx_incoming_numbers->get_numbers();
     } catch (VBX_IncomingNumberException $e) {
         $this->error_message = ErrorMessages::message('twilio_api', $e->getCode());
     }
     $incoming_numbers = array();
     // now generate table
     if (count($numbers) > 0) {
         $flows = VBX_Flow::search();
         foreach ($numbers as $item) {
             $item_msg = '';
             if (is_object($this->new_number) && $this->new_number->id == $item->id) {
                 $item_msg = 'New';
             }
             $flow_name = '(Not Set)';
             foreach ($flows as $flow) {
                 if ($flow->id == $item->flow_id) {
                     $flow_name = '';
                 }
             }
             $incoming_numbers[] = array('id' => $item->id, 'name' => $item->name, 'trial' => isset($item->trial) && $item->trial == 1 ? 1 : 0, 'phone' => format_phone($item->phone), 'pin' => $item->pin, 'status' => $item_msg, 'flow_id' => $item->flow_id, 'flow_name' => $flow_name, 'flows' => $flows);
         }
     }
     $data['highlighted_numbers'] = array($this->session->flashdata('new-number'));
     $data['items'] = $incoming_numbers;
     $data['twilio_sid'] = $this->twilio_sid;
     if (empty($this->error_message)) {
         $error_message = $this->session->flashdata('error');
         if (!empty($error_message)) {
             $this->error_message = $this->session->flashdata('error');
         }
     }
     if (!empty($this->error_message)) {
         $data['error'] = CI_Template::literal($this->error_message);
     }
     $data['counts'] = $this->message_counts();
     $this->respond('', 'numbers', $data);
 }
示例#4
0
 public static function getFlows($options = array(), $limit = -1, $offset = 0)
 {
     return VBX_Flow::search($options, $limit, $offset);
 }
示例#5
0
 /**
  * Key an ID keyed list of flows
  *
  * @return array
  */
 protected function get_flows_list()
 {
     $flows = array();
     $_flows = VBX_Flow::search();
     if (count($_flows)) {
         foreach ($_flows as $flow) {
             $flows[$flow->id] = $flow;
         }
     }
     unset($_flows);
     return $flows;
 }
示例#6
0
 function index()
 {
     $this->admin_only($this->section);
     $this->template->add_js('assets/j/numbers.js');
     $data = $this->init_view_data();
     $data['selected_country'] = $this->vbx_settings->get('numbers_country', $this->tenant->id);
     $numbers = array();
     $data['countries'] = array();
     try {
         $numbers = $this->vbx_incoming_numbers->get_numbers();
         $countries = $this->vbx_incoming_numbers->get_available_countries();
         // lighten the payload as we don't need the url data in the view
         foreach ($countries as &$country) {
             $data['countries'][$country->country_code] = $country->country;
             $country->available = array_keys(get_object_vars($country->subresource_uris));
             unset($country->uri, $country->subresource_uris);
         }
         $data['openvbx_js']['countries'] = json_encode($countries);
     } catch (VBX_IncomingNumberException $e) {
         $this->error_message = ErrorMessages::message('twilio_api', $e->getCode());
     }
     $incoming_numbers = array();
     // now generate table
     if (count($numbers) > 0) {
         $flows = VBX_Flow::search();
         foreach ($numbers as $item) {
             $item_msg = '';
             if (is_object($this->new_number) && $this->new_number->id == $item->id) {
                 $item_msg = 'New';
             }
             $flow_name = '(Not Set)';
             foreach ($flows as $flow) {
                 if ($flow->id == $item->flow_id) {
                     $flow_name = '';
                 }
             }
             $capabilities = array();
             if (!empty($item->capabilities)) {
                 foreach ($item->capabilities as $cap => $enabled) {
                     if ($enabled) {
                         array_push($capabilities, ucfirst($cap));
                     }
                 }
             }
             $incoming_numbers[] = array('id' => $item->id, 'name' => $item->name, 'trial' => isset($item->trial) && $item->trial == 1 ? 1 : 0, 'phone' => format_phone($item->phone), 'pin' => $item->pin, 'status' => $item_msg, 'flow_id' => $item->flow_id, 'flow_name' => $flow_name, 'flows' => $flows, 'capabilities' => $capabilities);
         }
     }
     $data['highlighted_numbers'] = array($this->session->flashdata('new-number'));
     $data['items'] = $incoming_numbers;
     $data['twilio_sid'] = $this->twilio_sid;
     if (empty($this->error_message)) {
         $error_message = $this->session->flashdata('error');
         if (!empty($error_message)) {
             $this->error_message = $this->session->flashdata('error');
         }
     }
     if (!empty($this->error_message)) {
         $data['error'] = CI_Template::literal($this->error_message);
     }
     $data['counts'] = $this->message_counts();
     $this->respond('', 'numbers', $data);
 }