Exemplo n.º 1
0
 /**
  * Declares an association between this object and a MissionLeg object.
  *
  * @param      MissionLeg $v
  * @return     MissionPhoto The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setMissionLeg(MissionLeg $v = null)
 {
     if ($v === null) {
         $this->setLegId(NULL);
     } else {
         $this->setLegId($v->getId());
     }
     $this->aMissionLeg = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the MissionLeg object, it will not be re-added.
     if ($v !== null) {
         $v->addMissionPhoto($this);
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Declares an association between this object and a MissionLeg object.
  *
  * @param      MissionLeg $v
  * @return     AfaLeg The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setMissionLeg(MissionLeg $v = null)
 {
     if ($v === null) {
         $this->setId(NULL);
     } else {
         $this->setId($v->getId());
     }
     $this->aMissionLeg = $v;
     // Add binding for other direction of this 1:1 relationship.
     if ($v !== null) {
         $v->setAfaLeg($this);
     }
     return $this;
 }
Exemplo n.º 3
0
 public function executeReverse(sfWebRequest $request)
 {
     #TODO
     #security
     if ($request->getParameter('id')) {
         $mission_leg = MissionLegPeer::retrieveByPK($request->getParameter('id'));
         $mission = MissionPeer::retrieveByPK($mission_leg->getMissionId());
         if (isset($mission) && $mission->getItineraryId()) {
             $iti = $mission->getItinerary();
         }
         if ($mission_leg->getTransportation() == 'air_mission') {
             if ($mission_leg->getReverseFrom() == $mission_leg->getId()) {
                 //Non reversed leg
                 $orgin = $mission_leg->getFromAirportId();
                 $dest = $mission_leg->getToAirportId();
                 $miss_id = $mission_leg->getMissionId();
                 $leg_id = $mission_leg->getId();
                 $mission_leg->setReverseFrom($mission_leg->getId());
                 $mission_leg->save();
                 $mission_leg = new MissionLeg();
                 $mission_leg->setMissionId($miss_id);
                 $mission_leg->setReverseFrom($leg_id);
                 $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($miss_id) + 1);
                 $mission_leg->setFromAirportId($dest);
                 $mission_leg->setToAirportId($orgin);
                 $mission_leg->setTransportation('air_mission');
                 $mission_leg->save();
                 $this->getUser()->setFlash('success', 'Mission #' . $mission->getId() . '\'s legs have reversed.');
                 $this->redirect('@itinerary_detail?id=' . $iti->getId());
             }
         } elseif ($mission_leg->getTransportation() == 'ground_mission') {
             if ($mission_leg->getGroundOrigin() && $mission_leg->getGroundDestination()) {
                 //Reversed by type which saved : like patient..lodging..
                 if ($mission_leg->getGroundOrigin() == 'patient' && $mission_leg->getGroundDestination() == 'lodging') {
                     $parent = $mission_leg->getGroundOrigin();
                     $lodging = $mission_leg->getGroundDestination();
                     $miss_id = $mission_leg->getMissionId();
                     $leg_id = $mission_leg->getId();
                     $mission_leg = new MissionLeg();
                     $mission_leg->setMissionId($miss_id);
                     $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($miss_id) + 1);
                     $mission_leg->setGroundOrigin($lodging);
                     $mission_leg->setGroundDestination($parent);
                     $mission_leg->setTransportation('ground_mission');
                     $mission_leg->setReverseFrom($leg_id);
                     $mission_leg->save();
                 }
                 if ($mission_leg->getGroundOrigin() == 'lodging' && $mission_leg->getGroundDestination() == 'facility') {
                     $facility = $mission_leg->getGroundDestination();
                     $lodging = $mission_leg->getGroundOrigin();
                     $miss_id = $mission_leg->getMissionId();
                     $leg_id = $mission_leg->getId();
                     $mission_leg = new MissionLeg();
                     $mission_leg->setMissionId($miss_id);
                     $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($miss_id) + 1);
                     $mission_leg->setGroundDestination($lodging);
                     $mission_leg->setGroundOrigin($facility);
                     $mission_leg->setTransportation('ground_mission');
                     $mission_leg->setReverseFrom($leg_id);
                     $mission_leg->save();
                 }
                 $this->getUser()->setFlash('success', 'Missoin #' . $mission->getId() . '\'s legs have reversed.');
                 $this->redirect('@itinerary_detail?id=' . $iti->getId());
             }
         }
         if ($mission_leg->getMissionId()) {
             $mission = MissionPeer::retrieveByPK($mission_leg->getMissionId());
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      MissionLeg $value A MissionLeg object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(MissionLeg $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }