Exemplo n.º 1
0
 public function executeAddLeg(sfWebRequest $request)
 {
     $camp = CampPeer::retrieveByPK($request->getParameter('id'));
     $this->forward404Unless($camp);
     if ($camp) {
         $mission_type = MissionTypePeer::getByName('normal');
     }
     if (!$mission_type instanceof MissionType) {
         $mission_type = MissionTypePeer::doSelectOne(new Criteria());
         $this->forward404Unless($mission_type);
     }
     $itinerary = new Itinerary();
     $itinerary->setCampId($camp->getId());
     $itinerary->setPassengerId($request->getParameter('passenger_id'));
     $existing = ItineraryPeer::doSelectOne($itinerary->buildCriteria());
     if ($existing) {
         $itinerary = $existing;
     } else {
         $itinerary->setDateRequested(time());
         $itinerary->setApointTime('unspecified');
         $itinerary->setMissionTypeId($mission_type->getId());
         $itinerary->setAgencyId($camp->getAgencyId());
         $itinerary->save();
     }
     $this->redirect('mission/update?id=' . $itinerary->getId());
 }
Exemplo n.º 2
0
 public function getItinerary()
 {
     $c = new Criteria();
     $c->add(ItineraryPeer::MISSION_REQUEST_ID, $this->getId());
     return ItineraryPeer::doSelectOne($c);
 }
Exemplo n.º 3
0
 /**
  * Get the associated Itinerary object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Itinerary The associated Itinerary object.
  * @throws     PropelException
  */
 public function getItinerary(PropelPDO $con = null)
 {
     if ($this->aItinerary === null && $this->itinerary_id !== null) {
         $c = new Criteria(ItineraryPeer::DATABASE_NAME);
         $c->add(ItineraryPeer::ID, $this->itinerary_id);
         $this->aItinerary = ItineraryPeer::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->aItinerary->addMissions($this);
         		 */
     }
     return $this->aItinerary;
 }