Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('propel_fellow_wingman')->delete();
     DB::table('propel_student_wingman')->delete();
     Subject::truncate();
     DB::table('propel_city_subject')->delete();
     CalendarEvent::truncate();
     CancelledCalendarEvent::truncate();
     WingmanModule::truncate();
     WingmanTime::truncate();
     VolunteerTime::truncate();
     WingmanJournal::truncate();
     $fellow = Fellow::find(1);
     $wingman1 = Wingman::find(2);
     $wingman2 = Wingman::find(3);
     $fellow->wingman()->attach($wingman1);
     $fellow->wingman()->attach($wingman2);
     $student1 = Student::find(3);
     $student2 = Student::find(4);
     $wingman1->student()->attach($student1);
     $wingman1->student()->attach($student2);
     $cEvent1 = new CalendarEvent();
     $cEvent1->type = 'volunteer_time';
     $cEvent1->student()->associate($student1);
     $cEvent1->status = 'created';
     $cEvent1->save();
     $vTime1 = new VolunteerTime();
     $vTime1->calendarEvent()->associate($cEvent1);
     $volunteer1 = Volunteer::find(4);
     $vTime1->volunteer()->associate($volunteer1);
     $subject1 = new Subject();
     $subject1->name = "English";
     $subject1->save();
     $vTime1->subject()->associate($subject1);
     $vTime1->save();
     $cEvent2 = new CalendarEvent();
     $cEvent2->type = 'wingman_time';
     $cEvent2->student()->associate($student1);
     $cEvent2->status = 'created';
     $cEvent2->save();
     $wTime1 = new WingmanTime();
     $wTime1->calendarEvent()->associate($cEvent2);
     $wTime1->wingman()->associate($wingman1);
     $wModule1 = new WingmanModule();
     $wModule1->name = "Programming";
     $wModule1->save();
     $wTime1->wingmanModule()->associate($wModule1);
     $wTime1->save();
     $city1 = City::find(1);
     $subject1->city()->attach($city1);
     $wJournal1 = new WingmanJournal();
     $wJournal1->type = 'formal';
     $wJournal1->title = "Day at Navy Camp";
     $wJournal1->mom = "It was awesome";
     $wJournal1->student()->associate($student1);
     $wJournal1->wingman()->associate($wingman1);
     $wJournal1->save();
 }
 public function showList($user_id)
 {
     $entries = WingmanJournal::where('wingman_id', '=', $user_id)->get();
     $session_id = $_SESSION['user_id'];
     $user = Volunteer::find($session_id);
     $groups = $user->group()->get();
     foreach ($groups as $group) {
         if ($group->name == 'Propel Multiplier' || $group->name == 'Propel Fellow') {
             $user_group = 'Propel Fellow';
         } elseif ($group->name == 'Propel Wingman') {
             $user_group = 'Propel Wingman';
         } elseif ($group->name == 'Propel Strat') {
             $user_group = 'Propel Strat';
         } elseif ($group->name == 'Aftercare Wingman') {
             $user_group = 'Aftercare Wingman';
         } elseif ($group->name == 'Program Director, Propel') {
             $user_group = 'Program Director, Propel';
         }
     }
     return View::make('wingman-journal', ['entries' => $entries, 'user_group' => $user_group]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $je = WingmanJournal::find($id);
     $wingman_id = $je->wingman_id;
     $je->delete();
     return Redirect::to(URL::to('/') . "/wingman-journal/" . $wingman_id);
 }
Beispiel #4
0
 public function showCenterReport($city_id, $center_id)
 {
     $cities = City::where('id', '<=', '25')->orderby('name', 'ASC')->get();
     $centers = Center::where('city_id', '=', $city_id)->where('status', '=', 1)->orderby('name', 'ASC')->get();
     $tables = DB::table('Student')->join('propel_student_wingman as B', 'Student.id', '=', 'B.student_id')->join('User as C', 'C.id', '=', 'B.wingman_id')->join('Center as D', 'D.id', '=', 'Student.center_id')->join('City as E', 'E.id', '=', 'D.city_id');
     $child_data = $tables->select('Student.id as id', 'Student.name as name', 'C.name as wingman_name', 'D.id as center_id', 'D.name as center_name', 'E.name as city_name', 'E.id as city_id')->distinct()->where('E.id', '=', $city_id)->orderby('D.name', 'ASC')->where('D.id', '=', $center_id)->get();
     //$child_data = $tables->select('Student.name as name','C.name as wingman_name','D.id as center_id','D.name as center_name','E.name as city_name','E.id as city_id','F.id','F.id as journal_count','G.id as event_count')->distinct()->where('E.id','=',$city_id)->where('F.type','=','child_feedback')->orderby('D.name','ASC')->get(); //Test Query
     $child_data = (array) $child_data;
     $total = array();
     $total['wingman_session_count'] = 0;
     $total['asv_session_count'] = 0;
     $total['journal_count'] = 0;
     foreach ($child_data as $child) {
         $calendarEvent = CalendarEvent::where('student_id', '=', $child->id)->where('status', '<>', 'cancelled')->where('type', '=', 'wingman_time')->get();
         $child->wingman_session_count = count($calendarEvent);
         $total['wingman_session_count'] += $child->wingman_session_count;
         $calendarEvent = DB::table('propel_calendarEvents as A')->join('propel_wingmanTimes as B', 'A.id', '=', 'B.calendar_event_id')->where('A.student_id', '=', $child->id)->where('A.status', '=', 'attended')->get();
         $child->wingman_module_attended = count($calendarEvent);
         $calendarEvent = CalendarEvent::where('student_id', '=', $child->id)->where('status', '<>', 'cancelled')->where('type', '=', 'volunteer_time')->get();
         $child->asv_session_count = count($calendarEvent);
         $total['asv_session_count'] += $child->asv_session_count;
         $journalEntry = WingmanJournal::where('student_id', '=', $child->id)->where('type', '=', 'child_feedback')->get();
         $child->journal_count = count($journalEntry);
         $total['journal_count'] += $child->journal_count;
     }
     return View::make('reports.child-report.city-report')->with('child_data', $child_data)->with('cities', $cities)->with('city_id', $city_id)->with('centers', $centers)->with('center_id', '0')->with('total', $total);
 }