$fbo = FboPeer::retrieveByPK($mleg->getFboId());
            if ($fbo->getAirportId()) {
                $fbo_airport = AirportPeer::retrieveByPK($fbo->getAirportId());
            }
        }
        $is_air = $mleg->getTransportation() == 'air_mission';
        if ($is_air) {
            $to_airport = $mleg->getAirportRelatedByToAirportId();
            $from_airport = $mleg->getAirportRelatedByFromAirportId();
        }
        //// FBO information
        if ($mleg->getFboId()) {
            $fromFbo = FboPeer::retrieveByPK($mleg->getFboId());
        }
        if ($mleg->getFboDestId()) {
            $destFbo = FboPeer::retrieveByPK($mleg->getFboDestId());
        }
        //ETD and ETA information
        $afaLeg = AfaLegPeer::retrieveByPK($mleg->getId());
        ?>
<table border="0" cellpadding="2" width="650" cellspacing="0">
<tr>
<td colspan="3" bgcolor="#2000BF"><font color="#FFFFFF"><strong>Leg <?php 
        echo $mleg->getLegNumber();
        ?>
:
    Angel Flight West -- (310) 390-2958</strong></font></td>
</tr>
<tr>
   <td width="215" valign="top" align="left"><small><strong>FROM: </strong><?php 
        if ($is_air) {
Exemple #2
0
             <label>Origin Address</label>
             <?php 
 echo select_tag('ground_origin', options_for_select($ground_addr_sel, $sf_params->has('ground_origin') ? $sf_params->get('ground_origin') : $leg->getGroundOrigin(), array('include_custom' => '-- select --')), array("onchange" => "changeGroundMissionDetails(this)"));
 ?>
           </div>
           <div class="wrap">
             <label>Destination Address</label>
             <?php 
 echo select_tag('ground_destination', options_for_select($ground_addr_sel, $sf_params->has('ground_destination') ? $sf_params->get('ground_destination') : $leg->getGroundDestination(), array('include_custom' => '-- select --')), array("onchange" => "changeGroundMissionDetails(this)"));
 ?>
           </div>
            <?php 
 $c = new Criteria();
 $c->add(FboPeer::NAME, '', Criteria::NOT_EQUAL);
 $c->addAscendingOrderByColumn(FboPeer::NAME);
 $fbo_addresses = FboPeer::doSelect($c);
 foreach ($fbo_addresses as $fbo_address) {
     $options[$fbo_address->getId()] = $fbo_address->getName();
 }
 ?>
           <div class="wrap">
             <label>FBO Name</label>
             <?php 
 echo select_tag('fbo_address', options_for_select($options, $leg ? $leg->getFboId() : null, array('include_custom' => '-- select --')));
 ?>
           </div>
           <div class="wrap">
             <label>FBO Address</label>
             <input type="text" name="fbo_address_new" value="<?php 
 echo $new_fbo_address;
 ?>
Exemple #3
0
 /**
  * Get the associated Fbo object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Fbo The associated Fbo object.
  * @throws     PropelException
  */
 public function getFbo(PropelPDO $con = null)
 {
     if ($this->aFbo === null && $this->fbo_id !== null) {
         $c = new Criteria(FboPeer::DATABASE_NAME);
         $c->add(FboPeer::ID, $this->fbo_id);
         $this->aFbo = FboPeer::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->aFbo->addCamps($this);
         		 */
     }
     return $this->aFbo;
 }
Exemple #4
0
 /**
  * TODO: Check related records.
  * CODE: fbo_delete
  */
 public function executeFboDelete(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();
         $this->fbo = FboPeer::retrieveByPK($request->getParameter('id'));
         $this->forward404Unless($this->fbo);
         $this->getUser()->setFlash('success', 'FBO information has been successfully deleted!');
         $this->fbo->delete();
     }
     return $this->redirect('@fbo');
 }
Exemple #5
0
 /**
  * Returns the number of related Fbo objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Fbo objects.
  * @throws     PropelException
  */
 public function countFbos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(AirportPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collFbos === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(FboPeer::AIRPORT_ID, $this->id);
             $count = FboPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // 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 count of the collection.
             $criteria->add(FboPeer::AIRPORT_ID, $this->id);
             if (!isset($this->lastFboCriteria) || !$this->lastFboCriteria->equals($criteria)) {
                 $count = FboPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collFbos);
             }
         } else {
             $count = count($this->collFbos);
         }
     }
     return $count;
 }
