示例#1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $societies = Society::where('group_birthdays', '<>', 0)->select('group_birthdays', 'id', 'email', 'society')->get();
     foreach ($societies as $soc) {
         // Birthdays
         $thisyr = date("Y");
         $mon = strval(date('m-d', strtotime("next Monday")));
         $tue = strval(date('m-d', strtotime("next Monday") + 86400));
         $wed = strval(date('m-d', strtotime("next Monday") + 172800));
         $thu = strval(date('m-d', strtotime("next Monday") + 259200));
         $fri = strval(date('m-d', strtotime("next Monday") + 345600));
         $sat = strval(date('m-d', strtotime("next Monday") + 432000));
         $sun = strval(date('m-d', strtotime("next Monday") + 518400));
         $msg = "Birthdays for the week: (starting " . $thisyr . "-" . $mon . ")<br><br>";
         $days = array($mon, $tue, $wed, $thu, $fri, $sat, $sun);
         //DB::enableQueryLog();
         $birthdays = Individual::join('households', 'household_id', '=', 'households.id')->where('households.society_id', '=', $soc->id)->select('individuals.id', 'homephone', 'householdcell', 'cellphone', 'firstname', 'surname', DB::raw('substr(birthdate, 6, 5) as bd'))->wherein(DB::raw('substr(birthdate, 6, 5)'), $days)->orderBy(DB::raw('substr(birthdate, 6, 5)'))->get();
         //Log::debug(DB::getQueryLog());
         foreach ($birthdays as $bday) {
             $msg = $msg . date("D d M", strtotime($thisyr . "-" . $bday->bd)) . " " . $bday->firstname . " " . $bday->surname . ":";
             if ($bday->cellphone) {
                 $msg = $msg . " Cellphone: " . $bday->cellphone;
             }
             if ($bday->homephone) {
                 $msg = $msg . " Homephone: " . $bday->homephone;
             }
             if ($bday->householdcell and $bday->householdcell != $bday->id) {
                 $msg = $msg . " Household cellphone: " . self::gethcell($bday->householdcell);
             }
             $msg = $msg . "<br>";
             //Log::notice($bday->surname . ", " . $bday->firstname);
         }
         $anniversaries = Specialday::join('households', 'household_id', '=', 'households.id')->select('homephone', 'householdcell', 'addressee', 'household_id', 'anntype', 'details', DB::raw('substr(anniversarydate, 6, 5) as ad'))->wherein(DB::raw('substr(anniversarydate, 6, 5)'), $days)->orderBy(DB::raw('substr(anniversarydate, 6, 5)'))->get();
         $msg = $msg . "<br>" . "Anniversaries" . "<br><br>";
         foreach ($anniversaries as $ann) {
             $msg = $msg . date("D d M", strtotime($thisyr . "-" . $ann->ad)) . " (" . $ann->addressee . ". " . ucfirst($ann->anntype) . ": " . $ann->details . ")";
             if ($ann->homephone) {
                 $msg = $msg . " Homephone: " . $ann->homephone;
             }
             if ($ann->householdcell) {
                 $msg = $msg . " Household cellphone: " . self::gethcell($ann->householdcell);
             }
             $msg = $msg . "<br>";
         }
         $group = Group::with('individual')->find($soc->group_birthdays);
         foreach ($group->individual as $recip) {
             $fname = $recip->firstname;
             $name = $recip->firstname . " " . $recip->surname;
             $email = $recip->email;
             $subject = "Birthday email from " . $soc->society . " Methodist Church";
             Mail::queue('messages.message', array('msg' => "Good morning, " . $fname . " :)<br><br>" . $msg), function ($message) use($name, $email, $subject, $soc) {
                 $message->from($soc->email, $soc->society . " Methodist Church");
                 $message->to($email, $name);
                 $message->replyTo($email);
                 $message->subject($subject);
             });
         }
     }
 }
示例#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['meeting'] = Meeting::find($id);
         $data['meetingdatetime'] = date("Y-m-d H:i", $data['meeting']->meetingdatetime);
         $data['societies'] = Society::all();
         return view('meetings.edit', $data);
     } else {
         return view("shared.unauthorised");
     }
 }
示例#3
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');
     }
 }
示例#4
0
 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function show($society, $slug)
 {
     $data['society'] = Society::where('society', '=', $society)->first();
     $data['soc'] = $society;
     $data['mission'] = Mission::where('slug', '=', $slug)->first();
     if ($data['mission']->subject_id) {
         $data['blogs'] = Subject::with('blog')->where('id', '=', $data['mission']->subject_id)->first();
         $data['subject'] = $data['blogs']->subject;
     }
     if ($data['mission']->category == "event") {
         $data['fbtitle'] = "For more event details on Facebook, click here";
     } elseif ($data['mission']->category == "project") {
         $data['fbtitle'] = "Follow this project on Facebook";
     }
     return view('missions.show', $data);
 }
示例#5
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');
     }
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $cministers = Minister::with('individual')->get();
     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'));
     if (Helpers::is_online() and Helpers::getSetting('circuit_calendar') != "") {
         $privatecal = new GoogleCalendar();
         $data['cals'] = $privatecal->getTen(Helpers::getSetting('circuit_calendar'), 8);
     }
     $view->with('data', $data);
 }
示例#7
0
 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function show($society, $category)
 {
     $data['soc'] = $society;
     $data['category'] = $category;
     $data['pagetitle'] = "Downloads: " . $category;
     $data['society'] = Society::where('society', '=', $society)->first();
     $downloads = Download::orderBy('category')->orderBy('title')->get();
     $data['iscat'] = false;
     foreach ($downloads as $download) {
         $societies = explode(',', $download->societies);
         if ($download->societies == "" or in_array($data['society']->id, $societies)) {
             $data['downloads'][$download->category][] = $download;
             if ($download->category == $category) {
                 $data['iscat'] = true;
             }
         }
     }
     return view('downloads.show', $data);
 }
