/** * @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.']); } }