public function main($id) { if (is_null(Agent::find($id))) { return Redirect::to('admin'); } $commissions = Commission::where('agent_id', $id)->orderBy('created_at', 'desc')->get(); $agent = Agent::find($id); View::make('admin.commission.list', compact('commissions', 'agent')); }
public function logout() { if (Session::has('process_id')) { $process = ProcessModel::find(Session::get('process_id')); $process->end_time = date('H:i:s'); $process->save(); Session::forget('process_id'); } $agent = AgentModel::find(Session::get('agent_id')); $agent->is_active = false; $agent->save(); Session::forget('agent_id'); return Redirect::route('agent.auth.login'); }
public function store() { $rules = ['name' => 'required', 'email' => 'required|email', 'phone' => 'required']; $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } else { $agent = AgentModel::find(Session::get('agent_id')); $password = Input::get('password'); if ($password !== '') { $agent->secure_key = md5($agent->salt . $password); } $agent->name = Input::get('name'); $agent->email = Input::get('email'); $agent->phone = Input::get('phone'); $agent->save(); $alert['msg'] = 'Account has been saved successfully'; $alert['type'] = 'success'; return Redirect::route('agent.account')->with('alert', $alert); } }
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']); } }
/** * Returns TRUE if the string you're looking for exists in the user agent string and FALSE if not. * * <code> * if (Agent::is('iphone')) { * // Do something... * } * * if (Agent::is(array('iphone', 'ipod'))) { * // Do something... * } * </code> * * @param mixed $device String or array of strings you're looking for * @return boolean */ public static function is($device) { return Agent::find((array) $device); }
} }, 'agency.delete' => function ($agencyId) { if (Auth::user()->hasMtmAgency(Agency::find($agencyId))) { return true; } }, 'agency.clients' => function ($agencyId) { if (Auth::user()->hasMtmAgency(Agency::find($agencyId))) { return true; } }, 'agency.agents' => function ($agencyId) { // return false; if (Auth::user()->hasMtmAgency(Agency::find($agencyId))) { return true; } }, 'agent.update' => function ($agent_id) { $agent = Agent::find($agent_id); if ($agent && Auth::user()->hasMtmAgency(Agency::find($agent->agency_id))) { return true; } }, 'client.create' => function () { $agencyId = Input::get('agency_id', false); if ($agencyId && Auth::user()->hasMtmAgency(Agency::find($agencyId))) { return true; } }, 'client.show' => function ($clientId) { $client = Client::find($clientId); if (Auth::user()->hasMtmAgency(Agency::find($client->agency_id))) { return true; } }, 'agent.create' => function () { $agencyId = Input::get('agency_id', false);
public function give_commission_post($id) { if (is_null(Agent::find($id))) { return Redirect::to('admin'); } $agent = Agent::find($id); $action = Input::get('action'); if ($action == 'deduct') { $rules = array('action' => 'required', 'remarks' => 'required', 'amount' => 'required|numeric'); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { $commissions = new Commission(); $commissions->user_id = Input::get('user_id'); $commissions->property_id = Input::get('property_id'); $commissions->agent_id = $agent->id; $commissions->action = 'deduct'; $commissions->remarks = Input::get('remarks'); $commissions->amount = Input::get('amount'); $commissions->save(); // AGENT COMMISSION if ($agent->earnings > 0) { $agent->earnings = $agent->earnings - Input::get('amount'); $agent->save(); } return Redirect::to('admin/agents/commissions/' . $id)->with('success', 'Commission has been added.'); } else { return Redirect::to('admin/give_commission/' . $id)->withErrors($validator)->withInput(); } } elseif ($action == 'add') { $rules = array('user_id' => 'required|numeric|exists:users,id', 'property_id' => 'required|numeric|exists:properties,id', 'action' => 'required', 'remarks' => 'required', 'amount' => 'required|numeric'); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { $commissions = new Commission(); $commissions->user_id = Input::get('user_id'); $commissions->property_id = Input::get('property_id'); $commissions->agent_id = $agent->id; $commissions->action = 'add'; $commissions->remarks = Input::get('remarks'); $commissions->amount = Input::get('amount'); $commissions->save(); // AGENT COMMISSION $agent->earnings = $agent->earnings + Input::get('amount'); $agent->save(); return Redirect::to('admin/agents/commissions/' . $id)->with('success', 'Commission has been added.'); } else { return Redirect::to('admin/give_commission/' . $id)->withErrors($validator)->withInput(); } } }
/** * Show the form for editing the specified agent. * * @param int $id * @return Response */ public function edit($id) { $agent = Agent::find($id); return View::make('control-panel.agents.edit', compact('agent')); }
function get_biomedical_terms_availability() { $BOA_agent_id = Agent::find('Biology of Aging'); if (!$BOA_agent_id) { return; } $result = $this->mysqli_slave->query("SELECT MAX(harvest_events.id) latest_harvent_event_id\n FROM harvest_events JOIN agents_resources ON agents_resources.resource_id = harvest_events.resource_id\n WHERE agents_resources.agent_id = {$BOA_agent_id} AND harvest_events.published_at IS NOT NULL"); if ($result && ($row = $result->fetch_assoc())) { $latest_harvent_event_id = $row['latest_harvent_event_id']; } $sql = "SELECT he.taxon_concept_id FROM harvest_events_hierarchy_entries hehe\n JOIN hierarchy_entries he ON (hehe.hierarchy_entry_id = he.id)\n WHERE hehe.harvest_event_id = {$latest_harvent_event_id} "; if ($this->test_taxon_concept_ids) { $sql .= " AND he.taxon_concept_id IN (" . $this->test_taxon_concept_ids . ")"; } $raw_stats = array(); foreach ($this->mysqli_slave->iterate_file($sql) as $row_number => $row) { $taxon_concept_id = trim($row[0]); $raw_stats[$taxon_concept_id] = "1"; } echo count($raw_stats) . "\n"; $this->save_category_stats($raw_stats, "get_biomedical_terms_availability"); }
public function delete($id) { try { AgentModel::find($id)->delete(); $alert['msg'] = 'Agent has been deleted successfully'; $alert['type'] = 'success'; } catch (\Exception $ex) { $alert['msg'] = 'This Agent has been already used'; $alert['type'] = 'danger'; } return Redirect::route('company.agent')->with('alert', $alert); }