示例#8
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $society = $view->getData()['soc'];
     $data['services'] = Society::with('service')->where('society', '=', $society)->first();
     foreach ($data['services']->service as $service) {
         if ($service['language'] == "English" and $service['description'] == "") {
             $service->description = "Our " . $service->servicetime . " service is led in English by a minister or local preacher and a team of musicians. Everyone is welcome!";
         } elseif ($service['language'] == "isiZulu" and $service['description'] == "") {
             $service->description = "Our " . $service->servicetime . " service is led in isiZulu by a minister or local preacher and uses the liturgy and music of the Methodist Hymn Book. Everyone is welcome!";
         }
         $data['allservices'][] = $service;
     }
     if (!count($data['services'])) {
         return View::make('errors.404');
     }
     if (isset($view->getData()['pagetitle'])) {
         $data['pagetitle'] = $view->getData()['pagetitle'];
     } else {
         $data['pagetitle'] = $society;
     }
     $socid = Society::where('society', '=', $society)->select('id')->first()->id;
     if (Helpers::is_online() and $data['services']->society_calendar != "") {
         $privatecal = new GoogleCalendar();
         $data['cals'] = $privatecal->getTen($data['services']->society_calendar, 8);
     }
     $data['sermon'] = Sermon::with(['series' => function ($query) use($socid) {
         $query->where('society_id', '=', $socid);
     }])->orderBy('servicedate', 'DESC')->first();
     if (!$data['sermon'] or !$data['sermon']->series) {
         $data['sermon'] = "None";
     } else {
         if ($data['sermon']->preachable_type == 'App\\Models\\Minister') {
             $data['preacher'] = Minister::find($data['sermon']->preachable_id);
         } elseif ($data['sermon']->preachable_type == 'App\\Models\\Guest') {
             $data['preacher'] = Guest::find($data['sermon']->preachable_id);
         } else {
             $data['preacher'] = Preacher::find($data['sermon']->preachable_id);
         }
     }
     $data['welcome_page'] = "together a transforming discipleship movement";
     $data['welcome_page_pic'] = "/public/images/715.jpg";
     if ($data['services']->roster) {
         $data['roster'] = $data['services']->roster;
     }
     $data['society'] = Society::where('society', '=', $society)->first();
     if ($data['society']->roster) {
         $data['roster'] = $data['society']->roster;
     }
     $webpage = Webpage::where('society_id', '=', $data['society']->id)->get();
     foreach ($webpage as $pg) {
         $data[$pg->fieldname] = $pg->fieldvalue;
         $data[$pg->fieldname . '_pic'] = $pg->pageimage;
     }
     $data['route'] = Route::getCurrentRoute()->getPath();
     if ($data['route'] != "{society}" and $data['route'] != "/") {
         $linkadd = Helpers::makeUrl(strtolower($society), '');
     } else {
         $linkadd = "";
     }
     $menu['link'] = $linkadd . "#sundays";
     $menu['label'] = "Sundays";
     $menu['longlabel'] = "Sunday services";
     $data['menu'][] = $menu;
     $data['youth'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'youth')->orderBy('created_at')->take(5)->get();
     if (count($data['youth'])) {
         $menu['link'] = $linkadd . "#youth";
         $menu['label'] = "Youth";
         $menu['longlabel'] = "Children and Youth";
         $data['menu'][] = $menu;
     }
     $data['groups'] = Group::where('society_id', '=', $data['society']->id)->where('publish', '=', 1)->get();
     if (count($data['groups'])) {
         foreach ($data['groups'] as $obj) {
             $dum[0] = $obj->groupname;
             $dum[1] = $obj->latitude;
             $dum[2] = $obj->longitude;
             $dum[3] = Helpers::makeUrl(strtolower($data['services']->society), 'groups/' . $obj->slug);
             $fin[] = $dum;
         }
         $data['fin'] = json_encode($fin);
         $menu['link'] = "#groups";
         $menu['label'] = "Groups";
         $menu['longlabel'] = "Small groups";
         $data['menu'][] = $menu;
     } else {
         $data['fin'] = "";
     }
     $data['missions'] = Mission::where('society_id', '=', $data['society']->id)->where('category', '=', 'project')->take(5)->get();
     if (count($data['missions'])) {
         $menu['link'] = $linkadd . "#projects";
         $menu['label'] = "Projects";
         $menu['longlabel'] = "Mission projects";
         $data['menu'][] = $menu;
     }
     $blogs = Blog::with('individual')->orderBy('created_at', 'desc')->take(10)->get();
     if (count($blogs)) {
         $first = true;
         foreach ($blogs as $blog) {
             $societies = explode(',', $blog->societies);
             if (in_array($data['society']->id, $societies)) {
                 if ($first) {
                     $data['firstblog'] = $blog;
                     $first = false;
                 } else {
                     $data['blogs'][] = $blog;
                 }
             }
         }
         if (isset($data['firstblog'])) {
             $menu['link'] = $linkadd . "#blog";
             $menu['label'] = "Blog";
             $menu['longlabel'] = "Latest blogs";
             $data['menu'][] = $menu;
         }
     }
     $menu['link'] = $linkadd . "#contact";
     $menu['label'] = "Contact";
     $menu['longlabel'] = "Contact us";
     $data['menu'][] = $menu;
     $data['counter'] = 1;
     $view->with('data', $data);
 }
示例#9
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['group'] = Group::with(array('individual' => function ($query) {
             $query->wherePivot('deleted_at', null)->orderBy('surname', 'asc');
         }))->find($id);
         $data['individuals'] = Individual::socindiv($society)->get();
         $data['society'] = $society;
         $coords = Society::find($society);
         if ($data['group']->latitude == "0") {
             $data['deflat'] = $coords->latitude;
             $data['deflon'] = $coords->longitude;
         }
         $data['history'] = Group::with('individual')->find($id);
         $data['members'] = Individual::socindiv($society)->get();
         $data['contact'] = Individual::find($data['group']->contact);
         $daysofweek = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
         $data['meeting'] = $daysofweek[-1 + $data['group']->meeting];
         return View::make('groups.edit', $data);
     } else {
         return View::make("shared.unauthorised");
     }
 }
