public function doCreate(CreatePlanRequest $request) { $plan = new SMPlan(); $plan->sm_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() { $AMsIds = Employee::select('id')->where('manager_id', \Auth::user()->id)->get(); $employees = Employee::select('line_id')->whereIn('manager_id', $AMsIds)->get(); //am_session $products = Product::whereIn('line_id', $employees)->get(); $employeesId = Employee::select('id')->whereIn('manager_id', $AMsIds)->get(); $customers = Customer::whereIn('mr_id', $employeesId)->get(); $MRs = Employee::whereIn('manager_id', $AMsIds)->get(); $AMs = Employee::where('manager_id', \Auth::user()->id)->get(); $dataView = ['productsCount' => count($products), 'plansCount' => SMPlan::where('month', \Config::get('app.current_month'))->count(), 'reportsCount' => SMReport::where('month', \Config::get('app.current_month'))->count(), 'customersCount' => count($customers), 'employeesCount' => count($MRs) + count($AMs)]; return view('sm.index', $dataView); }
public function declineSM($id) { $plan = SMPlan::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 getSMPendingPlans() { $plans = SMPlan::pending()->get(); return count($plans); }