Exemplo n.º 1
0
 public function search(Request $request)
 {
     $results = array();
     $term = $request->get('term');
     $goals = Goal::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $objectives = Objective::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $actions = Action::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $tasks = Task::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $teams = Team::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get();
     $departments = Department::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get();
     $users = User::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get()->all();
     foreach (User::where('email', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get() as $matching_user_email) {
         if (in_array($matching_user_email, $users)) {
             continue;
         }
         $users[] = $matching_user_email;
     }
     $notes = Note::where('content', 'like', '%' . $term . '%')->orderBy('content', 'asc')->get();
     $types = [$goals, $objectives, $actions, $tasks, $teams, $departments, $users, $notes];
     foreach ($types as $type) {
         foreach ($type as $result) {
             $results[] = $result;
         }
     }
     return view('search.show')->with('results', $results)->with('term', $term);
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (!empty(Input::get('plan_id'))) {
         $this->viewData['currentPlan'] = Plan::find(Input::get('plan_id'));
     }
     $list = _MODEL::leftJoin('plans', 'plans.id', '=', 'dimensions.plan_id')->where('plans.user_id', '=', $this->viewData['user_id'])->where('plans.id', '=', $this->viewData['currentPlan']->id)->select('dimensions.*')->get();
     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);
 }
Exemplo n.º 3
0
 /**
  * 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);
 }
 public function getAverageDimension($dimension)
 {
     $dimension->AVERAGE = 0;
     // get objectives list related to dimension
     $objectives = Objective::where('objectives.dimension_id', '=', (int) $dimension->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) {
         $dimension->AVERAGE = (double) $objective_AVERAGE / $objective_count;
     }
     return $dimension;
 }
 /**
  * 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'] = 'Measures';
     $this->viewData['controller_name'] = $this->controller;
     $this->viewData['whatisit'] = 'Measure';
     $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');
     $this->viewData['currentObjective'] = NULL;
     if (!empty($_GET['objective_id'])) {
         $this->viewData['currentObjective'] = Objective::find($_GET['objective_id']);
     } else {
         if (!empty($this->viewData['objectives'])) {
             $this->viewData['currentObjective'] = Objective::where('objectives.dimension_id', '=', !empty($this->viewData['currentDimension']) ? $this->viewData['currentDimension']->id : NULL)->where('objectives.status', 0)->orderBy('objectives.name')->get()->first();
         }
     }
     $this->viewData['currentObjectiveId'] = !empty($this->viewData['currentObjective']) ? $this->viewData['currentObjective']->id : '';
     $this->viewData['initiatives'] = Initiative::leftJoin('objectives', 'objectives.id', '=', 'initiatives.objective_id')->leftJoin('dimensions', 'dimensions.id', '=', 'objectives.dimension_id')->leftJoin('plans', 'plans.id', '=', 'dimensions.plan_id')->where('plans.user_id', '=', $this->viewData['user_id'])->where('initiatives.objective_id', '=', $this->viewData['currentObjectiveId'])->where('initiatives.status', 0)->orderBy('initiatives.name')->select('initiatives.*')->lists('initiatives.name', 'initiatives.id');
     $this->viewData['periods'] = array(1 => 'Yearly', 2 => 'Quaterly', 3 => 'Monthly');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $objectives = \App\Objective::where('lesson_date', date('Y-m-d'))->get();
     return view('display', ['objectives' => $objectives]);
 }