/** * Search the resource by providing a querystring * * @return Response */ public function search(Request $request) { // ?discharged -- [ none | include | only ] $withDischarged = $request->query('discharged', 'none'); if ($withDischarged == 'include') { $query = Member::withTrashed(); } elseif ($withDischarged == 'only') { $query = Member::onlyTrashed(); } else { $query = Member::select(); } // join on 3p table $query->leftJoin('posting_promo', function ($join) { $join->on('members.regt_num', '=', 'posting_promo.regt_num'); }); $query->select('members.*', 'posting_promo.new_rank as rank'); if ($request->has('keywords')) { $keywords = explode(' ', $request->query('keywords')); foreach ($keywords as $keyword) { // If keyword resembles a regt number_format if ($this->keywordLikeRegtNum($keyword)) { $query->where('members.regt_num', 'like', "{$keyword}%"); continue; } // If keyword matches a known rank abbrev if ($this->keywordLikeRank($keyword)) { $rank = $this->keywordExtractRank($keyword); $query->where('rank', $rank); continue; } // Otherwise add this as a name search $query->where(function ($query) use($keyword) { $query->where('last_name', 'like', "%{$keyword}%")->orWhere('first_name', 'like', "%{$keyword}%"); }); } } else { foreach ($request->only('rank', 'last_name', 'first_name', 'regt_num') as $name => $input) { $input = trim($input); if (!empty($input)) { $query->where($name, 'like', "{$input}%"); $query->orderBy($name, 'asc'); } } foreach ($request->only('sex') as $name => $input) { // ('sex', 'is_active') $input = trim($input); if (!empty($input)) { $query->where($name, $input); } } } // return var_dump($input); return response()->json(['members' => $query->get()]); }
/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { if (!$request['fromdate']) { Redirect::to('report'); echo "string"; } print_r($request->only('todate', 'fromdate')); die; if ($request['todate']) { $tdate = date("Y-m-d h:m:s", strtotime($request['todate'])); } else { $tdate = date("Y-m-d h:m:s"); } if ($request['fromdate']) { $fdate = date("Y-m-d h:m:s", strtotime($request['fromdate'])); } else { $fdate = date("Y-m-d h:m:s"); } if (Auth::user()->type == 1 && Auth::user()->loginas == 1) { $admin = count(Member::select('id')->where('type', 1)->whereBetween('created_at', [$fdate, $tdate])->get()); $employer = count(Member::select('id')->where('type', 2)->whereBetween('created_at', [$fdate, $tdate])->get()); $agent = count(Member::select('id')->where('type', 3)->whereBetween('created_at', [$fdate, $tdate])->get()); $adminblock = count(Member::select('id')->whereTypeAndStatus(1, 0)->whereBetween('created_at', [$fdate, $tdate])->get()); $employerblock = count(Member::select('id')->whereTypeAndStatus(2, 0)->whereBetween('created_at', [$fdate, $tdate])->get()); $agentblock = count(Member::select('id')->whereTypeAndStatus(3, 0)->whereBetween('created_at', [$fdate, $tdate])->get()); $resume = count(PersonalInformation::select('id')->whereBetween('created_at', [$fdate, $tdate])->get()); $resumerequest = count(PersonalInformation::select('id')->where('approved_by', '!=', 0)->whereBetween('created_at', [$fdate, $tdate])->get()); $resumeapproved = count(PersonalInformation::select('id')->where('approval_status', 1)->whereBetween('created_at', [$fdate, $tdate])->get()); $demand = count(Demand::select('id')->whereBetween('created_at', [$fdate, $tdate])->get()); return view('history.index')->with('admin', $admin)->with('employer', $employer)->with('agent', $agent)->with('adminblock', $adminblock)->with('employerblock', $employerblock)->with('agentblock', $agentblock)->with('resume', $resume)->with('resumerequest', $resumerequest)->with('resumeapproved', $resumeapproved)->with('demand', $demand); } else { if (Auth::user()->loginas == 2) { $resume = count(PersonalInformation::select('id')->whereBetween('created_at', [$fdate, $tdate])->get()); $resumerequest = count(EmployerApproval::select('apid')->whereEmpid(Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get()); $resumeapproved = count(PersonalInformation::select('id')->whereApproval_statusAndApproved_by(1, Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get()); $demand = count(Demand::select('id')->whereEid(Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get()); return view('history.index')->with('resume', $resume)->with('resumerequest', $resumerequest)->with('resumeapproved', $resumeapproved)->with('demand', $demand); } else { $resume = count(PersonalInformation::select('id')->where('agent_id', Auth::user()->id)->whereBetween('created_at', [$fdate, $tdate])->get()); $resumerequest = count(PersonalInformation::select('id')->where('agent_id', Auth::user()->id)->where('approved_by', '!=', 0)->whereBetween('created_at', [$fdate, $tdate])->get()); $resumeapproved = count(PersonalInformation::select('id')->where('agent_id', Auth::user()->id)->where('approval_status', 1)->whereBetween('created_at', [$fdate, $tdate])->get()); $demand = count(Demand::select('id')->whereBetween('created_at', [$fdate, $tdate])->get()); return view('history.index')->with('resume', $resume)->with('resumerequest', $resumerequest)->with('resumeapproved', $resumeapproved)->with('demand', $demand); } } }
/** * Generate a regimental number * * @param Array $opts * @return String */ protected function generateStandardRegtNumber($opts = 0) { /* * Regimental numbers take the following format * 206 prefix for all * 115 (1st of 2015) if after 2010; 81 (first of 2008) if pre-2010 * 00 denoting their order in the roll * [F] if female -- this function doesn't take notice of those */ // Extract the overrides if (is_array($opts)) { extract($opts); } $prefix = '206' . $thisCycle . $thisYear; // Lookup the index for this number $res = DB::table('ref_misc')->where('name', 'regtNumLast')->where('cond', $prefix)->first(); if (sizeof($res) > 0) { $refDataRowId = $res->id; $lastIndex = intval($res->value); $nextIndex = $lastIndex + 1; } else { $nextIndex = 0; } // Check for no conflict - try a few $proposedRegtNum = $prefix . str_pad($nextIndex, 2, '0', STR_PAD_LEFT); $counterNoConflict = 0; while ($counterNoConflict < 10) { $res = Member::select()->whereIn('regt_num', [$proposedRegtNum, $proposedRegtNum . 'F'])->first(); // $res = DB::table('members')->whereIn('regt_num', [$proposedRegtNum, $proposedRegtNum . 'F'])->first(); if (sizeof($res) > 0) { // Is conflicted; try next index $counterNoConflict++; $proposedRegtNum = $prefix . str_pad(++$nextIndex, 2, '0', STR_PAD_LEFT); continue; } break; } if ($counterNoConflict >= 10) { // The no conflict attempts didn't work return false; } if (isset($refDataRowId)) { // Update the ref_misc table with this latest regtNumLast index $res = DB::table('ref_misc')->where('id', $refDataRowId)->update(['value' => $nextIndex]); } else { // Insert it cos it doesn't exist yet $res = DB::table('ref_misc')->insert(['name' => 'regtNumLast', 'value' => $nextIndex, 'cond' => $prefix]); } return $proposedRegtNum; }
/** * Returns an array of all members' ids and full names * ('id' => 'full_name') * * @return array */ private function membersFullNameList() { return Member::select(DB::raw("CONCAT(first_name, ' ', last_name) AS full_name, id"))->lists('full_name', 'id'); }
public function getAllMember() { $user = Member::select('id', 'fname', 'mname', 'lname')->where('status', '=', 1)->get(); return $user; }
public function verifyMember(Request $request) { $user = Login::where('remember_token', '=', $request->header('token'))->where('login_from', '=', $request->ip())->join('members', 'members.id', '=', 'logins.member_id')->where('logins.status', '=', '1')->first(); if ($user->mtype != 1) { $returnData = array('status' => 'fail', 'mesage' => 'insufficient permision', 'code' => 403); return $returnData; } $data = $request->only('member_id'); $member = Member::find($data['member_id']); $member->status = 1; //return $member ; if ($member->save()) { $new = Member::select('id', 'fname', 'mname', 'lname', 'mtype', 'username')->where('id', '=', $member->id)->first(); $returnData = array('status' => 'ok', 'message' => 'member verified', 'code' => 200, 'member' => $new); return Response::json($returnData, 200); } else { $returnData = array('status' => 'fail', 'message' => 'member verified', 'code' => 500); return Response::json($returnData, 200); } }
public function getUnverifiedMember() { $members = Member::select('id')->where('status', '=', '0')->get(); return Response::json(array('members' => $members)); }