/** * Returns a view that displays the user creation form. * * @author [A. Gianotto] [<*****@*****.**>] * @since [v1.0] * @return View */ public function getCreate() { $groups = Group::pluck('name', 'id'); if (Input::old('groups')) { $userGroups = Group::whereIn('id', Input::old('groups'))->pluck('name', 'id'); } else { $userGroups = collect(); } $permissions = config('permissions'); $userPermissions = Helper::selectedPermissionsArray($permissions, Input::old('permissions', array())); $location_list = Helper::locationsList(); $manager_list = Helper::managerList(); $company_list = Helper::companyList(); return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))->with('location_list', $location_list)->with('manager_list', $manager_list)->with('company_list', $company_list)->with('user', new User()); }
public function details($society, $id, $year, $month) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $data['society'] = $society; $data['roster'] = Roster::with('group')->find($id); $extrainfo = explode(",", $data['roster']->extrainfo); $data['extragroups'] = Group::whereIn('id', $extrainfo)->get(); $data['multigroups'] = explode(",", $data['roster']->multichoice); $subcat = explode(",", $data['roster']->subcategories); if ($subcat[0] != "") { $subcat[] = "#!@"; foreach ($data['roster']->group as $thisgroup) { $shortened = false; foreach ($subcat as $thisubcat) { if (strpos($thisgroup->groupname, $thisubcat)) { $key = trim(str_replace($thisubcat, "", $thisgroup->groupname)); $shortgroups[$key][$thisubcat] = $thisgroup->id; $shortened = true; } } if (!$shortened) { $key = trim($thisgroup->groupname); $shortgroups["_" . $key]['#!@'] = $thisgroup->id; } } } else { foreach ($data['roster']->group as $thisgroup) { $shortgroups[$thisgroup->groupname]['#!@'] = $thisgroup->id; } $subcat[0] = "#!@"; } ksort($shortgroups); $firstinmonth = $data['roster']->dayofweek - date_format(date_create($year . "-" . $month . '-01'), 'N') + 1; if ($firstinmonth > 7) { $firstinmonth = $firstinmonth - 7; } elseif ($firstinmonth < 1) { $firstinmonth = $firstinmonth + 7; } $dates[] = date_format(date_create($year . "-" . $month . '-' . $firstinmonth), 'Y-m-d'); for ($i = 1; $i < 5; $i++) { $testdate = strtotime('+1 week', strtotime($dates[$i - 1])); if (date("m", $testdate) == $month) { $dates[] = date("Y-m-d", $testdate); } else { break; } } $selnum = array('1', '2'); foreach ($dates as $tdate) { foreach ($shortgroups as $skey => $sgrp) { foreach ($subcat as $thiscat) { foreach ($selnum as $seln) { if (array_key_exists($thiscat, $sgrp)) { $individ = DB::table('group_individual_roster')->where('rosterdate', '=', $tdate)->where('roster_id', '=', $id)->where('group_id', '=', $sgrp[$thiscat])->where('selection', '=', $seln)->get(); $data['weeks'][$tdate][$thiscat][$skey][$seln]['group_id'] = $sgrp[$thiscat]; if (isset($individ[0]->individual_id)) { $data['weeks'][$tdate][$thiscat][$skey][$seln]['individual_id'] = $individ[0]->individual_id; } } } } } } $data['groupheadings'] = array_keys($shortgroups); $data['rosterdetails'] = Roster::with('rosterdetails_group', 'rosterdetails_individual')->find($id); foreach ($data['roster']->group as $grp) { $data['groupmembers'][$grp->id][0] = ""; foreach ($grp->individual as $ind) { $data['groupmembers'][$grp->id][$ind->id] = $ind->firstname . " " . $ind->surname; } } $data['rosteryear'] = $year; $data['socname'] = Society::find($society)->society; $data['rostermonth'] = $month; $data['months'] = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); return View::make('rosters.details', $data); } else { return view('shared.unauthorised'); } }