Пример #1
0
 public function ajaxPlans()
 {
     $arr = array();
     $plans = SMPlan::where('sm_id', \Auth::user()->id)->approved()->get();
     $leave = SMLeaveRequest::where('sm_id', \Auth::user()->id)->approved()->get();
     $i = 0;
     foreach ($plans as $singlePlan) {
         foreach ((array) json_decode($singlePlan['doctors']) as $singleDoctorId) {
             $color = $this->isDoctorVisited($singleDoctorId, $singlePlan['date']) == true ? 'green' : 'red';
             $url = $this->isDoctorVisited($singleDoctorId, $singlePlan['date']) != true ? \URL::route('smAddReport', $singleDoctorId) : NULL;
             $arr[$i]['url'] = $url;
             $arr[$i]['title'] = Customer::findOrFail($singleDoctorId)->name;
             $arr[$i]['start'] = $singlePlan['date'];
             $arr[$i]['color'] = $color;
             $i++;
         }
     }
     foreach ($leave as $singleLeave) {
         $arr[$i]['title'] = 'Holiday';
         $arr[$i]['start'] = $singleLeave['leave_start'];
         $arr[$i]['end'] = date('Y-m-d', strtotime($singleLeave['leave_end'] . "+1 days"));
         $arr[$i]['color'] = '#9b59b6';
         $arr[$i]['allDay'] = true;
         $i++;
     }
     return json_encode($arr);
 }
Пример #2
0
 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);
 }
Пример #3
0
 public function doSMSearch(SMPlanSearchRequest $request)
 {
     $sm = $request->sm;
     $planSearchResult = [];
     $leaveRequestSearchResult = [];
     $from = $request->date_from;
     $to = $request->date_to;
     $allSearchedPlan = SMPlan::where('sm_id', $sm)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get();
     $allSearchLeaveRequest = SMLeaveRequest::where('sm_id', $sm)->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', $sm);
     \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);
 }