Exemplo n.º 1
0
 protected function processStep3Check(sfWebRequest $request)
 {
     $default_airport = AirportPeer::getByIdent(sfConfig::get('app_default_airport_ident'));
     $this->forward404Unless($default_airport);
     $app = $this->application_temp;
     $person = $this->person;
     if (!$person instanceof Person) {
         $person = new Person();
     }
     /* @var $app ApplicationTemp */
     /* @var $person Person */
     // Person
     $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME);
     $tmp_arr['evening_phone'] = $tmp_arr['eve_phone'];
     $tmp_arr['evening_comment'] = $tmp_arr['eve_comment'];
     unset($tmp_arr['id']);
     $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME);
     $person->save();
     // Member
     $member = MemberPeer::getByPersonId($person->getId());
     if (!$member instanceof Member) {
         $member = new Member();
     }
     // Generate external id using last member is and external id
     $c = new Criteria();
     $c->add(MemberPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
     $c->addDescendingOrderByColumn(MemberPeer::ID);
     $external_member = MemberPeer::doSelectOne($c);
     $external_id = $external_member->getExternalId();
     $currentExternalId = $external_id + 1;
     //print_r($external_id);
     //print_r($currentExternalId);
     $member->setActive(1);
     $member->setCoPilot($app->getApplicantCopilot());
     $member->setContact('By Email');
     $member->setDateOfBirth($app->getDateOfBirth());
     $member->setDriversLicenseState($app->getDriversLicenseState());
     $member->setDriversLicenseNumber($app->getDriversLicenseNumber());
     $member->setEmergencyContactName($app->getEmergencyContactName());
     $member->setEmergencyContactPhone($app->getEmergencyContactPhone());
     $member->setFlightStatus($app->getApplicantPilot() ? 'Verify Orientation' : 'Non-pilot');
     $member->setJoinDate(time());
     $member->setLanguages($app->getLanguagesSpoken());
     //$member->setMasterMemberId($app->getMasterMemberId());
     $member->setMemberClassId($app->getMemberClassId());
     $member->setPersonId($person->getId());
     $member->setRenewedDate(time());
     $member->setRenewalDate(strtotime('+1 year'));
     $member->setSpouseName($app->getSpouseFirstName() . ' ' . $app->getSpouseLastName());
     //external_id generate
     $member->setExternalId($currentExternalId);
     $member->setWingId($app->getWingId());
     $member->save();
     // Pilot
     if ($app->getApplicantPilot()) {
         $pilot = new Pilot();
         $pilot->setMemberId($member->getId());
         $airport = AirportPeer::getByIdent($app->getHomeBase());
         if (!$airport instanceof Airport) {
             $airport = $default_airport;
         }
         $pilot->setPrimaryAirportId($airport->getId());
         $pilot->setTotalHours($app->getTotalHours());
         $pilot->setLicenseType('Private');
         foreach (sfConfig::get('app_pilot_license_types') as $key => $val) {
             if (stripos($app->getRatings(), $key) !== false) {
                 $pilot->setLicenseType($key);
             }
         }
         $pilot->setIfr(stripos($app->getRatings(), 'ifr') !== false ? 1 : 0);
         $pilot->setMultiEngine(stripos($app->getRatings(), 'multi') !== false ? 1 : 0);
         $pilot->setSeInstructor('No');
         // @see ApplicationForm
         foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) {
             if (stripos($app->getRatings(), $key) !== false) {
                 $pilot->setSeInstructor($key);
             }
         }
         $pilot->setMeInstructor($pilot->getSeInstructor());
         $pilot->save();
         // Availability
         $availability = new Availability();
         $availability->setMemberId($member->getId());
         $availability->setNotAvailable(0);
         $availability->setNoWeekday($app->getAvailabilityWeekdays() == 0);
         $availability->setNoNight($app->getAvailabilityWeeknights() == 0);
         $availability->setLastMinute($app->getAvailabilityLastMinute());
         $availability->setAsMissionMssistant($app->getAvailabilityCopilot());
         $availability->setNoWeekend($app->getAvailabilityWeekends() == 0);
         try {
             $availability->save();
         } catch (Exception $e) {
         }
         // Primary aircraft
         if ($app->getAircraftPrimaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftPrimaryId()))) {
             $pilot_aircraft = new PilotAircraft();
             $pilot_aircraft->setMemberId($member->getId());
             $pilot_aircraft->setAircraftId($aircraft->getId());
             $pilot_aircraft->setNNumber($app->getAircraftPrimaryNNumber());
             $pilot_aircraft->setOwn($app->getAircraftPrimaryOwn());
             $pilot_aircraft->setSeats($app->getAircraftPrimarySeats());
             $pilot_aircraft->setKnownIce($app->getAircraftPrimaryIce());
             $pilot_aircraft->save();
         }
         // Secondary aircraft
         if ($app->getAircraftSecondaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftSecondaryId()))) {
             $pilot_aircraft = new PilotAircraft();
             $pilot_aircraft->setMemberId($member->getId());
             $pilot_aircraft->setAircraftId($aircraft->getId());
             $pilot_aircraft->setNNumber($app->getAircraftSecondaryNNumber());
             $pilot_aircraft->setOwn($app->getAircraftSecondaryOwn());
             $pilot_aircraft->setSeats($app->getAircraftSecondarySeats());
             $pilot_aircraft->setKnownIce($app->getAircraftSecondaryIce());
             $pilot_aircraft->save();
         }
         // Third aircraft
         if ($app->getAircraftThirdId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftThirdId()))) {
             $pilot_aircraft = new PilotAircraft();
             $pilot_aircraft->setMemberId($member->getId());
             $pilot_aircraft->setAircraftId($aircraft->getId());
             $pilot_aircraft->setNNumber($app->getAircraftThirdNNumber());
             $pilot_aircraft->setOwn($app->getAircraftThirdOwn());
             $pilot_aircraft->setSeats($app->getAircraftThirdSeats());
             $pilot_aircraft->setKnownIce($app->getAircraftThirdIce());
             $pilot_aircraft->save();
         }
     }
     // Application_temp
     $app->setPersonId($person->getId());
     $app->setMemberId($member->getId());
     $app->setProcessedDate(time());
     $app->save();
     // Application
     $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME);
     $tmp_arr['date'] = $tmp_arr['application_date'];
     $tmp_arr['company'] = $tmp_arr['company_name'];
     foreach (sfConfig::get('app_pilot_license_types') as $key => $val) {
         if (stripos($tmp_arr['ratings'], $key) !== false) {
             $tmp_arr['license_type'] = $key;
         }
     }
     $tmp_arr['ifr'] = stripos($tmp_arr['ratings'], 'ifr') !== false ? 1 : 0;
     $tmp_arr['multi_engine'] = stripos($tmp_arr['ratings'], 'multi') !== false ? 1 : 0;
     $tmp_arr['se_instructor'] = 'No';
     // @see ApplicationForm
     foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) {
         if (stripos($tmp_arr['ratings'], $key) !== false) {
             $tmp_arr['se_instructor'] = $key;
         }
     }
     $tmp_arr['me_instructor'] = $tmp_arr['se_instructor'];
     $tmp_arr['other_ratings'] = $tmp_arr['ratings'];
     $tmp_arr['fbo'] = $tmp_arr['fbo_name'];
     $tmp_arr['member_meetings'] = 0;
     $tmp_arr['executive_board'] = 0;
     $tmp_arr['dues_amount_paid'] = $tmp_arr['dues_amount_paid'] ? $tmp_arr['dues_amount_paid'] : 0;
     unset($tmp_arr['id']);
     $application = new Application();
     $application->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME);
     $application->save();
     $where = $request->getParameter('step3_redirect');
     //Ziyed  save default role for new member
     $appTemp = $this->application_temp;
     if ($appTemp->getPersonId()) {
         $person_role = new PersonRole();
         $person_role->setPersonId($appTemp->getPersonId());
         if ($appTemp->getApplicantPilot() == 1) {
             $person_role->setRoleId(27);
         } else {
             $person_role->setRoleId(31);
         }
         $person_role->save();
     }
     //Ziyed end save
     if ($where == 1) {
         $this->redirect('@member_view?id=' . $member->getId());
     } else {
         /*
                     if ($application->getEmail()) {
                         # send email failure to payment
                         $this->getComponent('mail', 'memberApplicationProcessed', array('email' => $application->getEmail(),'member_id'=>$member->getId(), 'name' => $application->getFirstName() . ' ' . $application->getLastName()));
         
                     }*/
         $this->redirect('pending_member/processComplete?id=' . $member->getId());
     }
 }
