Exemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($society, $category)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['socname'] = Society::find($society)->society;
         $data['society'] = $society;
         $data['missions'] = Mission::where('society_id', '=', $society)->where('category', '=', $category)->orderBy('mission')->get();
         $data['category'] = $category;
         return view('missions.index', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
Exemplo n.º 2
0
 public function register()
 {
     $preachers = Preacher::sortedpreachers()->get();
     $pdf = new Fpdf();
     $pdf->AddPage('P');
     $logopath = base_path() . '/public/images/logo.jpg';
     $pdf->SetAutoPageBreak(true, 0);
     $pdf->Image($logopath, 5, 5, 0, 21);
     $pdf->SetFillColor(0, 0, 0);
     $pdf->SetFont('Arial', 'B', 11);
     $pdf->text(30, 13, "THE METHODIST CHURCH OF SOUTHERN AFRICA: " . strtoupper(Helpers::getSetting('circuit_name')) . " CIRCUIT " . Helpers::getSetting('circuit_number'));
     $pdf->text(30, 21, "LOCAL PREACHERS MEETING ATTENDANCE REGISTER " . date('Y'));
     $y = 39;
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->text(10, $y - 5, "Surname");
     $pdf->text(35, $y - 5, "First name");
     $pdf->text(54, $y - 5, "Title");
     $pdf->text(62, $y - 5, "Cellphone");
     $pdf->text(85, $y - 5, "Society");
     $pdf->text(110, $y - 5, "Status");
     $pdf->text(140, $y - 5, "Jan");
     $pdf->text(156, $y - 5, "Apr");
     $pdf->text(172, $y - 5, "Jul");
     $pdf->text(188, $y - 5, "Oct");
     $pdf->SetFont('Arial', '', 9);
     foreach ($preachers as $preacher) {
         if ($preacher->emeritus) {
             $preachersurname = "*" . $preacher->surname;
         } else {
             $preachersurname = $preacher->surname;
         }
         $pdf->text(10, $y, utf8_decode($preachersurname));
         $pdf->text(35, $y, utf8_decode($preacher->firstname));
         $pdf->text(54, $y, utf8_decode($preacher->title));
         $pdf->text(62, $y, substr($preacher->cellphone, 0, 3) . ' ' . substr($preacher->cellphone, 3, 3) . ' ' . substr($preacher->cellphone, 6, 4));
         $soc = Society::find($preacher->society_id);
         $pdf->text(85, $y, utf8_decode($soc->society));
         if ($preacher->fullplan == "Trial") {
             $pdf->text(110, $y, "On trial");
         } else {
             $pdf->text(110, $y, "Full plan: " . $preacher->fullplan);
         }
         $pdf->rect(135, $y - 4, 15, 5);
         $pdf->rect(151, $y - 4, 15, 5);
         $pdf->rect(167, $y - 4, 15, 5);
         $pdf->rect(183, $y - 4, 15, 5);
         $y = $y + 5;
     }
     $pdf->Output();
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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');
 }
Exemplo n.º 5
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;
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($society)
 {
     $data['downloads'] = Download::orderBy('title')->get();
     $data['society'] = Society::find($society);
     return view('downloads.index', $data);
 }
Exemplo n.º 8
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");
     }
 }
Exemplo n.º 9
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();
 }
Exemplo n.º 10
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 {
         //
     }
 }
Exemplo n.º 11
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');
     }
 }
Exemplo n.º 12
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');
     }
 }
Exemplo n.º 13
0
 public static function societySetting($field, $society)
 {
     $society = Society::find($society);
     return $society->{$field};
 }
Exemplo n.º 14
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");
     }
 }
Exemplo n.º 15
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');
 }