/** * @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.']); } }
private function queueNumberExists($email) { $date = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $count = PriorityNumber::where('priority_number.date', '=', $date)->join('priority_queue', 'priority_queue.track_id', '=', 'priority_number.track_id')->where('priority_queue.email', '=', $email)->select(DB::raw('COUNT(priority_number.track_id) as number_exists'))->first()->number_exists; return $count > 0 ? TRUE : FALSE; }
public function getServicesCurrentNumber($branch_id) { $services = PriorityNumber::getBranchServicesActiveQueue($branch_id); foreach ($services as $key => $service) { $services[$key] = $this->getServiceKeyDetails($service, $branch_id); } return $services; }