Example #1
0
 public function saveTrackerEntry(Request $request)
 {
     // return $request->all();
     $validator = Validator::make($request->all(), ['desc' => 'required|min:5', 'time' => 'required|numeric', 'tags' => 'required', 'project_id' => 'required']);
     if ($request->input('project_id') == 'Select Project') {
         Session::flash('flash_error', 'You need to select the project');
         return redirect()->back()->withInput();
     }
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     try {
         DB::beginTransaction();
         $project = Project::with('client')->find($request->input('project_id'));
         $entry = TimeEntry::create(['desc' => $request->input('desc'), 'user_id' => Auth::user()->id, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $request->input('time')]);
         // adding the entry of the ticket with tags mapping table
         foreach ($request->input('tags') as $key => $value) {
             DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entry->id, 'taggable_type' => 'ticket', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
         }
         if ($request->input('estimate_id')) {
             DB::table('time_entry_estimates')->insert(['time_entry_id' => $entry->id, 'estimate_id' => $request->input('estimate_id'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
             DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $request->input('time'), 'id' => $request->input('estimate_id')]);
         }
         DB::commit();
         Session::flash('flash_message', 'Entry saved');
         return redirect('time-tracker');
     } catch (\PDOException $e) {
         DB::rollBack();
         abort(403, 'Data was not saved. Try again' . $e->getMessage());
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Project::with(['positions' => function ($query) {
         $query->with(['targets' => function ($query) {
             $query->withTrashed()->orderBy('created_at', 'desc');
         }]);
     }])->where('id', $id)->first();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $name = Input::get('name');
     $query = Project::with('photos', 'users');
     if ($name != null) {
         $query->where('name', 'LIKE', "%{$name}%");
     }
     $projects = $query->paginate(10);
     return Response::json($projects->all());
 }
 /**
  * @param $id
  * @param bool $withOrganizations
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withRelations = [])
 {
     if (!empty($withRelations)) {
         $relations = implode(',', $withRelations);
         $project = Project::with($relations)->find($id);
     } else {
         $project = Project::find($id);
     }
     if (!is_null($project)) {
         return $project;
     }
     throw new GeneralException('That project does not exist.');
 }
 /**
  * @param $id
  * @param bool $withOrganizations
  * @return mixed
  * @throws GeneralException
  */
 public function findOrThrowException($id, $withOrganization = false, $withQuestions = false)
 {
     if ($withOrganization && $withQuestions) {
         $project = Project::with('organization', 'questions')->find($id);
     } elseif ($withQuestions) {
         $project = Project::with('questions')->find($id);
     } elseif ($withOrganization) {
         $project = Project::with('organization')->find($id);
     } else {
         $project = Project::find($id);
     }
     if (!is_null($project)) {
         return $project;
     }
     throw new GeneralException('That project does not exist.');
 }
 /**
  * @param string $locale
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index($locale = "nl")
 {
     $projects = Project::with(["descriptions", "tasks"]);
     $projects = $projects->get();
     foreach ($projects as $project) {
         $progress = 0;
         if (!$project->is_done) {
             foreach ($project->tasks as $task) {
                 $progress += $task->progress;
             }
             $precentage = 0;
             if (count($project->tasks) != 0) {
                 $precentage = $progress / count($project->tasks);
             }
             $project->progress = round($precentage, 1);
         }
     }
     return view("portfolio.index", ["projects" => $projects]);
 }
 public function backdateTimeEntry($otp, $userId)
 {
     $projects = Project::with('client')->get();
     $tags = Tag::all();
     $otp = DB::table('backdate_timeentry')->where('otp', $otp)->where('user_id', $userId)->where('status', 1)->first();
     if (!$otp) {
         abort(403, 'Wrong url');
     }
     return view('manager.backdate-form', compact('projects', 'tags', 'otp'));
 }
Example #8
0
 /**
  * Display the specified resource.
  * @param  int $id
  * @param RevenueVsCost $revenue_vs_cost
  * @return Response
  */
 public function show($id, RevenueVsCost $revenue_vs_cost)
 {
     $project = Project::with(['revenues', 'costs', 'costs.staff'])->findOrFail($id);
     $performance = $revenue_vs_cost->get(['project_id' => $id], ['month_logged']);
     return view('project.show', compact('project', 'performance'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Project::with('categories', 'project_images', 'agents', 'project_parts')->findOrFail($id)->toArray();
 }
Example #10
0
 public function getProjectsManagement()
 {
     $projects = Project::with('images')->get();
     return view('admin_projects', ['projects' => $projects]);
 }
 /**
  * Helper function to Save timeEntry
  *
  * @return mixed
  */
 public function saveTimesheet($postdata)
 {
     try {
         $output = array();
         //            \Log::info(print_r($postdata, true));
         DB::beginTransaction();
         $project = Project::with('client')->find($postdata['project_id']);
         // if the user id is set, it means it's a backdate entry
         $createdAt = Carbon::now();
         $updatedAt = Carbon::now();
         $userId = 0;
         if ($postdata['uid']) {
             $userId = $postdata['uid'];
             $timestamp = $postdata['start_time'] / 1000;
             $createdAt = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
             $updatedAt = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
         }
         $entryId = DB::table('time_entries')->insertGetId(['desc' => $postdata['desc'], 'user_id' => $userId, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $postdata['total_time'], 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
         $tagsArr = explode(',', $postdata['tags']);
         // adding the entry of the ticket with tags mapping table
         foreach ($tagsArr as $key => $value) {
             DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entryId, 'taggable_type' => 'ticket', 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
         }
         $output = array('id' => $entryId, 'uid' => $userId, 'desc' => $postdata['desc'], 'project_id' => $postdata['project_id'], 'project' => $project->name, 'total_time' => $postdata['total_time'], 'start_time' => $postdata['start_time'], 'end_time' => $postdata['end_time'], 'tags' => $postdata['tags'], 'client_name' => $project->client->name);
         if (isset($postdata['estimate_id']) && $postdata['estimate_id'] != 0) {
             DB::table('time_entry_estimates')->insert(['time_entry_id' => $entryId, 'estimate_id' => $postdata['estimate_id'], 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
             DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $postdata['total_time'], 'id' => $postdata['estimate_id']]);
         }
         $output['estimate_id'] = $postdata['estimate_id'];
         DB::commit();
         return response($output, 201);
     } catch (\PDOException $e) {
         DB::rollBack();
         abort(403, 'Data was not saved. Try again' . $e->getMessage());
     }
 }
Example #12
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $projects = Project::with('client')->get();
     return view('projects.index', compact('projects'));
 }
 public function monthly()
 {
     $this->date_start = new Carbon('first Monday of this month');
     $this->date_end = new Carbon('last Monday of this month');
     $projects = Project::with('positions')->get();
     foreach ($projects as $project_key => $project) {
         $project->first_report = Report::where('project_id', $project->id)->whereBetween('date_start', [$this->date_start, $this->date_end])->first();
         if ($project->first_report) {
             $project->date_start = $this->date_start->toFormattedDateString();
             $project->date_end = $this->date_end->toFormattedDateString();
             $project->members = Experience::with(['member' => function ($query) {
                 $query->withTrashed();
             }])->where('project_id', $project->id)->get();
             $project->beginner_total_output = 0;
             $project->beginner_total_hours_worked = 0;
             $project->beginner_total_average_output = 0;
             $project->moderately_experienced_total_output = 0;
             $project->moderately_experienced_total_hours_worked = 0;
             $project->moderately_experienced_total_average_output = 0;
             $project->experienced_total_output = 0;
             $project->experienced_total_hours_worked = 0;
             $project->experienced_total_average_output = 0;
             foreach ($project->positions as $position_key => $position) {
                 $position->beginner = 0;
                 $position->moderately_experienced = 0;
                 $position->experienced = 0;
                 $position->beginner_total_output = 0;
                 $position->beginner_total_hours_worked = 0;
                 $position->beginner_total_average_output = 0;
                 $position->moderately_experienced_total_output = 0;
                 $position->moderately_experienced_total_hours_worked = 0;
                 $position->moderately_experienced_total_average_output = 0;
                 $position->experienced_total_output = 0;
                 $position->experienced_total_hours_worked = 0;
                 $position->experienced_total_average_output = 0;
             }
             foreach ($project->members as $member_key => $member) {
                 $member->positions = $project->positions;
                 $member->roles = 0;
                 $overall_monthly_productivity = 0;
                 $overall_monthly_quality = 0;
                 $overall_count = 0;
                 foreach ($member->positions as $position_key => $position) {
                     $performances = Performance::with('project', 'position')->with(['target' => function ($query) {
                         $query->withTrashed();
                     }])->with(['member' => function ($query) {
                         $query->withTrashed()->with(['experiences' => function ($query) {
                             $query->with('project');
                         }]);
                     }])->where('daily_work_hours', 'like', $project->first_report->daily_work_hours . '%')->where('position_id', $position->id)->where('member_id', $member->member_id)->whereBetween('date_start', [$this->date_start, $this->date_end])->get();
                     if (count($performances)) {
                         $member->roles++;
                         $position->total_hours_worked = 0;
                         $position->total_output = 0;
                         $position->total_output_error = 0;
                         $position->total_average_output = 0;
                         $position->monthly_productivity = 0;
                         $position->monthly_quality = 0;
                         foreach ($performances as $performance_key => $performance) {
                             $position->total_hours_worked += $performance->hours_worked;
                             $position->total_output += $performance->output;
                             $position->total_output_error += $performance->output_error;
                             if ($performance->target->experience == 'Beginner') {
                                 if ($performance_key === 0) {
                                     $project->positions[$position_key]->beginner += 1;
                                 }
                                 $project->positions[$position_key]->beginner_total_output += $performance->output;
                                 $project->positions[$position_key]->beginner_total_hours_worked += $performance->hours_worked;
                             } else {
                                 if ($performance->target->experience == 'Moderately Experienced') {
                                     if ($performance_key === 0) {
                                         $project->positions[$position_key]->moderately_experienced += 1;
                                     }
                                     $project->positions[$position_key]->moderately_experienced_total_output += $performance->output;
                                     $project->positions[$position_key]->moderately_experienced_total_hours_worked += $performance->hours_worked;
                                 } else {
                                     if ($performance->target->experience == 'Experienced') {
                                         if ($performance_key === 0) {
                                             $project->positions[$position_key]->experienced += 1;
                                         }
                                         $project->positions[$position_key]->experienced_total_output += $performance->output;
                                         $project->positions[$position_key]->experienced_total_hours_worked += $performance->hours_worked;
                                     }
                                 }
                             }
                         }
                         $project->positions[$position_key]->head_count = $project->positions[$position_key]->beginner + $project->positions[$position_key]->moderately_experienced + $project->positions[$position_key]->experienced;
                         $position->total_average_output = round($position->total_output / $position->total_hours_worked * $performances[0]->daily_work_hours, 2);
                         $position->monthly_productivity = round($position->total_average_output / $performances[0]->target->productivity * 100, 2);
                         $position->monthly_quality = round((1 - $position->total_output_error / $position->total_output) * 100, 2);
                         if ($position->monthly_productivity < 100 && $position->monthly_quality >= $performances[0]->target->quality) {
                             $position->quadrant = 'Quadrant 1';
                         } else {
                             if ($position->monthly_productivity >= 100 && $position->monthly_quality >= $performances[0]->target->quality) {
                                 $position->quadrant = 'Quadrant 2';
                             } else {
                                 if ($position->monthly_productivity >= 100 && $position->monthly_quality < $performances[0]->target->quality) {
                                     $position->quadrant = 'Quadrant 3';
                                 } else {
                                     if ($position->monthly_productivity < 100 && $position->monthly_quality < $performances[0]->target->quality) {
                                         $position->quadrant = 'Quadrant 4';
                                     }
                                 }
                             }
                         }
                         $overall_monthly_productivity += $position->monthly_productivity;
                         $overall_monthly_quality += $position->monthly_quality;
                         $overall_count++;
                     }
                 }
                 if ($overall_count) {
                     $member->average_productivity = $overall_monthly_productivity / $overall_count;
                     $member->average_quality = $overall_monthly_quality / $overall_count;
                 }
             }
             foreach ($project->positions as $position_key => $position) {
                 $position->beginner_total_average_output = $position->beginner_total_hours_worked ? round($position->beginner_total_output / $position->beginner_total_hours_worked * $project->first_report->daily_work_hours, 2) : 0;
                 $position->moderately_experienced_total_average_output = $position->moderately_experienced_total_hours_worked ? round($position->moderately_experienced_total_output / $position->moderately_experienced_total_hours_worked * $project->first_report->daily_work_hours, 2) : 0;
                 $position->experienced_total_average_output = $position->experienced_total_hours_worked ? round($position->experienced_total_output / $position->experienced_total_hours_worked * $project->first_report->daily_work_hours, 2) : 0;
                 $project->beginner_total_output += $position->beginner_total_output;
                 $project->beginner_total_hours_worked += $position->beginner_total_hours_worked;
                 $project->moderately_experienced_total_output += $position->moderately_experienced_total_output;
                 $project->moderately_experienced_total_hours_worked += $position->moderately_experienced_total_hours_worked;
                 $project->experienced_total_output += $position->experienced_total_output;
                 $project->experienced_total_hours_worked += $position->experienced_total_hours_worked;
             }
             $project->beginner_total_average_output = $project->beginner_total_hours_worked ? round($project->beginner_total_output / $project->beginner_total_hours_worked * $project->first_report->daily_work_hours, 2) : 0;
             $project->moderately_experienced_total_average_output = $project->moderately_experienced_total_hours_worked ? round($project->moderately_experienced_total_output / $project->moderately_experienced_total_hours_worked * $project->first_report->daily_work_hours, 2) : 0;
             $project->experienced_total_average_output = $project->experienced_total_hours_worked ? round($project->experienced_total_output / $project->experienced_total_hours_worked * $project->first_report->daily_work_hours, 2) : 0;
             $project->total_output = $project->beginner_total_output + $project->moderately_experienced_total_output + $project->experienced_total_output;
             $project->total_hours_worked = $project->beginner_total_hours_worked + $project->moderately_experienced_total_hours_worked + $project->experienced_total_hours_worked;
             $project->total_average_output = round($project->total_output / $project->total_hours_worked * $project->first_report->daily_work_hours, 2);
         }
     }
     return $projects;
 }
Example #14
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $projects = Project::with('company', 'step')->get();
     return view('project.index', compact('projects'));
 }
Example #15
0
 /**
  * Invoice
  */
 public function invoice($id)
 {
     $project = Project::with(['tasks' => function ($query) {
         $query->whereNotNull('closed_at')->orderBy('closed_at');
     }])->find($id);
     return PDF::loadView('project.invoice', compact('project'))->stream();
     //->download(Str::slug($project->name) . '.pdf');
 }
Example #16
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $project = Project::with('lists.topics')->findOrFail($id);
     return $project;
 }
Example #17
0
 /**
  * Get the list of projects in the system with client and estimate data
  *
  * @return mixed
  */
 public function getProjectList()
 {
     return Project::with('client')->with('estimates')->orderBy('name')->get();
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $estimates = Estimate::where('project_id', $id)->with('project')->orderBy('created_at', 'desc')->paginate(20);
     $project = Project::with('client')->with('estimates')->find($id);
     return view('project.show', compact('project', 'estimates'));
 }