Example #1
0
 /**
  * Show Itinerary details
  * CODE: itinerary_view
  */
 public function executeDetail(sfWebRequest $request)
 {
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $this->orginset = '';
     $this->destset = '';
     $this->orgintset = '';
     $this->desttset = '';
     if ($request->getParameter('add_passengers')) {
         $this->group_camp_id = $request->getParameter('add_passengers');
     }
     $this->mission;
     $this->mission2;
     $mission;
     $mission2;
     $this->ground_addr_sel = sfConfig::get('app_ground_address_type', array());
     $this->errors = array();
     $this->errors2 = array();
     if ($request->getParameter('id')) {
         $this->itinerary = ItineraryPeer::retrieveByPK($request->getParameter('id'));
         $this->back = $request->getReferer();
         //echo $this->itinerary->getId();
         if (strstr($this->back, '/mission/view')) {
             $this->frommission = 1;
         } else {
             $this->frommission = 0;
         }
         $this->mis = MissionPeer::getMissionByItineraryId($this->itinerary->getId(), 1);
         $mission = $this->mis;
         /*echo "<pre>";
           print_r($this->mis);
           echo "</pre>";
           die("ok");
           */
         $this->mission = $mission;
         //print_r($mission);      exit ();
         ///Show leges
         if (isset($mission)) {
             $this->mis_legs = MissionLegPeer::getbyMissId($mission->getId());
         }
         //echo "<pre>";
         //print_r($this->mis_legs);
         //echo $this->itinerary->getId();
         $this->mis2 = MissionPeer::getMissionByItineraryId($this->itinerary->getId(), 2);
         /*
         echo "<pre>";
         print_r($this->mis2);
         echo "</pre>";
         die("ok");
         */
         $mission2 = $this->mis2;
         $this->mission2 = $mission2;
         $this->ground_addresses = array('patient' => '', 'facility' => '', 'lodging' => '', 'airport' => '');
         $pass;
         $this->personnew;
         if ($this->itinerary) {
             $this->ground_addresses['lodging'] = $this->ground_addresses['facility'] = $this->itinerary->getDestCity() . ', ' . $this->itinerary->getDestState();
             $pass = PassengerPeer::retrieveByPK($this->itinerary->getPassengerId());
             $this->personnew = PersonPeer::retrieveByPK($pass->getPersonId());
         }
         if ($pass) {
             $this->ground_addresses['lodging'] = $pass->getLodgingName() . ' ' . $this->ground_addresses['lodging'];
             $this->ground_addresses['facility'] = $pass->getFacilityName() . ' ' . $this->ground_addresses['facility'];
             $this->ground_addresses['patient'] = $this->personnew->getAddress1() . ' ' . $this->personnew->getAddress2() . ' ' . $this->personnew->getCity() . ', ' . $this->personnew->getState() . ' ' . $this->personnew->getZipcode();
             $this->ground_addresses['airport'] = $this->personnew->getAddress1() . ' ' . $this->personnew->getAddress2() . ' ' . $this->personnew->getCity() . ', ' . $this->personnew->getState() . ' ' . $this->personnew->getZipcode();
         }
     }
     if ($request->isMethod('post')) {
         if ($request->getParameter('com')) {
             if ($request->getParameter('com') == 1) {
                 $mission->setComment($request->getParameter('mis_comment'));
                 $mission->save();
             } elseif ($request->getParameter('com') == 2) {
                 $mission2->setComment($request->getParameter('mist_comment'));
                 $mission2->save();
             }
             $this->getUser()->setFlash('success', 'Comment successfully saved.');
         } else {
             if ($request->getParameter('misstsave') == 1) {
                 switch ($request->getParameter('transportation')) {
                     case 'air_mission':
                         $origin_airports = (array) $request->getParameter('origint_idents');
                         $dest_airports = (array) $request->getParameter('destinationt_idents');
                         $idents = $dest_airports;
                         $tmp_arr = array();
                         foreach ($origin_airports as $i => $ident) {
                             $idents[] = $ident;
                             $v = $ident . ' to ' . $dest_airports[$i];
                             if (in_array($v, $tmp_arr)) {
                                 $this->errors2[] = 'Leg ' . $v . ' appeared more than one';
                             } else {
                                 $tmp_arr[] = $v;
                             }
                             if ($dest_airports[$i] == $ident) {
                                 $this->errors2[] = 'Leg ' . $ident . ' to ' . $dest_airports[$i] . ' is invalid';
                             }
                         }
                         $idents = array_unique($idents);
                         $c = new Criteria();
                         $c->add(AirportPeer::IDENT, $idents, Criteria::IN);
                         if (count($idents) != AirportPeer::doCount($c)) {
                             $this->errors2[] = 'Some airport idents are invalid';
                         }
                         break;
                     case 'ground_mission':
                         $origin = $request->getParameter('groundt_origin');
                         $destination = $request->getParameter('groundt_destination');
                         $orgintset = $request->getParameter('orgintset');
                         $desttset = $request->getParameter('desttset');
                         $this->desttset = $desttset;
                         $this->orgintset = $orgintset;
                         if (empty($destination) && empty($desttset)) {
                             $this->errors2[] = 'Please specify destination address';
                         }
                         if (empty($origin) && empty($orgintset)) {
                             $this->errors2[] = 'Please specify origin address';
                         } elseif ($destination == $origin && $destination != '') {
                             $this->errors2[] = 'Origin and Destination addresses conflict';
                         }
                         break;
                     case 'commercial_mission':
                         $mission_date = $request->getParameter('mission_date');
                         if (empty($mission_date)) {
                             $this->errors2[] = 'Mission date is required';
                         }
                         if ($v = $request->getParameter('airline_id')) {
                             $custom = $request->getParameter('airline_custom');
                             if ($v == 'other') {
                                 if (empty($custom)) {
                                     $this->errors2[] = 'Please type a new airline name!';
                                 }
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($v = $request->getParameter('airline_id'));
                                 if (!$airline instanceof Airline) {
                                     $this->errors2[] = 'Please select airline!';
                                 }
                             }
                         } else {
                             $this->errors2[] = 'Please select airline!';
                         }
                         break;
                     default:
                         $this->errors2[] = 'Please select Transportation Type';
                 }
                 if (count($this->errors2)) {
                     # error in form
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $this->origin_idents = $origin_airports;
                             $this->dest_idents = $dest_airports;
                             break;
                         case 'ground_mission':
                             break;
                         case 'commercial_mission':
                             break;
                     }
                     $this->erer = 2;
                 } else {
                     $missioncount = MissionLegPeer::getMaxLegNumber($mission2->getId());
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $aircount = MissionLegPeer::getCountbyMissIdAndType($mission2->getId(), 'air_mission');
                             for ($i = 0; $i < sizeof($origin_airports); $i++) {
                                 $airport_o = AirportPeer::getByIdent($origin_airports[$i]);
                                 $airport_d = AirportPeer::getByIdent($dest_airports[$i]);
                                 $missioncount++;
                                 $aircount++;
                                 $mission_leg = new MissionLeg();
                                 $mission_leg->setMissionId($mission2->getId());
                                 $mission_leg->setLegNumber($missioncount);
                                 $mission_leg->setFromAirportId($airport_o->getId());
                                 $mission_leg->setToAirportId($airport_d->getId());
                                 $mission_leg->setPrefix('air' . $aircount);
                                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 $mission_leg->setPassOnBoard(0);
                                 $mission_leg->setTransportation('air_mission');
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                             }
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'ground_mission':
                             $groundcount = MissionLegPeer::getCountbyMissIdAndType($mission2->getId(), 'ground_mission');
                             $mission_leg = new MissionLeg();
                             $orgintsetsave = $request->getParameter('groundt_origin');
                             if (empty($orgintsetsave)) {
                                 $orgintsetsave = $request->getParameter('orgintset');
                             }
                             $desttsetsave = $request->getParameter('groundt_destination');
                             if (empty($desttsetsave)) {
                                 $desttsetsave = $request->getParameter('desttset');
                             }
                             $groundcount++;
                             $sas = $missioncount + 1;
                             $mission_leg->setMissionId($mission2->getId());
                             $mission_leg->setLegNumber($sas);
                             $mission_leg->setPassOnBoard(0);
                             $mission_leg->setTransportation('ground_mission');
                             $mission_leg->setGroundOrigin($orgintsetsave);
                             $mission_leg->setGroundDestination($desttsetsave);
                             $mission_leg->setPrefix('g' . $groundcount);
                             $mission_leg->setCancelMissionLeg(1);
                             $mission_leg->save();
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'commercial_mission':
                             $comcount = MissionLegPeer::getCountbyMissIdAndType($mission2->getId(), 'commercial_mission');
                             $flight_time = $request->getParameter('flight_time');
                             if (empty($flight_time['hour']) || empty($flight_time['minute'])) {
                                 $flight_time = null;
                             }
                             $airline_id = $request->getParameter('airline_id');
                             if ($airline_id == 'other') {
                                 $airline = new Airline();
                                 $airline->setName($request->getParameter('airline_custom'));
                                 $airline->save();
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($airline_id);
                                 $this->forward404Unless($airline);
                             }
                             $origins = $request->getParameter('origin');
                             $destinations = $request->getParameter('destination');
                             $flight_numbers = $request->getParameter('flight_number');
                             $departures = $request->getParameter('departure');
                             $arrivals = $request->getParameter('arrival');
                             $mission->setFlightTime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']);
                             $missioncount++;
                             $n_leg = $missioncount;
                             foreach ($origins as $i => $origin) {
                                 if (empty($origin) || empty($destinations[$i])) {
                                     continue;
                                 }
                                 $mission_leg = new MissionLeg();
                                 $comcount++;
                                 $mission_leg->setMissionId($mission2->getId());
                                 $mission_leg->setLegNumber($n_leg++);
                                 $mission_leg->setFlightTime($flight_time ? strtotime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']) : null);
                                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 $mission_leg->setAirlineId($airline->getId());
                                 $mission_leg->setFundId($request->getParameter('fund_id'));
                                 $mission_leg->setConfirmCode($request->getParameter('confirm_code'));
                                 $mission_leg->setFlightCost($request->getParameter('flight_cost'));
                                 $mission_leg->setCommOrigin($origin);
                                 $mission_leg->setCommDest($destinations[$i]);
                                 $mission_leg->setFlightNumber($flight_numbers[$i]);
                                 $v = $departures[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $v = $arrivals[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $mission_leg->setTransportation('commercial_mission');
                                 $mission_leg->setPrefix('com' . $comcount);
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                                 $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                                 return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             }
                             break;
                     }
                 }
             } else {
                 switch ($request->getParameter('transportation')) {
                     case 'air_mission':
                         $origin_airports = (array) $request->getParameter('origin_idents');
                         $dest_airports = (array) $request->getParameter('destination_idents');
                         $idents = $dest_airports;
                         $tmp_arr = array();
                         foreach ($origin_airports as $i => $ident) {
                             $idents[] = $ident;
                             $v = $ident . ' to ' . $dest_airports[$i];
                             if (in_array($v, $tmp_arr)) {
                                 $this->errors[] = 'Leg ' . $v . ' appeared more than one';
                             } else {
                                 $tmp_arr[] = $v;
                             }
                             if ($dest_airports[$i] == $ident) {
                                 $this->errors[] = 'Leg ' . $ident . ' to ' . $dest_airports[$i] . ' is invalid';
                             }
                         }
                         $idents = array_unique($idents);
                         $c = new Criteria();
                         $c->add(AirportPeer::IDENT, $idents, Criteria::IN);
                         if (count($idents) != AirportPeer::doCount($c)) {
                             $this->errors[] = 'Some airport idents are invalid';
                         }
                         break;
                     case 'ground_mission':
                         $origin = $request->getParameter('ground_origin');
                         $destination = $request->getParameter('ground_destination');
                         //echo $destination; die();
                         $orginset = $request->getParameter('orginset');
                         $destset = $request->getParameter('destset');
                         $this->destset = $destset;
                         $this->orginset = $orginset;
                         if (empty($destination) && empty($destset)) {
                             $this->errors[] = 'Please specify destination address';
                         }
                         if (empty($origin) && empty($orginset)) {
                             $this->errors[] = 'Please specify origin address';
                         } elseif ($destination == $origin && $destination != '') {
                             $this->errors[] = 'Origin and Destination addresses conflict';
                         }
                         break;
                     case 'commercial_mission':
                         $mission_date = $request->getParameter('mission_date');
                         if (empty($mission_date)) {
                             $this->errors[] = 'Mission date is required';
                         }
                         if ($v = $request->getParameter('airline_id')) {
                             $custom = $request->getParameter('airline_custom');
                             if ($v == 'other') {
                                 if (empty($custom)) {
                                     $this->errors[] = 'Please type a new airline name!';
                                 }
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($v = $request->getParameter('airline_id'));
                                 if (!$airline instanceof Airline) {
                                     $this->errors[] = 'Please select airline!';
                                 }
                             }
                         } else {
                             $this->errors[] = 'Please select airline!';
                         }
                         break;
                     default:
                         $this->errors[] = 'Please select Transportation Type';
                 }
                 if (count($this->errors)) {
                     # error in form
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $this->origin_idents = $origin_airports;
                             $this->dest_idents = $dest_airports;
                             break;
                         case 'ground_mission':
                             break;
                         case 'commercial_mission':
                             break;
                     }
                 } else {
                     $missioncount = MissionLegPeer::getMaxLegNumber($mission->getId());
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $aircount = MissionLegPeer::getCountbyMissIdAndType($mission->getId(), 'air_mission');
                             for ($i = 0; $i < sizeof($origin_airports); $i++) {
                                 $airport_o = AirportPeer::getByIdent($origin_airports[$i]);
                                 $airport_d = AirportPeer::getByIdent($dest_airports[$i]);
                                 $missioncount++;
                                 $aircount++;
                                 $mission_leg = new MissionLeg();
                                 $mission_leg->setMissionId($mission->getId());
                                 $mission_leg->setLegNumber($missioncount);
                                 $mission_leg->setFromAirportId($airport_o->getId());
                                 $mission_leg->setToAirportId($airport_d->getId());
                                 $mission_leg->setPrefix('air' . $aircount);
                                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 $mission_leg->setPassOnBoard(0);
                                 $mission_leg->setTransportation('air_mission');
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                             }
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'ground_mission':
                             $groundcount = MissionLegPeer::getCountbyMissIdAndType($mission->getId(), 'ground_mission');
                             $mission_leg = new MissionLeg();
                             $orginsetsave = $request->getParameter('ground_origin');
                             if (empty($orginsetsave)) {
                                 $orginsetsave = $request->getParameter('orginset');
                             }
                             $destsetsave = $request->getParameter('ground_destination');
                             if (empty($destsetsave)) {
                                 $destsetsave = $request->getParameter('destset');
                             }
                             $groundcount++;
                             $missioncount++;
                             $sa = $missioncount;
                             $mission_leg->setMissionId($mission->getId());
                             $mission_leg->setLegNumber($sa);
                             $mission_leg->setPassOnBoard(0);
                             $mission_leg->setTransportation('ground_mission');
                             $mission_leg->setGroundOrigin($orginsetsave);
                             $mission_leg->setGroundDestination($destsetsave);
                             $mission_leg->setPrefix('g' . $groundcount);
                             $mission_leg->setCancelMissionLeg(1);
                             $mission_leg->save();
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'commercial_mission':
                             $comcount = MissionLegPeer::getCountbyMissIdAndType($mission->getId(), 'commercial_mission');
                             $flight_time = $request->getParameter('flight_time');
                             if (empty($flight_time['hour']) || empty($flight_time['minute'])) {
                                 $flight_time = null;
                             }
                             $airline_id = $request->getParameter('airline_id');
                             if ($airline_id == 'other') {
                                 $airline = new Airline();
                                 $airline->setName($request->getParameter('airline_custom'));
                                 $airline->save();
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($airline_id);
                                 $this->forward404Unless($airline);
                             }
                             $origins = $request->getParameter('origin');
                             $destinations = $request->getParameter('destination');
                             $flight_numbers = $request->getParameter('flight_number');
                             $departures = $request->getParameter('departure');
                             $arrivals = $request->getParameter('arrival');
                             $mission->setFlightTime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']);
                             $missioncount++;
                             $n_leg = $missioncount;
                             foreach ($origins as $i => $origin) {
                                 if (empty($origin) || empty($destinations[$i])) {
                                     continue;
                                 }
                                 $mission_leg = new MissionLeg();
                                 $comcount++;
                                 $mission_leg->setMissionId($mission->getId());
                                 $mission_leg->setLegNumber($n_leg++);
                                 $mission_leg->setFlightTime($flight_time ? strtotime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']) : null);
                                 $mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 $mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 $mission_leg->setAirlineId($airline->getId());
                                 $mission_leg->setFundId($request->getParameter('fund_id'));
                                 $mission_leg->setConfirmCode($request->getParameter('confirm_code'));
                                 $mission_leg->setFlightCost($request->getParameter('flight_cost'));
                                 $mission_leg->setCommOrigin($origin);
                                 $mission_leg->setCommDest($destinations[$i]);
                                 $mission_leg->setFlightNumber($flight_numbers[$i]);
                                 $v = $departures[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $v = $arrivals[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $mission_leg->setTransportation('commercial_mission');
                                 $mission_leg->setPrefix('com' . $comcount);
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                                 $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                                 return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             }
                             break;
                     }
                 }
             }
         }
     }
     if ($request->getParameter('id')) {
         //$this->itinerary = ItineraryPeer::retrieveByPK($request->getParameter('id'));
         //$this->mis  = MissionPeer::getMissionByItineraryId($this->itinerary->getId(), 'Home');
         //$mission = $this->mis;
         if (isset($mission)) {
             $this->mis_comment = $mission->getComment();
         }
         //$this->mis_legs = MissionLegPeer::getbyMissId($mission->getId());
         if ($mission2) {
             $this->mis2_legs = MissionLegPeer::getbyMissId($mission2->getId());
             $this->mist_comment = $mission2->getComment();
         }
         $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text'));
         $this->time_widget = new widgetFormTime();
         $this->airport_list = AirportPeer::getMappable();
         $this->ground_addresses = $this->getGroundAddresses();
         $this->airlines = AirlinePeer::doSelect(new Criteria());
         $this->funds = FundPeer::doSelect(new Criteria());
         $this->miss_ids = array();
         $c = 0;
         $count = 0;
         $count2 = 0;
         if (isset($this->itinerary)) {
             $this->missions = MissionPeer::getByItiId($this->itinerary->getId());
             if (isset($this->missions)) {
                 foreach ($this->missions as $mi) {
                     $this->miss_ids[$c] = $mi->getId();
                     $legs = MissionLegPeer::getbyMissId($mi->getId());
                 }
             }
         }
         $this->title = '#' . $this->itinerary->getId() . ' Itinerary Details';
     }
 }
Example #2
0
 /**
  * Mission Leg Edit
  * CODE: mission_leg_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $this->errors = array();
     // for validation
     $this->orig_set = '';
     $this->dest_set = '';
     if ($request->getParameter('id')) {
         $this->title = 'Edit Mission Leg';
         $this->leg = MissionLegPeer::retrieveByPK($request->getParameter('id'));
         if ($this->leg->getFromAirportId()) {
             $this->fromAirport = $this->leg->getAirportRelatedByFromAirportId();
         }
         if ($this->leg->getToAirportId()) {
             $this->toAirport = $this->leg->getAirportRelatedBytoAirportId();
         }
         if ($this->leg->getCoordinatorId()) {
             $this->coordinator = CoordinatorPeer::retrieveByPK($this->leg->getCoordinatorId());
         }
         //print_r($this->coordinator);
         if ($this->leg->getFboId()) {
             $this->fbo = FboPeer::retrieveByPK($this->leg->getFboId());
             $this->fbo_address = $this->leg->getFboId();
         }
         if ($this->leg->getBackupPilotId()) {
             $this->backup_pilot = PilotPeer::retrieveByPK($this->leg->getBackupPilotId());
             if (isset($this->backup_pilot) && $this->backup_pilot instanceof Pilot) {
                 $this->bp_person = $this->backup_pilot->getMember()->getPerson();
             }
         }
         if ($this->leg->getBackupCopilotId()) {
             $this->backup_co_pilot = PilotPeer::retrieveByPK($this->leg->getBackupCopilotId());
             if (isset($this->backup_co_pilot) && $this->backup_co_pilot instanceof Pilot) {
                 $this->bp_co_person = $this->backup_co_pilot->getMember()->getPerson();
             }
         }
         if ($this->leg->getWaiverReceived()) {
             $this->waiver_rec = $this->leg->getWaiverReceived();
         } else {
             $this->waiver_rec = '';
         }
         if ($this->leg->getFboAddressNew()) {
             $this->new_fbo_address = $this->leg->getFboAddressNew();
         } else {
             $this->new_fbo_address = '';
         }
         $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text'));
         $this->forward404Unless($this->leg);
         $this->mission = $this->leg->getMission();
         $this->passenger = $this->mission->getPassenger();
         $this->person = $this->passenger->getPerson();
         $this->member = MemberPeer::getByPersonId($this->person->getId());
         /*echo "<pre>";
           print_r($this->member );
           */
         /*
          if(isset($this->member) && $this->member instanceof Member){
          $this->pilot = PilotPeer::getByMemberId($this->member->getId());
          }
          /*
          if(isset($this->leg) && $this->leg instanceof MissionLeg){
          $this->pilot = PilotPeer::retrieveByPK($this->leg->getPilotId());
          }
         *
         */
         if (isset($this->leg) && $this->leg instanceof MissionLeg) {
             if ($this->leg->getPilotId()) {
                 $this->pilot = PilotPeer::retrieveByPK($this->leg->getPilotId());
                 $this->pilot_member = MemberPeer::retrieveByPK($this->pilot->getMemberId());
                 $this->copilot = PilotPeer::retrieveByPK($this->leg->getCoPilotId());
                 //echo "<pre>";
                 //print_r($this->mission_assistant);
                 $this->back_up_mission_assistant = PilotPeer::retrieveByPK($this->leg->getBackupMissAssisId());
             }
             if ($this->leg->getMissAssisId()) {
                 $this->mission_assistant = PilotPeer::getByMemberId($this->leg->getMissAssisId());
             }
         }
         //echo "<pre>";
         //print_r($this->pilot_member);
         $is_pilot_requested = PilotRequestPeer::getByLegId($this->leg->getId());
         if (isset($is_pilot_requested) && $is_pilot_requested instanceof PilotRequest) {
             $this->p_req = $is_pilot_requested;
         }
         /*
          echo "<pre>";
          print_r($this->person->getId());
          die();
         */
         $this->forward404Unless($this->mission);
         $mission_id = $this->mission->getId();
     } else {
         $this->title = 'Add Mission Leg';
         $this->leg = new MissionLeg();
         $mission_id = $request->hasParameter('mis') ? $request->getParameter('mis') : $request->getParameter('mission_id');
         $this->mission = MissionPeer::retrieveByPK($mission_id);
         $this->forward404Unless($this->mission);
     }
     if ($request->isMethod('post')) {
         if ($request->getParameter('transportation') == 'air_mission') {
             # AIR MISSION
             if ($request->getParameter('orgin_airport')) {
                 $o_airport = AirportPeer::getByIdent($request->getParameter('orgin_airport'));
                 if (!$o_airport instanceof Airport) {
                     $this->errors[] = 'Origin airport not found in database';
                 }
             } else {
                 $this->errors[] = 'Please specify origin airport';
             }
             if ($request->getParameter('dest_airport')) {
                 $d_airport = AirportPeer::getByIdent($request->getParameter('dest_airport'));
                 if (!$d_airport instanceof Airport) {
                     $this->errors[] = 'Destination airport not found in database';
                 }
             } else {
                 $this->errors[] = 'Please specify destination airport';
             }
             if (count($this->errors) == 0) {
                 $mission_leg = $this->leg;
                 $mission_leg->setMissionId($mission_id);
                 $mission_leg->setCancelled($request->getParameter('cancelled'));
                 if ($mission_leg->isNew()) {
                     $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($mission_id) + 1);
                 }
                 $mission_leg->setFromAirportId($o_airport->getId());
                 $mission_leg->setToAirportId($d_airport->getId());
                 $o_air = AirportPeer::retrieveByPK($o_airport->getId());
                 $d_air = AirportPeer::retrieveByPK($d_airport->getId());
                 $distances = MissionLegPeer::getDistance($o_air->getIdent(), $d_air->getIdent());
                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                 $mission_leg->setPassOnBoard(0);
                 $mission_leg->setTransportation('air_mission');
                 $mission_leg->save();
                 $id = $mission_leg->getId();
                 $leg = MissionLegPeer::retrieveByPK($id);
                 $leg->setReverseFrom($id);
                 $leg->save();
             }
         } elseif ($request->getParameter('transportation') == 'ground_mission') {
             # GROUND MISSION
             $origin = $request->getParameter('ground_origin');
             $destination = $request->getParameter('ground_destination');
             $orgintset = $request->getParameter('orig_set');
             $desttset = $request->getParameter('dest_set');
             $fbo_address = $request->getParameter('fbo_address');
             $this->orig_set = $orgintset;
             $this->dest_set = $desttset;
             $this->fbo_address = $fbo_address;
             if (empty($destination) && empty($desttset)) {
                 $this->errors[] = 'Please specify destination address';
             }
             if (empty($origin) && empty($orgintset)) {
                 $this->errors[] = 'Please specify origin address';
             } elseif ($destination == $origin && $destination != '') {
                 $this->errors[] = 'Origin and Destination addresses conflict';
             }
             if (empty($fbo_address)) {
                 $this->errors[] = 'Please specify FBO name';
             }
             if (count($this->errors) == 0) {
                 $mission_leg = $this->leg;
                 $mission_leg->setMissionId($mission_id);
                 if ($mission_leg->isNew()) {
                     $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($mission_id) + 1);
                 }
                 $mission_leg->setPassOnBoard(0);
                 $mission_leg->setTransportation('ground_mission');
                 //get addresses by type
                 $p = $this->passenger = $this->mission->getPassenger();
                 if ($p instanceof Passenger) {
                     $this->person = $p->getPerson();
                 }
                 $this->ground_addresses = array('patient' => '', 'facility' => '', 'lodging' => '');
                 $orgintsetsave = $request->getParameter('ground_origin');
                 if (empty($orgintsetsave)) {
                     $orgintsetsave = $request->getParameter('orig_set');
                 }
                 $desttsetsave = $request->getParameter('ground_destination');
                 if (empty($desttsetsave)) {
                     $desttsetsave = $request->getParameter('dest_set');
                 }
                 $mission_leg->setGroundOrigin($orgintsetsave);
                 $mission_leg->setGroundDestination($desttsetsave);
                 $mission_leg->setFboId($fbo_address);
                 //ziyed
                 $fbo_address_new = $request->getParameter('fbo_address_new');
                 $mission_leg->setFboAddressNew($fbo_address_new);
                 //end ziyed
                 $mission_leg->save();
                 $id = $mission_leg->getId();
                 $leg = MissionLegPeer::retrieveByPK($id);
                 $leg->setReverseFrom($id);
                 $leg->save();
             }
         } elseif ($request->getParameter('transportation') == 'commercial_mission') {
             # COMMERCIAL MISSION
             $airline_id = $request->getParameter('airline_id');
             if ($airline_id) {
                 $custom = $request->getParameter('airline_custom');
                 if ($airline_id == 'other') {
                     if (empty($custom)) {
                         $this->errors[] = 'Please type a new airline name!';
                     }
                 } else {
                     $airline = AirlinePeer::retrieveByPK($airline_id = $request->getParameter('airline_id'));
                     if (!$airline instanceof Airline) {
                         $this->errors[] = 'Please select airline!';
                     }
                 }
             } else {
                 $this->errors[] = 'Please select airline!';
             }
             $origin = $request->getParameter('origin');
             $destination = $request->getParameter('destination');
             if (empty($origin)) {
                 $this->errors[] = 'Please specify origin';
             }
             if (empty($destination)) {
                 $this->errors[] = 'Please specify destination';
             }
             if (count($this->errors) == 0) {
                 $flight_time = $request->getParameter('flight_time');
                 if (empty($flight_time['hour']) || empty($flight_time['minute'])) {
                     $flight_time = null;
                 }
                 $airline_id = $request->getParameter('airline_id');
                 if ($airline_id == 'other') {
                     $airline = new Airline();
                     $airline->setName($request->getParameter('airline_custom'));
                     $airline->save();
                 } else {
                     $airline = AirlinePeer::retrieveByPK($airline_id);
                     $this->forward404Unless($airline);
                 }
                 $flight_number = $request->getParameter('flight_number');
                 $departure = $request->getParameter('departure');
                 $arrival = $request->getParameter('arrival');
                 $mission_leg = $this->leg;
                 $mission_leg->setMissionId($this->mission->getId());
                 if ($mission_leg->isNew()) {
                     $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($mission_id) + 1);
                 }
                 $mission_leg->setFlightTime($flight_time ? strtotime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']) : null);
                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                 $mission_leg->setAirlineId($airline->getId());
                 $mission_leg->setFundId($request->getParameter('fund_id'));
                 $mission_leg->setConfirmCode($request->getParameter('confirm_code'));
                 $mission_leg->setFlightCost($request->getParameter('flight_cost'));
                 $mission_leg->setCommOrigin($origin);
                 $mission_leg->setCommDest($destination);
                 $mission_leg->setFlightNumber($flight_number);
                 $v = $departure;
                 if (empty($v[0]['hour']) || empty($v[0]['minute'])) {
                     $v = null;
                 }
                 $mission_leg->setDeparture($v ? strtotime($v[0]['hour'] . ':' . $v[0]['minute'] . ' ' . $v[0]['period']) : null);
                 $v = $arrival;
                 if (empty($v[0]['hour']) || empty($v[0]['minute'])) {
                     $v = null;
                 }
                 $mission_leg->setArrival($v ? strtotime($v[0]['hour'] . ':' . $v[0]['minute'] . ' ' . $v[0]['period']) : null);
                 $mission_leg->setTransportation('commercial_mission');
                 $mission_leg->save();
             }
         } else {
             $this->forward404();
         }
         if (count($this->errors) == 0) {
             $this->getUser()->setFlash('success', 'New Mission leg has successfully created!');
             if ($request->getParameter('add_another')) {
                 $this->redirect('@leg_create?mis=' . $this->mission->getId());
             } else {
                 $this->redirect('@mission_view?id=' . $this->mission->getId());
             }
         }
     }
     $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text'));
     //echo '<pre>';print_r($this->date_widget);
     $this->time_widget = new widgetFormTime();
     $this->airport_list = AirportPeer::getMappable();
     $this->airlines = AirlinePeer::doSelect(new Criteria());
     $this->funds = FundPeer::doSelect(new Criteria());
     $p = $this->passenger = $this->mission->getPassenger();
     if ($p instanceof Passenger) {
         $this->person = $p->getPerson();
     } else {
         unset($this->passenger);
     }
     $this->itinerary = $this->mission->getItinerary();
     //echo '<pre>';print_r($this->itinerary);
     // Pre-define addresses for ground missions
     $this->ground_addresses = array('patient' => '', 'facility' => '', 'lodging' => '', 'airport' => '');
     $this->ground_addr_sel = sfConfig::get('app_ground_address_type', array());
     if ($this->itinerary) {
         $this->ground_addresses['lodging'] = $this->ground_addresses['facility'] = $this->itinerary->getDestCity() . ', ' . $this->itinerary->getDestState();
     }
     if ($this->passenger) {
         $this->ground_addresses['lodging'] = $this->passenger->getLodgingName() . ' ' . $this->ground_addresses['lodging'];
         $this->ground_addresses['facility'] = $this->passenger->getFacilityName() . ' ' . $this->ground_addresses['facility'];
         $this->ground_addresses['patient'] = $this->person->getAddress1() . ' ' . $this->person->getAddress2() . ' ' . $this->person->getCity() . ', ' . $this->person->getState() . ' ' . $this->person->getZipcode();
     }
 }
