public function getItinerary() { $c = new Criteria(); $c->add(ItineraryPeer::MISSION_REQUEST_ID, $this->getId()); return ItineraryPeer::doSelectOne($c); }
/** * 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(ItineraryPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ItineraryPeer::DATABASE_NAME); $criteria->add(ItineraryPeer::ID, $pks, Criteria::IN); $objs = ItineraryPeer::doSelect($criteria, $con); } return $objs; }
/** * Selects a collection of Mission objects pre-filled with all related objects except Coordinator. * * @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 Mission objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptCoordinator(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); } MissionPeer::addSelectColumns($c); $startcol2 = MissionPeer::NUM_COLUMNS - MissionPeer::NUM_LAZY_LOAD_COLUMNS; MissionRequestPeer::addSelectColumns($c); $startcol3 = $startcol2 + (MissionRequestPeer::NUM_COLUMNS - MissionRequestPeer::NUM_LAZY_LOAD_COLUMNS); ItineraryPeer::addSelectColumns($c); $startcol4 = $startcol3 + (ItineraryPeer::NUM_COLUMNS - ItineraryPeer::NUM_LAZY_LOAD_COLUMNS); MissionTypePeer::addSelectColumns($c); $startcol5 = $startcol4 + (MissionTypePeer::NUM_COLUMNS - MissionTypePeer::NUM_LAZY_LOAD_COLUMNS); PassengerPeer::addSelectColumns($c); $startcol6 = $startcol5 + (PassengerPeer::NUM_COLUMNS - PassengerPeer::NUM_LAZY_LOAD_COLUMNS); RequesterPeer::addSelectColumns($c); $startcol7 = $startcol6 + (RequesterPeer::NUM_COLUMNS - RequesterPeer::NUM_LAZY_LOAD_COLUMNS); AgencyPeer::addSelectColumns($c); $startcol8 = $startcol7 + (AgencyPeer::NUM_COLUMNS - AgencyPeer::NUM_LAZY_LOAD_COLUMNS); RequesterPeer::addSelectColumns($c); $startcol9 = $startcol8 + (RequesterPeer::NUM_COLUMNS - RequesterPeer::NUM_LAZY_LOAD_COLUMNS); AgencyPeer::addSelectColumns($c); $startcol10 = $startcol9 + (AgencyPeer::NUM_COLUMNS - AgencyPeer::NUM_LAZY_LOAD_COLUMNS); CampPeer::addSelectColumns($c); $startcol11 = $startcol10 + (CampPeer::NUM_COLUMNS - CampPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(MissionPeer::REQUEST_ID), array(MissionRequestPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::ITINERARY_ID), array(ItineraryPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::MISSION_TYPE_ID), array(MissionTypePeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::PASSENGER_ID), array(PassengerPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::REQUESTER_ID), array(RequesterPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::AGENCY_ID), array(AgencyPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::OTHER_REQUESTER_ID), array(RequesterPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::OTHER_AGENCY_ID), array(AgencyPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::CAMP_ID), array(CampPeer::ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = MissionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = MissionPeer::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 = MissionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); MissionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined MissionRequest rows $key2 = MissionRequestPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = MissionRequestPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = MissionRequestPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); MissionRequestPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (Mission) to the collection in $obj2 (MissionRequest) $obj2->addMission($obj1); } // if joined row is not null // Add objects for joined Itinerary rows $key3 = ItineraryPeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = ItineraryPeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = ItineraryPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); ItineraryPeer::addInstanceToPool($obj3, $key3); } // if $obj3 already loaded // Add the $obj1 (Mission) to the collection in $obj3 (Itinerary) $obj3->addMission($obj1); } // if joined row is not null // Add objects for joined MissionType rows $key4 = MissionTypePeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = MissionTypePeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = MissionTypePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); MissionTypePeer::addInstanceToPool($obj4, $key4); } // if $obj4 already loaded // Add the $obj1 (Mission) to the collection in $obj4 (MissionType) $obj4->addMission($obj1); } // if joined row is not null // Add objects for joined Passenger rows $key5 = PassengerPeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = PassengerPeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = PassengerPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); PassengerPeer::addInstanceToPool($obj5, $key5); } // if $obj5 already loaded // Add the $obj1 (Mission) to the collection in $obj5 (Passenger) $obj5->addMission($obj1); } // if joined row is not null // Add objects for joined Requester rows $key6 = RequesterPeer::getPrimaryKeyHashFromRow($row, $startcol6); if ($key6 !== null) { $obj6 = RequesterPeer::getInstanceFromPool($key6); if (!$obj6) { $omClass = RequesterPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj6 = new $cls(); $obj6->hydrate($row, $startcol6); RequesterPeer::addInstanceToPool($obj6, $key6); } // if $obj6 already loaded // Add the $obj1 (Mission) to the collection in $obj6 (Requester) $obj6->addMissionRelatedByRequesterId($obj1); } // if joined row is not null // Add objects for joined Agency rows $key7 = AgencyPeer::getPrimaryKeyHashFromRow($row, $startcol7); if ($key7 !== null) { $obj7 = AgencyPeer::getInstanceFromPool($key7); if (!$obj7) { $omClass = AgencyPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj7 = new $cls(); $obj7->hydrate($row, $startcol7); AgencyPeer::addInstanceToPool($obj7, $key7); } // if $obj7 already loaded // Add the $obj1 (Mission) to the collection in $obj7 (Agency) $obj7->addMissionRelatedByAgencyId($obj1); } // if joined row is not null // Add objects for joined Requester rows $key8 = RequesterPeer::getPrimaryKeyHashFromRow($row, $startcol8); if ($key8 !== null) { $obj8 = RequesterPeer::getInstanceFromPool($key8); if (!$obj8) { $omClass = RequesterPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj8 = new $cls(); $obj8->hydrate($row, $startcol8); RequesterPeer::addInstanceToPool($obj8, $key8); } // if $obj8 already loaded // Add the $obj1 (Mission) to the collection in $obj8 (Requester) $obj8->addMissionRelatedByOtherRequesterId($obj1); } // if joined row is not null // Add objects for joined Agency rows $key9 = AgencyPeer::getPrimaryKeyHashFromRow($row, $startcol9); if ($key9 !== null) { $obj9 = AgencyPeer::getInstanceFromPool($key9); if (!$obj9) { $omClass = AgencyPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj9 = new $cls(); $obj9->hydrate($row, $startcol9); AgencyPeer::addInstanceToPool($obj9, $key9); } // if $obj9 already loaded // Add the $obj1 (Mission) to the collection in $obj9 (Agency) $obj9->addMissionRelatedByOtherAgencyId($obj1); } // if joined row is not null // Add objects for joined Camp rows $key10 = CampPeer::getPrimaryKeyHashFromRow($row, $startcol10); if ($key10 !== null) { $obj10 = CampPeer::getInstanceFromPool($key10); if (!$obj10) { $omClass = CampPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj10 = new $cls(); $obj10->hydrate($row, $startcol10); CampPeer::addInstanceToPool($obj10, $key10); } // if $obj10 already loaded // Add the $obj1 (Mission) to the collection in $obj10 (Camp) $obj10->addMission($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
public static function doSelectJoinCustom(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN) { foreach (sfMixer::getCallables('MissionPeer:doSelectJoinCustom:doSelectJoinCustom') as $callable) { call_user_func($callable, 'MissionPeer', $c, $con); } $c = clone $c; // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } MissionPeer::addSelectColumns($c); $startcol2 = MissionPeer::NUM_COLUMNS - MissionPeer::NUM_LAZY_LOAD_COLUMNS; ItineraryPeer::addSelectColumns($c); $startcol3 = $startcol2 + (ItineraryPeer::NUM_COLUMNS - ItineraryPeer::NUM_LAZY_LOAD_COLUMNS); MissionTypePeer::addSelectColumns($c); $startcol4 = $startcol3 + (MissionTypePeer::NUM_COLUMNS - MissionTypePeer::NUM_LAZY_LOAD_COLUMNS); PassengerPeer::addSelectColumns($c); $startcol5 = $startcol4 + (PassengerPeer::NUM_COLUMNS - PassengerPeer::NUM_LAZY_LOAD_COLUMNS); MissionLegPeer::addSelectColumns($c); $startcol6 = $startcol5 + (MissionLegPeer::NUM_COLUMNS - MissionLegPeer::NUM_LAZY_LOAD_COLUMNS); $c->addJoin(array(MissionPeer::ITINERARY_ID), array(ItineraryPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::MISSION_TYPE_ID), array(MissionTypePeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::PASSENGER_ID), array(PassengerPeer::ID), $join_behavior); $c->addJoin(array(MissionPeer::ID), array(MissionLegPeer::MISSION_ID), $join_behavior); $stmt = BasePeer::doSelect($c, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = MissionPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = MissionPeer::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 = MissionPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj1 = new $cls(); $obj1->hydrate($row); MissionPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Itinerary rows $key2 = ItineraryPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = ItineraryPeer::getInstanceFromPool($key2); if (!$obj2) { $omClass = ItineraryPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); ItineraryPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Mission) to the collection in $obj3 (Itinerary) $obj2->addMission($obj1); } // if joined row not null // Add objects for joined MissionType rows $key3 = MissionTypePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = MissionTypePeer::getInstanceFromPool($key3); if (!$obj3) { $omClass = MissionTypePeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); MissionTypePeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (Mission) to the collection in $obj3 (MissionType) $obj3->addMission($obj1); } // if joined row not null // Add objects for joined Passenger rows $key4 = PassengerPeer::getPrimaryKeyHashFromRow($row, $startcol4); if ($key4 !== null) { $obj4 = PassengerPeer::getInstanceFromPool($key4); if (!$obj4) { $omClass = PassengerPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj4 = new $cls(); $obj4->hydrate($row, $startcol4); PassengerPeer::addInstanceToPool($obj4, $key4); } // if obj4 loaded // Add the $obj1 (Mission) to the collection in $obj4 (Passenger) $obj4->addMission($obj1); } // if joined row not null // Add objects for joined MissionLeg rows $key5 = MissionLegPeer::getPrimaryKeyHashFromRow($row, $startcol5); if ($key5 !== null) { $obj5 = MissionLegPeer::getInstanceFromPool($key5); if (!$obj5) { $omClass = MissionLegPeer::getOMClass(); $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1); $obj5 = new $cls(); $obj5->hydrate($row, $startcol5); MissionLegPeer::addInstanceToPool($obj5, $key5); } // if obj5 loaded // Add the $obj1 (Mission) to the collection in $obj5 (MissionLeg) $obj5->setMission($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
<h2><?php echo $title . ' # ' . $mission->getExternalId() . ($leg->getLegNumber() ? ' - ' . $leg->getLegNumber() : ''); ?> </h2> <h3><?php if (isset($mission)) { echo 'Mission # ' . $mission->getExternalId(); } ?> </h3> <div class="person-info"> <?php if (isset($mission)) { if ($mission->getItineraryId()) { $iti = ItineraryPeer::retrieveByPK($mission->getItineraryId()); } } ?> <dl class="person-data"> <dt>Itinerary ID:</dt> <dd> <?php if (isset($iti)) { echo $iti->getId(); } else { echo '--'; } ?> </dd> <dt>Mission Date:</dt>
public function executeAutoRemoveMissionsOnCamp(sfWebRequest $request) { $passenger_id = $request->getParameter('passenger'); $airport_id = $request->getParameter('airport_id'); $camp_id = $request->getParameter('camp'); $mission_id = $request->getParameter('mission_id'); $camp = CampPeer::retrieveByPK($camp_id); $camp_airport_id = $camp->getAirportId(); // To airport id for first mission $from = $request->getParameter('from'); // indicates what should be removed, home to treatement or treatement to home mission? $c = new Criteria(); $c->add(MissionPeer::PASSENGER_ID, $passenger_id); $c->add(MissionPeer::CAMP_ID, $camp_id); $c->add(MissionPeer::ID, $mission_id); $mission = MissionPeer::doSelectOne($c); $itinerary_id = $mission->getItineraryId(); $mission->setCancelMission(0); // Make it hide from public $mission->save(); $itinerary = ItineraryPeer::retrieveByPK($itinerary_id); $itinerary->setCancelItinerary(0); $itinerary->save(); /*foreach($missions as $mission){ $mission_ids[] = $mission->getId(); $itinerary_id = $mission->getItineraryId(); $mission->setCancelMission(0); // Make it hide from public $mission->save(); }*/ //$this->_setAutoLegCancelled($camp_airport_id, $airport_id, $mission_ids[0], 'come'); //$this->_setAutoLegCancelled($camp_airport_id, $airport_id, $mission_ids[1], 'return'); $this->_setAutoLegCancelled($camp_airport_id, $airport_id, $mission->getId(), $from); $c->clear(); $c->add(CampPassengerPeer::CAMP_ID, $camp_id); $c->add(CampPassengerPeer::PASSENGER_ID, $passenger_id); if ($from == 'source') { $c->add(CampPassengerPeer::AIRPORT_ID, $airport_id); } else { $c->add(CampPassengerPeer::RETURN_AIRPORT_ID, $airport_id); } CampPassengerPeer::doDelete($c); return $this->redirect('camp/view?id=' . $camp_id); }
/** * 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()); }
/** * cancel Itinerary * CODE: itinerary_delete */ public function executeCancelItinerary(sfWebRequest $request) { 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'); } $this->forward404Unless($itinerary = ItineraryPeer::retrieveByPk($request->getParameter('id')), sprintf('Object itinerary does not exist (%s).', $request->getParameter('id'))); $itinerary = ItineraryPeer::retrieveByPk($request->getParameter('id')); if ($this->getRequest()->isXmlHttpRequest()) { $itId = $request->getParameter('id'); $final_mails = $this->filterAllMailsFromSubmittedData($request); $itinerary->setCancelItinerary(0); $text = 'Itinerary ' . $itId . ' has been cancelled. Regards, Angel Flight West'; $itinerary->save(); $this->getComponent('mail', 'itinerary_Mission_MissionLegCancel', array('email' => $final_mails, 'subject' => 'Angel Flight West Itinerary cancel information', 'text' => $text)); $this->getUser()->setFlash('success', 'The itinerary ' . $itinerary->getId() . ' has been cancelled successfully.'); //$this->redirect('itinerary/index'); return $this->renderText('success'); } //$request->checkCSRFProtection(); /*$itinerary = ItineraryPeer::retrieveByPk($request->getParameter('id')); $misall = MissionPeer::getAllMissionByItineraryId($request->getParameter('id')); $countMission = MissionPeer::getMissionByItineraryIdCount($request->getParameter('id')); if(isset($itinerary)){ //Fetch email addresses for staffs related to missions of that itinerary $receivers = array(); $receivers = retrieveEmailAddressesRelatedToItinerary::getEmailAddressesOfPersonsRelatedToItinerary($itinerary); if(isset($countMission)){ foreach($misall as $misc){ $mLegs = MissionLegPeer::getAllMissionLegByMissionId($misc->getId()); //$countLeg = MissionLegPeer::getMissionLegByMissionIdCount($misc->getId()); if(count($mLegs)){ foreach($mLegs as $ml){ $ml->setCancelMissionLeg(0); $ml->save(); // Fetch email addresses for staffs related to mission legs of that mission $receivers = array_merge($receivers,retrieveEmailAddressesRelatedToItinerary::getEmailAddressesOfPersonsRelatedToMissionLeg($ml)); } } $misc->setCancelMission(0); $misc->save(); // Fetch email addresses for staffs related to missions of that itinerary $receivers = array_merge($receivers, retrieveEmailAddressesRelatedToItinerary::getEmailAddressesOfPersonsRelatedToMission($misc)); } }*/ /*$itinerary->setCancelItinerary(0); $text = 'Itinerary '.$itinerary->getId().' has been cancelled. Regards, Angel Flight West'; $itinerary->save(); $this->getComponent('mail', 'itinerary_Mission_MissionLegCancel', array( 'email' => array_unique($receivers), 'subject' => 'Angel Flight West Itinerary cancel information', 'text' => $text ));*/ //echo count($receivers); echo '<pre>';print_r(array_unique($receivers));exit; /*}*/ }
/** * 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; }
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'); } } }
/** * Mission * CODE:mission_create */ public function executeEdit(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->mission = MissionPeer::retrieveByPK($request->getParameter('id')); } //ziyed edited $itine = ItineraryPeer::retrieveByPk($this->mission->getItineraryId()); $this->itine = $itine; $this->passenger = PassengerPeer::retrieveByPK($this->mission->getPassengerId()); $this->passenger_a = $this->passenger && $this->passenger->getPerson() ? $this->passenger->getPerson()->getName() : ''; $this->requester = RequesterPeer::retrieveByPK($this->mission->getRequesterId()); $this->requester_a = $this->requester && $this->requester->getPerson() ? $this->requester->getPerson()->getName() : ''; $this->agency = AgencyPeer::retrieveByPK($this->mission->getAgencyId()); $this->agencyName = $this->agency ? $this->agency->getName() : ''; $this->camp = CampPeer::retrieveByPK($this->mission->getCampId()); $this->campName = $this->camp ? $this->camp->getCampName() : ''; //end of ziyed $this->form = new MissionForm($this->mission); $this->referer = $request->getReferer(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('mission_edit')); $this->referer = $request->getReferer(); /*$errors = $this->form->getErrorSchema()->getErrors(); if (count($errors) > 0) echo 'List of Errors:' . '<br>'; { foreach ($errors as $name => $error) { echo $name . ': ' . $error . '<BR>'; } }*/ if ($this->form->isValid()) { $this->mission->setMissionTypeId($this->form->getValue('mission_type_id')); $this->mission->setMissionDate($this->form->getValue('mission_date')); $this->mission->setDateRequested($this->form->getValue('date_requested')); $pass = PassengerPeer::retrieveByPK($this->form->getValue('passenger_id')); if (isset($pass)) { $this->mission->setPassengerId($pass->getId()); } $req = RequesterPeer::retrieveByPK($this->form->getValue('requester_id')); if ($req) { $this->mission->setRequesterId($req->getId()); } if ($this->form->getValue('agency_id') == 0) { $this->mission->setAgencyId(null); } else { $this->mission->setAgencyId($this->form->getValue('agency_id')); } if ($this->form->getValue('camp_id') == 0) { $this->mission->setCampId(null); } else { $this->mission->setCampId($this->form->getValue('camp_id')); } $coor = CoordinatorPeer::retrieveByPK($this->form->getValue('coordinator_id')); if (isset($coor)) { $this->mission->setCoordinatorId($coor->getId()); } $itId = ItineraryPeer::retrieveByPK($this->mission->getItineraryId()); $mLeg = MissionLegPeer::getAllMissionLegByMissionId($request->getParameter('id')); $countLeg = MissionLegPeer::getMissionLegByMissionIdCount($request->getParameter('id')); $this->mission->setApptDate($this->form->getValue('appt_date')); $this->mission->setFlightTime($this->form->getValue('flight_time')); $this->mission->setTreatment($this->form->getValue('treatment')); $this->mission->setComment($this->form->getValue('comment')); $this->mission->setAppointment($this->form->getValue('appointment')); $this->mission->setMissionSpecificComments($this->form->getValue('mission_specific_comments')); if ($this->form->getValue('cancel_mission') == 0) { if (isset($countLeg)) { foreach ($mLeg as $ml) { $ml->setCancelMissionLeg(0); $ml->save(); } } } $this->mission->setCancelMission($this->form->getValue('cancel_mission')); $this->mission->save(); $this->getUser()->setFlash('success', 'Mission has succesfully edited!'); $this->redirect('@mission_view?id=' . $this->mission->getId()); } } }
/** * Returns the number of related Itinerary objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Itinerary objects. * @throws PropelException */ public function countItinerarys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(MissionRequestPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collItinerarys === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(ItineraryPeer::MISSION_REQUEST_ID, $this->id); $count = ItineraryPeer::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(ItineraryPeer::MISSION_REQUEST_ID, $this->id); if (!isset($this->lastItineraryCriteria) || !$this->lastItineraryCriteria->equals($criteria)) { $count = ItineraryPeer::doCount($criteria, $con); } else { $count = count($this->collItinerarys); } } else { $count = count($this->collItinerarys); } } return $count; }
/** * 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 = ItineraryPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setDateRequested($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setMissionRequestId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setMissionTypeId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setApointTime($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setPassengerId($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setRequesterId($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setFacility($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setLodging($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setOrginCity($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setOrginState($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setDestCity($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setDestState($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setWaiverNeed($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setNeedMedicalRelease($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setComment($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setAgencyId($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setCampId($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setLegId($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setPointTime($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setTimetype($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setCancelItinerary($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setCopiedItinerary($arr[$keys[22]]); } }