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); }
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); } }
/** * Show the form for creating a new resource. * * @return Response */ public function create($society) { if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society)) { if (!count(Input::all())) { $data['society'] = $society; if (count(Session::get('errors'))) { $data['latitude'] = Helpers::getSetting('church_latitude'); $data['longitude'] = Helpers::getSetting('church_longitude'); $data['sortsurname'] = Input::get('sortsurname'); return View::make('households.newmem', $data); } else { return View::make('households.check', $data); } } else { if (isset($society)) { $data['society'] = $society; $data['societyname'] = Society::find($society)->society; } else { $data['society'] = Input::get('society'); } $addbut = ""; $addbut = Input::get('addbut'); $searchbut = ""; $searchbut = Input::get('searchbut'); $newbut = ""; $newbut = Input::get('newbut'); if ($searchbut) { $sortsurname = Input::get('sortsurname'); if (strlen($sortsurname) > 2) { $data['households'] = Household::where('society_id', '=', $society)->where('addressee', 'like', '%' . $sortsurname . '%')->get(); $data['sortsurname'] = $sortsurname; return View::make('households.choose', $data); } else { return Redirect::back()->withInput()->withErrors('Surname is required and must be at least 3 letters long'); } } elseif ($addbut) { $newperson = "households/" . Input::get('household') . "/individuals/create"; return Redirect::to($newperson); } elseif ($newbut) { $data['latitude'] = 50; $data['longitude'] = 50; $data['sortsurname'] = Input::get('sortsurname'); $data['societies'] = Society::orderBy('society')->get(); return View::make('households.newmem', $data); } } } else { return View::make("shared.unauthorised"); } }