Пример #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();
 }
Пример #2
0
 public function rescheduleEvent()
 {
     if (Input::get('reschedule_event_type') == "") {
         return Redirect::to(URL::to('/calendar/' . Input::get('reschedule_wingman_id') . '/' . Input::get('reschedule_student_id')));
     }
     if (Input::get('reschedule_subject') == "" && Input::get('reschedule_type') == 'volunteer_time') {
         return Redirect::to(URL::to('/calendar/' . Input::get('reschedule_wingman_id') . '/' . Input::get('reschedule_student_id')))->with('error', 'Subject not selected.');
     }
     $id = Input::get('rescheduleCalendar_id');
     $existing_ce = CalendarEvent::where('id', '=', $id)->first();
     if (!empty($existing_ce)) {
         WingmanTime::where('calendar_event_id', '=', $existing_ce->id)->delete();
         VolunteerTime::where('calendar_event_id', '=', $existing_ce->id)->delete();
         CancelledCalendarEvent::where('calendar_event_id', '=', $existing_ce->id)->delete();
     }
     $existing_ce->type = Input::get('reschedule_event_type');
     //return Input::get('edit_start_date').' '.Input::get('edit_start_time');
     $existing_ce->start_time = new DateTime(Input::get('reschedule_start_date') . ' ' . Input::get('reschedule_start_time'));
     $existing_ce->end_time = new DateTime(Input::get('reschedule_end_date') . ' ' . Input::get('reschedule_end_time'));
     $existing_ce->student_id = Input::get('reschedule_student_id');
     $existing_ce->status = 'approved';
     $existing_ce->save();
     switch ($existing_ce->type) {
         case 'wingman_time':
             $wt = new WingmanTime();
             $wt->wingman_id = Input::get('reschedule_wingman_id');
             $wt->wingman_module_id = Input::get('reschedule_wingman_module');
             $wt->calendar_event_id = $existing_ce->id;
             $wt->save();
             break;
         case 'volunteer_time':
             $vt = new VolunteerTime();
             $vt->volunteer_id = Input::get('reschedule_volunteer');
             $vt->subject_id = Input::get('reschedule_subject');
             $vt->calendar_event_id = $existing_ce->id;
             $vt->save();
             //Send SMS to the volunteer informing them about the class
             $volunteer = Volunteer::find(Input::get('reschedule_volunteer'));
             //To get the first name
             list($volunteer_name) = explode(" ", $volunteer->name);
             $user = Volunteer::find($_SESSION['user_id']);
             list($user_name) = explode(" ", $user->name);
             //To get correctly formatted date and time
             $on_date = date("d-M", strtotime(Input::get('on_date')));
             $on_time = Input::get('start_time');
             $student = Student::find($existing_ce->student_id);
             $center_name = $student->center()->first()->name;
             $sms = new SMSController();
             $sms->message = "Hi {$volunteer_name},\n\nYou have a class scheduled at {$center_name} on {$on_date}({$on_time}).\n\nPlease contact {$user_name}({$user->phone}) for more details.";
             $sms->number = $volunteer->phone;
             $sms->send();
             break;
     }
     return Redirect::to(URL::to('/calendar/' . Input::get('reschedule_wingman_id') . '/' . Input::get('reschedule_student_id')));
 }