Ejemplo n.º 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;
 }
Ejemplo n.º 3
0
 public static function sendSMS($message, $phone, $service_id)
 {
     //ARA Adding sms as business feature
     $business_features = Business::getBusinessFeatures(Branch::businessId(Service::branchId($service_id)));
     if ($business_features['allow_sms'] == 'true') {
         $gateway = QueueSettings::smsGateway($service_id);
         $api_variables = unserialize(QueueSettings::smsGatewayApi($service_id));
         if ($gateway == 'frontline_sms') {
             $url = QueueSettings::frontlineUrl($service_id);
             $secret = QueueSettings::frontlineSecret($service_id);
             $api_key = null;
             if ($url == FRONTLINE_SMS_URL && $secret == FRONTLINE_SMS_SECRET) {
                 $url = $api_variables['frontline_sms_url'];
                 $api_key = $api_variables['frontline_sms_api_key'];
             }
             Notifier::sendFrontlineSMS($message, $phone, $url, $secret, $api_key);
         } else {
             if ($gateway == 'twilio') {
                 if ($api_variables['twilio_phone_number'] == TWILIO_PHONE_NUMBER && $api_variables['twilio_account_sid'] == TWILIO_ACCOUNT_SID && $api_variables['twilio_auth_token'] == TWILIO_AUTH_TOKEN) {
                     //@todo do something says that they are using featherq twilio service
                 }
                 $from = $api_variables['twilio_phone_number'];
                 $account_sid = $api_variables['twilio_account_sid'];
                 $auth_token = $api_variables['twilio_auth_token'];
                 Notifier::sendTwilio($phone, $message, $from, $account_sid, $auth_token);
             }
         }
     }
 }