Exemplo n.º 1
0
 public function gethcell($id)
 {
     $indiv = Individual::find($id);
     if ($indiv) {
         return $indiv->firstname . " (" . $indiv->cellphone . ")";
     }
     return "Invalid individual";
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($society, $id)
 {
     if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) {
         $data['society'] = $society;
         $data['skill'] = Skill::with(array('individual' => function ($query) {
             $query->orderBy('surname', 'asc');
         }))->find($id);
         $data['members'] = Individual::socindiv($society)->get();
         $data['contact'] = Individual::find($data['skill']->contact);
         return View::make('skills.show', $data);
     } else {
         return view('shared.unauthorised');
     }
 }
Exemplo n.º 3
0
 public function circuit($society)
 {
     $data['soc'] = $society;
     $data['pagetitle'] = Helpers::getSetting('circuit_name') . " Circuit";
     $cministers = Minister::with('individual')->get();
     if (Helpers::is_online() and Helpers::getSetting('circuit_calendar') != "") {
         $privatecal = new GoogleCalendar();
         $data['cals'] = $privatecal->getTen(Helpers::getSetting('circuit_calendar'), 8);
     }
     foreach ($cministers as $cm) {
         $dum['name'] = "<strong>" . $cm->individual->title . " " . $cm->individual->firstname . " " . $cm->individual->surname . "</strong>";
         $dum['contact'] = $cm->individual->cellphone;
         if ($cm->individual->id == Helpers::getSetting('superintendent')) {
             $dum['contact'] = "(Superintendent Minister)<br>" . $dum['contact'];
         }
         $dum['sort'] = $cm->individual->surname . $cm->individual->firstname;
         $dum['bio'] = $cm->individual->notes;
         $dum['photo'] = $cm->individual->photo;
         $dum['slug'] = $cm->individual->slug;
         $socs = Society::wherein('id', explode(',', $cm->societies))->get();
         $societies = "";
         foreach ($socs as $soc) {
             $societies .= "<a href=\"" . Helpers::makeUrl(strtolower($soc->society), '') . "\">" . $soc->society . "</a>, ";
         }
         $dum['societies'] = substr($societies, 0, -2);
         $data['ministers'][$dum['sort']] = $dum;
     }
     ksort($data['ministers']);
     $data['allsocieties'] = Society::orderBy('society')->get();
     if (count($data['allsocieties'])) {
         foreach ($data['allsocieties'] as $obj) {
             $dum1[0] = $obj->society;
             $dum1[1] = $obj->latitude;
             $dum1[2] = $obj->longitude;
             $dum1[3] = Helpers::makeUrl(strtolower($obj->society), '');
             $fin[] = $dum1;
         }
         $data['fin'] = json_encode($fin);
     } else {
         $data['fin'] = "";
     }
     $data['stewards'] = Individual::wherein('id', explode(',', Helpers::getSetting('circuit_stewards')))->get();
     $data['secretary'] = Individual::find(Helpers::getSetting('circuit_secretary'));
     $data['treasurer'] = Individual::find(Helpers::getSetting('treasurer'));
     return view('societies.circuit', $data);
 }
Exemplo n.º 4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $parray = array('circuit_stewards', 'treasurer', 'superintendent', 'circuit_secretary', 'site_editors', 'supervisor_of_studies', 'local_preachers_secretary');
     $settings = Setting::orderBy('category')->orderBy('setting_field')->get();
     foreach ($settings as $setting) {
         if (!in_array($setting->setting_field, $parray)) {
             $data[$setting->category][$setting->setting_field] = $setting->setting_value;
         } else {
             $data[$setting->category][$setting->setting_field] = "";
             $indarray = explode(',', $setting->setting_value);
             foreach ($indarray as $ind) {
                 if ($data[$setting->category][$setting->setting_field] != "") {
                     $data[$setting->category][$setting->setting_field] .= ", ";
                 }
                 $indiv = Individual::find($ind);
                 $data[$setting->category][$setting->setting_field] .= $indiv->title . " " . $indiv->firstname . " " . $indiv->surname;
             }
         }
     }
     return View::make('settings.index', $data);
 }
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
 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');
 }
Exemplo n.º 8
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');
     }
 }
Exemplo n.º 9
0
 public static function get_indiv($id)
 {
     $indiv = Individual::find($id);
     return utf8_decode($indiv->firstname) . " " . utf8_decode($indiv->surname);
 }
Exemplo n.º 10
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");
     }
 }