public function postEvaluate(Request $request) { $data = $request->all(); $user_id = $data['user_id']; $evaluation = $data['evaluation']; $user = User::where("id", $user_id)->first(); $event = $this->currentEvent(); if ($evaluation == "false") { $user->delete(); } else { $user->standing = "active"; $user->save(); $position = $data['position']; if ($position == "Overall Activity Head") { $event->oah_id = $user_id; $event->save(); } elseif ($position == "Committee Head") { $comm_id = $data['comm_id']; $comm = Committee::where("event_id", $event->id)->where("id", $comm_id)->first(); $head = new Head(); $head->position = $comm->name . " Head"; $head->user_id = $user_id; $head->comm_id = $comm->id; $head->event_id = $event->id; $head->save(); } else { $member = new Member(); $member->user_id = $user_id; $member->comm_id = $comm_id; $member->save(); } } return redirect('/admin'); }
function postTask(Request $request) { $task = $request->all(); Task::create($task); $comm = Committee::where('id', $task['comm_id'])->first(); $evnt = Event::where('id', $comm['event_id'])->first(); //UPDATING WEIGHT OF COMMITTEE AND EVENT $comm->increment('weight', $task['weight']); $evnt->increment('weight', $task['weight']); //UPDATING PROGRESS OF COMMITTEE $progress = 0; $tasks = Task::where('comm_id', $comm->id)->get(); foreach ($tasks as $task1) { $progress += $task1->weight * $task1->progress; } $progress = $progress / $comm->weight; $comm->progress = $progress; $comm->save(); //UPDATING PROGRESS OF EVENT $progress2 = 0; $committees = Committee::all(); foreach ($committees as $committee) { if ($committee->event_id == $evnt->id) { $progress2 += $committee->weight * $committee->progress; } } $progress2 = $progress2 / $evnt->weight; $evnt->progress = $progress2; $evnt->save(); return redirect('profile'); }
public function getIndex() { $event = Event::latest('id')->first(); $user = \Auth::user(); $comm_name = Committee::where('event_id', $event->id)->get(); $comm_progress = Committee::where('event_id', $event->id)->get(array('progress'))->toArray(); if ($user->id == 1) { return redirect('/admin'); } if ($user->standing == 'unconfirmed') { return view('pages/oops', compact('user')); } $fin_status = FinancialStatus::latest('created_at')->first(); $tasks = Task::where('assigned_to', $user->id)->where('event_id', $event->id)->latest('deadline')->get(); if ($user == "") { return view('auth/login'); } $shouts = EventShout::where('event_id', $event->id)->latest('created_at')->get(); $heads = Head::where("event_id", $event->id)->get(); return view('pages/home', compact('user', 'event', 'shouts', 'heads', 'fin_status', 'tasks', 'comm_name', 'comm_progress')); }
public function run() { Member::create(['id' => '1', 'user_id' => User::where('lname', 'Macaraig')->first()->id, 'comm_id' => '7', 'event_id' => Committee::where('id', '7')->first()->event_id]); Member::create(['id' => '2', 'user_id' => User::where('lname', 'Fernandez')->first()->id, 'comm_id' => '8', 'event_id' => Committee::where('id', '8')->first()->event_id]); Member::create(['id' => '3', 'user_id' => User::where('lname', 'Cabarles')->first()->id, 'comm_id' => '8', 'event_id' => Committee::where('id', '8')->first()->event_id]); Member::create(['id' => '4', 'user_id' => User::where('lname', 'Bautista')->first()->id, 'comm_id' => '9', 'event_id' => Committee::where('id', '9')->first()->event_id]); Member::create(['id' => '5', 'user_id' => User::where('lname', 'Silvania')->first()->id, 'comm_id' => '10', 'event_id' => Committee::where('id', '10')->first()->event_id]); Member::create(['id' => '6', 'user_id' => User::where('lname', 'Cepe')->first()->id, 'comm_id' => '11', 'event_id' => Committee::where('id', '11')->first()->event_id]); Member::create(['id' => '7', 'user_id' => User::where('lname', 'Bawanan')->first()->id, 'comm_id' => '12', 'event_id' => Committee::where('id', '12')->first()->event_id]); Member::create(['id' => '8', 'user_id' => User::where('lname', 'Clemente')->first()->id, 'comm_id' => '12', 'event_id' => Committee::where('id', '12')->first()->event_id]); Member::create(['id' => '9', 'user_id' => User::where('lname', 'Caymo')->first()->id, 'comm_id' => '11', 'event_id' => Committee::where('id', '11')->first()->event_id]); Member::create(['id' => '10', 'user_id' => User::where('lname', 'Sibal')->first()->id, 'comm_id' => '10', 'event_id' => Committee::where('id', '10')->first()->event_id]); Member::create(['id' => '11', 'user_id' => User::where('lname', 'Rupa')->first()->id, 'comm_id' => '10', 'event_id' => Committee::where('id', '10')->first()->event_id]); Member::create(['id' => '12', 'user_id' => User::where('lname', 'Pastores')->first()->id, 'comm_id' => '10', 'event_id' => Committee::where('id', '10')->first()->event_id]); Member::create(['id' => '13', 'user_id' => User::where('lname', 'Ware')->first()->id, 'comm_id' => '12', 'event_id' => Committee::where('id', '12')->first()->event_id]); $this->call('FinancialStatusesTableSeeder'); }
protected function leagueData() { $committees = Committee::where('active', 1)->orderBy('name')->get(); $positions = Position::all(); $requirements = $this->currentYearBaseReqs(); $teams = Team::where('active', 1)->orderBy('name')->get(); $groups = Group::orderBy('name')->get(); $roles = Role::orderBy('name')->get(); return array('committees' => $committees, 'positions' => $positions, 'requirements' => $requirements, 'teams' => $teams, 'groups' => $groups, 'roles' => $roles); }
public function getId($id) { $users = User::all(); $user = $this->getUser(); $curr_event = Event::where('id', $id)->first(); $all_comm = Committee::all(); $committees = Committee::where('event_id', $curr_event->id)->get(); $comm_array = Committee::where('event_id', $curr_event->id)->get(array('id'))->toArray(); $events = Event::all(); $tasks = Task::where('assigned_to', $user['id'])->whereIn('comm_id', $comm_array)->get(); //tasks assigned to current user $all_tasks = Task::all(); $categories = array('Pending', 'In-progress', 'Delayed', 'Finished'); $comments = Comment::all(); //get current event id $curr_event_id = $curr_event->id; //check if current user is upper head //get all heads of current event $heads = Head::where('event_id', $curr_event_id)->where('user_id', $user->id)->get(); //get all comm_id(as array) in the current event where current user is a head $heads_comm = Head::where('event_id', $curr_event_id)->where('user_id', $user['id'])->get(array('comm_id'))->toArray(); //members of committee $mem = Member::whereIn('comm_id', $heads_comm)->get(array('user_id'))->toArray(); $members = User::whereIn('id', $mem)->get(); //get all committees in the current event where current user is a head $head_committees = Committee::whereIn('id', $heads_comm)->get(); //current user is a head $heads_comm = Head::where('user_id', $user['id'])->get(); //committees where current user is a member $mem_comm = Member::where('user_id', $user['id'])->get(); $url = "pages/profile"; //check if curret user is admin if ($user->id == 1) { return redirect('/admin/'); } //check if current user is OAH if ($curr_event->oah_id == $user->id) { $url = "pages/oah"; } //return heads page if user is lower head if ($heads != "[]") { $url = "pages/heads"; } if ($user->standing == "unconfirmed") { $url = "pages/oops"; } echo $url; return view($url, compact('users', 'user', 'events', 'curr_event', 'all_comm', 'committees', 'tasks', 'all_tasks', 'categories', 'comments', 'head_committees', 'heads_comm', 'mem_comm', 'members')); }