示例#10
0
 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function show($society, $author = "all", $subject = "all")
 {
     $data['author'] = $author;
     if ($author != "all") {
         $filterindiv = Individual::where('slug', '=', $author)->first();
         $filter = "Showing posts by " . $filterindiv->firstname . " " . $filterindiv->surname;
         if ($subject != "all") {
             $filter = $filter . " tagged " . $subject;
         }
     } elseif ($subject != "all") {
         $filter = "Showing posts tagged " . $subject;
     } else {
         $filter = "Showing all posts";
     }
     $data['filter'] = $filter;
     $data['subjects'] = Subject::has('blog')->orderBy('subject')->get();
     $data['bloggers'] = Individual::has('blog')->orderBy('surname')->orderBy('firstname')->get();
     $data['soc'] = $society;
     $data['pagetitle'] = $society . " Blog";
     $data['society'] = Society::where('society', '=', $society)->first();
     $blogs = Blog::with('individual')->orderBy('created_at', 'desc')->get();
     $blogids = array();
     if (count($blogs)) {
         $first = true;
         foreach ($blogs as $blog) {
             $societies = explode(',', $blog->societies);
             if (in_array($data['society']->id, $societies)) {
                 $subjs = array();
                 $thissubjs = $blog->subject;
                 foreach ($thissubjs as $thissub) {
                     $subjs[] = $thissub->subject;
                 }
                 if ($subject == "all" or in_array($subject, $subjs)) {
                     if ($author == "all" or $author == $blog->individual->slug) {
                         $blogids[] = $blog->id;
                     }
                 }
             }
         }
     }
     $data['blogs'] = Blog::with('individual')->wherein('id', $blogids)->orderBy('created_at', 'desc')->paginate(20);
     return view('blogs.show', $data);
 }
示例#11
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($society, $series, $id)
 {
     $data['sermon'] = Sermon::where('slug', '=', $id)->first();
     if ($data['sermon']->preachable_type == 'App\\Models\\Minister') {
         $data['preacher'] = Minister::find($data['sermon']->preachable_id);
     } elseif ($data['sermon']->preachable_type == 'App\\Models\\Guest') {
         $data['preacher'] = Guest::find($data['sermon']->preachable_id);
     } else {
         $data['preacher'] = Preacher::find($data['sermon']->preachable_id);
     }
     $data['soc'] = $society;
     $data['society'] = Society::where('society', '=', $society)->first();
     $data['pagetitle'] = $data['sermon']->sermon;
     return view('sermons.show', $data);
 }
示例#12
0
 public static function societySetting($field, $society)
 {
     $society = Society::find($society);
     return $society->{$field};
 }
