$mission_assistant = MemberPeer::retrieveByPK($mission_leg->getMissAssisId());
    $miss_assi_persopn = PersonPeer::retrieveByPK($mission_assistant->getPersonId());
}
// Backup Pilot
if ($mission_leg->getBackupPilotId()) {
    $backupPilot = PilotPeer::retrieveByPK($mission_leg->getBackupPilotId());
    $backupPilotMember = $pilot->getMember();
    $backupPilot_person = PersonPeer::retrieveByPK($backupPilotMember->getPersonId());
}
/*
echo "<pre>";
print_r($pilotMember);
die();
//*/
//Companions information
$companions = CompanionPeer::getByPassId($passenger->getId());
if ($passenger) {
    $passenger_type = $passenger->getPassengerType();
}
$is_air = $mission_leg->getTransportation() == 'air_mission';
if ($is_air) {
    $to_airport = $mission_leg->getAirportRelatedByToAirportId();
    $from_airport = $mission_leg->getAirportRelatedByFromAirportId();
}
?>
<html xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
<title>Air Charity Network&trade; Mission Itinerary Form</title>
<style>
html {
Пример #2
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Person is new, it will return
  * an empty collection; or if this Person has previously
  * been saved, it will retrieve related Companions from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Person.
  */
 public function getCompanionsJoinPassenger($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PersonPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCompanions === null) {
         if ($this->isNew()) {
             $this->collCompanions = array();
         } else {
             $criteria->add(CompanionPeer::PERSON_ID, $this->id);
             $this->collCompanions = CompanionPeer::doSelectJoinPassenger($criteria, $con, $join_behavior);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(CompanionPeer::PERSON_ID, $this->id);
         if (!isset($this->lastCompanionCriteria) || !$this->lastCompanionCriteria->equals($criteria)) {
             $this->collCompanions = CompanionPeer::doSelectJoinPassenger($criteria, $con, $join_behavior);
         }
     }
     $this->lastCompanionCriteria = $criteria;
     return $this->collCompanions;
 }
Пример #3
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = CompanionPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPassengerId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setRelationship($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDateOfBirth($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setWeight($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setCompanionPhone($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setCompanionPhoneComment($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setPersonId($arr[$keys[8]]);
     }
 }
Пример #4
0
 /**
  * Get the associated Companion object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Companion The associated Companion object.
  * @throws     PropelException
  */
 public function getCompanion(PropelPDO $con = null)
 {
     if ($this->aCompanion === null && $this->companion_id !== null) {
         $c = new Criteria(CompanionPeer::DATABASE_NAME);
         $c->add(CompanionPeer::ID, $this->companion_id);
         $this->aCompanion = CompanionPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aCompanion->addMissionCompanions($this);
         		 */
     }
     return $this->aCompanion;
 }
Пример #5
0
                } elseif ($leg->getTransportation() == 'ground_mission') {
                    ?>
 <?php 
                    echo $leg->getGroundDestination();
                    ?>
				<?php 
                }
                ?>
 <em>PST</em></dd>
			</dl>
			</td>
			<td class="cell-3">
			<dl class="mission-ad-info">
				<dt>Passengers:</dt>
				<dd><?php 
                $comps = CompanionPeer::getByPassId($pass->getId());
                $county = 0;
                $weg = 0;
                foreach ($comps as $comp) {
                    $county++;
                    $weg = $weg + $comp->getWeight();
                }
                // wtf?
                if ($county != 0 && isset($pass)) {
                    echo $county + 1;
                } else {
                    echo "1";
                }
                ?>
</dd>
				<dt>Weight:</dt>
Пример #6
0
 public function executeIndex(sfWebRequest $request)
 {
     $text = $request->getParameter('search_by');
     $this->results = array();
     $this->messages = array();
     $this->uris = array();
     //person search
     if ($this->getUser()->hasRights('person_index')) {
         $c = new Criteria();
         $c1 = $c->getNewCriterion(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $c2 = $c->getNewCriterion(PersonPeer::LAST_NAME, $text . '%', Criteria::LIKE);
         //$c->setDistinct(PersonPeer::FIRST_NAME);
         //$c->setDistinct(PersonPeer::LAST_NAME);
         $c->add($c1->addOr($c2));
         $this->results['person'] = PersonPeer::doCount($c);
         $this->messages['person'] = ' person results';
         $this->uris['person'] = 'person/index?filter=1&findperson=1&firstname=' . $text;
     }
     //passenger search
     if ($this->getUser()->hasRights('passenger_index')) {
         $c = new Criteria();
         $c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['passenger'] = PassengerPeer::doCount($c);
         $this->messages['passenger'] = ' passenger results';
         $this->uris['passenger'] = 'passenger/index?filter=1&firstname=' . $text;
     }
     //companion search
     if ($this->getUser()->hasRights('companion_index')) {
         $c = new Criteria();
         $c->add(CompanionPeer::NAME, $text . '%', Criteria::LIKE);
         $this->results['companion'] = CompanionPeer::doCount($c);
         $this->messages['companion'] = ' companion results';
         $this->uris['companion'] = 'companion/index?filter=1&name=' . $text;
     }
     //mission search
     if ($this->getUser()->hasRights('mission_index')) {
         $c = new Criteria();
         if (is_numeric($text)) {
             $c->add(MissionPeer::ID, $text . '%', Criteria::LIKE);
             $this->results['mission'] = MissionPeer::doCount($c);
             $this->uris['mission'] = 'mission/index?filter=1&miss_id=' . $text;
         } else {
             $c->addJoin(MissionPeer::PASSENGER_ID, PassengerPeer::ID, Criteria::LEFT_JOIN);
             $c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
             $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
             $this->results['mission'] = MissionPeer::doCount($c);
             $this->uris['mission'] = 'mission/index?filter=1&pass_fname=' . $text;
         }
         $this->messages['mission'] = ' mission results';
     }
     //leg search
     if ($this->getUser()->hasRights('leg_index')) {
         $c = new Criteria();
         $c->addJoin(MissionLegPeer::MISSION_ID, MissionPeer::ID, Criteria::LEFT_JOIN);
         $c->addJoin(MissionPeer::PASSENGER_ID, PassengerPeer::ID, Criteria::LEFT_JOIN);
         $c->addJoin(PassengerPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['leg'] = MissionLegPeer::doCount($c);
         $this->messages['leg'] = ' mission leg results';
         $this->uris['leg'] = 'missionLeg/index?filter=1&pass_fname=' . $text;
     }
     //requester search
     if ($this->getUser()->hasRights('requester_index')) {
         $c = new Criteria();
         $c->addJoin(RequesterPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['requester'] = RequesterPeer::doCount($c);
         $this->messages['requester'] = ' requester results';
         $this->uris['requester'] = 'requester/index?filter=1&firstname=' . $text;
     }
     //agency search
     if ($this->getUser()->hasRights('agency_index')) {
         $c = new Criteria();
         $c->add(AgencyPeer::NAME, $text . '%', Criteria::LIKE);
         $this->results['agency'] = AgencyPeer::doCount($c);
         $this->messages['agency'] = ' agency results';
         $this->uris['agency'] = 'agency/index?filter=1&name=' . $text;
     }
     //coordinator search
     if ($this->getUser()->hasRights('coordinator_index')) {
         $c = new Criteria();
         $c->addJoin(CoordinatorPeer::MEMBER_ID, MemberPeer::ID);
         $c->addJoin(PersonPeer::ID, MemberPeer::PERSON_ID);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['coordinator'] = CoordinatorPeer::doCount($c);
         $this->messages['coordinator'] = ' coordinator results';
         $this->uris['coordinator'] = 'coordinator/index?filter=1&firstname=' . $text;
     }
     //camp search
     if ($this->getUser()->hasRights('camp_index')) {
         $c = new Criteria();
         $c->add(CampPeer::CAMP_NAME, $text . '%', Criteria::LIKE);
         $this->results['camp'] = CampPeer::doCount($c);
         $this->messages['camp'] = ' camp results';
         $this->uris['camp'] = 'camp/index?filter=1&camp_name=' . $text;
     }
     //airport search
     if ($this->getUser()->hasRights('airport_index')) {
         $c = new Criteria();
         $c->add(AirportPeer::NAME, $text . '%', Criteria::LIKE);
         $this->results['airport'] = AirportPeer::doCount($c);
         $this->messages['airport'] = ' airport results';
         $this->uris['airport'] = 'airport/index?filter=1&name=' . $text;
     }
     //member search
     if ($this->getUser()->hasRights('member_index')) {
         $c = new Criteria();
         if (is_numeric($text)) {
             $c->add(MemberPeer::ID, $text . '%', Criteria::LIKE);
             $this->results['member'] = MemberPeer::doCount($c);
             $this->uris['member'] = 'member/index?filter=1&member_id=' . $text;
         } else {
             $c->addJoin(MemberPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
             $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
             $this->results['member'] = MemberPeer::doCount($c);
             $this->uris['member'] = 'member/index?filter=1&firstname=' . $text;
         }
         $this->messages['member'] = ' member results';
     }
     //pilot search
     if ($this->getUser()->hasRights('pilot_index')) {
         $c = new Criteria();
         $c->addJoin(PilotPeer::MEMBER_ID, MemberPeer::ID, Criteria::LEFT_JOIN);
         $c->addJoin(MemberPeer::PERSON_ID, PersonPeer::ID, Criteria::LEFT_JOIN);
         $c->add(PersonPeer::FIRST_NAME, $text . '%', Criteria::LIKE);
         $this->results['pilot'] = PilotPeer::doCount($c);
         $this->messages['pilot'] = ' pilot results';
         $this->uris['pilot'] = 'pilot/index?filter=1&firstname=' . $text;
     }
     //pilot request search
     if ($this->getUser()->hasRights('mission_available_list')) {
         $c = new Criteria();
         if ($text) {
             $c->add(PilotRequestPeer::DATE, date('Y-m-d', strtotime($text)), Criteria::GREATER_EQUAL);
         }
         $this->results['pilotRequest'] = PilotRequestPeer::doCount($c);
         $this->messages['pilotRequest'] = ' pilot request results';
         $this->uris['pilotRequest'] = 'pilotRequest/index?filter=1&req_date2=' . $text;
     }
     //mission request search
     if ($this->getUser()->hasRights('mission_request_index')) {
         $c = new Criteria();
         if ($text) {
             $c->add(MissionRequestPeer::REQUESTER_DATE, date('Y-m-d', strtotime($text)), Criteria::GREATER_EQUAL);
         }
         $this->results['missionRequest'] = MissionRequestPeer::doCount($c);
         $this->messages['missionRequest'] = ' missionRequest results';
         $this->uris['missionRequest'] = 'missionRequest/index?filter=1&request_date2=' . $text;
     }
     //mission report search
     if ($this->getUser()->hasRights('mission_report_review')) {
         $c = new Criteria();
         $c->add(MissionReportPeer::COPILOT_NAME, $text . '%', Criteria::LIKE);
         $this->results['missionReport'] = MissionReportPeer::doCount($c);
         $this->messages['missionReport'] = ' missionReport results';
         $this->uris['missionReport'] = 'mission_report/review?filter=1&pilot_name=' . $text;
     }
     //role search
     if (1 == 1) {
         $c = new Criteria();
         if (isset($text)) {
             $c->add(RolePeer::TITLE, $text . '%', Criteria::LIKE);
         }
         $this->results['role'] = RolePeer::doCount($c);
         $this->messages['role'] = ' role results';
         $this->uris['role'] = 'role_permission/index?search_by=' . $text;
     }
     $this->text = $text;
 }
Пример #7
0
 public function executeUpdateAjaxCompanion(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');
     }
     # id parameter is companion id which then edits
     if ($request->hasParameter('id')) {
         $cmp = CompanionPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($cmp);
     } else {
         #new companion adding to existing passenger
         $cmpnnPid = $request->getParameter('campnn[passenger_id]');
         $cmp = new Companion();
         if (isset($cmpnnPid)) {
             $cmp->setPassengerId($cmpnnPid);
         } else {
             $cmp->setPassengerId($request->getParameter('passenger_id'));
         }
     }
     $this->itId = $request->getParameter('itId');
     #referer
     if ($request->hasParameter('referer')) {
         $this->referer = $request->getParameter('referer');
     } else {
         $this->referer = $request->getReferer() ? $request->getReferer() : $this->generateUrl('companion', array(), true);
     }
     $form = new CompanionForm($cmp);
     if ($request->getParameter('back')) {
         $this->back = $request->getParameter('back');
     }
     # validate and save
     if ($request->isMethod('post')) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             $is_new = $form->isNew();
             if ($is_new) {
                 $person = new Person();
                 $names = explode(" ", $form->getValue('name'));
                 $person->setFirstName($names[0]);
                 if (isset($names[1])) {
                     $person->setLastName($names[1]);
                 } else {
                     $person->setLastName(NULL);
                 }
                 $person->setDayPhone($form->getValue('companion_phone'));
                 $person->setDayComment($form->getValue('companion_phone_comment'));
                 $person->save();
                 $comp = $form->getObject();
                 $comp->setName($form->getValue('name'));
                 $comp->setRelationship($form->getValue('relationship'));
                 $comp->setDateOfBirth($form->getValue('date_of_birth'));
                 $comp->setWeight($form->getValue('weight'));
                 $comp->setCompanionPhone($form->getValue('companion_phone'));
                 $comp->setCompanionPhoneComment($form->getValue('companion_phone_comment'));
                 $comp->setPersonId($person->getId());
                 $comp->save();
             } else {
                 $form->save();
             }
             $this->getUser()->setFlash('success', 'Companion has successfully ' . ($is_new ? 'created' : 'saved') . '!');
             $this->companion_saved = $form->getValue('name');
             $this->companion_id = $comp->getId();
             $this->relationship = $form->getValue('relationship');
         }
     }
     $passenger = $cmp->getPassenger();
     $this->forward404Unless($passenger);
     $this->passenger = $passenger;
     $this->form_a = $form;
     $this->cmp = $cmp;
 }
Пример #8
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(CompanionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(CompanionPeer::DATABASE_NAME);
         $criteria->add(CompanionPeer::ID, $pks, Criteria::IN);
         $objs = CompanionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Пример #9
0
 /**
  * Selects a collection of MissionCompanion objects pre-filled with all related objects except Mission.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of MissionCompanion objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptMission(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseMissionCompanionPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BaseMissionCompanionPeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     MissionCompanionPeer::addSelectColumns($c);
     $startcol2 = MissionCompanionPeer::NUM_COLUMNS - MissionCompanionPeer::NUM_LAZY_LOAD_COLUMNS;
     CompanionPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (CompanionPeer::NUM_COLUMNS - CompanionPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(MissionCompanionPeer::COMPANION_ID), array(CompanionPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = MissionCompanionPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = MissionCompanionPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = MissionCompanionPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             MissionCompanionPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Companion rows
         $key2 = CompanionPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = CompanionPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = CompanionPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 CompanionPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (MissionCompanion) to the collection in $obj2 (Companion)
             $obj2->addMissionCompanion($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Пример #10
0
 /**
  * Removes a companion and redirects to referer
  * CODE: companion_delete
  */
 public function executeDelete(sfWebRequest $request)
 {
     # security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     //if ($request->isMethod('delete')){
     $request->checkCSRFProtection();
     $cmp = CompanionPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404Unless($cmp);
     $cmp->delete();
     $this->getUser()->setFlash('success', 'Companion information has been successfully deleted!');
     //}
     return $this->redirect($request->getReferer() ? $request->getReferer() : '@companion');
 }
Пример #11
0
 public function executePrintMissionLeg(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('id')) {
         $this->leg = MissionLegPeer::retrieveByPK($request->getParameter('id'));
         if (isset($this->leg)) {
             $this->mission = MissionPeer::retrieveByPK($this->leg->getMissionId());
             $this->requester = RequesterPeer::retrieveByPK($this->mission->getRequesterId());
             $this->req_person = $this->requester->getPerson();
             $this->agency = $this->requester->getAgency();
             // Camp information
             if ($this->mission->getCampId()) {
                 $this->camp = CampPeer::retrieveByPK($this->mission->getCampId());
             }
             //Coordinator
             if ($this->mission->getCoordinatorId()) {
                 $this->coordinator = CoordinatorPeer::retrieveByPK($this->mission->getCoordinatorId());
                 $this->coordiPerson = PersonPeer::retrieveByPK($this->coordinator->getMember()->getPersonId());
             }
             if (isset($this->mission)) {
                 $this->itinerary = ItineraryPeer::retrieveByPK($this->mission->getItineraryId());
                 $pass = PassengerPeer::retrieveByPK($this->mission->getPassengerId());
                 //Companions information
                 $this->companions = CompanionPeer::getByPassId($this->mission->getPassengerId());
                 if (isset($pass) && $pass instanceof Passenger) {
                     $this->pass = $pass;
                     //print_r($this->pass);
                     //die();
                     $this->person = PersonPeer::retrieveByPK($pass->getPersonId());
                     $this->itinerary = $this->mission->getItinerary();
                     // 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();
                     }
                 } else {
                     unset($this->passenger);
                 }
             }
         }
         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());
                 $this->mission_assistant = PilotPeer::getByMemberId($this->leg->getMissAssisId());
                 $this->back_up_mission_assistant = PilotPeer::retrieveByPK($this->leg->getBackupMissAssisId());
             }
         }
         if ($this->getUser()->hasAttribute('pilotAddToLegview')) {
             $this->getUser()->setFlash("success", 'Pilot is added to this mission leg successfully !');
             $this->getUser()->getAttributeHolder()->remove('pilotAddToLegview');
         }
     }
 }
