public function link_report()
 {
     $excel = new PHPExcel();
     $sheet = new PHPExcel_Worksheet($excel, "Heads of Household");
     $sheet->fromArray(["Family Number", "Last Name", "First Name"], NULL, 'A1');
     $households = Household::all();
     // TODO ATN ::where('approved', 1);
     $i = 2;
     foreach ($households as $h) {
         $sheet->fromArray([$h->id, $h->name_last, $h->name_first], NULL, 'A' . $i++);
     }
     Export::AutoSizeSheet($sheet);
     $excel->addSheet($sheet);
     $sheet = new PHPExcel_Worksheet($excel, "Children");
     $sheet->fromArray(["Family Number", "Head of Household", "Child Number", "Child First Name", "Age", "Wish List", "Bike?", "Bike Style", "Bike Size", "Clothes?", "Shirt Size", "Pants Size", "Shoe Size"], NULL, 'A1');
     $children = Child::join('household', 'household.id', '=', 'child.household_id')->where('household.deleted_at')->select('child.*')->get();
     $i = 2;
     foreach ($children as $c) {
         if (!$c->household) {
             continue;
         }
         $sheet->fromArray([$c->household_id, $c->household->name_last . ", " . $c->household->name_first, $c->id, $c->name_first, $c->age, $c->additional_ideas, $c->bike_want == "Y" ? "Yes" : "", $c->bike_want == "Y" ? $c->bike_style : "", $c->bike_want == "Y" ? $c->bike_size : "", $c->clothes_want == "Y" ? "Yes" : "", $c->clothes_size_shirt, $c->clothes_size_pants, $c->shoe_size], NULL, 'A' . $i++);
     }
     Export::AutoSizeSheet($sheet);
     $excel->addSheet($sheet);
     $excel->removeSheetByIndex(0);
     header('Content-type: application/vnd.ms-excel');
     header('Content-Disposition: attachment; filename="GiftProjectTheLinkReport_' . date("YmdHis") . '.xlsx"');
     header('Cache-Control: max-age=0');
     $writer = new PHPExcel_Writer_Excel2007($excel);
     $writer->setOffice2003Compatibility(true);
     $writer->save('php://output');
     flush();
     exit(0);
 }
Example #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data = array('title' => 'Dashboard', 'household_count' => Household::all()->count(), 'family_count' => Family::all()->count(), 'person_count' => Person::all()->count(), 'guest_count' => Guest::all()->count());
     return view('dashboard')->with($data);
 }