Ejemplo n.º 1
0
 public static function sendNumberNextAndroid($transaction_number, $diff)
 {
     $priority_queue = PriorityQueue::find($transaction_number);
     if ($priority_queue) {
         $user_id = $priority_queue->user_id;
         $priority_number = $priority_queue->priority_number;
         $queue_platform = $priority_queue->queue_platform;
         $email = $priority_queue->email;
         $terminal_id = TerminalTransaction::terminalId($transaction_number);
         $terminal_name = $terminal_id != 0 ? Terminal::name($terminal_id) : '';
         $business_id = $terminal_id != 0 ? Business::getBusinessIdByTerminalId($terminal_id) : 0;
         $business_name = $business_id != 0 ? Business::name($business_id) : '';
         $waiting_time = Analytics::getWaitingTime($business_id);
         $estimated_time = Helper::millisecondsToHMSFormat($waiting_time);
         $message = "Your number ({$priority_number}) will be called in approximately {$estimated_time}. ";
         if ($diff == 1) {
             $message .= "There is currently {$diff} person ahead of you at the {$terminal_name} at {$business_name}.";
         } else {
             $message .= "There are currently {$diff} people ahead of you at the {$terminal_name} at {$business_name}.";
         }
         if ($queue_platform != 'web' && $queue_platform != 'specific') {
             $gcm_token = User::gcmToken($user_id);
             if ($gcm_token) {
                 Notifier::sendAndroid($gcm_token, $message);
             }
         } else {
             if (($queue_platform == 'web' || $queue_platform == 'specific') && $email != null) {
                 $user = User::searchByEmail($email);
                 $gcm_token = $user ? User::gcmToken($user['user_id']) : null;
                 if ($gcm_token) {
                     Notifier::sendAndroid($gcm_token, $message);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static function getWaitingTimeString($business_id)
 {
     $waiting_time = Analytics::getWaitingTime($business_id);
     $waiting_time = floor($waiting_time / 60);
     //Reduced to 3 different line statuses
     if ($waiting_time > 30) {
         $waiting_time_string = 'heavy';
     } else {
         if ($waiting_time <= 30 && $waiting_time > 15) {
             $waiting_time_string = 'moderate';
         } else {
             $waiting_time_string = 'light';
         }
     }
     return $waiting_time_string;
 }