Пример #12
0
 public function executeSaveCompanions(sfWebRequest $request)
 {
     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->mission = MissionPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404Unless($this->mission);
     $this->passenger = $this->mission->getPassenger();
     if (!$this->passenger instanceof Passenger) {
         $this->getUser()->setFlash('warning', 'This mission don\'t have passenger specified!');
         $this->redirect('mission/view?id=' . $this->mission->getId());
     }
     $this->mission_companions = (array) $request->getParameter('companions');
     $c = new Criteria();
     $c->add(CompanionPeer::ID, $this->mission_companions, Criteria::IN);
     $c->add(CompanionPeer::PASSENGER_ID, $this->passenger->getId());
     if (CompanionPeer::doCount($c) != count($this->mission_companions)) {
         $this->getUser()->setFlash('warning', 'Some companions not found.');
         $this->setTemplate('companions');
         $this->companions = $this->passenger->getCompanions();
         return sfView::SUCCESS;
     }
     # passing this point makes all valid
     $c->clear();
     $c->add(MissionCompanionPeer::MISSION_ID, $this->mission->getId());
     MissionCompanionPeer::doDelete($c);
     foreach ($this->mission_companions as $id) {
         $mission_companion = new MissionCompanion();
         $mission_companion->setMissionId($this->mission->getId());
         $mission_companion->setCompanionId($id);
         $mission_companion->save();
     }
     $this->getUser()->setFlash('success', 'Companions successfully managed!');
     $this->redirect('mission/view?id=' . $this->mission->getId());
 }