示例#13
0
 public function sendMessage($society, $type)
 {
     $soc = Society::find($society);
     $input = Input::all();
     $alldat = array();
     if ($input['leaderoptions'] == "everyone") {
         $allhouseholds = Household::with('individual')->where('society_id', '=', $society)->get();
         foreach ($allhouseholds as $hhh) {
             foreach ($hhh->individual as $iii) {
                 if ($iii->id == $hhh->householdcell) {
                     $dum = self::PopulateRecipient($iii);
                     if ($dum['cellphone'] != "" and $iii->memberstatus == "member") {
                         $alldat[$iii->id] = $dum;
                     }
                 }
             }
         }
     } elseif (isset($input['groups'])) {
         $groups = $input['groups'];
         if ($input['leaderoptions'] == "allmembers") {
             foreach ($groups as $thisgroup) {
                 $group = Group::with('individual')->find($thisgroup);
                 foreach ($group->individual as $indiv) {
                     $dum = self::PopulateRecipient($indiv);
                     $alldat[$indiv->id] = $dum;
                 }
             }
         } elseif ($input['leaderoptions'] == "leadersonly" or $input['leaderoptions'] == "leadersandlist") {
             foreach ($groups as $thisgroup) {
                 $group = Group::with('individual')->find($thisgroup);
                 foreach ($group->individual as $indiv) {
                     if ($group->contact == $indiv->id) {
                         $dum = self::PopulateRecipient($indiv);
                         if (!isset($alldat[$indiv->id])) {
                             $alldat[$indiv->id] = $dum;
                         }
                         if ($input['leaderoptions'] == "leadersandlist") {
                             if (isset($alldat[$indiv->id]['grouplist'])) {
                                 $alldat[$indiv->id]['grouplist'] = $alldat[$indiv->id]['grouplist'] . $group->id . ",";
                             } else {
                                 $alldat[$indiv->id]['grouplist'] = $group->id . ",";
                             }
                         }
                     }
                 }
             }
         }
     }
     if (isset($input['indivs'])) {
         foreach ($input['indivs'] as $individ) {
             $indiv = Individual::find($individ);
             $dum = self::PopulateRecipient($indiv);
             if (!isset($alldat[$individ])) {
                 $alldat[$individ] = $dum;
             }
         }
     }
     if ($type == "email") {
         if (isset($input['htmlbody'])) {
             $message = nl2br($input['message']) . file_get_contents($input['htmlbody']);
         } else {
             $message = nl2br($input['message']);
         }
         $message = HTML::decode($message);
         $subject = $input['subject'];
         $sender = Input::get('sender');
         Mail::queue('messages.message', array('msg' => $message), function ($message) use($subject, $soc, $alldat, $sender) {
             if (Input::file('attachment')) {
                 $message->attach(Input::file('attachment'), array('as' => Input::file('attachment')->getClientOriginalName(), 'mime' => Input::file('attachment')->getMimeType()));
             }
             foreach ($alldat as $thisrec) {
                 $name = $thisrec['name'];
                 $email = $thisrec['email'];
                 $household = $thisrec['household'];
                 if (isset($thisrec['grouplist'])) {
                     $grouplist = $thisrec['grouplist'];
                 } else {
                     $grouplist = "No group";
                 }
                 $message->from('*****@*****.**', $soc->society . " Methodist Church");
                 $message->to($email, $name)->replyTo($sender);
                 if ($subject == "") {
                     $subject = "Email from " . $soc->society . " Methodist Church";
                 }
                 if ($grouplist != "No group") {
                     $ggl = explode(",", substr($grouplist, 0, -1));
                     foreach ($ggl as $gl) {
                         $repdata = app('App\\Http\\Controllers\\ReportsController')->show($gl, true);
                         $tg = Group::find($gl);
                         $message->attachData($repdata, $tg->groupname . ".pdf");
                     }
                 }
                 $message->subject($subject);
             }
         });
         $results = array();
         foreach ($alldat as $tdat) {
             $result['name'] = $tdat['name'];
             $result['address'] = $tdat['email'];
             $result['household'] = $tdat['household'];
             $results[] = $result;
         }
     } else {
         $final = array();
         foreach ($alldat as $thisdat) {
             $ndx = intval($thisdat['household']);
             if (Input::get('economy') == "household") {
                 if (array_key_exists($ndx, $final)) {
                     $keyhouse = Household::find($ndx)->householdcell;
                     $keycell = Individual::find($keyhouse);
                     if (SMSfunctions::checkcell($keycell->cellphone)) {
                         $final[$ndx]['cellphone'] = $keycell->cellphone;
                         $final[$ndx]['name'] = $keycell->firstname . " " . $keycell->surname;
                         $final[$ndx]['household'] = $ndx;
                     }
                 } else {
                     $final[$ndx]['cellphone'] = $thisdat['cellphone'];
                     $final[$ndx]['name'] = $thisdat['name'];
                     $final[$ndx]['household'] = $ndx;
                 }
             } else {
                 $dummy['cellphone'] = $thisdat['cellphone'];
                 $dummy['name'] = $thisdat['name'];
                 $dummy['household'] = $ndx;
                 $final[] = $dummy;
             }
         }
         if ($soc->sms_provider == "bulksms") {
             if (count($final) > SMSfunctions::BS_get_credits($soc->sms_username, $soc->sms_password)) {
                 return Redirect::back()->withInput()->withErrors("Insufficient Bulk SMS credits to send SMS");
             }
             $url = 'http://community.bulksms.com/eapi/submission/send_sms/2/2.0';
             $port = 80;
         } elseif ($soc->sms_provider == "smsfactory") {
             if (count($final) > SMSfunctions::SF_checkCredits($soc->sms_username, $soc->sms_password)) {
                 return Redirect::back()->withInput()->withErrors("Insufficient SMS Factory credits to send SMS");
             }
         }
         $seven_bit_msg = Input::get('message') . " (From " . substr($soc->society, 0, 1) . "MC)";
         foreach ($final as $sms) {
             if ($soc->sms_provider == "bulksms") {
                 $transient_errors = array(40 => 1);
                 $msisdn = "+27" . substr($sms['cellphone'], 1);
                 $post_body = SMSfunctions::BS_seven_bit_sms($soc->sms_username, $soc->sms_password, $seven_bit_msg, $msisdn);
             }
             $dum2['name'] = $sms['name'];
             $dum2['household'] = $sms['household'];
             if (SMSfunctions::checkcell($sms['cellphone'])) {
                 if ($soc->sms_provider == "bulksms") {
                     $smsresult = SMSfunctions::BS_send_message($post_body, $url, $port);
                 } elseif ($soc->sms_provider == "smsfactory") {
                     $smsresult = SMSfunctions::SF_sendSms($soc->sms_username, $soc->sms_password, $sms['cellphone'], $seven_bit_msg);
                 }
                 $dum2['address'] = $sms['cellphone'];
             } else {
                 if ($sms['cellphone'] == "") {
                     $dum2['address'] = "No cell number provided.";
                 } else {
                     $dum2['address'] = "Invalid cell number: " . $sms['cellphone'] . ".";
                 }
             }
             $results[] = $dum2;
         }
         $data['results'] = $results;
     }
     $data['type'] = $type;
     $data['results'] = $results;
     return View::make('messages.results', $data);
 }