Example #3
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(FundPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(FundPeer::DATABASE_NAME);
         $criteria->add(FundPeer::ID, $pks, Criteria::IN);
         $objs = FundPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #4
0
 /**
  * Mission
  * CODE: mission_create, mission_leg_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     #security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     if ($request->getParameter('add_passengers')) {
         $this->group_camp_id = $request->getParameter('add_passengers');
     }
     if ($request->getParameter('id')) {
     } else {
         if ($request->isMethod('post')) {
             $main_id = $request->getParameter('main_id');
             $row_id = $request->getParameter('row_id');
             $camp_id = $request->getParameter('camp_id');
             if (isset($row_id)) {
                 $fname = $request->getParameter('pass_fname' . $row_id);
                 $lname = $request->getParameter('pass_lname' . $row_id);
                 $location = $request->getParameter('pass_loc' . $row_id);
                 $note = $request->getParameter('pass_note' . $row_id);
                 $link = $request->getParameter('pass_link' . $row_id);
             } else {
                 $main_id = $request->getParameter('person_id');
                 $fname = $request->getParameter('pass_fname');
                 $lname = $request->getParameter('pass_lname');
                 $location = $request->getParameter('pass_loc');
                 $note = $request->getParameter('pass_note');
                 $link = $request->getParameter('link');
             }
             //echo var_dump($request->getParameter('link'));die();
             #create default Itinerary to passenger
             if (isset($main_id)) {
                 $is_passenger = PassengerPeer::getByPersonId($main_id);
                 if (!$is_passenger->getRequesterId() && $camp_id) {
                     $this->getUser()->setFlash('success', 'Passenger has no Requester. Requester must be selected before create a Mission!');
                     $this->redirect('@add_passengers?id=' . $camp_id);
                 }
                 $itinerary = new Itinerary();
                 if (isset($is_passenger) && $is_passenger instanceof Passenger) {
                     $itinerary->setDateRequested(date('y/m/d'));
                     $itinerary->setApointTime('Morning');
                     $itinerary->setPassengerId($is_passenger->getId());
                     $miss_type = MissionTypePeer::getName('Camp');
                     if (isset($miss_type) && $miss_type instanceof MissionType) {
                         $itinerary->setMissionTypeId($miss_type->getId());
                     }
                     if ($is_passenger->getRequesterId()) {
                         $pass_req = $is_passenger->getRequester();
                         if (isset($pass_req) && $pass_req) {
                             if (isset($pass_req) && $pass_req instanceof Requester) {
                                 $itinerary->setRequesterId($pass_req->getId());
                             }
                         }
                     }
                     if (isset($camp_id)) {
                         $camp = CampPeer::retrieveByPK($camp_id);
                         if (isset($camp) && $camp instanceof Camp) {
                             if ($camp->getAgencyId()) {
                                 $agency = $camp->getAgency();
                                 if (isset($agency) && $agency instanceof Agency) {
                                     $itinerary->setAgencyId($agency->getId());
                                 }
                             }
                         }
                     }
                     $itinerary->setCampId($camp_id);
                     $itinerary->save();
                     if (isset($itinerary) && $itinerary instanceof Itinerary) {
                         $this->redirect('@itinerary_detail?id=' . $itinerary->getId() . '&add_passengers=' . $camp_id);
                     }
                 }
             }
         }
     }
     $this->itinerary = ItineraryPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404Unless($this->itinerary);
     $itinerary =& $this->itinerary;
     $this->errors = array();
     if ($request->isMethod('post')) {
         # validation
         $mission_date = $request->getParameter('mission_date');
         if (empty($mission_date)) {
             $this->errors[] = 'Mission date is required';
         }
         $companions = (array) $request->getParameter('companions');
         if (count($companions)) {
             $c = new Criteria();
             $c->add(CompanionPeer::ID, $companions, Criteria::IN);
             $c->add(CompanionPeer::PASSENGER_ID, $this->itinerary->getPassengerId());
             if (CompanionPeer::doCount($c) != count($companions)) {
                 $this->errors[] = 'Some companions not found';
             }
         }
         #use it when add group mission
         $group_camp_id = $request->getParameter('add_passengers');
         switch ($request->getParameter('transportation')) {
             case 'air_mission':
                 $origin_airports = (array) $request->getParameter('origin_idents');
                 $dest_airports = (array) $request->getParameter('destination_idents');
                 $idents = $dest_airports;
                 $tmp_arr = array();
                 foreach ($origin_airports as $i => $ident) {
                     $idents[] = $ident;
                     $v = $ident . ' to ' . $dest_airports[$i];
                     if (in_array($v, $tmp_arr)) {
                         $this->errors[] = 'Leg ' . $v . ' appeared more than one';
                     } else {
                         $tmp_arr[] = $v;
                     }
                     if ($dest_airports[$i] == $ident) {
                         $this->errors[] = 'Leg ' . $ident . ' to ' . $dest_airports[$i] . ' is invalid';
                     }
                 }
                 $idents = array_unique($idents);
                 $c = new Criteria();
                 $c->add(AirportPeer::IDENT, $idents, Criteria::IN);
                 if (count($idents) != AirportPeer::doCount($c)) {
                     $this->errors[] = 'Some airport idents are invalid';
                 }
                 break;
             case 'ground_mission':
                 $origin = $request->getParameter('ground_origin');
                 $destination = $request->getParameter('ground_destination');
                 if (empty($destination)) {
                     $this->errors[] = 'Please specify destination address';
                 }
                 if (empty($origin)) {
                     $this->errors[] = 'Please specify origin address';
                 } elseif ($destination == $origin) {
                     $this->errors[] = 'Origin and Destination addresses conflict';
                 }
                 break;
             case 'commercial_mission':
                 if ($v = $request->getParameter('airline_id')) {
                     $custom = $request->getParameter('airline_custom');
                     if ($v == 'other') {
                         if (empty($custom)) {
                             $this->errors[] = 'Please type a new airline name!';
                         }
                     } else {
                         $airline = AirlinePeer::retrieveByPK($v = $request->getParameter('airline_id'));
                         if (!$airline instanceof Airline) {
                             $this->errors[] = 'Please select airline!';
                         }
                     }
                 } else {
                     $this->errors[] = 'Please select airline!';
                 }
                 break;
             default:
                 $this->errors[] = 'Please select Transportation Type';
         }
         if (count($this->errors)) {
             # error in form
             switch ($request->getParameter('transportation')) {
                 case 'air_mission':
                     $this->origin_idents = $origin_airports;
                     $this->dest_idents = $dest_airports;
                     break;
                 case 'ground_mission':
                     break;
                 case 'commercial_mission':
                     break;
             }
             $this->selected_companions = $companions;
         } else {
             # Create Mission
             $mission = new Mission();
             $mission->setItineraryId($itinerary->getId());
             $mission->setMissionTypeId($itinerary->getMissionTypeId());
             $mission->setDateRequested($itinerary->getDateRequested());
             $mission->setPassengerId($itinerary->getPassengerId());
             $mission->setRequesterId($itinerary->getRequesterId());
             $mission->setCampId($itinerary->getCampId());
             $mission->setMissionDate(strtotime($request->getParameter('mission_date')));
             $mission->setMissionSpecificComments($request->getParameter('comment'));
             $mission->save();
             # Create Companions
             foreach ($companions as $id) {
                 $mission_companion = new MissionCompanion();
                 $mission_companion->setMissionId($mission->getId());
                 $mission_companion->setCompanionId($id);
                 $mission_companion->save();
             }
             # Create Legs
             switch ($request->getParameter('transportation')) {
                 case 'air_mission':
                     for ($i = 0; $i < sizeof($origin_airports); $i++) {
                         $airport_o = AirportPeer::getByIdent($origin_airports[$i]);
                         $airport_d = AirportPeer::getByIdent($dest_airports[$i]);
                         $mission_leg = new MissionLeg();
                         $mission_leg->setMissionId($mission->getId());
                         $mission_leg->setLegNumber($i + 1);
                         $mission_leg->setFromAirportId($airport_o->getId());
                         $mission_leg->setToAirportId($airport_d->getId());
                         $mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                         $mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                         $mission_leg->setPassOnBoard(0);
                         $mission_leg->setTransportation('air_mission');
                         $mission_leg->save();
                     }
                     $this->getUser()->setFlash('success', 'Mission and Leg(s) has successfully created!');
                     break;
                 case 'ground_mission':
                     $mission_leg = new MissionLeg();
                     $mission_leg->setMissionId($mission->getId());
                     $mission_leg->setLegNumber(1);
                     $mission_leg->setPassOnBoard(0);
                     $mission_leg->setTransportation('ground_mission');
                     $mission_leg->setGroundOrigin($request->getParameter('ground_origin'));
                     $mission_leg->setGroundDestination($request->getParameter('ground_destination'));
                     $mission_leg->save();
                     break;
                 case 'commercial_mission':
                     $flight_time = $request->getParameter('flight_time');
                     if (empty($flight_time['hour']) || empty($flight_time['minute'])) {
                         $flight_time = null;
                     }
                     $airline_id = $request->getParameter('airline_id');
                     if ($airline_id == 'other') {
                         $airline = new Airline();
                         $airline->setName($request->getParameter('airline_custom'));
                         $airline->save();
                     } else {
                         $airline = AirlinePeer::retrieveByPK($airline_id);
                         $this->forward404Unless($airline);
                     }
                     $origins = $request->getParameter('origin');
                     $destinations = $request->getParameter('destination');
                     $flight_numbers = $request->getParameter('flight_number');
                     $departures = $request->getParameter('departure');
                     $arrivals = $request->getParameter('arrival');
                     $mission->setFlightTime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']);
                     $n_leg = 0;
                     foreach ($origins as $i => $origin) {
                         if (empty($origin) || empty($destinations[$i])) {
                             continue;
                         }
                         $mission_leg = new MissionLeg();
                         $mission_leg->setMissionId($mission->getId());
                         $mission_leg->setLegNumber(++$n_leg);
                         $mission_leg->setFlightTime($flight_time ? strtotime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']) : null);
                         $mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                         $mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                         $mission_leg->setAirlineId($airline->getId());
                         $mission_leg->setFundId($request->getParameter('fund_id'));
                         $mission_leg->setConfirmCode($request->getParameter('confirm_code'));
                         $mission_leg->setFlightCost($request->getParameter('flight_cost'));
                         $mission_leg->setCommOrigin($origin);
                         $mission_leg->setCommDest($destinations[$i]);
                         $mission_leg->setFlightNumber($flight_numbers[$i]);
                         $v = $departures[$i];
                         if (empty($v['hour']) || empty($v['minute'])) {
                             $v = null;
                         }
                         $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                         $v = $arrivals[$i];
                         if (empty($v['hour']) || empty($v['minute'])) {
                             $v = null;
                         }
                         $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                         $mission_leg->setTransportation('commercial_mission');
                         $mission_leg->save();
                     }
                     break;
             }
             //        $this->redirect('@create_companion?id='.$mission_leg->getId());
             if (isset($group_camp_id)) {
                 $this->redirect('@mission_view?id=' . $mission->getId() . '&add_passengers=' . $group_camp_id);
             } else {
                 $this->redirect('@mission_view?id=' . $mission->getId());
             }
         }
     }
     $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text'));
     $this->time_widget = new widgetFormTime();
     $this->mission = MissionPeer::getByItineraryId($this->itinerary->getId());
     $this->airport_list = AirportPeer::getMappable();
     $this->ground_addresses = $this->getGroundAddresses();
     $this->airlines = AirlinePeer::doSelect(new Criteria());
     $this->funds = FundPeer::doSelect(new Criteria());
 }