Exemplo n.º 2
0
 protected function processStep3Check(sfWebRequest $request)
 {
     $default_airport = AirportPeer::getByIdent(sfConfig::get('app_default_airport_ident'));
     $this->forward404Unless($default_airport);
     $app = $this->application_temp;
     $person = $this->person;
     if (!$person instanceof Person) {
         $person = new Person();
     }
     /* @var $app ApplicationTemp */
     /* @var $person Person */
     // Person
     $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME);
     $tmp_arr['evening_phone'] = $tmp_arr['eve_phone'];
     $tmp_arr['evening_comment'] = $tmp_arr['eve_comment'];
     unset($tmp_arr['id']);
     $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME);
     $person->save();
     // Member
     $member = MemberPeer::retrieveByPK($app->getMemberId());
     if (!$member instanceof Member) {
         $member = new Member();
     }
     $member->setActive(1);
     $member->setCoPilot($app->getApplicantCopilot());
     $member->setContact('By Email');
     $member->setDateOfBirth($app->getDateOfBirth());
     $member->setDriversLicenseState($app->getDriversLicenseState());
     $member->setDriversLicenseNumber($app->getDriversLicenseNumber());
     $member->setEmergencyContactName($app->getEmergencyContactName());
     $member->setEmergencyContactPhone($app->getEmergencyContactPhone());
     $member->setFlightStatus($app->getApplicantPilot() ? 'Verify Orientation' : 'Non-pilot');
     //$member->setJoinDate(time());
     $member->setLanguages($app->getLanguagesSpoken());
     //Farazi
     //$member->setMasterMemberId($app->getMasterMemberId());
     // Get Last renewal date
     $this->member = MemberPeer::retrieveByPK($app->getMemberId());
     $lastRenewalDate = strtotime($this->member->getRenewalDate());
     $member->setMemberClassId($app->getMemberClassId());
     $member->setPersonId($person->getId());
     $member->setRenewedDate(time());
     ///Farazi Renewal Date From Memberclass
     if ($app->getMemberClassId()) {
         $memclass = MemberClassPeer::retrieveByPK($app->getMemberClassId());
         $renewal_period = $memclass->getRenewalPeriod();
         $renewalTime = strtotime('+' . $renewal_period . ' month', $lastRenewalDate);
         //echo $renewalTime;
         $member->setRenewalDate($renewalTime);
         //$member->setRenewalDate(strtotime('+'.$renewal_period.' month'));
     }
     // Farazi End
     //$member->setRenewalDate(strtotime('+1 year'));
     $member->setSpouseName($app->getSpouseFirstName() . ' ' . $app->getSpouseLastName());
     $member->setWeight($app->getWeight());
     $member->setWingId($app->getWingId());
     $member->save();
     // Pilot
     if ($app->getApplicantPilot()) {
         $pilot = $member->getPilot();
         if (!$pilot instanceof Pilot) {
             $pilot = new Pilot();
         }
         if ($pilot->isNew()) {
             // remove aircrafts
             foreach ($member->getPilotAircrafts() as $p_a) {
                 PilotAircraftPeer::doDelete($p_a);
             }
         }
         $pilot->setMemberId($member->getId());
         $airport = AirportPeer::getByIdent($app->getHomeBase());
         if (!$airport instanceof Airport) {
             $airport = $default_airport;
         }
         $pilot->setPrimaryAirportId($airport->getId());
         $pilot->setTotalHours($app->getTotalHours());
         $pilot->setLicenseType('Private');
         foreach (sfConfig::get('app_pilot_license_types') as $key => $val) {
             if (stripos($app->getRatings(), $key) !== false) {
                 $pilot->setLicenseType($key);
             }
         }
         $pilot->setIfr(stripos($app->getRatings(), 'ifr') !== false ? 1 : 0);
         $pilot->setMultiEngine(stripos($app->getRatings(), 'multi') !== false ? 1 : 0);
         $pilot->setSeInstructor('No');
         // @see ApplicationForm
         foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) {
             if (stripos($app->getRatings(), $key) !== false) {
                 $pilot->setSeInstructor($key);
             }
         }
         $pilot->setMeInstructor($pilot->getSeInstructor());
         $pilot->save();
         // Availability
         $availability = $member->getAvailability();
         if (!$availability instanceof Availability) {
             $availability = new Availability();
         }
         $availability->setMemberId($member->getId());
         $availability->setNotAvailable(0);
         $availability->setNoWeekday($app->getAvailabilityWeekdays() == 0);
         $availability->setNoNight($app->getAvailabilityWeeknights() == 0);
         $availability->setLastMinute($app->getAvailabilityLastMinute());
         $availability->setAsMissionMssistant($app->getAvailabilityCopilot());
         $availability->setNoWeekend($app->getAvailabilityWeekends() == 0);
         $availability->save();
         //Farazi
         //Delete all aircrafts
         $pilot_aircrafts = PilotAircraftPeer::getByMemberId($member->getId());
         foreach ($pilot_aircrafts as $pilot_aircraft) {
             $pilot_aircraft->delete();
         }
         // Primary aircraft
         if ($app->getAircraftPrimaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftPrimaryId()))) {
             $pilot_aircraft = new PilotAircraft();
             $pilot_aircraft->setMemberId($member->getId());
             $pilot_aircraft->setAircraftId($aircraft->getId());
             $pilot_aircraft->setNNumber($app->getAircraftPrimaryNNumber());
             $pilot_aircraft->setOwn($app->getAircraftPrimaryOwn());
             $pilot_aircraft->setSeats($app->getAircraftPrimarySeats());
             $pilot_aircraft->setKnownIce($app->getAircraftPrimaryIce());
             $pilot_aircraft->save();
         }
         // Secondary aircraft
         if ($app->getAircraftSecondaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftSecondaryId()))) {
             $pilot_aircraft = new PilotAircraft();
             $pilot_aircraft->setMemberId($member->getId());
             $pilot_aircraft->setAircraftId($aircraft->getId());
             $pilot_aircraft->setNNumber($app->getAircraftSecondaryNNumber());
             $pilot_aircraft->setOwn($app->getAircraftSecondaryOwn());
             $pilot_aircraft->setSeats($app->getAircraftSecondarySeats());
             $pilot_aircraft->setKnownIce($app->getAircraftSecondaryIce());
             $pilot_aircraft->save();
         }
         // Third aircraft
         if ($app->getAircraftThirdId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftThirdId()))) {
             $pilot_aircraft = new PilotAircraft();
             $pilot_aircraft->setMemberId($member->getId());
             $pilot_aircraft->setAircraftId($aircraft->getId());
             $pilot_aircraft->setNNumber($app->getAircraftThirdNNumber());
             $pilot_aircraft->setOwn($app->getAircraftThirdOwn());
             $pilot_aircraft->setSeats($app->getAircraftThirdSeats());
             $pilot_aircraft->setKnownIce($app->getAircraftThirdIce());
             $pilot_aircraft->save();
         }
     }
     // Application_temp
     $app->setPersonId($person->getId());
     $app->setMemberId($member->getId());
     $app->setProcessedDate(time());
     $app->save();
     // Application
     $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME);
     $tmp_arr['date'] = $tmp_arr['application_date'];
     $tmp_arr['company'] = $tmp_arr['company_name'];
     foreach (sfConfig::get('app_pilot_license_types') as $key => $val) {
         if (stripos($tmp_arr['ratings'], $key) !== false) {
             $tmp_arr['license_type'] = $key;
         }
     }
     $tmp_arr['ifr'] = stripos($tmp_arr['ratings'], 'ifr') !== false ? 1 : 0;
     $tmp_arr['multi_engine'] = stripos($tmp_arr['ratings'], 'multi') !== false ? 1 : 0;
     $tmp_arr['se_instructor'] = 'No';
     // @see ApplicationForm
     foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) {
         if (stripos($tmp_arr['ratings'], $key) !== false) {
             $tmp_arr['se_instructor'] = $key;
         }
     }
     $tmp_arr['me_instructor'] = $tmp_arr['se_instructor'];
     $tmp_arr['other_ratings'] = $tmp_arr['ratings'];
     $tmp_arr['fbo'] = $tmp_arr['fbo_name'];
     $tmp_arr['member_meetings'] = 0;
     $tmp_arr['executive_board'] = 0;
     $tmp_arr['dues_amount_paid'] = $tmp_arr['dues_amount_paid'] ? $tmp_arr['dues_amount_paid'] : 0;
     $tmp_arr['donation_amount_paid'] = $tmp_arr['donation_amount_paid'] ? $tmp_arr['donation_amount_paid'] : 0;
     unset($tmp_arr['id']);
     $application = new Application();
     $application->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME);
     $application->save();
     $this->getUser()->setFlash('success', 'Membership renewal completed successfully.');
     //$this->redirect('renewal/processComplete?id='.$member->getId());
     $this->redirect('renewal/processStep3?id=' . $this->application_temp->getId());
     //$this->redirect('renewal/index?id='.$member->getId());
 }
