コード例 #1
0
ファイル: BaseCompanion.php プロジェクト: yasirgit/afids
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPassenger !== null) {
             if ($this->aPassenger->isModified() || $this->aPassenger->isNew()) {
                 $affectedRows += $this->aPassenger->save($con);
             }
             $this->setPassenger($this->aPassenger);
         }
         if ($this->aPerson !== null) {
             if ($this->aPerson->isModified() || $this->aPerson->isNew()) {
                 $affectedRows += $this->aPerson->save($con);
             }
             $this->setPerson($this->aPerson);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CompanionPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CompanionPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CompanionPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collMissionCompanions !== null) {
             foreach ($this->collMissionCompanions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #2
0
ファイル: BaseCampPassenger.php プロジェクト: yasirgit/afids
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aCamp !== null) {
             if ($this->aCamp->isModified() || $this->aCamp->isNew()) {
                 $affectedRows += $this->aCamp->save($con);
             }
             $this->setCamp($this->aCamp);
         }
         if ($this->aPassenger !== null) {
             if ($this->aPassenger->isModified() || $this->aPassenger->isNew()) {
                 $affectedRows += $this->aPassenger->save($con);
             }
             $this->setPassenger($this->aPassenger);
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CampPassengerPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setNew(false);
             } else {
                 $affectedRows += CampPassengerPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * CODE: passenger_create
  */
 public function executeSave(sfWebRequest $request)
 {
     $passenger_session = $this->getUser()->getAttribute('passangers');
     $camp_id = $passenger_session['camp_id'];
     //    if (!$passenger_session)
     //    {
     //      return $this->forward('passanger', 'step3');
     //    }
     //save
     if ($passenger_session['sub_title'] === "Edit passenger") {
         //echo $passenger_session['sub_title'];die();
         $passenger = $passenger_session['passenger'];
         $success = 'Passenger information has been successfully edited!';
     } else {
         $passenger = new Passenger();
         $success = 'Passenger information has been successfully created!';
     }
     $passenger->setPersonId($passenger_session['person_id']);
     if ($passenger_session['passenger_type_id'] == 0) {
         $passenger->setPassengerTypeId(null);
     } else {
         $passenger->setPassengerTypeId($passenger_session['passenger_type_id']);
     }
     $passenger->setParent($passenger_session['parent']);
     $passenger->setDateOfBirth($passenger_session['date_of_birth']);
     $passenger->setWeight($passenger_session['weight']);
     $passenger->setIllness($passenger_session['illness']);
     if ($passenger_session['passenger_illness_category_id'] == 0) {
         $passenger->setPassengerIllnessCategoryId(null);
     } else {
         $passenger->setPassengerIllnessCategoryId($passenger_session['passenger_illness_category_id']);
     }
     $passenger->setLanguageSpoken($passenger_session['language_spoken']);
     $passenger->setBestContactMethod($passenger_session['best_contact_method']);
     $passenger->setFinancial($passenger_session['financial']);
     $passenger->setPublicConsiderations($passenger_session['public_considerations']);
     $passenger->setPrivateConsiderations($passenger_session['private_considerations']);
     $passenger->setGroundTransportationComment($passenger_session['ground_transportation_comment']);
     $passenger->setTravelHistoryNotes($passenger_session['travel_history_notes']);
     $passenger->setReleasingPhysician($passenger_session['releasing_physician']);
     $passenger->setReleasingPhone($passenger_session['releasing_phone']);
     $passenger->setReleasingFax1($passenger_session['releasing_fax1']);
     $passenger->setReleasingFax1Comment($passenger_session['releasing_fax1_comment']);
     $passenger->setReleasingEmail($passenger_session['releasing_email']);
     $passenger->setNeedMedicalRelease($passenger_session['need_medical_release']);
     $passenger->setMedicalReleaseRequested($passenger_session['medical_release_requested']);
     $passenger->setMedicalReleaseReceived($passenger_session['medical_release_received']);
     $passenger->setTreatingPhysician($passenger_session['treating_physician']);
     $passenger->setTreatingPhone($passenger_session['treating_phone']);
     //echo $passenger_session['treating_phone']; die();
     $passenger->setTreatingFax1($passenger_session['treating_fax1']);
     $passenger->setTreatingFax1Comment($passenger_session['treating_fax1_comment']);
     $passenger->setTreatingEmail($passenger_session['treating_email']);
     $passenger->setLanguageSpoken($passenger_session['language_spoken']);
     $passenger->setLodgingName($passenger_session['lodging_name']);
     $passenger->setLodgingPhone($passenger_session['lodging_phone']);
     $passenger->setLodgingPhoneComment($passenger_session['lodging_phone_comment']);
     $passenger->setFacilityName($passenger_session['facility_name']);
     $passenger->setFacilityCity($passenger_session['facility_city']);
     $passenger->setFacilityState($passenger_session['facility_state']);
     $passenger->setFacilityPhone($passenger_session['facility_phone']);
     $passenger->setFacilityPhoneComment($passenger_session['facility_phone_comment']);
     if ($passenger_session['requester_id'] == 0) {
         $passenger->setRequesterId(null);
     } else {
         $passenger->setRequesterId($passenger_session['requester_id']);
     }
     $passenger->setEmergencyContactName($passenger_session['emergency_contact_name']);
     $passenger->setEmergencyContactPrimaryPhone($passenger_session['emergency_contact_primary_phone']);
     $passenger->setEmergencyContactPrimaryComment($passenger_session['emergency_contact_primary_comment']);
     $passenger->setEmergencyContactSecondaryPhone($passenger_session['emergency_contact_secondary_phone']);
     $passenger->setEmergencyContactSecondaryComment($passenger_session['emergency_contact_secondary_comment']);
     $newPass = false;
     if ($passenger->isNew()) {
         $person = PersonPeer::retrieveByPK($passenger_session['person_id']);
         $content = $this->getUser()->getName() . ' added new Passenger: ' . $person->getFirstName();
         ActivityPeer::log($content);
         $newPass = true;
     }
     $passenger->save();
     //die("farazi");
     if ($newPass) {
         $passengerDest = new PassengerDest();
         $passengerDest->setPassengerId($passenger->getId());
         $passengerDest->setLodging($passenger_session['lodging_name']);
         $passengerDest->setFacility($passenger_session['facility_name']);
         $passengerDest->setFacilityCity($passenger_session['facility_city']);
         $passengerDest->setFacilityState($passenger_session['facility_state']);
         $passengerDest->setLodPhone($passenger_session['lodging_phone']);
         $passengerDest->setLodPhoneComment($passenger_session['lodging_phone_comment']);
         $passengerDest->setFacPhone($passenger_session['facility_phone']);
         $passengerDest->setFacilityPhoneComment($passenger_session['facility_phone_comment']);
         $passengerDest->save();
     }
     $return_path = $this->getUser()->getAttribute('return_path');
     if ($return_path) {
         $this->getUser()->setAttribute('return_path', null);
         $success = "Passenger information has been successfully created: Passenger lastname - " . $person->getLastName();
     }
     $this->getUser()->setFlash('success', $success);
     if ($this->getUser()->getAttribute('passangers')) {
         $pass = $this->getUser()->getAttribute('passangers');
         $back = $pass['back'];
         $last = $pass['referer'];
     }
     $back_url = 'passenger';
     //    if($last || $back){
     //      if(strstr($back,'@passenger_view')){
     //        if($passenger_session['person_id']){
     //          $back_url = '@passenger_view?id='.$passenger->getId();
     //        }
     //      }elseif(strstr($back,'@person_view')){
     //        $back_url = $back;
     //      }elseif(strstr($last,'/mission/view/')){
     //        $back_url = $last;
     //      }
     //    }
     if ($last) {
         $back_url = $last;
     }
     if ($back) {
         $back_url = $back;
     }
     if ($camp_id) {
         $campPassenger = new CampPassenger();
         $campPassenger->setCampId($camp_id);
         $campPassenger->setPassengerId($passenger->getId());
         $campPassenger->save();
         $this->redirect('/camp/view/id/' . $camp_id);
     }
     // redirecting blah
     if ($return_path) {
         $this->redirect($return_path);
     }
     //    echo var_dump($back_url);die();
     //removing used session like passenger data
     unset($passenger_session[$key]);
     $this->getUser()->setAttribute('passangers', $passenger_session);
     if (strstr($back_url, '/mission/view/')) {
         $this->redirect($back_url);
     }
     //echo $passenger->getId();
     //die("farazi");
     //$personId=$passenger_session['person_id'];
     //$urlGet="/person/view/".$personId;
     $passId = $passenger->getId();
     $urlGet = "/passenger/view/" . $passId;
     //die($urlGet);
     $this->redirect($urlGet);
 }
コード例 #4
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * missionRequests save all data into corresponding tables
  * CODE:mission_request_create
  */
 public function executeSave(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');
     }
     $miss_req_session = $this->getUser()->getAttribute('miss_req');
     if (!$miss_req_session) {
         return $this->forward('passenger', 'step3');
     }
     //set Requester Person
     $req_person = new Person();
     $req_person->setFirstName($miss_req_session->getReqFirstname());
     $req_person->setLastName($miss_req_session->getReqLastname());
     $req_person->setAddress1($miss_req_session->getReqAddress1());
     $req_person->setAddress2($miss_req_session->getReqAddress2());
     $req_person->setCity($miss_req_session->getReqCity());
     $req_person->setCounty($miss_req_session->getReqCounty());
     $req_person->setState($miss_req_session->getReqState());
     $req_person->setCountry($miss_req_session->getReqCountry());
     $req_person->setZipcode($miss_req_session->getReqZipcode());
     $req_person->setEmail($miss_req_session->getReqEmail());
     $req_person->setSecondaryEmail($miss_req_session->getReqSecondaryEmail());
     $req_person->setPagerEmail($miss_req_session->getReqPagerEmail());
     $req_person->setDayPhone($miss_req_session->getReqDayPhone());
     $req_person->setDayComment($miss_req_session->getReqDayComment());
     $req_person->setEveningPhone($miss_req_session->getReqEvePhone());
     $req_person->setEveningComment($miss_req_session->getReqEveComment());
     $req_person->setMobilePhone($miss_req_session->getReqMobilePhone());
     $req_person->setMobileComment($miss_req_session->getReqMobileComment());
     $req_person->setPagerPhone($miss_req_session->getReqPagerPhone());
     $req_person->setPagerComment($miss_req_session->getReqPagerComment());
     $req_person->setOtherPhone($miss_req_session->getReqOtherPhone());
     $req_person->setOtherComment($miss_req_session->getReqOtherComment());
     $req_person->save();
     //end of Requester Person
     // set Requester Agency
     $agency = AgencyPeer::getByNamePhone(trim($miss_req_session->getAgencyName()));
     if ($agency) {
         # nothing
     } else {
         $agency = new Agency();
         $agency->setName(trim($miss_req_session->getAgencyName()));
         $agency->save();
     }
     //set Requester
     $requester = new Requester();
     $requester->setPersonId($req_person->getId());
     $requester->setAgencyId($agency->getId());
     //$requester->setDischarge($miss_req_session->getReqDischarge());
     $requester->save();
     if (isset($miss_req_session->passenger_id)) {
         $passenger = PassengerPeer::retrieveByPK($miss_req_session->passenger_id);
         if (!$passenger instanceof Passenger) {
             $passenger = new Passenger();
         }
     } else {
         $passenger = new Passenger();
     }
     if ($passenger->isNew()) {
         $person = new Person();
     } else {
         $person = $passenger->getPerson();
     }
     //set Person to Passenger
     $person->setTitle($miss_req_session->getPassTitle());
     $person->setFirstName($miss_req_session->getPassFirstName());
     $person->setLastName($miss_req_session->getPassLastName());
     $person->setGender($miss_req_session->getPassGender());
     $person->setAddress1($miss_req_session->getPassAddress1());
     $person->setAddress2($miss_req_session->getPassAddress2());
     $person->setCity($miss_req_session->getPassCity());
     $person->setState($miss_req_session->getPassState());
     $person->setZipcode($miss_req_session->getPassZipcode());
     $person->setCountry($miss_req_session->getPassCountry());
     $person->setEmail($miss_req_session->getPassEmail());
     $person->setDayPhone($miss_req_session->getPassDayPhone());
     $person->setDayComment($miss_req_session->getPassDayComment());
     $person->setEveningPhone($miss_req_session->getPassEvePhone());
     $person->setEveningComment($miss_req_session->getPassEveComment());
     $person->setMobilePhone($miss_req_session->getPassMobilePhone());
     $person->setMobileComment($miss_req_session->getPassMobileComment());
     $person->setPagerPhone($miss_req_session->getPassPagerPhone());
     $person->setPagerComment($miss_req_session->getPassPagerComment());
     $person->setOtherPhone($miss_req_session->getPassOtherPhone());
     $person->setOtherComment($miss_req_session->getPassOtherComment());
     $person->save();
     //set Passenger
     $passenger->setPersonId($person->getId());
     $passenger->setPassengerTypeId($miss_req_session->getPassType());
     $passenger->setDateOfBirth($miss_req_session->getPassDateOfBirth());
     $passenger->setIllness($miss_req_session->getIllness());
     $passenger->setFinancial($miss_req_session->getFinancial());
     $passenger->setPublicConsiderations($miss_req_session->getPassPublicCons());
     $passenger->setPrivateConsiderations($miss_req_session->getPassPrivateCons());
     $passenger->setReleasingPhysician($miss_req_session->getReleasingPhysician());
     $passenger->setReleasingPhone($miss_req_session->getReleasePhone());
     $passenger->setReleasingFax1($miss_req_session->getReleaseFax());
     $passenger->setReleasingFax1Comment($miss_req_session->getReleaseFaxComment());
     $passenger->setLodgingName($miss_req_session->getLodgingName());
     $passenger->setLodgingPhone($miss_req_session->getLodgingPhone());
     $passenger->setLodgingPhoneComment($miss_req_session->getLodgingPhoneComment());
     $passenger->setFacilityName($miss_req_session->getFacilityName());
     $passenger->setFacilityPhone($miss_req_session->getFacilityPhone());
     $passenger->setFacilityPhoneComment($miss_req_session->getFacilityPhoneComment());
     $passenger->setReleasingEmail($miss_req_session->getReleaseEmail());
     $passenger->setTreatingPhysician($miss_req_session->getTreatingPhysician());
     $passenger->setTreatingPhone($miss_req_session->getTreatingPhone());
     $passenger->setTreatingFax1($miss_req_session->getTreatingFax());
     $passenger->setTreatingFax1Comment($miss_req_session->getTreatingFaxComment());
     $passenger->setTreatingEmail($miss_req_session->getTreatingEmail());
     $passenger->setLanguageSpoken($miss_req_session->getPassLanguage());
     $passenger->setBestContactMethod($miss_req_session->getBestContact());
     $passenger->setEmergencyContactName($miss_req_session->getEmergencyName());
     $passenger->setEmergencyContactPrimaryPhone($miss_req_session->getEmergencyPhone1());
     $passenger->setEmergencyContactPrimaryComment($miss_req_session->getEmergencyPhone1Comment());
     $passenger->setEmergencyContactSecondaryPhone($miss_req_session->getEmergencyPhone2());
     $passenger->setEmergencyContactSecondaryComment($miss_req_session->getEmergencyPhone2Comment());
     $passenger->setNeedMedicalRelease($miss_req_session->getPassMedical());
     $passenger->save();
     //set Companions
     if ($passenger && $miss_req_session->getCom1Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom1Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom1Phone());
         $person->setDayComment($miss_req_session->getCom1Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom1Name());
         $companion->setRelationship($miss_req_session->getCom1Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom1DateOfBirth());
         $companion->setWeight($miss_req_session->getCom1Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom1Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom1Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom2Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom2Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom2Phone());
         $person->setDayComment($miss_req_session->getCom2Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom2Name());
         $companion->setRelationship($miss_req_session->getCom2Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom2DateOfBirth());
         $companion->setWeight($miss_req_session->getCom2Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom2Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom2Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom3Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom3Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom3Phone());
         $person->setDayComment($miss_req_session->getCom3Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom3Name());
         $companion->setRelationship($miss_req_session->getCom3Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom3DateOfBirth());
         $companion->setWeight($miss_req_session->getCom3Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom3Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom3Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom4Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom4Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom4Phone());
         $person->setDayComment($miss_req_session->getCom4Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom4Name());
         $companion->setRelationship($miss_req_session->getCom4Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom4DateOfBirth());
         $companion->setWeight($miss_req_session->getCom4Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom4Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom4Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom5Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom5Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom5Phone());
         $person->setDayComment($miss_req_session->getCom5Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom5Name());
         $companion->setRelationship($miss_req_session->getCom5Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom5DateOfBirth());
         $companion->setWeight($miss_req_session->getCom5Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom5Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom5Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     //set Itinerary
     $itinerary = ItineraryPeer::getByMissReqId($miss_req_session->getId());
     if (!$itinerary) {
         $new_itinerary = new Itinerary();
         $new_itinerary->setDateRequested(date('m/d/Y'));
         $new_itinerary->setMissionRequestId($miss_req_session->getId());
         $new_itinerary->setMissionTypeId($miss_req_session->getMissionRequestTypeId());
         $new_itinerary->setApointTime($miss_req_session->getApptDate());
         $new_itinerary->setPassengerId($passenger->getId());
         $new_itinerary->setRequesterId($requester->getId());
         $new_itinerary->setFacility($miss_req_session->getFacilityName());
         $new_itinerary->setLodging($miss_req_session->getLodgingName());
         $new_itinerary->setOrginCity($miss_req_session->getOrginCity());
         $new_itinerary->setOrginState($miss_req_session->getOrginState());
         $new_itinerary->setDestCity($miss_req_session->getDestCity());
         $new_itinerary->setDestState($miss_req_session->getDestState());
         $new_itinerary->setWaiverNeed(0);
         $new_itinerary->setNeedMedicalRelease($miss_req_session->getPassMedical());
         $new_itinerary->setComment($miss_req_session->getComment());
         $new_itinerary->setAgencyId($agency->getId());
         $new_itinerary->save();
     }
     //set default Mission to Mission table
     //get Passenger
     //$passenger = PassengerPeer::getByPersonId($person->getId());
     $misson = new Mission();
     $misson->setRequestId($miss_req_session->getId());
     $misson->setItineraryId($new_itinerary->getId());
     $misson->setMissionTypeId($miss_req_session->getMissionRequestTypeId());
     $misson->setDateRequested($miss_req_session->getRequesterDate());
     if ($passenger) {
         $misson->setPassengerId($passenger->getId());
     }
     if ($requester) {
         $misson->setRequesterId($requester->getId());
     }
     if ($agency) {
         $misson->setAgencyId($agency->getId());
     }
     // Farazi Mission 1 externa ID
     $c = new Criteria();
     $c->add(MissionPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
     $c->addDescendingOrderByColumn(MissionPeer::ID);
     $external_mission = MissionPeer::doSelectOne($c);
     $external_id = $external_mission->getExternalId();
     $currentExternalId = $external_id + 1;
     $misson->setExternalId($currentExternalId);
     $misson->setApptDate($miss_req_session->getApptDate());
     $misson->setFlightTime($miss_req_session->getFlightTime());
     $misson->setMissionDate($miss_req_session->getMissionDate());
     $misson->setMissionCount(1);
     $misson->save();
     $missLeg = new MissionLeg();
     $missLeg->setMissionId($misson->getId());
     $missLeg->setLegNumber(1);
     if ($miss_req_session->getOrginState() && $miss_req_session->getOrginZipcode()) {
         //echo $miss_req_session->getOrginState().'-'.$miss_req_session->getOrginZipcode();die();
         $fromairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getOrginState(), $miss_req_session->getOrginZipcode());
         if ($fromairport) {
             $missLeg->setFromAirportId($fromairport->getId());
         }
     }
     if ($miss_req_session->getDestState() && $miss_req_session->getDestZipcode()) {
         //echo $miss_req_session->getDestState().'--'.$miss_req_session->getDestZipcode();die();
         $toairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getDestState(), $miss_req_session->getDestZipcode());
         if ($toairport) {
             $missLeg->setToAirportId($toairport->getId());
         }
     }
     //echo "oder";die();
     $missLeg->setPassOnBoard(0);
     $missLeg->setWebCoordinated(0);
     $missLeg->setTransportation('air_mission');
     $missLeg->save();
     //end set Mission
     $this->getUser()->setFlash('success', 'New mission has successfully created!');
     $miss_req_session->setProcessedDate(time());
     $miss_req_session->save();
     $this->getUser()->setAttribute('miss_req', null);
     //$this->redirect('miss_req');
     //$this->getUser()->setFlash('success',$success);
     //$request->getParameter('back')
     $this->redirect('/itinerary/detail/' . $new_itinerary->getId());
 }