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); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($society, $slug) { $data['soc'] = $society; $data['individual'] = Individual::where('slug', '=', $slug)->first(); if ($data['individual'] and $data['individual']->social) { $socials = explode(',', $data['individual']->social); foreach ($socials as $social) { if (strpos($social, 'twitter')) { $data['socials']['twitter'] = $social; } elseif (strpos($social, 'facebook')) { $data['socials']['facebook'] = $social; } elseif (strpos($social, 'instagram')) { $data['socials']['instagram'] = $social; } elseif (strpos($social, 'youtube')) { $data['socials']['youtube'] = $social; } } } if ($data['individual']) { $id = $data['individual']->id; if (count(Preacher::where('individual_id', '=', $id)->get()) > 0) { $data['preacher'] = Preacher::with(array('sermons' => function ($query) { $query->orderBy('created_at', 'DESC'); }))->where('individual_id', '=', $id)->first(); } elseif (count(Minister::with('sermons')->where('individual_id', '=', $id)->get()) > 0) { $data['preacher'] = Minister::where('individual_id', '=', $id)->first(); } $data['pagetitle'] = $data['individual']->firstname . " " . $data['individual']->surname; } else { $data['preacher'] = Guest::where('slug', '=', $slug)->first(); $data['pagetitle'] = $data['preacher']->firstname . " " . $data['preacher']->surname; $id = 0; } if (isset($data['preacher'])) { $sermons = $data['preacher']->sermons->lists('id')->all(); $data['sermons'] = Sermon::wherein('id', $sermons)->orderBy('servicedate', 'DESC')->paginate(5); } $data['blogs'] = Blog::where('individual_id', '=', $id)->orderBy('created_at', 'DESC')->limit(9)->get(); return View::make('individuals.show', $data); }
/** * 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"); } }
public function fixUp($society, $field) { $data['society'] = $society; $data['lets'] = array('1' => 'A', '2' => 'B', '3' => 'C', '4' => 'D', '5' => 'E', '6' => 'F', '7' => 'G', '8' => 'H', '9' => 'I', '10' => 'J', '11' => 'K', '12' => 'L', '13' => 'M', '14' => 'N', '15' => 'O', '16' => 'P', '17' => 'Q', '18' => 'R', '19' => 'S', '20' => 'T', '21' => 'U', '22' => 'V', '23' => 'W', '24' => 'X', '25' => 'Y', '26' => 'Z'); if ($field == "gps") { $data['households'] = Household::where('latitude', '=', null)->orderBy('sortsurname')->get(); return View::make('households.index', $data); } elseif ($field == "cellphone") { $data['households'] = Household::where('householdcell', '=', '')->orderBy('sortsurname')->get(); return View::make('households.index', $data); } elseif ($field == "address") { $data['households'] = Household::where('addr1', '=', '')->orderBy('sortsurname')->get(); return View::make('households.index', $data); } elseif ($field == "birthdate") { $data['individuals'] = Individual::where('birthdate', '<', '1901-01-01')->get(); return View::make('individuals.index', $data); } }
private function _covenant($society, $blank = "false") { $pdf = new Fpdf(); $soc = Society::find($society); if (!$blank) { $households = Household::with('individual')->where('society_id', '=', $society)->orderBy('sortsurname')->get(); if ($soc->logo == "") { $logopath = base_path() . '/public/images/defaultlogo.jpg'; } else { $logopath = base_path() . '/public/images/defaultlogo.jpg'; } } else { $individual = (object) ['firstname' => 'Name:', 'surname' => '', 'memberstatus' => 'member', 'title' => '', 'birthdate' => '', 'cellphone' => '', 'email' => '', 'giving' => '', 'group' => array()]; $individuals[] = $individual; $individuals[] = $individual; $individuals[] = $individual; $household = (object) ['addressee' => 'Household:', 'addr1' => '', 'addr2' => '', 'addr3' => '', 'post1' => '', 'post2' => '', 'post3' => '', 'homephone' => '', 'householdcell' => '', 'individual' => $individuals]; $households[] = $household; } $churchname = $soc->society . " Methodist Church"; foreach ($households as $household) { $pg = 1; $pdf->AddPage('P'); $pdf->SetAutoPageBreak(0, 0); $pdf->SetFont('Arial', 'B', 12); $pdf->text(10, 10, utf8_decode($household->addressee)); $pdf->SetFont('Arial', '', 11); $pdf->rect(48, 12, 152, 7); $pdf->text(10, 17, "Physical Address"); if ($household->addr1) { $addr = $household->addr1; if ($household->addr2) { $addr = $addr . ", " . $household->addr2; if ($household->addr3) { $addr = $addr . ", " . $household->addr3; } } $pdf->text(50, 17, $addr); } $pdf->rect(48, 21, 152, 7); $pdf->text(10, 26, "Postal Address"); if ($household->addr1) { $paddr = $household->post1; if ($household->post2) { $paddr = $paddr . ", " . $household->post2; if ($household->post3) { $paddr = $paddr . ", " . $household->post3; } } $pdf->text(50, 26, $paddr); } $pdf->text(10, 35, "Home phone"); $pdf->rect(48, 30, 152, 7); $pdf->text(10, 44, "Church SMSes go to"); $pdf->rect(48, 40, 152, 7); $pdf->text(50, 35, substr($household->homephone, 0, 3) . " " . substr($household->homephone, 3, 4) . " " . substr($household->homephone, 7, 3)); if ($household->householdcell != 0 and Individual::where('id', '=', $household->householdcell)->exists()) { $pdf->text(50, 45, Individual::find($household->householdcell)->firstname); } $yy = 54; foreach ($household->individual as $indiv) { if ($indiv->memberstatus == "child") { $threshold = 270; } else { $threshold = 210; } if ($yy > $threshold) { $pg++; $pdf->AddPage('P'); $pdf->SetFont('Arial', 'B', 11); $pdf->text(10, 10, utf8_decode($household->addressee) . " - page " . $pg); $yy = 18; $pdf->SetFont('Arial', '', 11); } $starty = $yy; $pdf->SetFont('Arial', 'B', 11); $pdf->text(10, $yy, $indiv->title . " " . utf8_decode($indiv->firstname) . " " . utf8_decode($indiv->surname)); $pdf->SetFont('Arial', '', 11); $pdf->text(100, $yy, "Date of birth"); $pdf->rect(123, $yy - 5, 8, 7); $pdf->rect(132, $yy - 5, 25, 7); $pdf->rect(158, $yy - 5, 20, 7); if ($indiv->birthdate != "0000-00-00" and $indiv->birthdate != "") { $pdf->text(125, $yy, date("d", strtotime($indiv->birthdate))); $pdf->text(134, $yy, date("F", strtotime($indiv->birthdate))); if (substr($indiv->birthdate, 0, 4) != "1900" and substr($indiv->birthdate, 0, 4) != "") { $pdf->text(163, $yy, date("Y", strtotime($indiv->birthdate))); } else { $pdf->SetFont('Arial', '', 7); $pdf->setxy(178, $yy - 5.2); $pdf->multicell(23, 2, "Please include year of birth - this is helpful for worship planning"); } } else { $pdf->SetFont('Arial', '', 7); $pdf->setxy(178, $yy - 5.2); $pdf->multicell(23, 2, "Please include year of birth - this is helpful for worship planning"); } $pdf->SetFont('Arial', '', 11); $yy = $yy + 9; $pdf->text(10, $yy, "Cellphone"); $pdf->rect(48, $yy - 5, 50, 7); $pdf->text(50, $yy, substr($indiv->cellphone, 0, 3) . " " . substr($indiv->cellphone, 3, 4) . " " . substr($indiv->cellphone, 7, 3)); $pdf->text(100, $yy, "Email"); $pdf->rect(111, $yy - 5, 89, 7); $pdf->text(113, $yy, $indiv->email); $yy = $yy + 9; $pdf->text(10, $yy, "I would like to be considered as a: "); $pdf->rect(72, $yy - 4, 6, 6); $pdf->text(80, $yy, "member"); $pdf->rect(102, $yy - 4, 6, 6); $pdf->text(110, $yy, "non-member"); $pdf->rect(138, $yy - 4, 6, 6); $pdf->text(146, $yy, "child"); if ($indiv->memberstatus == "child") { $pdf->text(140, $yy, "X"); } $pdf->rect(162, $yy - 4, 6, 6); $pdf->text(170, $yy, "youth"); if ($indiv->memberstatus == "youth") { $pdf->text(164, $yy, "X"); } $yy = $yy + 3; if (strtolower($indiv->memberstatus) != "child") { $adultgroups = array(); $pdf->rect(10, $yy, 38, 45); $pdf->image(base_path() . '/public/images/serve.png', 32, $yy + 30, 14, 14); $pdf->rect(48, $yy, 38, 45); $pdf->image(base_path() . '/public/images/worship.png', 70, $yy + 30, 14, 14); $pdf->rect(86, $yy, 38, 45); $pdf->image(base_path() . '/public/images/learn.png', 108, $yy + 30, 14, 14); $pdf->rect(124, $yy, 38, 45); $pdf->image(base_path() . '/public/images/give.png', 147, $yy + 30, 14, 14); $pdf->rect(162, $yy, 38, 45); $pdf->image(base_path() . '/public/images/connect.png', 184, $yy + 30, 14, 14); $adultgroups['service'] = ""; $adultgroups['course'] = ""; $adultgroups['fellowship'] = ""; $adultgroups['worship'] = ""; $pdf->SetFont('Arial', '', 8); // Giving $pdf->setxy(124, $yy); if ($indiv->giving == 0) { $pdf->multicell(38, 4, "I do not have a planned giving number."); $pdf->rect(125, $yy + 9, 5, 5); $pdf->text(132, $yy + 12, "Please send me info"); $pdf->rect(125, $yy + 15, 5, 5); $pdf->text(132, $yy + 18, "Please sign me up"); } else { $pdf->multicell(38, 4, "I am a planned giver and have a PG number."); $pdf->rect(125, $yy + 9, 5, 5); $pdf->text(132, $yy + 12, "But I can't remember it!"); $pdf->rect(125, $yy + 15, 5, 5); $pdf->setxy(131, $yy + 16); $pdf->multicell(30, 4, "I have not been receiving a quarterly acknowledgement of my planned giving offerings"); } foreach ($indiv->group as $group) { if ($group->grouptype != "admin") { $adultgroups[$group->grouptype] = $adultgroups[$group->grouptype] . $group->groupname . ", "; } } //Service $pdf->setxy(10, $yy); $pdf->SetFont('Arial', 'B', 8); if ($adultgroups['service']) { $pdf->multicell(38, 3, "Current: " . substr($adultgroups['service'], 0, strlen($adultgroups['service']) - 2)); } $pdf->SetFont('Arial', '', 8); $pdf->setxy(10, $pdf->gety()); $pdf->multicell(38, 3, "I'm interested in getting involved in: "); // Worship $pdf->setxy(48, $yy); $services = Service::where('society_id', '=', $soc->id)->get(); if (count($services) > 1) { $pdf->multicell(38, 4, "The service I usually attend is:"); $yadd = 0; foreach ($services as $service) { $pdf->rect(60, $yy + 9 + $yadd, 5, 5); $pdf->text(67, $yy + 12 + $yadd, $service->servicetime); $yadd = $yadd + 7; } } else { $pdf->text(58, $yy + 6, $services[0]->servicetime . " service"); } // Courses $pdf->setxy(86, $yy); $courses = Group::where('society_id', '=', $soc->id)->where('groupname', 'like', date('Y') . "%")->where('grouptype', '=', 'course')->get(); if (count($courses)) { $pdf->multicell(38, 4, "I am interested in doing a course this year:"); $yadd = 0; foreach ($courses as $course) { $pdf->rect(87, $yy + 9 + $yadd, 5, 5); $pdf->text(93, $yy + 12 + $yadd, substr($course->groupname, 4)); $yadd = $yadd + 7; } } else { $pdf->multicell(38, 4, "I would love to do a course this year. I am interested in:"); } //Groups $pdf->setxy(162, $yy); if ($adultgroups['fellowship']) { $pdf->SetFont('Arial', 'B', 8); $pdf->multicell(38, 4, "Current group: " . substr($adultgroups['fellowship'], 0, -2)); $pdf->SetFont('Arial', '', 8); } else { $groups = Group::where('society_id', '=', $soc->id)->where('groupname', 'like', date('Y') . "%")->where('grouptype', '=', 'fellowship')->get(); if (count($groups)) { $pdf->multicell(38, 4, "I would like to join a small group:"); $yadd = 0; foreach ($groups as $group) { $pdf->rect(163, $yy + 9 + $yadd, 5, 5); $pdf->text(169, $yy + 12 + $yadd, substr($group->groupname, 4)); $yadd = $yadd + 7; } } else { $pdf->multicell(38, 4, "I would like to join a small group - please send more info."); } } $yy = $yy + 3; $yy = $yy + 48; $pdf->rect(9, $starty - 6, 192, $yy - $starty + 1); } else { $allgroups = ""; foreach ($indiv->group as $group) { $allgroups = $allgroups . $group->groupname . ", "; } $pdf->SetFont('Arial', '', 8); $pdf->text(10, $yy + 2, substr($allgroups, 0, -2)); $yy = $yy + 6; $pdf->rect(9, $starty - 6, 192, $yy - $starty + 3); $yy = $yy + 2; } $yy = $yy + 2; } } $pdf->Output(); exit; }
public function giving($society) { $data['society'] = Society::find($society); if (Auth::user()->individual_id == $data['society']->pgadmin) { $givers = Individual::where('giving', '<>', 0)->where('giving', '<>', '')->orderBy('giving')->get(); foreach ($givers as $giver) { $dum['name'] = $giver->firstname . " " . $giver['surname']; $dum['id'] = $giver->id; $dum['household'] = $giver->household_id; $data['givers'][intval($giver->giving)][] = $dum; } ksort($data['givers']); return View::make('societies.giving', $data); } else { return view('shared.unauthorised'); } }