示例#14
0
 public function report($dat)
 {
     $pdf = new Fpdf();
     $pdf->AddPage('L');
     $logopath = base_path() . '/public/images/logo.jpg';
     $pdf->SetAutoPageBreak(true, 0);
     $pdf->SetFont('Arial', '', 9);
     $num_ser = 0;
     foreach ($dat['societies'] as $s1) {
         foreach ($s1->service as $se1) {
             $num_ser++;
         }
     }
     $header = 20;
     $left_side = 5;
     $left_edge = 40;
     $num_soc = count($dat['societies']);
     $num_sun = count($dat['sundays']);
     $soc_width = $left_edge - 17;
     $pg_height = 210;
     $pg_width = 297;
     $y = $header;
     $x = $left_edge;
     $y_add = ($pg_height - $header - 3 * ($num_ser - $num_soc)) / $num_ser;
     $x_add = ($pg_width - 5 - $left_edge) / $num_sun;
     $toprow = true;
     $pdf->Image($logopath, 5, 5, 0, 21);
     $pdf->SetFillColor(0, 0, 0);
     $pdf->SetFont('Arial', 'B', 14);
     $pdf->text($left_side + $soc_width, 10, "THE METHODIST CHURCH OF SOUTHERN AFRICA: " . strtoupper(Helpers::getSetting('circuit_name')) . " CIRCUIT " . Helpers::getSetting('circuit_number'));
     $pdf->text($left_side + $soc_width, 17, "PREACHING PLAN: " . strtoupper(date("F Y", $dat['sundays'][0]['dt'])) . " - " . strtoupper(date("F Y", $dat['sundays'][count($dat['sundays']) - 1]['dt'])));
     foreach ($dat['societies'] as $soc) {
         $firstserv = true;
         foreach ($soc->service as $ser) {
             if ($firstserv) {
                 $y = $y + $y_add;
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->rect($left_side, $y - 2, $pg_width - 2 * $left_side, $y_add + $y_add * (count($soc->service) - 1) - 3 * (count($soc->service) - 1), 'D');
                 $pdf->setxy($left_side, $y);
                 if (count($soc->service) == 1) {
                     $pdf->setxy($left_side, $y);
                 } else {
                     $pdf->setxy($left_side, $y + ($y_add - 3) * (count($soc->service) - 1) / 2);
                 }
                 $font_size = 8;
                 $decrement_step = 0.1;
                 $pdf->SetFont('Arial', 'B', $font_size);
                 while ($pdf->GetStringWidth($soc->society) > $soc_width - 2) {
                     $pdf->SetFontSize($font_size -= $decrement_step);
                 }
                 $pdf->cell($soc_width, $y_add - 3, $soc->society, 0, 0, 'R');
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->setxy($left_side + $soc_width, $y);
                 $pdf->cell(12, $y_add - 3, $ser->servicetime, 0, 0, 'C');
                 $pdf->SetFillColor(0, 0, 0);
                 $pdf->SetTextColor(0, 0, 0);
                 $pdf->SetDrawColor(0, 0, 0);
             } else {
                 $y = $y + $y_add - 3;
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->setxy($left_side + $soc_width, $y);
                 $pdf->cell(12, $y_add - 3, $ser->servicetime, 0, 0, 'C');
                 $pdf->SetFillColor(0, 0, 0);
                 $pdf->SetTextColor(0, 0, 0);
             }
             $firstserv = false;
             foreach ($dat['sundays'] as $sun) {
                 if ($toprow) {
                     // Weekly dates
                     $pdf->SetFont('Arial', 'B', 8);
                     if (date("D", $sun['dt']) == "Sun") {
                         $pdf->setxy($x, $header + 2);
                         $pdf->cell($x_add, $y_add - 6, date("j M", $sun['dt']), 0, 0, 'C');
                     } else {
                         $wd = Weekday::where('servicedate', '=', $sun['dt'])->first();
                         $pdf->setxy($x, $header + 4);
                         $pdf->SetFont('Arial', '', 7);
                         $pdf->cell($x_add, $y_add - 6, $wd->description, 0, 0, 'C');
                         $pdf->SetFont('Arial', 'B', 8);
                         $pdf->setxy($x, $header);
                         $pdf->cell($x_add, $y_add - 6, date("j M", $sun['dt']), 0, 0, 'C');
                     }
                 }
                 if (isset($dat['fin'][$soc['society']][$sun['yy']][$sun['mm']][$sun['dd']][$ser->servicetime]['tname'])) {
                     $tagadd = 1;
                     $pdf->setxy($x, $y - 2);
                     $pdf->SetFont('Arial', 'B', 7.5);
                     $pdf->cell($x_add, $y_add - 2, $dat['fin'][$soc['society']][$sun['yy']][$sun['mm']][$sun['dd']][$ser->servicetime]['tname'], 0, 0, 'C');
                 } else {
                     $tagadd = 0;
                 }
                 if (isset($dat['fin'][$soc['society']][$sun['yy']][$sun['mm']][$sun['dd']][$ser->servicetime]['pname'])) {
                     $pdf->setxy($x, $y + $tagadd);
                     $pname = utf8_decode($dat['fin'][$soc['society']][$sun['yy']][$sun['mm']][$sun['dd']][$ser->servicetime]['pname']);
                     $font_size = 8;
                     $decrement_step = 0.1;
                     $pdf->SetFont('Arial', '', $font_size);
                     while ($pdf->GetStringWidth($pname) > $x_add - 1) {
                         $pdf->SetFontSize($font_size -= $decrement_step);
                     }
                     $pdf->cell($x_add, $y_add - 3, $pname, 0, 0, 'C');
                 }
                 $x = $x + $x_add;
             }
             $toprow = false;
             $x = $left_edge;
         }
     }
     $x2 = $x;
     foreach ($dat['sundays'] as $sun2) {
         $pdf->line($x2, $header + 8, $x2, $y + $y_add - 2);
         $x2 = $x2 + $x_add;
     }
     $pdf->AddPage('L');
     $pdf->Image($logopath, 10, 5, 0, 21);
     $pdf->SetFillColor(0, 0, 0);
     $pdf->SetFont('Arial', 'B', 14);
     $pdf->text($left_side + $soc_width + 8, 10, "THE METHODIST CHURCH OF SOUTHERN AFRICA: " . strtoupper(Helpers::getSetting('circuit_name')) . " CIRCUIT " . Helpers::getSetting('circuit_number'));
     $pdf->text($left_side + $soc_width + 8, 17, "PREACHING PLAN: " . strtoupper(date("F Y", $dat['sundays'][0]['dt'])) . " - " . strtoupper(date("F Y", $dat['sundays'][count($dat['sundays']) - 1]['dt'])));
     $pfin = array();
     foreach ($dat['preachers'] as $preacher1) {
         $dum = array();
         $thissoc = Society::find($preacher1->society_id)->society;
         $dum['name'] = $preacher1->individual->title . " " . $preacher1->individual->firstname . " " . $preacher1->individual->surname;
         if ($preacher1->emeritus) {
             $dum['name'] = $dum['name'] . "*";
         }
         $dum['soc'] = $preacher1->society_id;
         if ($preacher1->individual->cellphone == "") {
             $dum['cellphone'] = $preacher1->individual->officephone;
         } else {
             $dum['cellphone'] = $preacher1->individual->cellphone;
         }
         $dum['fullplan'] = $preacher1->fullplan;
         if ($dum['fullplan'] == "Trial") {
             $vdum['9999' . $preacher1->individual->surname . $preacher1->individual->firstname] = $dum;
         } else {
             $vdum[$preacher1->fullplan . $preacher1->individual->surname . $preacher1->individual->firstname] = $dum;
         }
     }
     foreach ($dat['guests'] as $guest1) {
         $dum['name'] = $guest1->title . " " . $guest1->firstname . " " . $guest1->surname;
     }
     ksort($vdum);
     foreach ($vdum as $vd) {
         $thissoc = Society::find($vd['soc'])->society;
         $pfin[$thissoc][] = $vd;
     }
     $cols = 4;
     $spacer = 5;
     $col_width = ($pg_width - 2 * $left_side) / $cols;
     $y = 30;
     $col = 1;
     $pdf->SetFont('Arial', '', 8);
     $pdf->text($left_side + $spacer, $y, "Presiding Bishop: " . $dat['pb']);
     $y = $y + 4;
     $pdf->text($left_side + $spacer, $y, "General Secretary: " . $dat['gs']);
     $y = $y + 4;
     $pdf->text($left_side + $spacer, $y, "District Bishop: " . $dat['db']);
     $y = $y + 4;
     $pdf->text($left_side + $spacer, $y, "Superintendent: " . $dat['super']->title . " " . $dat['super']->firstname . " " . $dat['super']->surname);
     $y = $y + 6;
     $pdf->SetFont('Arial', 'B', 11);
     $pdf->text($left_side + $spacer, $y, "Circuit Ministers");
     $y = $y + 4;
     $pdf->SetFont('Arial', '', 8);
     foreach ($dat['ministers'] as $minister) {
         $mins[$minister->individual->surname . $minister->individual->firstname]['name'] = $minister->individual->title . " " . $minister->individual->firstname . " " . $minister->individual->surname . " (" . $minister->individual->cellphone . ")";
     }
     ksort($mins);
     foreach ($mins as $min) {
         $pdf->text($left_side + $spacer, $y, $min['name']);
         $y = $y + 4;
     }
     $y = $y + 2;
     $pdf->SetFont('Arial', '', 8);
     $officers = explode(',', Helpers::getSetting('circuit_stewards'));
     $subhead = "";
     $pdf->SetFont('Arial', 'B', 11);
     $pdf->text($left_side + $spacer, $y, "Circuit Stewards");
     $pdf->SetFont('Arial', '', 8);
     foreach ($officers as $officer) {
         $y = $y + 4;
         $fn = Individual::find($officer);
         $pdf->text($left_side + $spacer, $y, $fn->title . " " . $fn->firstname . " " . $fn->surname . " (" . $fn->cellphone . ")");
     }
     $pdf->SetFont('Arial', 'B', 11);
     $y = $y + 6;
     $pdf->text($left_side + $spacer, $y, "Circuit Treasurer");
     $pdf->SetFont('Arial', '', 8);
     $treasurer = Helpers::getSetting('treasurer');
     $y = $y + 4;
     $fn = Individual::find($treasurer);
     $pdf->text($left_side + $spacer, $y, $fn->title . " " . $fn->firstname . " " . $fn->surname . " (" . $fn->cellphone . ")");
     $pdf->SetFont('Arial', 'B', 11);
     $y = $y + 6;
     $pdf->SetFont('Arial', 'B', 11);
     $pdf->text($left_side + $spacer, $y, "Circuit Office");
     $circuitoffice = Society::find(Helpers::getSetting('circuit_office'));
     $pdf->SetFont('Arial', '', 8);
     $y = $y + 4;
     $pdf->text($left_side + $spacer, $y, $circuitoffice->society . " Methodist Church");
     if ($circuitoffice->phone) {
         $y = $y + 4;
         $pdf->text($left_side + $spacer, $y, "Phone: " . $circuitoffice->phone);
     }
     if ($circuitoffice->email) {
         $y = $y + 4;
         $pdf->text($left_side + $spacer, $y, "Email: " . $circuitoffice->email);
     }
     $csecretary = Helpers::getSetting('circuit_secretary');
     if ($csecretary) {
         $y = $y + 4;
         $pdf->SetFont('Arial', '', 8);
         $fn = Individual::find($csecretary);
         $pdf->text($left_side + $spacer, $y, "Secretary: " . $fn->title . " " . $fn->firstname . " " . $fn->surname);
     }
     $y = $y + 6;
     if (count($dat['meetings'])) {
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->text($left_side + $spacer, $y, "Circuit Meetings");
         $y = $y + 4;
         foreach ($dat['meetings'] as $meeting) {
             $x = $left_side + $spacer + ($col - 1) * $col_width;
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->text($x, $y, $meeting['description']);
             $pdf->SetFont('Arial', '', 8);
             $y = $y + 4;
             $msoc = Society::find($meeting['society_id'])->society;
             $pdf->text($x, $y, date("d M Y H:i", $meeting['meetingdatetime']) . " (" . $msoc . ")");
             $y = $y + 4;
         }
     }
     $y = $y + 2;
     $col++;
     $x = $left_side + $spacer + ($col - 1) * $col_width;
     $y = 30;
     $pdf->SetFont('Arial', 'B', 11);
     $pdf->text($x, $y, "Local Preachers");
     $supervisor = Helpers::getSetting('supervisor_of_studies');
     if ($supervisor) {
         $y = $y + 4;
         $pdf->SetFont('Arial', '', 8);
         $fn = Individual::find($supervisor);
         $pdf->text($x, $y, "Supervisor of studies: " . $fn->title . " " . $fn->firstname . " " . $fn->surname);
     }
     $lpsec = Helpers::getSetting('local_preachers_secretary');
     if ($lpsec) {
         $y = $y + 4;
         $pdf->SetFont('Arial', '', 8);
         $fn = Individual::find($lpsec);
         $pdf->text($x, $y, "Local Preachers Secretary: " . $fn->title . " " . $fn->firstname . " " . $fn->surname);
     }
     $y = $y + 4;
     $ythresh = 200;
     ksort($pfin);
     foreach ($pfin as $key => $soc) {
         if ($y > $ythresh - 6) {
             $col++;
             $y = 30;
         }
         $x = $left_side + $spacer + ($col - 1) * $col_width;
         $pdf->SetFont('Arial', 'B', 9);
         $y = $y + 2;
         $pdf->text($x, $y, $key);
         $y = $y + 4;
         $pdf->SetFont('Arial', '', 8);
         foreach ($soc as $pre) {
             if ($y > $ythresh) {
                 $col++;
                 $x = $left_side + $spacer + ($col - 1) * $col_width;
                 $y = 30;
             }
             $pre['name'] = utf8_decode($pre['name']);
             $pdf->text($x + 2, $y, $pre['fullplan']);
             $pdf->text($x + 10, $y, $pre['name'] . " (" . $pre['cellphone'] . ")");
             $y = $y + 4;
         }
     }
     $pdf->SetFont('Arial', '', 8);
     $y = $y + 4;
     $pdf->text($x + 2, $y, "* Emeritus");
     /*
     $y=$y+8;
     if (count($guest1)){
         $pdf->SetFont('Arial','B',11);
         $pdf->text($x,$y,"Guest Preachers");
         $y=$y+2;
         foreach ($guest1 as $guest){
             $y=$y+4;
             $pdf->text($x+10,$y,$guest['name'] . " (" . $guest['cellphone'] . ")");
         }
     }
     */
     $pdf->Output();
     exit;
 }
