public function getIndex() { $stats = array(); $stats['accounts_pending_approval'] = User::query()->pending()->count(); // TODO: unify 'Y'/'N'/0/1 $stats['nominations_pending_review'] = Household::where('draft', 'N')->where('reviewed', 0)->count(); $stats['nominations_approved'] = Household::where('reviewed', 1)->count(); $stats['nominations_reviewed'] = Household::where('approved', 1)->count(); $stats['children_approved'] = Household::where('reviewed', 1)->join('child', 'child.household_id', '=', 'household.id')->count(); $stats['children_reviewed'] = Household::where('household.approved', 1)->join('child', 'child.household_id', '=', 'household.id')->count(); $stats['children_pending'] = Household::where('household.reviewed', 0)->where('household.draft', 'N')->join('child', 'child.household_id', '=', 'household.id')->count(); $stats['drafts'] = Household::query()->draft()->count(); $stats['orgs'] = DB::table('household')->select('affiliation.type', DB::raw('count(case when household.approved = 1 then 1 else null end) as approved'), DB::raw('count(case when household.reviewed = 1 then 1 else null end) as reviewed'), DB::raw('count(case when household.draft = "N" and household.reviewed = 0 then 1 else null end) as pending'))->join('users', 'users.id', '=', 'household.nominator_user_id')->join('affiliation', 'affiliation.id', '=', 'users.affiliation_id')->groupBy('affiliation.type')->get(); return view('admin.dashboard.index', $stats); }
/** * Whether or not the user has reached their limit of nominations for the year * * TODO: Rejected nominations should not count toward the limit * TODO: Need to use current year for limit * * @return bool */ public function getMaxNominationsReachedAttribute() { $nominated_by_user = Household::query()->where("nominator_user_id", "=", $this->id)->notRejected()->count(); return $nominated_by_user >= $this->nomination_limit; }
public function packing_slips(Request $request) { if (!\Auth::user()->hasRole("admin")) { abort(403); } $radio = $request->cookie('packing_slip_radio'); $phone = $request->cookie('packing_slip_phone'); if (!$phone || !$radio) { return redirect('/admin/packing_slip_config'); } $households = Household::query()->where('approved', '=', 1); // TODO: limit which packing slips to print // $after = $request->input('after'); // if($after != NULL){ // $when = strtotime($after); // if(!$when){ // Flash::error('Invalid date or time: ' . $after); // return redirect('/admin'); // } // $households = $households->andWhere('updated_at', '>=', date('y-m-d H:i:s', $when)); // } return view("admin.households.packing_slip", ["households" => $households->get(), "assistance" => ["phone" => $phone, "radio" => $radio]]); }