public function postIssueOther()
 {
     $queue_platform = 'web';
     $terminal_id = 0;
     $business_id = Input::get('business_id');
     $forwarder_id = Input::get('forwarder_id');
     $transaction_number = Input::get('transaction_number');
     if (Business::getForwarderAllowedInBusiness($business_id, $forwarder_id)) {
         $name = PriorityQueue::name($transaction_number);
         $phone = PriorityQueue::phone($transaction_number);
         $email = PriorityQueue::email($transaction_number);
         $service = Service::getFirstServiceOfBusiness($business_id);
         $service_id = $service->service_id;
         $next_number = ProcessQueue::nextNumber(ProcessQueue::lastNumberGiven($service_id), QueueSettings::numberStart($service_id), QueueSettings::numberLimit($service_id));
         $priority_number = $next_number;
         $number = ProcessQueue::issueNumber($service_id, $priority_number, null, $queue_platform, $terminal_id);
         PriorityQueue::updatePriorityQueueUser($number['transaction_number'], $name, $phone, $email);
         return json_encode(['success' => 1, 'number' => $number]);
     }
     return json_encode(['error' => 'You are not allowed to issue a number to this business']);
 }
 /**
  * @param $service_id
  * @param $name
  * @param $phone
  * @param $email
  * @return JSON-formatted queued number
  */
 public function getQueueNumber($service_id, $name, $phone, $email)
 {
     try {
         $next_number = ProcessQueue::nextNumber(ProcessQueue::lastNumberGiven($service_id), QueueSettings::numberStart($service_id), QueueSettings::numberLimit($service_id));
         $priority_number = $next_number;
         $queue_platform = 'kiosk';
         $number = ProcessQueue::issueNumber($service_id, $priority_number, null, $queue_platform);
         PriorityQueue::updatePriorityQueueUser($number['transaction_number'], $name, $phone, $email);
         $details = ['number_assigned' => $priority_number];
         return Response::json($details, 200, array(), JSON_PRETTY_PRINT);
     } catch (Exception $e) {
         return json_encode(['error' => 'Something went wrong!']);
     }
 }
 public function getAllvalues($service_id)
 {
     $values = QueueSettings::getServiceQueueSettings($service_id);
     $queue_settings = ['number_start' => $values->number_start, 'number_limit' => $values->number_limit, 'auto_issue' => $values->auto_issue, 'allow_sms' => $values->allow_sms, 'allow_remote' => $values->allow_remote];
     return json_encode(['success' => 1, 'queue_settings' => $queue_settings]);
 }
 /**
  * @author Ruffy
  * @param int $business_id
  * @return mixed
  * @description Adds an option to display the broadcast page by Business
  */
 public function getBusiness($business_id = 0)
 {
     $data = json_decode(file_get_contents(public_path() . '/json/' . $business_id . '.json'));
     $arr = explode("-", $data->display);
     if ($arr[0]) {
         $template_type = 'ads-' . $arr[1];
     } else {
         $template_type = 'noads-' . $arr[1];
     }
     if ($data->ad_type == 'image') {
         $ad_src = array();
         $res = AdImages::getAllImagesByBusinessId($business_id);
         foreach ($res as $count => $img) {
             $ad_src[] = $img->path;
         }
         /*
         $ad_directory = public_path() . '/ads/' . $business_id;
         if (file_exists($ad_directory)) {
           foreach(glob($ad_directory . '/*.*') as $filename){
             $ad_src[] = 'ads/' . $business_id . '/' . basename($filename);
           }
         }
         */
     } else {
         $ad_src = $data->ad_video;
     }
     $business_name = Business::name($business_id);
     $open_time = str_pad(Business::openHour($business_id), 2, 0, STR_PAD_LEFT) . ':' . str_pad(Business::openMinute($business_id), 2, 0, STR_PAD_LEFT) . ' ' . Business::openAMPM($business_id);
     $close_time = str_pad(Business::closeHour($business_id), 2, 0, STR_PAD_LEFT) . ':' . str_pad(Business::closeMinute($business_id), 2, 0, STR_PAD_LEFT) . ' ' . Business::closeAMPM($business_id);
     $first_service = Service::getFirstServiceOfBusiness($business_id);
     $allow_remote = QueueSettings::allowRemote($first_service->service_id);
     // Update Contact Form with Custom Fields if applicable
     $custom_fields = '';
     $forms = new FormsController();
     $fields = $forms->getFields($business_id);
     foreach ($fields as $form_id => $field_data) {
         if ($field_data['field_type'] == 'Text Field') {
             $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div>
           <div class="col-md-9"><input type="text" class="form-control custom-field" id="forms_' . $form_id . '" /></div>';
         } elseif ($field_data['field_type'] == 'Radio') {
             $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div>
           <div class="col-md-9"><label class="radio-inline"><input type="radio" name="forms_' . $form_id . '" value="' . $field_data['value_a'] . '" >' . $field_data['value_a'] . '</label><label class="radio-inline"><input type="radio" name="forms_' . $form_id . '" value="' . $field_data['value_b'] . '">' . $field_data['value_b'] . '</label></div>';
         } elseif ($field_data['field_type'] == 'Checkbox') {
             $custom_fields .= '<div class="col-md-offset-3 col-md-9 mb10 mt10"><label class="checkbox-inline"><input type="checkbox" id="forms_' . $form_id . '" value="1"/>' . $field_data['label'] . '</label></div>';
         } elseif ($field_data['field_type'] == 'Dropdown') {
             $select_options = '';
             $select_options .= '<option value="0">- Select -</option>';
             foreach ($field_data['options'] as $count => $val) {
                 $select_options .= '<option value="' . $val . '">' . $val . '</option>';
             }
             $custom_fields .= '<div class="col-md-3"><label>' . $field_data['label'] . '</label></div>
           <div class="col-md-9"><select class="form-control custom-dropdown" id="forms_' . $form_id . '"/>' . $select_options . '</select></div>';
         }
     }
     $ticker_message = array();
     if (isset($data->ticker_message)) {
         if ($data->ticker_message != '') {
             array_push($ticker_message, $data->ticker_message);
         }
     }
     if (isset($data->ticker_message2)) {
         if ($data->ticker_message2 != '') {
             array_push($ticker_message, $data->ticker_message2);
         }
     }
     if (isset($data->ticker_message3)) {
         if ($data->ticker_message3 != '') {
             array_push($ticker_message, $data->ticker_message3);
         }
     }
     if (isset($data->ticker_message4)) {
         if ($data->ticker_message4 != '') {
             array_push($ticker_message, $data->ticker_message4);
         }
     }
     if (isset($data->ticker_message5)) {
         if ($data->ticker_message5 != '') {
             array_push($ticker_message, $data->ticker_message5);
         }
     }
     if (Auth::check()) {
         $user = User::getUserByUserId(Auth::user()->user_id);
         // business owners have different broadcast screens for display
         if (UserBusiness::getBusinessIdByOwner(Auth::user()->user_id) == $business_id) {
             if ($arr[0] == 2 || $arr[0] == 3) {
                 $ad_src = $data->tv_channel;
                 // check if TV is on
                 if ($arr[0] == 3) {
                     $template_type = 'ads-' . $arr[1] . '-2';
                 }
                 $broadcast_template = 'broadcast.default.internet-tv-master';
             } else {
                 $broadcast_template = 'broadcast.default.business-master';
             }
         } else {
             $broadcast_template = 'broadcast.default.public-master';
         }
     } else {
         $user = [];
         $broadcast_template = 'broadcast.default.public-master';
     }
     $date = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
     return View::make($broadcast_template)->with('carousel_interval', isset($data->carousel_delay) ? (int) $data->carousel_delay : 5000)->with('custom_fields', $custom_fields)->with('ad_type', $data->ad_type)->with('ad_src', $ad_src)->with('box_num', $arr[1])->with('template_type', $template_type)->with('broadcast_type', $data->display)->with('open_time', $open_time)->with('close_time', $close_time)->with('local_address', Business::localAddress($business_id))->with('business_id', $business_id)->with('business_name', $business_name)->with('lines_in_queue', Analytics::getBusinessRemainingCount($business_id))->with('estimate_serving_time', Analytics::getAverageTimeServedByBusinessId($business_id, 'string', $date, $date))->with('first_service', Service::getFirstServiceOfBusiness($business_id))->with('allow_remote', $allow_remote)->with('ticker_message', $ticker_message)->with('user', $user);
 }