Exemple #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);
             });
         }
     }
 }
Exemple #2
0
 /**
  * Show the form for editing the specified resource.
  * GET /tasks/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $project, $id)
 {
     $data['society'] = $society;
     $data['task'] = Task::find($id);
     $data['project'] = Project::find($data['task']->project_id);
     $data['individuals'] = Individual::all();
     return View::make('tasks.edit', $data);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $data['parray'] = array('circuit_stewards', 'treasurer', 'superintendent', 'circuit_secretary', 'site_editors', 'supervisor_of_studies', 'local_preachers_secretary');
     $data['setting'] = Setting::where('setting_field', '=', $id)->firstOrFail();
     if (in_array($data['setting']->setting_field, $data['parray'])) {
         $data['chosenind'] = explode(',', $data['setting']->setting_value);
         $data['individuals'] = Individual::orderBy('surname')->orderBy('firstname')->get();
     }
     return View::make('settings.edit', $data);
 }
Exemple #4
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     if (Auth::user()->admin) {
         $data['user'] = User::find($id);
         $data['individuals'] = Individual::orderBy('surname')->orderBy('firstname')->get();
         return View::make('users.edit', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
 /**
  * Show the form for editing the specified resource.
  * GET /portfolios/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['society'] = $society;
         $data['portfolio'] = Portfolio::with('individual')->find($id);
         $data['individuals'] = Individual::all();
         return View::make('portfolios.edit', $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 (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');
     }
 }
 /**
  * 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);
 }
Exemple #8
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $data['user'] = Auth::user();
     $perms = Auth::user()->menushow()->get();
     foreach ($perms as $perm) {
         $ltdperms[] = $perm->society_id;
     }
     $data['groups'] = Group::wherein('society_id', $ltdperms)->where('contact', '=', $data['user']->individual_id)->orderBy('groupname')->get();
     $data['recentedits'] = Individual::socindivrecent($ltdperms)->orderBy('individuals.updated_at', 'desc')->take(5)->get();
     $data['recentadds'] = Individual::socindivrecent($ltdperms)->orderBy('individuals.created_at', 'desc')->take(5)->get();
     $data['recentpastorals'] = Pastoral::with('household', 'individual')->has('household')->orderBy('diarydate', 'desc')->take(5)->get();
     $thisyr = date("Y");
     $mon = strval(date('m-d', strtotime("next Monday") - 604800));
     $tue = strval(date('m-d', strtotime("next Monday") + 86400 - 604800));
     $wed = strval(date('m-d', strtotime("next Monday") + 172800 - 604800));
     $thu = strval(date('m-d', strtotime("next Monday") + 259200 - 604800));
     $fri = strval(date('m-d', strtotime("next Monday") + 345600 - 604800));
     $sat = strval(date('m-d', strtotime("next Monday") + 432000 - 604800));
     $sun = strval(date('m-d', strtotime("next Monday") + 518400 - 604800));
     $days = array($mon, $tue, $wed, $thu, $fri, $sat, $sun);
     $data['birthdays'] = Individual::join('households', 'household_id', '=', 'households.id')->select('individuals.id', 'society_id', 'household_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();
     $data['anniversaries'] = Specialday::join('households', 'household_id', '=', 'households.id')->select('homephone', 'society_id', '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();
     $view->with($data);
 }
 public function domove($society)
 {
     $request = Request::all();
     $individual = Individual::find($request['id']);
     $individual->household_id = $request['newhousehold'];
     $individual->save();
     return redirect(url('/') . $society . '/households/' . $request['hid'])->with('okmessage', 'Household data updated');
 }
 public function dashboard($society)
 {
     $data['total_indivs'] = Individual::socindiv($society)->count();
     $data['total_households'] = Household::where('society_id', '=', $society)->count();
     $data['missing_gps'] = Household::where('society_id', '=', $society)->where('latitude', '=', null)->count();
     $data['missing_hc'] = Household::where('society_id', '=', $society)->where('householdcell', '=', '')->count();
     $data['missing_pa'] = Household::where('society_id', '=', $society)->where('addr1', '=', '')->count();
     $data['members'] = Individual::socindiv($society)->members()->count();
     $data['children'] = Individual::socindiv($society)->children()->count();
     $totaged = Individual::socindiv($society)->members()->get();
     $totnum = 0;
     $totyr = 0;
     foreach ($totaged as $thisa) {
         if ($thisa->age) {
             $totyr = $totyr + $thisa->age;
             $totnum++;
         }
     }
     $data['missing_bd'] = Individual::socindiv($society)->members()->where('birthdate', '<', '1901-01-01')->count();
     if ($totnum) {
         $data['avg_age'] = round($totyr / $totnum, 1);
     }
     $data['fellowship'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'fellowship');
     })->count();
     $data['service'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'service');
     })->count();
     $data['worship'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'worship');
     })->count();
     $data['learning'] = Individual::socindiv($society)->members()->whereHas('group', function ($query) {
         $query->where('grouptype', '=', 'learning');
     })->count();
     $data['groups'] = Group::where('society_id', '=', $society)->where('statistics', '=', 'yes')->orderBy('groupname')->get();
     $data['society'] = $society;
     //$data['analyticsData'] = LaravelAnalytics::getVisitorsAndPageViews(7);
     return view('statistics.dashboard', $data);
 }
Exemple #11
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;
 }
Exemple #12
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);
 }
Exemple #13
0
 public function addmember($sid, $id)
 {
     if (Helpers::perm('admin', $sid) or Helpers::perm('edit', $sid)) {
         $today = date("Y-m-d");
         $group = Group::find($id);
         $mid = Input::get('newmember');
         $newmember = Individual::find($mid);
         if (!$group->individual->contains($newmember->id)) {
             $group->individual()->save($newmember);
             $update = Group::find($id)->individual()->updateExistingPivot($mid, array('created_at' => DB::raw('NOW()')));
             return Redirect::route('society.groups.edit', array($sid, $id))->with('okmessage', 'New member has been added');
         } else {
             return Redirect::route('society.groups.edit', array($sid, $id))->with('okmessage', 'This person is already in the group');
         }
     } else {
         return View::make("shared.unauthorised");
     }
 }
Exemple #14
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;
         $data['blog'] = Blog::find($id);
         $data['chosensoc'] = explode(',', $data['blog']->societies);
         if (count($data['blog']->subject)) {
             foreach ($data['blog']->subject as $subj) {
                 $data['blogsubjects'][] = $subj->id;
             }
         } else {
             $data['blogsubjects'][0] = 0;
         }
         $data['author'] = Individual::where('slug', '<>', '')->orderBy('surname')->orderBy('firstname')->get();
         $data['subjects'] = Subject::orderBy('subject')->get();
         $allsoc = Permission::where('user_id', '=', Auth::user()->id)->get();
         foreach ($allsoc as $asoc) {
             $data['societies'][$asoc->society_id] = $asoc->society->society;
         }
         return view('blogs.edit', $data);
     } else {
         return View::make("shared.unauthorised");
     }
 }
Exemple #15
0
 public function restore($model, $id)
 {
     $fullmodel = "\\App\\Models\\" . ucfirst($model);
     $record = $fullmodel::onlyTrashed()->find($id)->restore();
     if ($model == "individual") {
         $hid = Individual::find($id)->household_id;
         return Redirect::route('households.show', $hid)->with('okmessage', 'Record restored');
     } else {
         $newroute = $model . "s.index";
         return Redirect::route($newroute)->with('okmessage', 'Record restored');
     }
 }
 protected function gethcell($id)
 {
     $indiv = Individual::find($id);
     if ($indiv) {
         return $indiv->firstname . " (" . $indiv->cellphone . ")";
     }
     return "Invalid individual";
 }
Exemple #17
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['society'] = $society;
         $data['skill'] = Skill::with('individual')->where('society_id', '=', $society)->find($id);
         $data['individuals'] = Individual::all();
         return View::make('skills.edit', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
Exemple #18
0
 public static function get_indiv($id)
 {
     $indiv = Individual::find($id);
     return utf8_decode($indiv->firstname) . " " . utf8_decode($indiv->surname);
 }
 public function search()
 {
     $input = Input::all();
     $data['q'] = $input['q'];
     $perms = array_flatten(Permission::where('user_id', '=', Auth::user()->id)->select('society_id')->get()->toArray());
     $individuals = Individual::where('surname', 'like', '%' . $input['q'] . '%')->orWhere('firstname', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->orderBy('surname')->get();
     foreach ($individuals as $indiv) {
         if ($indiv->household) {
             if (in_array($indiv->household->society_id, $perms)) {
                 $ids[] = $indiv->id;
             }
         }
     }
     $data['individuals'] = Individual::wherein('id', $ids)->get();
     $data['groups'] = Group::where('groupname', 'like', '%' . $input['q'] . '%')->whereIn('society_id', $perms)->whereNull('deleted_at')->get();
     $data['projects'] = Project::where('project', 'like', '%' . $input['q'] . '%')->whereNull('deleted_at')->get();
     return view('home', $data);
 }
 /**
  * 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');
     }
 }
 /**
  * Show the form for editing the specified resource.
  * GET /projects/{id}/edit
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($society, $id)
 {
     $project = Project::find($id);
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society) or $project->individual_id == Auth::user()->individual_id) {
         $portfolios = Portfolio::orderBy('portfolio')->lists('portfolio', 'id');
         $individuals = Individual::orderBy('surname')->get();
         return View::make('projects.edit')->with('project', $project)->with('individuals', $individuals)->with('portfolios', $portfolios)->with('society', $society);
     } 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');
     }
 }