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'); } }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { if (Helpers::perm('admin', $id)) { $data['page_title'] = "Edit society"; $data['page_description'] = Helpers::getSetting('circuit_name') . " Circuit"; $data['society'] = Society::with('service')->find($id); $data['latitude'] = $data['society']->latitude; $data['longitude'] = $data['society']->longitude; $data['indivs'] = Individual::socindiv($data['society']->id)->get(); $data['groups'] = Group::where('society_id', '=', $data['society']->id)->orderBy('groupname')->get(); $data['rosters'] = Roster::where('society_id', '=', $data['society']->id)->orderBy('rostername')->get(); $data['provideropts'] = array('none' => '', 'bulksms' => 'Bulk SMS', 'smsfactory' => 'SMS Factory'); return View::make('societies.edit', $data); } else { return view('shared.unauthorised'); } }