示例#15
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($society, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['society'] = Society::find($society);
         $data['webpage'] = Webpage::find($id);
         return view('webpages.edit', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
示例#16
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'))) or Auth::user()->individual_id == Helpers::getSetting('local_preachers_secretary')) {
         $data['individuals'] = Individual::orderBy('surname')->orderBy('firstname')->get();
         $data['preacher'] = Preacher::find($id);
         $data['societies'] = Society::all();
         return View::make('preachers.edit', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
示例#17
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($society, $slug = "all")
 {
     $socid = Society::where('society', '=', $society)->first()->id;
     if ($slug == "all" or strlen($slug) == 4 and is_numeric($slug)) {
         $syears = array();
         $data['series'] = Series::with('sermon')->where('society_id', '=', $socid)->orderBy('created_at', 'DESC')->get();
         foreach ($data['series'] as $serie) {
             if (!in_array(substr($serie->created_at, 0, 4), $syears)) {
                 $syears[] = substr($serie->created_at, 0, 4);
             }
         }
         asort($syears);
         $data['syears'] = $syears;
         $data['slug'] = $slug;
         if ($slug != "all") {
             $series = Series::with('sermon')->where('society_id', '=', $socid)->orderBy('created_at', 'DESC')->get();
             $data['series'] = array();
             foreach ($series as $serie) {
                 if (substr($serie->created_at, 0, 4) == $slug) {
                     $data['series'][] = $serie;
                 }
             }
             if (!isset($data['series'])) {
                 $data['series'] = array();
             }
         }
     } else {
         $data['series'] = Series::with('sermon')->where('society_id', '=', $socid)->where('slug', '=', $slug)->get();
         $data['slug'] = $data['series'][0]->series;
     }
     $data['pagetitle'] = $society . " sermons";
     $data['soc'] = $society;
     $others = Series::has('sermon')->where('society_id', '<>', $socid)->groupBy('society_id')->lists('society_id')->toArray();
     $data['othersocieties'] = Society::wherein('id', $others)->orderBy('society')->get();
     return view('series.show', $data);
 }
示例#18
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $yr, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['goal'] = Goal::find($id);
         $data['soc'] = Society::find($society);
         $data['yr'] = $yr;
         return View::make('goals.edit', $data);
     } else {
         return View::make("shared.unauthorised");
     }
 }
示例#19
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update($society, SongsRequest $request, $id)
 {
     $data['soc'] = Society::find($society);
     $keys = array('A', 'Bb', 'B', 'C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'G#', 'A');
     $song = song::find($id);
     $song->fill($request->except('transpose'));
     $song->key = $this->_moveOne($keys, $request->key, strtolower($request->transpose));
     if (isset($request->transpose)) {
         $song->lyrics = $this->_transposeLyrics($request->lyrics, strtolower($request->transpose));
     }
     $song->save();
     return Redirect::route('society.songs.edit', array($society, $song->id))->with('okmessage', 'Data updated');
 }
示例#20
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $hid, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['society'] = $society;
         $data['individual'] = Individual::with('group', 'skill')->find($id);
         if (!$data['individual']->photo) {
             $data['individual']->photo = "/public/images/profile.png";
         }
         if (count($data['individual']->currentgroups) != 0) {
             foreach ($data['individual']->currentgroups as $group) {
                 $groupmembers[] = $group->id;
             }
             $data['groupmembers'] = $groupmembers;
         }
         $data['groups'] = Group::where('society_id', '=', $society)->orderBy('groupname')->get();
         if (count($data['individual']->skill) != 0) {
             foreach ($data['individual']->skill as $skill) {
                 $skillmembers[] = $skill->id;
             }
             $data['skillmembers'] = $skillmembers;
         }
         $data['household_id'] = $data['individual']->household_id;
         $data['skills'] = Skill::orderBy('skill')->get();
         $data['pgadmin'] = Society::find($society)->pgadmin;
         return View::make('individuals.edit', $data);
     } else {
         //
     }
 }
示例#21
0
 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');
     }
 }
示例#22
0
 public function feed($society)
 {
     $feed = App::make("feed");
     // cache the feed for 60 minutes (second parameter is optional)
     $feed->setCache(0, 'LowerTugelaCircuitFeed');
     // check if there is cached feed and build new only if is not
     if (!$feed->isCached()) {
         $society = Society::where('society', '=', $society)->first();
         // creating rss feed with our most recent 20 posts
         $blogs = Blog::where('created_at', '>', '2016-02-13')->orderBy('created_at', 'desc')->take(20)->get();
         $sermons = Sermon::where('servicedate', '>', '2016-02-13')->orderBy('servicedate', 'desc')->orderBy('created_at', 'desc')->take(20)->get();
         // set your feed's title, description, link, pubdate and language
         $feed->title = $society->society . ' Methodist Church';
         $feed->description = 'Together, a transforming discipleship movement';
         $feed->logo = 'http://church.net.za/public/images/logo.jpg';
         $feed->link = url('feed');
         $feed->setDateFormat('datetime');
         // 'datetime', 'timestamp' or 'carbon'
         $feed->pubdate = date('d-m-Y');
         $feed->lang = 'en';
         $feed->setShortening(true);
         // true or false
         $feed->setTextLimit(120);
         // maximum length of description text
         $feeddata = array();
         foreach ($blogs as $blog) {
             // set item's title, author, url, pubdate, description and content
             if ($blog->blogimage != "") {
                 $imgurl = url($blog->blogimage);
             } elseif ($blog->individual->photo) {
                 $imgurl = url($blog->individual->photo);
             } elseif ($society->logo) {
                 $imgurl = url($society->logo);
             } else {
                 $imgurl = "http://church.net.za/public/images/logo.jpg";
             }
             $fulldescrip = strip_tags($blog->post);
             $dum['title'] = $blog->title;
             $dum['author'] = $imgurl;
             $dum['link'] = url('/blog#' . $blog->id);
             $dum['pubdate'] = $blog->created_at;
             $dum['summary'] = "A new blog post has been published on our site.";
             $dum['content'] = $fulldescrip;
             $feeddata[] = $dum;
         }
         foreach ($sermons as $sermon) {
             // set item's title, author, url, pubdate, description and content
             $seriesimage = url($sermon->series->seriesimage);
             if ($sermon->preachable_type == "App\\Models\\Guest") {
                 $preacher = $sermon->preachable->firstname . " " . $sermon->preachable->surname;
             } else {
                 $preacher = $sermon->preachable->individual->firstname . " " . ($preacher = $sermon->preachable->individual->surname);
             }
             $fulldescrip = "Recording of a sermon preached by " . $preacher . " at " . $society->society . ' Methodist Church on ' . date("l j F Y", strtotime($sermon->servicedate)) . '. Bible readings: ' . $sermon->readings;
             $dum['title'] = $sermon->sermon;
             $dum['author'] = $seriesimage;
             $dum['link'] = url('/sermons/' . $sermon->series->slug . '/' . $sermon->slug);
             $dum['pubdate'] = $sermon->servicedate . " 12:00:00";
             $dum['summary'] = "A new sermon has been uploaded to our site.";
             $dum['content'] = $fulldescrip;
             $feeddata[] = $dum;
         }
         usort($feeddata, function ($a, $b) {
             return strcmp($b["pubdate"], $a["pubdate"]);
         });
     }
     foreach ($feeddata as $fd) {
         $feed->add($fd['title'], $fd['author'], $fd['link'], $fd['pubdate'], $fd['summary'], $fd['content']);
     }
     return $feed->render('atom');
 }