Exemple #6
0
 /**
  * Selects a collection of Camp objects pre-filled with all related objects except Airport.
  *
  * @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 Camp objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptAirport(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $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);
     }
     CampPeer::addSelectColumns($c);
     $startcol2 = CampPeer::NUM_COLUMNS - CampPeer::NUM_LAZY_LOAD_COLUMNS;
     AgencyPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (AgencyPeer::NUM_COLUMNS - AgencyPeer::NUM_LAZY_LOAD_COLUMNS);
     FboPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (FboPeer::NUM_COLUMNS - FboPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(CampPeer::AGENCY_ID), array(AgencyPeer::ID), $join_behavior);
     $c->addJoin(array(CampPeer::FBO_ID), array(FboPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = CampPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = CampPeer::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 = CampPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             CampPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Agency rows
         $key2 = AgencyPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = AgencyPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = AgencyPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 AgencyPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Camp) to the collection in $obj2 (Agency)
             $obj2->addCamp($obj1);
         }
         // if joined row is not null
         // Add objects for joined Fbo rows
         $key3 = FboPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = FboPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = FboPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 FboPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (Camp) to the collection in $obj3 (Fbo)
             $obj3->addCamp($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
                </dl>
                <dl class="person-data">
                  <dt>Destination</dt>
                  <dd><?php 
    echo $ground_addr_sel[$leg->getGroundDestination()];
    ?>
</dd>
                  <dt>Address</dt>
                  <dd><?php 
    echo $ground_addresses[$leg->getGroundDestination()];
    ?>
</dd>
                </dl>
                 <?php 
    if ($leg->getFboId()) {
        $fbo_name = FboPeer::retrieveByPK($leg->getFboId());
        ?>
                <dl class="person-data">
                  <dt>FBO Name</dt>
                  <dd><?php 
        echo $fbo_name->getName();
        ?>
</dd>
                </dl>
                <dl class="person-data">
                  <dt>FBO Address</dt>
                  <dd><?php 
        echo $leg->getFboAddressNew() ? $leg->getFboAddressNew() : '--';
        ?>
</dd>
                </dl>
$req_person = PersonPeer::retrieveByPK($requester->getPersonId());
$req_passenger = PassengerPeer::getByPersonId($requester->getPersonId());
//Coordinator
if ($mission_leg->getCoordinatorId()) {
    $coordinator = CoordinatorPeer::retrieveByPK($mission_leg->getCoordinatorId());
    if ($coordinator->getMemberId()) {
        $coordiPerson = PersonPeer::retrieveByPK($coordinator->getMember()->getPersonId());
    }
}
//Mission Fbo Information
/*echo "<pre>";
print_r($mission_leg);
die();
*/
if ($mission_leg->getFboId()) {
    $fbo = FboPeer::retrieveByPK($mission_leg->getFboId());
    if ($fbo->getAirportId()) {
        $fbo_airport = AirportPeer::retrieveByPK($fbo->getAirportId());
    }
}
//Pilot
if ($mission_leg->getPilotId()) {
    $pilot = PilotPeer::retrieveByPK($mission_leg->getPilotId());
    $pilotMember = $pilot->getMember();
    $pilot_person = PersonPeer::retrieveByPK($pilotMember->getPersonId());
    $pilot_aircrafts = PilotAircraftPeer::getByMemberId($pilot->getMemberId());
}
// Mission Assistant
if ($mission_leg->getMissAssisId()) {
    $mission_assistant = MemberPeer::retrieveByPK($mission_leg->getMissAssisId());
    $miss_assi_persopn = PersonPeer::retrieveByPK($mission_assistant->getPersonId());
Exemple #9
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(FboPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(FboPeer::DATABASE_NAME);
         $criteria->add(FboPeer::ID, $pks, Criteria::IN);
         $objs = FboPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #10
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 = FboPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setAirportId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setVoicePhone($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setFaxPhone($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setDiscountAmount($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setFuelDiscount($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setDefaultFbo($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setAddress($arr[$keys[8]]);
     }
 }
Exemple #11
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();
     }
 }
Exemple #12
0
 /**
  * Selects a collection of MissionLeg objects pre-filled with all related objects except PilotAircraft.
  *
  * @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 MissionLeg objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptPilotAircraft(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $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);
     }
     MissionLegPeer::addSelectColumns($c);
     $startcol2 = MissionLegPeer::NUM_COLUMNS - MissionLegPeer::NUM_LAZY_LOAD_COLUMNS;
     MissionPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (MissionPeer::NUM_COLUMNS - MissionPeer::NUM_LAZY_LOAD_COLUMNS);
     AirportPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + (AirportPeer::NUM_COLUMNS - AirportPeer::NUM_LAZY_LOAD_COLUMNS);
     AirportPeer::addSelectColumns($c);
     $startcol5 = $startcol4 + (AirportPeer::NUM_COLUMNS - AirportPeer::NUM_LAZY_LOAD_COLUMNS);
     CoordinatorPeer::addSelectColumns($c);
     $startcol6 = $startcol5 + (CoordinatorPeer::NUM_COLUMNS - CoordinatorPeer::NUM_LAZY_LOAD_COLUMNS);
     PilotPeer::addSelectColumns($c);
     $startcol7 = $startcol6 + (PilotPeer::NUM_COLUMNS - PilotPeer::NUM_LAZY_LOAD_COLUMNS);
     MemberPeer::addSelectColumns($c);
     $startcol8 = $startcol7 + (MemberPeer::NUM_COLUMNS - MemberPeer::NUM_LAZY_LOAD_COLUMNS);
     PilotPeer::addSelectColumns($c);
     $startcol9 = $startcol8 + (PilotPeer::NUM_COLUMNS - PilotPeer::NUM_LAZY_LOAD_COLUMNS);
     MemberPeer::addSelectColumns($c);
     $startcol10 = $startcol9 + (MemberPeer::NUM_COLUMNS - MemberPeer::NUM_LAZY_LOAD_COLUMNS);
     MissionReportPeer::addSelectColumns($c);
     $startcol11 = $startcol10 + (MissionReportPeer::NUM_COLUMNS - MissionReportPeer::NUM_LAZY_LOAD_COLUMNS);
     FboPeer::addSelectColumns($c);
     $startcol12 = $startcol11 + (FboPeer::NUM_COLUMNS - FboPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(MissionLegPeer::MISSION_ID), array(MissionPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::FROM_AIRPORT_ID), array(AirportPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::TO_AIRPORT_ID), array(AirportPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::COORDINATOR_ID), array(CoordinatorPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::PILOT_ID), array(PilotPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::COPILOT_ID), array(MemberPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::BACKUP_PILOT_ID), array(PilotPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::BACKUP_COPILOT_ID), array(MemberPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::MISSION_REPORT_ID), array(MissionReportPeer::ID), $join_behavior);
     $c->addJoin(array(MissionLegPeer::FBO_ID), array(FboPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = MissionLegPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = MissionLegPeer::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 = MissionLegPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             MissionLegPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Mission rows
         $key2 = MissionPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = MissionPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = MissionPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 MissionPeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj2 (Mission)
             $obj2->addMissionLeg($obj1);
         }
         // if joined row is not null
         // Add objects for joined Airport rows
         $key3 = AirportPeer::getPrimaryKeyHashFromRow($row, $startcol3);
         if ($key3 !== null) {
             $obj3 = AirportPeer::getInstanceFromPool($key3);
             if (!$obj3) {
                 $omClass = AirportPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj3 = new $cls();
                 $obj3->hydrate($row, $startcol3);
                 AirportPeer::addInstanceToPool($obj3, $key3);
             }
             // if $obj3 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj3 (Airport)
             $obj3->addMissionLegRelatedByFromAirportId($obj1);
         }
         // if joined row is not null
         // Add objects for joined Airport rows
         $key4 = AirportPeer::getPrimaryKeyHashFromRow($row, $startcol4);
         if ($key4 !== null) {
             $obj4 = AirportPeer::getInstanceFromPool($key4);
             if (!$obj4) {
                 $omClass = AirportPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj4 = new $cls();
                 $obj4->hydrate($row, $startcol4);
                 AirportPeer::addInstanceToPool($obj4, $key4);
             }
             // if $obj4 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj4 (Airport)
             $obj4->addMissionLegRelatedByToAirportId($obj1);
         }
         // if joined row is not null
         // Add objects for joined Coordinator rows
         $key5 = CoordinatorPeer::getPrimaryKeyHashFromRow($row, $startcol5);
         if ($key5 !== null) {
             $obj5 = CoordinatorPeer::getInstanceFromPool($key5);
             if (!$obj5) {
                 $omClass = CoordinatorPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj5 = new $cls();
                 $obj5->hydrate($row, $startcol5);
                 CoordinatorPeer::addInstanceToPool($obj5, $key5);
             }
             // if $obj5 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj5 (Coordinator)
             $obj5->addMissionLeg($obj1);
         }
         // if joined row is not null
         // Add objects for joined Pilot rows
         $key6 = PilotPeer::getPrimaryKeyHashFromRow($row, $startcol6);
         if ($key6 !== null) {
             $obj6 = PilotPeer::getInstanceFromPool($key6);
             if (!$obj6) {
                 $omClass = PilotPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj6 = new $cls();
                 $obj6->hydrate($row, $startcol6);
                 PilotPeer::addInstanceToPool($obj6, $key6);
             }
             // if $obj6 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj6 (Pilot)
             $obj6->addMissionLegRelatedByPilotId($obj1);
         }
         // if joined row is not null
         // Add objects for joined Member rows
         $key7 = MemberPeer::getPrimaryKeyHashFromRow($row, $startcol7);
         if ($key7 !== null) {
             $obj7 = MemberPeer::getInstanceFromPool($key7);
             if (!$obj7) {
                 $omClass = MemberPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj7 = new $cls();
                 $obj7->hydrate($row, $startcol7);
                 MemberPeer::addInstanceToPool($obj7, $key7);
             }
             // if $obj7 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj7 (Member)
             $obj7->addMissionLegRelatedByCopilotId($obj1);
         }
         // if joined row is not null
         // Add objects for joined Pilot rows
         $key8 = PilotPeer::getPrimaryKeyHashFromRow($row, $startcol8);
         if ($key8 !== null) {
             $obj8 = PilotPeer::getInstanceFromPool($key8);
             if (!$obj8) {
                 $omClass = PilotPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj8 = new $cls();
                 $obj8->hydrate($row, $startcol8);
                 PilotPeer::addInstanceToPool($obj8, $key8);
             }
             // if $obj8 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj8 (Pilot)
             $obj8->addMissionLegRelatedByBackupPilotId($obj1);
         }
         // if joined row is not null
         // Add objects for joined Member rows
         $key9 = MemberPeer::getPrimaryKeyHashFromRow($row, $startcol9);
         if ($key9 !== null) {
             $obj9 = MemberPeer::getInstanceFromPool($key9);
             if (!$obj9) {
                 $omClass = MemberPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj9 = new $cls();
                 $obj9->hydrate($row, $startcol9);
                 MemberPeer::addInstanceToPool($obj9, $key9);
             }
             // if $obj9 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj9 (Member)
             $obj9->addMissionLegRelatedByBackupCopilotId($obj1);
         }
         // if joined row is not null
         // Add objects for joined MissionReport rows
         $key10 = MissionReportPeer::getPrimaryKeyHashFromRow($row, $startcol10);
         if ($key10 !== null) {
             $obj10 = MissionReportPeer::getInstanceFromPool($key10);
             if (!$obj10) {
                 $omClass = MissionReportPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj10 = new $cls();
                 $obj10->hydrate($row, $startcol10);
                 MissionReportPeer::addInstanceToPool($obj10, $key10);
             }
             // if $obj10 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj10 (MissionReport)
             $obj10->addMissionLeg($obj1);
         }
         // if joined row is not null
         // Add objects for joined Fbo rows
         $key11 = FboPeer::getPrimaryKeyHashFromRow($row, $startcol11);
         if ($key11 !== null) {
             $obj11 = FboPeer::getInstanceFromPool($key11);
             if (!$obj11) {
                 $omClass = FboPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj11 = new $cls();
                 $obj11->hydrate($row, $startcol11);
                 FboPeer::addInstanceToPool($obj11, $key11);
             }
             // if $obj11 already loaded
             // Add the $obj1 (MissionLeg) to the collection in $obj11 (Fbo)
             $obj11->addMissionLeg($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }