Пример #1
0
 static function init()
 {
     $init['user'] = $_SESSION['user'];
     $host = $_SERVER['HTTP_HOST'];
     if (substr($host, 0, 7) != 'http://') {
         $host = 'http://' . $host;
     }
     $init['app'] = array('host' => $host);
     $query = self::_reffer();
     if (isset($query['gid'])) {
         $gid = $query['gid'];
         $game = GameModel::get($gid);
         $game['user'] = UserBusiness::publicShow($game['uid']);
         $game['createtime'] = date('Y-m-d H:i:s', $game['createtime']);
         $init['game'] = $game;
     }
     return $init;
 }
 public function postRemove()
 {
     $post = json_decode(file_get_contents("php://input"));
     if (Helper::isBusinessOwner($post->business_id, Helper::userId())) {
         // PAG added permission checking
         Business::deleteBusinessByBusinessId($post->business_id);
         $branches = Branch::getBranchesByBusinessId($post->business_id);
         foreach ($branches as $count => $data) {
             $services = Service::getServicesByBranchId($data->branch_id);
             foreach ($services as $count2 => $data2) {
                 $terminals = Terminal::getTerminalsByServiceId($data2->service_id);
                 foreach ($terminals as $count3 => $data3) {
                     TerminalUser::deleteUserByTerminalId($data3['terminal_id']);
                 }
                 Terminal::deleteTerminalsByServiceId($data2->service_id);
             }
             Service::deleteServicesByBranchId($data->branch_id);
         }
         Branch::deleteBranchesByBusinessId($post->business_id);
         UserBusiness::deleteUserByBusinessId($post->business_id);
         return json_encode(array('status' => 1));
     } else {
         return json_encode(array('status' => 0, 'message' => 'You are not allowed to access this function.'));
     }
 }
 /**
  * @param $facebook_id
  * @return JSON-formatted response of the business name, estimated time, people-in-queue and next number available .
  */
 public function getBusinessServiceDetails($facebook_id)
 {
     try {
         $user_id = User::getUserIdByFbId($facebook_id);
     } catch (Exception $e) {
         $user_id = null;
     }
     if ($user_id) {
         $business_id = UserBusiness::getBusinessIdByOwner($user_id);
         $business_name = Business::name($business_id);
         $estimated_time = Analytics::getWaitingTime($business_id);
         $service = Service::getFirstServiceOfBusiness($business_id);
         $remaining_queue_count = Analytics::getServiceRemainingCount($service->service_id);
         $next_available_number = ProcessQueue::nextNumber(ProcessQueue::lastNumberGiven($service->service_id), QueueSettings::numberStart($service->service_id), QueueSettings::numberLimit($service->service_id));
         $details = ['business_name' => $business_name, 'estimated_time' => $estimated_time, 'people_in_queue' => $remaining_queue_count, 'next_available_number' => $next_available_number];
         return Response::json($details, 200, array(), JSON_PRETTY_PRINT);
     } else {
         return json_encode(['error' => 'Something went wrong!']);
     }
 }
 /**
  * @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);
 }