public function apply() { if (Session::has('user_id')) { if (Input::has('storeId')) { $storeId = Input::get('storeId'); $userId = Session::get('user_id'); $status = StatusModel::where('store_id', $storeId)->first(); $myQueue = QueueModel::where('store_id', $storeId)->where('user_id', $userId)->where('queue_no', '>', $status->current_queue_no)->whereRaw('DATE(created_at) = DATE(NOW())')->count(); if ($myQueue == 0) { $queueNo = $status->last_queue_no; $status->last_queue_no = $queueNo + 1; $status->save(); $queue = new QueueModel(); $queue->store_id = $storeId; $queue->user_id = $userId; $queue->queue_no = $queueNo + 1; $queue->save(); return Response::json(['result' => 'success', 'msg' => 'You have been successfully apply on this store']); } else { return Response::json(['result' => 'failed', 'msg' => 'You have already apply on this store', 'code' => 'CD00']); } } else { return Response::json(['result' => 'failed', 'msg' => 'Invalid Request', 'code' => 'CD00']); } } else { return Response::json(['result' => 'failed', 'msg' => 'You must login for apply', 'code' => 'CD01']); } }
public static function getStatus($id) { switch ((int) $id) { case self::SUCCESS: return Status::where('id', '=', self::SUCCESS)->firstOrFail(); case self::FAILURE: return Status::where('id', '=', self::FAILURE)->firstOrFail(); case self::SKIP: return Status::where('id', '=', self::SKIP)->firstOrFail(); default: return Status::where('id', '=', self::UNKNOWN)->firstOrFail(); } }
public function apply() { if (Input::has('store_id')) { $storeId = Input::get('store_id'); $status = StatusModel::where('store_id', $storeId)->first(); $queueNo = $status->last_queue_no; $status->last_queue_no = $queueNo + 1; $status->save(); $store = StoreModel::find($storeId); return Response::json(['result' => 'success', 'msg' => '', 'queue_no' => $queueNo + 1, 'created_at' => $status->updated_at->format('Y-m-d H:i:s'), 'logo' => HTTP_PATH . "/assets/img/logo.png"]); } else { return Response::json(['result' => 'failed', 'msg' => 'Invalid Request']); } }
public function findSelectedFilter($filters, $aggregations, $status_filter) { if (!empty($status_filter)) { $values = array(); $status_ranges = explode("-", $status_filter); foreach ($status_ranges as $status_range) { $statuses = Status::where('id', '=', $status_range); if ($statuses->count()) { $title = $statuses->first()->status; array_push($values, array("title" => $title, "index" => 'status-remove-' . $status_range)); } } array_push($filters, array("name" => "Condition", "values" => $values, "modal" => "status")); } return $filters; }
public function asyncNext() { $agent = AgentModel::find(Session::get('agent_id')); $agent->is_active = true; $agent->save(); $status = StatusModel::where('store_id', $agent->store_id)->first(); if (Session::has('process_id')) { $process = ProcessModel::find(Session::get('process_id')); $process->end_time = date('H:i:s'); if (Input::has('ticket_type') && Input::get('ticket_type') != '') { $process->ticket_type = Input::get('ticket_type'); } $process->save(); Session::forget('process_id'); } if (Input::get('is_next') == '1') { if ($status->current_queue_no + 1 <= $status->last_queue_no) { $status->current_queue_no = $status->current_queue_no + 1; $status->save(); $process = new ProcessModel(); $process->agent_id = Session::get('agent_id'); $process->queue_no = $status->current_queue_no; $process->start_time = date('H:i:s'); $process->save(); Session::set('process_id', $process->id); return Response::json(['result' => 'success', 'currentQueueNo' => $status->current_queue_no, 'lastQueueNo' => $status->last_queue_no, 'processId' => $process->id]); } else { $agent->is_active = false; $agent->save(); return Response::json(['result' => 'failed', 'msg' => 'The queue is empty']); } } else { $agent->is_active = false; $agent->save(); return Response::json(['result' => 'failed', 'msg' => 'Your status is DEACTIVE']); } }
public function postStatus($doc) { $toAdd = null; $status = Input::get('status'); $doc = Doc::find($doc); if (!isset($status)) { $doc->statuses()->sync(array()); } else { $toAdd = Status::where('label', $status['text'])->first(); if (!isset($toAdd)) { $toAdd = new Status(); $toAdd->label = $status['text']; } $toAdd->save(); $doc->statuses()->sync(array($toAdd->id)); } $response['messages'][0] = array('text' => 'Document saved', 'severity' => 'info'); return Response::json($response); }
public function getStatusByName($name) { return Status::where('title', $name)->firstOrFail(); }
public static function findClientStatus($id_client = null, $id_user = null) { return Status::where('id_client', '=', $id_client)->get(); }
/** * Display the specified resource. * * @param [int] $id * @return [Response] */ public function show($id) { // Check if user has access to loan if (!$this->user_loan_has_access($id)) { Session::flash('alert_danger', 'Access denied.'); return Redirect::to('dashboard'); } else { // Get loan info $loan = $this->loan->getById($id); $loan = $this->loan_add_status($loan); $loan = $this->show_add_user_info($loan); $conditions = $this->loan->getLoanConditions($loan["id"]); foreach ($conditions as &$condition) { $condition = $this->condition_add_info($condition); } $documents = $this->loan->getLoanDocuments($loan["id"]); // For the update status form $is_staff = $this->is_staff(); $statuses = Status::where('active', 1)->get()->toArray(); $condition_types = ConditionType::where('active', 1)->get()->toArray(); return View::make('auth.loan', ['loan' => $loan, 'documents' => $documents, 'conditions' => $conditions, 'is_staff' => $is_staff, 'statuses' => $statuses, 'condition_types' => $condition_types]); } }