/** * Show the form for creating a new resource. * * @return Response */ public function create(Request $request) { 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); } } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { if (Input::get('resume')) { $approveChecked = Input::get('resume'); if (Auth::user()->type == 1 && Auth::user()->loginas == 1) { $records = EmployerApproval::select('pid')->whereIn('apid', $approveChecked)->selectRaw('count(`pid`) as `occurences`')->from('employerapproval')->groupBy('pid')->having('occurences', '>', 1)->get(); if (count($records) != 0) { Session::flash('message', 'You can not Approve more than one Employer for same Resume'); return Redirect::to('approval'); } else { foreach ($approveChecked as $approve) { $rid = EmployerApproval::where('apid', $approve)->first(); $update = DB::table('personalinformation')->where('id', $rid->pid)->update(['approval_status' => 1, 'approved_by' => $rid->empid]); } Session::flash('message', 'Resume Approved Successfully'); } } else { foreach ($approveChecked as $approve) { $prvcheck = EmployerApproval::wherePidAndEmpid($approve, Auth::user()->id)->first(); if ($prvcheck) { } else { $update = DB::table('personalinformation')->where('id', $approve)->update(['approved_by' => -1]); $insert = new EmployerApproval(); $insert->pid = $approve; $insert->empid = Auth::user()->id; $insert->save(); Session::flash('message', 'Resume Requested Successfully'); } } } } return Redirect::to('approval'); }