public function doCreate(CreatePlanRequest $request) { $plan = new AMPlan(); $plan->am_id = \Auth::user()->id; $plan->month = $request->month . '-' . $request->year; $plan->date = $request->date; $plan->doctors = json_encode($request->doctors); try { $plan->save(); return redirect()->back()->with('message', 'Visit Plan has been sent to your managers successfully! . Wait for approval'); } catch (ParseException $ex) { echo 'Failed to create new plan , with error message: ' . $ex->getMessage(); } }
public function index() { $employees = Employee::select('line_id')->where('manager_id', \Auth::user()->id)->get(); $products = Product::whereIn('line_id', $employees)->get(); $employees = Employee::select('id')->where('manager_id', \Auth::user()->id)->get(); $customers = Customer::whereIn('mr_id', $employees)->get(); $employees = Employee::where('manager_id', \Auth::user()->id)->get(); $dataView = ['productsCount' => count($products), 'plansCount' => AMPlan::where('month', \Config::get('app.current_month'))->count(), 'reportsCount' => AMReport::where('month', \Config::get('app.current_month'))->count(), 'customersCount' => count($customers), 'employeesCount' => count($employees)]; return view('am.index', $dataView); }
public function doAMSearch(AMPlanSearchRequest $request) { $am = $request->am; $planSearchResult = []; $leaveRequestSearchResult = []; $from = $request->date_from; $to = $request->date_to; $allSearchedPlan = AMPlan::where('am_id', $am)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get(); $allSearchLeaveRequest = AMLeaveRequest::where('am_id', $am)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get(); foreach ($allSearchedPlan as $singleReport) { $planSearchResult[] = $singleReport; } foreach ($allSearchLeaveRequest as $singleLeaveRequest) { $leaveRequestSearchResult[] = $singleLeaveRequest; } $dataView = ['planSearchResult' => $planSearchResult, 'leaveRequestSearchResult' => $leaveRequestSearchResult]; \Session::flash('emp', $am); \Session::flash('date_from', $from); \Session::flash('date_to', $to); \Session::flash('planSearchResult', $planSearchResult); \Session::flash('leaveRequestSearchResult', $leaveRequestSearchResult); return view('admin.search.plans.result', $dataView); }
public function decline($id) { $plan = AMPlan::findOrFail($id); $plan->approved = 0; try { $plan->save(); return redirect()->back()->with('message', 'Plan has been decline successfully !'); } catch (ParseException $ex) { echo 'Failed to approve plan , with error message: ' . $ex->getMessage(); } }
public function getAMPendingPlans() { $plans = AMPlan::pending()->get(); return count($plans); }