/**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     $this->middleware('auth');
     $this->viewData['user_id'] = (int) Auth::User()->id;
     $this->viewData['controller_heading'] = 'Initiatives';
     $this->viewData['controller_name'] = $this->controller;
     $this->viewData['whatisit'] = 'Initiative';
     $this->viewData['plans'] = Plan::where('user_id', $this->viewData['user_id'])->where('status', 0)->orderBy('name')->lists('name', 'id');
     $this->viewData['currentPlan'] = NULL;
     if (!empty($_GET['plan_id'])) {
         $this->viewData['currentPlan'] = Plan::find($_GET['plan_id']);
     } else {
         if (!empty($this->viewData['plans'])) {
             $this->viewData['currentPlan'] = Plan::where('user_id', $this->viewData['user_id'])->where('status', 0)->orderBy('name')->get()->first();
         }
     }
     $this->viewData['dimensions'] = Dimension::leftJoin('plans', 'plans.id', '=', 'dimensions.plan_id')->where('plans.user_id', $this->viewData['user_id'])->where('dimensions.plan_id', $this->viewData['currentPlan']->id)->where('dimensions.status', 0)->orderBy('dimensions.name')->select('dimensions.*')->lists('dimensions.name', 'dimensions.id');
     $this->viewData['currentDimension'] = NULL;
     if (!empty($_GET['dimension_id'])) {
         $this->viewData['currentDimension'] = Dimension::find($_GET['dimension_id']);
     } else {
         if (!empty($this->viewData['dimensions'])) {
             $this->viewData['currentDimension'] = Dimension::where('dimensions.plan_id', $this->viewData['currentPlan']->id)->where('dimensions.status', 0)->orderBy('dimensions.name')->get()->first();
         }
     }
     $this->viewData['currentDimensionId'] = !empty($this->viewData['currentDimension']) ? $this->viewData['currentDimension']->id : '';
     $this->viewData['objectives'] = Objective::leftJoin('dimensions', 'dimensions.id', '=', 'objectives.dimension_id')->leftJoin('plans', 'plans.id', '=', 'dimensions.plan_id')->where('plans.user_id', '=', $this->viewData['user_id'])->where('objectives.dimension_id', '=', $this->viewData['currentDimensionId'])->where('objectives.status', 0)->orderBy('objectives.name')->select('objectives.*')->lists('objectives.name', 'objectives.id');
 }
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     $this->middleware('auth');
     $this->viewData['user_id'] = (int) Auth::User()->id;
     $this->viewData['controller_heading'] = 'Dimensions';
     $this->viewData['controller_name'] = $this->controller;
     $this->viewData['whatisit'] = 'Dimension';
     $this->viewData['plans'] = Plan::where('user_id', $this->viewData['user_id'])->where('status', 0)->orderBy('name')->lists('name', 'id');
     $this->viewData['currentPlan'] = NULL;
     if (!empty($this->viewData['plans'])) {
         $this->viewData['currentPlan'] = Plan::where('user_id', $this->viewData['user_id'])->where('status', 0)->orderBy('name')->get()->first();
     }
     $this->viewData['breadcrumb'] = array(array('name' => 'Home', 'href' => '/'), array('name' => $this->viewData['controller_heading'], 'href' => $this->controller));
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->viewData['user_id'] = Auth::User()->id;
     $list = _MODEL::where('user_id', '=', (int) $this->viewData['user_id'])->get();
     array_push($this->viewData['breadcrumb'], array());
     foreach ($list as $row) {
         $row->AVERAGE = 0;
         // get objectives list related to dimension
         $objectives = Objective::where('objectives.dimension_id', '=', (int) $row->id)->select('*')->get();
         $objective_AVERAGE = 0;
         $objective_count = 0;
         foreach ($objectives as $objective) {
             //get initiatives related to objective
             $initiatives = Initiative::where('initiatives.objective_id', '=', (int) $objective->id)->select('*')->get();
             $initiative_AVERAGE = 0;
             $initiative_count = 0;
             foreach ($initiatives as $initiative) {
                 //get measures related to initiative
                 $measures = Measure::where('measures.initiative_id', '=', (int) $initiative->id)->select('*')->get();
                 $measure_count = 0;
                 $percent = 0;
                 foreach ($measures as $measure) {
                     $measure->actual = ActualMeasure::where('actual_measures.measure_id', '=', (int) $measure->id)->sum('actual_measures.actual_measure');
                     if ($measure->target != 0) {
                         $percent += $measure->actual / $measure->target * 100;
                     }
                     $measure_count++;
                 }
                 //end measures
                 if ($measure_count != 0) {
                     $initiative_AVERAGE += $percent / $measure_count;
                 }
                 $initiative_count++;
             }
             //end initiative
             if ($initiative_count != 0) {
                 $objective_AVERAGE += $initiative_AVERAGE / $initiative_count;
             }
             $objective_count++;
         }
         if ($objective_count != 0) {
             $row->AVERAGE = $objective_AVERAGE / $objective_count;
         }
     }
     return view($this->controller . '.index', compact('list'), $this->viewData);
 }
示例#4
0
 public function doSearch(PlanSearchRequest $request)
 {
     $mr = $request->mr;
     $planSearchResult = [];
     $leaveRequestSearchResult = [];
     $from = $request->date_from;
     $to = $request->date_to;
     $allSearchedPlan = Plan::where('mr_id', $mr)->where('date', '>=', $from)->where('date', '<=', $to)->approved()->get();
     $allSearchLeaveRequest = LeaveRequest::where('mr_id', $mr)->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', $mr);
     \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);
 }
示例#5
0
 public function index()
 {
     $dataView = ['productsCount' => Product::count(), 'plansCount' => Plan::where('month', \Config::get('app.current_month'))->count(), 'reportsCount' => Report::where('month', \Config::get('app.current_month'))->count(), 'customersCount' => Customer::count(), 'employeesCount' => Employee::count()];
     return view('admin.index', $dataView);
 }
示例#6
0
 public function plans($type)
 {
     $plans = Plan::where('month', \config('app.current_month'))->where('mr_id', \Auth::user()->id)->get();
     \Excel::create('plans', function ($excel) use($plans) {
         $excel->sheet('plans', function ($sheet) use($plans) {
             $sheet->setAllBorders('thin');
             $sheet->loadView('mr.export.plans')->with('plans', $plans);
         });
     })->export($type);
 }
 public function __construct()
 {
     $this->middleware('auth');
     $this->viewData['user_id'] = (int) Auth::User()->id;
     $this->viewData['plans'] = Plan::where('user_id', $this->viewData['user_id'])->where('status', 0)->orderBy('name')->select('plans.*')->get();
 }