Exemplo n.º 3
0
 /**
  * Add/edit a pilot
  * CODE: pilot_create
  */
 public function executeUpdate(sfWebRequest $request)
 {
     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');
     }
     if ($request->getParameter('member_id')) {
         $this->member = MemberPeer::retrieveByPK($request->getParameter('member_id'));
         $pilot = new Pilot();
         $this->title = 'Add Pilot';
     }
     if ($request->getParameter('id')) {
         $pilot = PilotPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($pilot);
         ///ziyed////
         $this->url = $request->getReferer();
         if (strstr($this->url, '/pilot/mopAdd')) {
             $this->title = 'Add mop pilot';
             $success = 'MOP information has been successfully added!';
         } else {
             $this->title = 'Edit pilot';
             $success = 'Pilot information has been successfully changed!';
             $this->current_region = $pilot->getMopRegionsServed();
             $this->mopservedby = $pilot->getMopServedBy();
         }
         ////end//////
         $this->member = MemberPeer::retrieveByPK($pilot->getMemberId());
         if ($pilot->getPrimaryAirportId()) {
             $this->airport_id = $pilot->getPrimaryAirportId();
         }
         $this->airports = AirportPeer::doSelect(new Criteria());
     } else {
         $pilot = new Pilot();
         $this->title = 'Add Pilot';
         $success = 'Pilot information has been successfully created!';
     }
     $this->airport = trim($this->getRequestParameter('airport', '*')) == '' ? '*' : trim($this->getRequestParameter('airport', '*'));
     if ($request->getParameter('leg')) {
         $this->leg_id = $request->getParameter('leg');
     }
     if ($request->getParameter('back')) {
         $this->backup = $request->getParameter('back');
     }
     if ($request->getParameter('co')) {
         $this->backup_co = $request->getParameter('co');
     }
     if ($request->getParameter('member')) {
         $this->member = MemberPeer::retrieveByPK($request->getParameter('member'));
     }
     $this->form = new PilotForm($pilot);
     $this->pilot = $pilot;
     $this->back = $request->getReferer();
     ///////////////////Update ///////////
     if ($request->isMethod('post')) {
         $this->referer = $request->getReferer();
         $this->form->bind($request->getParameter('pilo'));
         if ($this->form->isValid() && $this->form->getValue('license_type')) {
             if ($request->getParameter('member_id')) {
                 $pilot->setMemberId($request->getParameter('member_id'));
             }
             //TODO:Set Member Flight status to command pilot
             $set_member = MemberPeer::retrieveByPK($request->getParameter('member_id'));
             if ($set_member) {
                 $set_member->setFlightStatus('Command pilot');
                 $set_member->save();
             }
             if ($request->getParameter('airport') != null) {
                 $airport = AirportPeer::getByIdent($request->getParameter('airport'));
                 if (isset($airport) && $airport instanceof Airport) {
                     $pilot->setPrimaryAirportId($airport->getId());
                 }
             } else {
                 $pilot->setPrimaryAirportId(null);
                 $member = MemberPeer::retrieveByPK($request->getParameter('member_id'));
                 $member->setFlightStatus('Non-pilot');
                 $member->save();
             }
             $pilot->setSecondaryHomeBases($this->form->getValue('secondary_home_bases'));
             $pilot->setTotalHours($this->form->getValue('total_hours'));
             $pilot->setLicenseType($this->form->getValue('license_type'));
             if ($this->form->getValue('ifr') == null) {
                 $pilot->setIfr(0);
             } else {
                 $pilot->setIfr($this->form->getValue('ifr'));
             }
             if ($this->form->getValue('multi_engine') == null) {
                 $pilot->setMultiEngine(0);
             } else {
                 $pilot->setMultiEngine($this->form->getValue('multi_engine'));
             }
             $pilot->setSeInstructor($this->form->getValue('se_instructor'));
             $pilot->setMeInstructor($this->form->getValue('me_instructor'));
             $pilot->setOtherRatings($this->form->getValue('other_ratings'));
             $pilot->setInsuranceReceived($this->form->getValue('insurance_received'));
             //ziyed task
             $pilot->setOrientedDate($this->form->getValue('oriented_date'));
             $pilot->setMopOrientedDate($this->form->getValue('mop_oriented_date'));
             if ($request->getParameter('pilot_name')) {
                 $pilot->setMopServedBy($request->getParameter('pilot_name'));
             } else {
                 $pilot->setMopServedBy(NULL);
             }
             // $pilot->setMopRegionsServed($request->getParameter('mop_regions_served'));
             if ($request->getParameter('mop_regions_served')) {
                 $pilot->setMopRegionsServed($request->getParameter('mop_regions_served'));
             } else {
                 $a = null;
                 $pilot->setMopRegionsServed($a);
             }
             //$pilot->setOrientedMemberId($this->form->getValue('oriented_member_id'));
             //$pilot->setOrientedMemberId($this->form->getValue('mop_oriented_member_id'));
             //$pilot->setMopQualifications($this->form->getValue('mop_qualifications'));
             $pilot->setHseats($this->form->getValue('hseats'));
             if ($this->form->getValue('transplant') == 1) {
                 $pilot->setTransplant(1);
             } else {
                 $pilot->setTransplant(0);
             }
             $pilot->save();
             $this->getUser()->setFlash('success', $success);
             $last = $request->getParameter('back');
             $back_url = 'pilot';
             if (strstr($last, 'member/view')) {
                 $back_url = '@member_view?id=' . $request->getParameter('member_id');
             } elseif (strstr($last, 'pilot/view')) {
                 $back_url = '@pilot_view?id=' . $pilot->getId();
             } elseif (strstr($last, 'pilot/edit')) {
                 $back_url = '@pilot_view?id=' . $pilot->getId();
             } elseif (strstr($last, 'pilot/mopAdd')) {
                 $back_url = '/pilot/mopAdd';
             }
             if ($request->getParameter('leg_id')) {
                 $back_url = '@leg_edit?id=' . $request->getParameter('leg_id');
             }
             if ($request->getParameter('leg_id')) {
                 if ($request->getParameter('leg_id') && !$request->getParameter('backup')) {
                     $set_leg = MissionLegPeer::retrieveByPK($request->getParameter('leg_id'));
                     if (isset($set_leg) && $set_leg instanceof MissionLeg) {
                         $set_leg->setPilotId($pilot->getId());
                         $set_leg->save();
                         $this->getUser()->setFlash('success', 'Mission Leg #' . $set_leg->getId() . ' \\s Pilot has been set!');
                     }
                     $back_url = '@leg_edit?id=' . $request->getParameter('leg_id');
                 }
             }
             if ($request->getParameter('leg_id')) {
                 if ($request->getParameter('leg_id') && $request->getParameter('backup')) {
                     $set_leg = MissionLegPeer::retrieveByPK($request->getParameter('leg_id'));
                     if (isset($set_leg) && $set_leg instanceof MissionLeg) {
                         $set_leg->setBackupPilotId($pilot->getId());
                         $set_leg->save();
                         $this->getUser()->setFlash('success', 'Mission Leg #' . $set_leg->getId() . ' \\s Backup Pilot has been set!');
                     }
                     $back_url = '@leg_edit?id=' . $request->getParameter('leg_id');
                 }
             }
             if ($request->getParameter('leg_id')) {
                 if ($request->getParameter('leg_id') && $request->getParameter('backup_co')) {
                     $set_leg = MissionLegPeer::retrieveByPK($request->getParameter('leg_id'));
                     if (isset($set_leg) && $set_leg instanceof MissionLeg) {
                         $set_leg->setBackupCopilotId($request->getParameter('member_id'));
                         $set_leg->save();
                         $this->getUser()->setFlash('success', 'Mission Leg #' . $set_leg->getId() . ' \\s Backup Co-Pilot has been set!');
                     }
                     $back_url = '@leg_edit?id=' . $request->getParameter('leg_id');
                 }
             }
             return $this->redirect($back_url);
         } else {
             if (!$request->getParameter('id')) {
                 $info = 'Please confirm License type and choose Member !';
             } else {
                 $info = 'Please confirm License type !';
             }
             $this->getUser()->setFlash('success', $info);
         }
     } else {
         # Set referer URL
         $this->referer = $request->getReferer() ? $request->getReferer() : '@pilot';
     }
     $this->pilot = $pilot;
 }