/** * Show the form for creating a new resource. * * @return Response */ public function create($society, $hid) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $data['society'] = $society; $data['household_id'] = $hid; $household = Household::find($hid); $data['sortsurname'] = $household->sortsurname; $data['photo'] = "/public/images/profile.png"; return View::make('individuals.create', $data); } else { // } }
/** * Show the form for editing the specified resource. * * @param int $id * @returnpResponse */ public function edit($society, $hid, $id) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { $pastoral = Pastoral::find($id); $pgid = Helpers::societySetting('group_pastors', $society); $addressee = Household::find($pastoral->household_id)->addressee; $pastorgroup = Group::where('id', '=', $pgid)->with('individual')->get(); $pastors = array(); foreach ($pastorgroup[0]->individual as $user) { $pastors[$user->id] = $user->surname . ", " . $user->firstname; } return View::make('pastorals.edit')->with('pastoral', $pastoral)->with('addressee', $addressee)->with('pastors', $pastors)->with('society', $society); } else { return view('shared.unauthorised'); } }
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); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($society, $hid, $id) { $specialday = Specialday::find($id); $addressee = Household::find($specialday->household_id)->addressee; return View::make('specialdays.edit')->with('specialday', $specialday)->with('addressee', $addressee)->with('society', $society); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($society, $id, HouseholdsRequest $request) { $household = Household::find($id); $household->fill($request->except('centrelat', 'centrelong', 'societyname')); $household->homephone = str_replace(" ", "", $request->input('homephone')); $household->save(); return Redirect::back()->with('okmessage', 'Data updated'); }