Пример #1
0
 public static function getBusinessDetails($business_id)
 {
     $business = Business::where('business_id', '=', $business_id)->get()->first();
     $terminals = Terminal::getTerminalsByBusinessId($business_id);
     $terminals = Terminal::getAssignedTerminalWithUsers($terminals);
     $analytics = Analytics::getBusinessAnalytics($business_id);
     $first_service = Service::getFirstServiceOfBusiness($business_id);
     $business_details = ['business_id' => $business_id, 'business_name' => $business->name, 'business_address' => $business->local_address, 'facebook_url' => $business->fb_url, 'industry' => $business->industry, 'time_open' => Helper::mergeTime($business->open_hour, $business->open_minute, $business->open_ampm), 'time_closed' => Helper::mergeTime($business->close_hour, $business->close_minute, $business->close_ampm), 'timezone' => $business->timezone, 'queue_limit' => $business->queue_limit, 'terminal_specific_issue' => QueueSettings::terminalSpecificIssue($first_service->service_id), 'sms_current_number' => QueueSettings::smsCurrentNumber($first_service->service_id), 'sms_1_ahead' => QueueSettings::smsOneAhead($first_service->service_id), 'sms_5_ahead' => QueueSettings::smsFiveAhead($first_service->service_id), 'sms_10_ahead' => QueueSettings::smsTenAhead($first_service->service_id), 'sms_blank_ahead' => QueueSettings::smsBlankAhead($first_service->service_id), 'input_sms_field' => QueueSettings::inputSmsField($first_service->service_id), 'allow_remote' => QueueSettings::allowRemote($first_service->service_id), 'remote_limit' => QueueSettings::remoteLimit($first_service->service_id), 'terminals' => $terminals, 'analytics' => $analytics, 'features' => Business::getBusinessFeatures($business_id), 'sms_gateway' => QueueSettings::smsGateway($first_service->service_id), 'allowed_businesses' => Business::getForwardingAllowedBusinesses($business_id)];
     $sms_gateway_api = unserialize(QueueSettings::smsGatewayApi($first_service->service_id));
     if ($business_details['sms_gateway'] == 'frontline_sms' && $sms_gateway_api) {
         $business_details['frontline_sms_url'] = $sms_gateway_api['frontline_sms_url'];
         $business_details['frontline_sms_api_key'] = $sms_gateway_api['frontline_sms_api_key'];
     } elseif ($business_details['sms_gateway'] == 'twilio' && $sms_gateway_api) {
         if ($sms_gateway_api['twilio_account_sid'] == TWILIO_ACCOUNT_SID && $sms_gateway_api['twilio_auth_token'] == TWILIO_AUTH_TOKEN && $sms_gateway_api['twilio_phone_number'] == TWILIO_PHONE_NUMBER) {
             $business_details['sms_gateway'] = NULL;
             $business_details['twilio_account_sid'] = NULL;
             $business_details['twilio_auth_token'] = NULL;
             $business_details['twilio_phone_number'] = NULL;
         } else {
             $business_details['twilio_account_sid'] = $sms_gateway_api['twilio_account_sid'];
             $business_details['twilio_auth_token'] = $sms_gateway_api['twilio_auth_token'];
             $business_details['twilio_phone_number'] = $sms_gateway_api['twilio_phone_number'];
         }
     } else {
         $business_details['sms_gateway'] = NULL;
         $business_details['twilio_account_sid'] = NULL;
         $business_details['twilio_auth_token'] = NULL;
         $business_details['twilio_phone_number'] = NULL;
     }
     return $business_details;
 }
 public static function checkRemoteQueue($service_id)
 {
     $date = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
     $allow_remote = QueueSettings::allowRemote($service_id);
     $remote_limit = QueueSettings::remoteLimit($service_id);
     $total_numbers_today = PriorityNumber::where('date', '=', $date)->select(DB::raw('COUNT(priority_number.track_id) as total_numbers_today'))->first()->total_numbers_today;
     $total_remote_today = PriorityNumber::where('date', '=', $date)->join('priority_queue', 'priority_queue.track_id', '=', 'priority_number.track_id')->where(function ($query) {
         $query->where('priority_queue.queue_platform', '=', 'remote')->orWhere('priority_queue.queue_platform', '=', 'android');
     })->select(DB::raw('COUNT(priority_number.track_id) as total_remote_today'))->first()->total_remote_today;
     $remote_queue_value = floor($total_numbers_today * ($remote_limit / 100));
     $result = $allow_remote && $remote_queue_value > $total_remote_today ? true : false;
     return $result;
 }