Пример #1
0
 public static function sendNumberNextSms($transaction_number, $diff)
 {
     $phone = PriorityQueue::phone($transaction_number);
     $name = PriorityQueue::name($transaction_number);
     if ($phone) {
         $pq = Helper::firstFromTable('priority_queue', 'transaction_number', $transaction_number);
         $terminal_id = TerminalTransaction::terminalId($transaction_number);
         $service_id = PriorityNumber::serviceId($pq->track_id);
         $priority_number = PriorityQueue::priorityNumber($transaction_number);
         $current_number = ProcessQueue::currentNumber($service_id);
         $terminal_name = $terminal_id != 0 ? Terminal::name($terminal_id) : '';
         $business_name = $terminal_id != 0 ? Business::name(Business::getBusinessIdByTerminalId($terminal_id)) : '';
         $name = $name == null ? null : ' ' . $name;
         $message = "Hello{$name}, Your number, ({$priority_number}), will be called soon. ";
         $message .= "Number ({$current_number}) has been called by {$terminal_name}. ";
         if ($diff >= 1) {
             $message .= $diff == 1 ? "There is currently " . $diff . " person ahead of you " : "There are currently " . $diff . " people ahead of you ";
         }
         $message .= "at the {$terminal_name} at {$business_name}.";
         Notifier::sendServiceSms($message, $phone, $service_id);
     }
 }
 /**
  * @author Aunne Rouie Arzadon
  * @param $facebook_id
  * @return string
  */
 public function getQueueInfo($facebook_id, $business_id = null)
 {
     try {
         $user_id = User::getUserIdByFbId($facebook_id);
     } catch (Exception $e) {
         $user_id = null;
     }
     if ($business_id) {
         $service = Service::getFirstServiceOfBusiness($business_id);
         $allow_remote = QueueSettings::allowRemote($service->service_id);
     }
     if ($user_id) {
         try {
             $transaction_number = PriorityQueue::getLatestTransactionNumberOfUser($user_id);
             $priority_number = PriorityQueue::priorityNumber($transaction_number);
             $track_id = PriorityQueue::trackId($transaction_number);
             $service_id = PriorityNumber::serviceId($track_id);
             $business_id = Branch::businessId(Service::branchId($service_id));
             $details = ['number_assigned' => $priority_number, 'business_id' => $business_id, 'business_name' => Business::name($business_id), 'current_number_called' => ProcessQueue::currentNumber($service_id), 'estimated_time_until_called' => Analytics::getWaitingTime($business_id), 'status' => TerminalTransaction::queueStatus($transaction_number), 'allow_remote' => isset($allow_remote) ? $allow_remote : null];
         } catch (Exception $e) {
             $details = ['number_assigned' => 0, 'business_id' => 0, 'business_name' => '', 'current_number_called' => 0, 'estimated_time_until_called' => 0, 'status' => 'Error', 'allow_remote' => isset($allow_remote) ? $allow_remote : null];
         }
         return json_encode($details);
     } else {
         return json_encode(['error' => 'You are not registered to FeatherQ.']);
     }
 }