Exemplo n.º 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     if (in_array(Auth::user()->individual_id, explode(',', Helpers::getSetting('site_editors')))) {
         $data['societies'] = Society::orderBy('society')->get();
         return view('meetings.create', $data);
     } else {
         return view("shared.unauthorised");
     }
 }
Exemplo n.º 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     if (in_array(Auth::user()->individual_id, explode(',', Helpers::getSetting('site_editors')))) {
         $data['minister'] = Minister::findOrFail($id);
         $data['societies'] = $data['minister']->societies;
         $data['individuals'] = Individual::orderBy('surname')->orderBy('firstname')->get();
         $data['allsocieties'] = Society::orderBy('society')->get();
         return View::make('ministers.edit', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
Exemplo n.º 3
0
 public function circuit($society)
 {
     $data['soc'] = $society;
     $data['pagetitle'] = Helpers::getSetting('circuit_name') . " Circuit";
     $cministers = Minister::with('individual')->get();
     if (Helpers::is_online() and Helpers::getSetting('circuit_calendar') != "") {
         $privatecal = new GoogleCalendar();
         $data['cals'] = $privatecal->getTen(Helpers::getSetting('circuit_calendar'), 8);
     }
     foreach ($cministers as $cm) {
         $dum['name'] = "<strong>" . $cm->individual->title . " " . $cm->individual->firstname . " " . $cm->individual->surname . "</strong>";
         $dum['contact'] = $cm->individual->cellphone;
         if ($cm->individual->id == Helpers::getSetting('superintendent')) {
             $dum['contact'] = "(Superintendent Minister)<br>" . $dum['contact'];
         }
         $dum['sort'] = $cm->individual->surname . $cm->individual->firstname;
         $dum['bio'] = $cm->individual->notes;
         $dum['photo'] = $cm->individual->photo;
         $dum['slug'] = $cm->individual->slug;
         $socs = Society::wherein('id', explode(',', $cm->societies))->get();
         $societies = "";
         foreach ($socs as $soc) {
             $societies .= "<a href=\"" . Helpers::makeUrl(strtolower($soc->society), '') . "\">" . $soc->society . "</a>, ";
         }
         $dum['societies'] = substr($societies, 0, -2);
         $data['ministers'][$dum['sort']] = $dum;
     }
     ksort($data['ministers']);
     $data['allsocieties'] = Society::orderBy('society')->get();
     if (count($data['allsocieties'])) {
         foreach ($data['allsocieties'] as $obj) {
             $dum1[0] = $obj->society;
             $dum1[1] = $obj->latitude;
             $dum1[2] = $obj->longitude;
             $dum1[3] = Helpers::makeUrl(strtolower($obj->society), '');
             $fin[] = $dum1;
         }
         $data['fin'] = json_encode($fin);
     } else {
         $data['fin'] = "";
     }
     $data['stewards'] = Individual::wherein('id', explode(',', Helpers::getSetting('circuit_stewards')))->get();
     $data['secretary'] = Individual::find(Helpers::getSetting('circuit_secretary'));
     $data['treasurer'] = Individual::find(Helpers::getSetting('treasurer'));
     return view('societies.circuit', $data);
 }
Exemplo n.º 4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($id)
 {
     if (Auth::user()->admin) {
         $data['user'] = User::find($id);
         $socs = Society::orderBy('society')->get();
         $curids = Permission::where('user_id', '=', $id)->select('society_id')->get()->toArray();
         $data['societies'][0] = "";
         foreach ($socs as $soc) {
             if (!in_array($soc->id, array_flatten($curids))) {
                 $data['societies'][$soc->id] = $soc->society;
             }
         }
         $data['permissions'] = Permission::where('user_id', '=', $id)->get();
         return View::make('permissions.index', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
Exemplo n.º 5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($yy, $qq, $aa)
 {
     $fin = array();
     $fm = Helpers::getSetting('first_month');
     $m1 = $qq * 3 - 3 + $fm;
     $y1 = $yy;
     $m2 = $qq * 3 - 2 + $fm;
     $y2 = $yy;
     $m3 = $qq * 3 - 1 + $fm;
     $y3 = $yy;
     if ($m2 > 12) {
         $m2 = $m2 - 12;
         $y2 = $y2 + 1;
     }
     if ($m3 > 12) {
         $m3 = $m3 - 12;
         $y3 = $y3 + 1;
     }
     if ($aa == "edit") {
         $perms = Permission::where('user_id', '=', Auth::user()->id)->get();
         foreach ($perms as $perm) {
             if ($perm->preaching or $perm->admin) {
                 $data['authsoc'][] = $perm['society_id'];
             }
         }
         if (!isset($data['authsoc'])) {
             $aa = "view";
         }
     }
     $firstDateTime = mktime(0, 0, 0, $m1, 1, $y1);
     $firstDay = date("N", $firstDateTime);
     $firstSunday = date("d M Y", mktime(0, 0, 0, $m1, 8 - $firstDay, $y1));
     $lastSunday = strtotime($firstSunday);
     $lastDay = mktime(23, 59, 59, $m3, cal_days_in_month(CAL_GREGORIAN, $m3, $y3), $y3);
     $extras = Weekday::where('servicedate', '>=', $firstDateTime)->where('servicedate', '<=', $lastDay)->orderBy('servicedate')->get()->toArray();
     $data['meetings'] = Meeting::where('meetingdatetime', '<', $lastDay)->where('meetingdatetime', '>', $firstDateTime)->orderBy('meetingdatetime')->get();
     $dum['dt'] = $lastSunday;
     $dum['yy'] = intval(date("Y", $lastSunday));
     $dum['mm'] = intval(date("n", $lastSunday));
     $dum['dd'] = intval(date("j", $lastSunday));
     $sundays[] = $dum;
     $data['societies'] = Society::orderBy('society')->with('service')->get();
     $data['ministers'] = Minister::has('individual')->get();
     $data['preachers'] = Preacher::has('individual')->get();
     $data['guests'] = Guest::where('active', '=', 1)->get();
     while (date($lastSunday + 604800 <= $lastDay)) {
         $lastSunday = $lastSunday + 604800;
         $dum['dt'] = $lastSunday;
         $dum['yy'] = intval(date("Y", $lastSunday));
         $dum['mm'] = intval(date("n", $lastSunday));
         $dum['dd'] = intval(date("j", $lastSunday));
         $sundays[] = $dum;
     }
     if (count($extras)) {
         $xco = 0;
         for ($q = 0; $q < count($sundays); $q++) {
             if ($xco < count($extras) and $extras[$xco]['servicedate'] < $sundays[$q]['dt']) {
                 $dum['dt'] = $extras[$xco]['servicedate'];
                 $dum['yy'] = intval(date("Y", $extras[$xco]['servicedate']));
                 $dum['mm'] = intval(date("n", $extras[$xco]['servicedate']));
                 $dum['dd'] = intval(date("j", $extras[$xco]['servicedate']));
                 $data['sundays'][] = $dum;
                 $xco++;
                 $q = $q - 1;
             } else {
                 $data['sundays'][] = $sundays[$q];
             }
         }
     } else {
         $data['sundays'] = $sundays;
     }
     $pm1 = Plan::where('planyear', '=', $y1)->where('planmonth', '=', $m1)->get();
     foreach ($pm1 as $p1) {
         $soc = Society::find($p1->society_id)->society;
         $ser = Service::find($p1->service_id)->servicetime;
         if ($p1->preachable) {
             @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['preacher'] = substr($p1->preachable_type, 11, 1) . "_" . $p1->preachable->id);
             if ($p1->preachable_type == "App\\Models\\Guest") {
                 @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['pname'] = substr($p1->preachable->firstname, 0, 1) . " " . $p1->preachable->surname);
             } else {
                 @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['pname'] = substr($p1->preachable->individual->firstname, 0, 1) . " " . $p1->preachable->individual->surname);
             }
         } else {
             @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['preacher'] = "");
         }
         if ($p1->tag_id) {
             @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tag'] = $p1->tag_id);
             @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tname'] = Tag::find($p1->tag_id)->abbr);
         } else {
             @($data['fin'][$soc][$p1->planyear][$p1->planmonth][$p1->planday][$ser]['tag'] = "");
         }
     }
     $pm2 = Plan::where('planyear', '=', $y2)->where('planmonth', '=', $m2)->get();
     foreach ($pm2 as $p2) {
         $soc = Society::find($p2->society_id)->society;
         $ser = Service::find($p2->service_id)->servicetime;
         if ($p2->preachable) {
             @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['preacher'] = substr($p2->preachable_type, 11, 1) . "_" . $p2->preachable->id);
             if ($p2->preachable_type == "App\\Models\\Guest") {
                 @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['pname'] = substr($p2->preachable->firstname, 0, 1) . " " . $p2->preachable->surname);
             } else {
                 @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['pname'] = substr($p2->preachable->individual->firstname, 0, 1) . " " . $p2->preachable->individual->surname);
             }
         } else {
             @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['preacher'] = "");
         }
         if ($p2->tag_id) {
             @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tag'] = $p2->tag_id);
             @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tname'] = Tag::find($p2->tag_id)->abbr);
         } else {
             @($data['fin'][$soc][$p2->planyear][$p2->planmonth][$p2->planday][$ser]['tag'] = "");
         }
     }
     $pm3 = Plan::where('planyear', '=', $y3)->where('planmonth', '=', $m3)->get();
     foreach ($pm3 as $p3) {
         $soc = Society::find($p3->society_id)->society;
         $ser = Service::find($p3->service_id)->servicetime;
         if ($p3->preachable) {
             @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['preacher'] = substr($p3->preachable_type, 11, 1) . "_" . $p3->preachable->id);
             if ($p3->preachable_type == "App\\Models\\Guest") {
                 @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['pname'] = substr($p3->preachable->firstname, 0, 1) . " " . $p3->preachable->surname);
             } else {
                 @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['pname'] = substr($p3->preachable->individual->firstname, 0, 1) . " " . $p3->preachable->individual->surname);
             }
         } else {
             @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['preacher'] = "");
         }
         if ($p3->tag_id) {
             @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tag'] = $p3->tag_id);
             @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tname'] = Tag::find($p3->tag_id)->abbr);
         } else {
             @($data['fin'][$soc][$p3->planyear][$p3->planmonth][$p3->planday][$ser]['tag'] = "");
         }
     }
     $data['tags'] = Tag::orderBy('abbr')->get();
     if ($qq == 1) {
         $data['prev'] = "plan/" . strval($yy - 1) . "/4";
     } else {
         $data['prev'] = "plan/{$yy}/" . strval($qq - 1);
     }
     if ($qq == 4) {
         $data['next'] = "plan/" . strval($yy + 1) . "/1";
     } else {
         $data['next'] = "plan/{$yy}/" . strval($qq + 1);
     }
     if ($aa == "edit") {
         return View::make('plans.edit', $data);
     } else {
         $data['pb'] = Helpers::getSetting('presiding_bishop');
         if (!$data['pb']) {
             return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the Presiding Bishop');
         }
         $data['gs'] = Helpers::getSetting('general_secretary');
         if (!$data['gs']) {
             return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the General Secretary');
         }
         $data['db'] = Helpers::getSetting('district_bishop');
         if (!$data['db']) {
             return view('errors.errors')->with('errormessage', 'Before you can view the plan, please enter the name of the District Bishop');
         }
         $data['super'] = Individual::find(Helpers::getSetting('superintendent'));
         if (!$data['super']) {
             return view('errors.errors')->with('errormessage', 'Before you can view the plan, please specify who the Circuit Superintendent is');
         }
         $this->report($data);
     }
 }
Exemplo n.º 6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['household'] = Household::with('individual')->find($id);
         $data['sortsurname'] = $data['household']->sortsurname;
         if (!$data['household']['longitude'] and !$data['household']['latitude']) {
             $address = $data['household']['addr1'] . ", " . $data['household']['addr2'] . ", " . $data['household']['addr3'];
             $coords = Geocoder::getCoordinatesForQuery($address);
             if ($coords['accuracy'] != "NOT FOUND") {
                 $data['household']->longitude = $coords['lng'];
                 $data['household']->latitude = $coords['lat'];
             } else {
                 $data['latitude'] = Helpers::getSetting('church_latitude');
                 $data['longitude'] = Helpers::getSetting('church_longitude');
             }
         }
         $cellphones = array();
         foreach ($data['household']->individual as $indiv) {
             if ($indiv->cellphone != "") {
                 $cellphones[$indiv->id] = $indiv->firstname;
             }
         }
         $data['societyname'] = Society::find($society)->society;
         $data['society'] = $society;
         $data['societies'] = Society::orderBy('society')->get();
         $data['household']->cellphones = $cellphones;
         return View::make('households.edit', $data)->render();
     } else {
         return View::make("shared.unauthorised");
     }
 }