示例#23
0
 public function birthdays($society)
 {
     $soc = Society::find($society);
     $houses = Household::with('individual')->where('society_id', '=', $society)->get();
     foreach ($houses as $house) {
         foreach ($house->individual as $indiv) {
             if ($indiv->memberstatus != 'non-member' and $indiv->birthdate != '0000-00-00' and $indiv->birthdate != '' and !is_null($indiv->birthdate)) {
                 $mth = intval(substr($indiv->birthdate, 5, 2));
                 $day = intval(substr($indiv->birthdate, 8, 2));
                 $dum = utf8_decode($indiv->firstname) . " " . utf8_decode($indiv->surname);
                 if ($indiv->cellphone != '') {
                     $dum = $dum . " (Cellphone: " . $indiv->cellphone . ")";
                 }
                 if ($house->homephone != '') {
                     $dum = $dum . " (Home phone: " . $house->homephone . ")";
                 }
                 if ($house->householdcell != 0 and $house->householdcell != $indiv->id) {
                     $dum = $dum . " (Additional cell number: " . $this->gethcell($house->householdcell) . ")";
                 }
                 $indivs[$mth][$day][] = $dum;
             }
         }
     }
     ksort($indivs);
     $pdf = new Fpdf();
     foreach ($indivs as $key => $mth) {
         ksort($mth);
         $pdf->AddPage('P');
         $pdf->SetAutoPageBreak(0, 0);
         $pdf->SetFont('Arial', 'B', 12);
         $monthName = date("F", mktime(null, null, null, $key));
         $pdf->text(10, 10, $soc->society . " Birthdays: " . $monthName);
         $pdf->SetFont('Arial', '', 9);
         $yy = 20;
         foreach ($mth as $dd => $day) {
             foreach ($day as $bd) {
                 $pdf->text(10, $yy, $dd . " " . $bd);
                 $yy = $yy + 4;
             }
         }
     }
     $pdf->Output();
 }
示例#24
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($soc_id, $ser_id)
 {
     $data['service'] = Service::find($ser_id);
     $data['society'] = Society::find($soc_id);
     return View::make('services.edit', $data);
 }
示例#25
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $society = Society::find($id);
     $society->delete();
     return Redirect::route('societies.index')->with('okmessage', 'Society has been deleted');
 }