public function dashboard() { $user = Auth::user(); $recent = Change::where('user_id', $user->id)->get(); $tasks = $user->goats()->orderBy('due_date')->get(); $dept = $user->departments()->get(); $recentEmpty = true; $tasksEmpty = true; foreach ($tasks as $task) { if (!$task->complete) { $tasksEmpty = false; } // if (Carbon\Carbon::parse($task->due_date)->diff(Carbon\Carbon::now())){ // $task->soon = 'red'; // } // else{ // $task->soon = ''; // } } //redo controller $inProgress = $user->goats()->where('complete', '0')->count(); $complete = $user->goats()->where('complete', '1')->count(); $overdue = 0; foreach ($tasks as $task) { if (Carbon\Carbon::parse($task->due_date)->lt(Carbon\Carbon::now())) { $overdue++; } } $inProgress -= $overdue; foreach ($recent as $task) { $recentEmpty = false; $task->task = Goat::where('id', $task->goat_id)->value('description'); } return view('dashboard', compact('user', 'tasks', 'dept', 'recent', 'recentEmpty', 'tasksEmpty', 'complete', 'inProgress', 'overdue')); }
public function forms() { $exitPass = ExitPass::where('status', '!=', 3)->get(); $leaveForm = Leaves::where('status', '!=', 3)->get(); $changeSchedule = Change::where('status', '!=', 3)->get(); $oas = Overtime::where('status', '!=', 3)->get(); return count($exitPass) + count($leaveForm) + count($changeSchedule) + count($oas); }
public function __construct() { /*Licznik zmian, który zmienia się po 24h od dodania zmiany*/ $date = Carbon::now(); $date->modify('-24 hours'); $formatted_date = $date->format('Y-m-d H:i:s'); $countchange = Change::where('created_at', '>', $formatted_date)->count(); /*Licznik graczy Online na serwerze*/ $countonline = Player::where('online', '=', 1)->count(); /*Licznik niedoczytanych wiadomości prywatnych*/ $notread1 = Message::where('to_user_id', \Auth::id())->where('read', 0)->count(); if (\Auth::check()) { Cache::remember('users', 5, function () { return User::where('id', \Auth::id())->update(['last_activity' => Carbon::now()]); }); } /*Licznik i skrypt usuwający i nadający banicję za 4 ostrzeżenia na stronie*/ $countcautions = Caution::where('user_id', \Auth::id())->count(); if (!\Auth::guest() && $countcautions == 4) { $user = User::where('id', \Auth::id())->first(); $g = array(4); $user->update(['banned' => 'Zbanowany za 4 ostrzeżenia na stronie']); $user->group()->sync($g); } $deleteCaution = Caution::where('user_id', \Auth::id())->where('created_at', '<=', Carbon::now()->subDays(14)); $deleteCaution->delete(); $section = Section::lists('name', 'id'); $lives = Live::latest('created_at')->take(5)->get(); if (!\Auth::guest()) { $notifications = \Auth::user()->notification()->latest('created_at')->take(10)->get(); View::share('notifications', $notifications); } View::share('countchange', $countchange); View::share('countonline', $countonline); View::share('notread1', $notread1); View::share('section', $section); View::share('lives', $lives); $this->middleware('banned', ['except' => ['auth']]); }
public function show($id) { $changes = Change::where('goat_id', $id)->get(); $task = Goat::where('id', $id)->first(); $leads = $task->userLeads()->get(); $collabs = $task->userCollaborators()->get(); $leadsArray = array(); $collabsArray = array(); foreach ($leads as $lead) { array_push($leadsArray, join(" ", array($lead->first_name, $lead->last_name))); } foreach ($collabs as $collab) { array_push($collabsArray, join(" ", array($collab->first_name, $collab->last_name))); } $needsResize = false; if (sizeof($changes) > 4) { $needsResize = true; } $empty = true; foreach ($changes as $change) { $empty = false; $change->fname = User::where('id', $change->user_id)->value('first_name'); $change->lname = User::where('id', $change->user_id)->value('last_name'); } // dd(Carbon\Carbon::parse($task->due_date)); $message = false; if (Carbon\Carbon::parse($task->due_date)->lt(Carbon\Carbon::now())) { $message = array('#b30000', 'Overdue'); } if ($task->complete) { $message = array('#669966', 'Complete'); } $leads = join(", ", $leadsArray); $collabs = join(", ", $collabsArray); $priority = array("High", "Medium", "Low"); $fields = array(array('Action', $task->description), array('Due Date', $task->due_date), array('Lead', $leads), array('Collaborators', $collabs), array('Status', 'In Progress'), array('Priority', $priority[$task->priority - 1])); return view('edit', compact('fields', 'changes', 'needsResize', 'empty', 'task', 'message')); }
public function editChange(array $data, $id) { $dateFromShift = strtotime($data['dateFromShift']); $dateToShift = strtotime($data['dateToShift']); $dateToday = strtotime(date("Y-m-d")); if ($dateFromShift > $dateToday) { if ($dateToShift < $dateFromShift) { return false; } else { return Change::where('id', $id)->update(array('shift_id' => $data['shiftSchedule'], 'dateFromShift' => $data['dateFromShift'], 'dateToShift' => $data['dateToShift'], 'permission_id1' => $data['supervisor'], 'permission_id2' => $data['projectManager'], 'permission_id3' => $data['permissioner'], 'permission_id4' => $data['HR'], 'purpose' => $data['reasonforChangeSchedule'])); } } else { return false; } }
public function editChange(array $data, $id) { $dateUpdate = date("Y-m-d H:i:s"); $change = Change::where('id', $id)->update(array('permission_id1' => $data['supervisor'], 'permission_id2' => $data['projectManager'], 'permission_id3' => $data['permissioner'], 'permission_id4' => $data['HR'], 'purpose' => $data['reasonforChangeSchedule'], 'updated_at' => $dateUpdate)); if ($change) { return DateTimeChange::where('change_id', $id)->update(array('dateFromEffectivity' => $data['dateFromEffectivity'], 'timeFromEffectivity' => $data['timeFromEffectivity'], 'dateToEffectivity' => $data['dateToEffectivity'], 'timeToEffectivity' => $data['timeToEffectivity'], 'dateFromShift' => $data['dateFromShift'], 'timeFromShift' => $data['timeFromShift'], 'dateToShift' => $data['dateToShift'], 'timeToShift' => $data['timeToShift'], 'updated_at' => $dateUpdate)); } else { return false; } }