/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } $pilot_id = $this->getUser()->getPilotId(); $c = new Criteria(); $c->add(MissionLegPeer::TRANSPORTATION, 'air_mission'); $c->add(MissionLegPeer::PILOT_ID, $pilot_id); $c->addJoin(MissionLegPeer::MISSION_ID, MissionPeer::ID, Criteria::RIGHT_JOIN); $c->add(MissionPeer::MISSION_DATE, date('Y-m-d H:i:s'), Criteria::LESS_THAN); $c->addJoin(MissionLegPeer::MISSION_REPORT_ID, MissionReportPeer::ID, Criteria::LEFT_JOIN); $c->add(MissionReportPeer::APPROVED, null, Criteria::ISNULL); $this->mission_legs = MissionLegPeer::doSelectJoinMission($c, null, Criteria::RIGHT_JOIN); }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this MissionReport is new, it will return * an empty collection; or if this MissionReport has previously * been saved, it will retrieve related MissionLegs from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in MissionReport. */ public function getMissionLegsJoinMission($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(MissionReportPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collMissionLegs === null) { if ($this->isNew()) { $this->collMissionLegs = array(); } else { $criteria->add(MissionLegPeer::MISSION_REPORT_ID, $this->id); $this->collMissionLegs = MissionLegPeer::doSelectJoinMission($criteria, $con, $join_behavior); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(MissionLegPeer::MISSION_REPORT_ID, $this->id); if (!isset($this->lastMissionLegCriteria) || !$this->lastMissionLegCriteria->equals($criteria)) { $this->collMissionLegs = MissionLegPeer::doSelectJoinMission($criteria, $con, $join_behavior); } } $this->lastMissionLegCriteria = $criteria; return $this->collMissionLegs; }
public function executeAvailableMissions(sfWebRequest $request) { $pilot = PilotPeer::retrieveByPK($this->getUser()->getPilotId()); if (!$pilot instanceof Pilot) { return sfView::NONE; } if ($pilot->getPrimaryAirportId()) { $this->mission_legs = MissionLegPeer::getPilotNear($pilot->getPrimaryAirportId()); } else { $this->mission_legs = array(); } $this->home_airport = $pilot->getAirport(); $ids = array(); foreach ($this->mission_legs as $leg) { $ids[] = $leg->getId(); } $c = new Criteria(); $c->add(MissionLegPeer::TRANSPORTATION, 'air_mission'); $c->add(MissionLegPeer::ID, $ids, Criteria::NOT_IN); $c->add(MissionLegPeer::CANCELLED, null, Criteria::ISNULL); $c1 = $c->getNewCriterion(MissionLegPeer::PILOT_ID, null, Criteria::ISNULL); $c2 = $c->getNewCriterion(MissionLegPeer::COPILOT_ID, null, Criteria::ISNULL); $c->add($c1->addOr($c2)); $c->setLimit(50); $this->interest_legs = MissionLegPeer::doSelectJoinMission($c); $c->clear(); $c->addJoin(MissionLegPeer::ID, PilotRequestPeer::LEG_ID, Criteria::LEFT_JOIN); $c->add(PilotRequestPeer::ACCEPTED, 1, Criteria::NOT_EQUAL); $c->add(MissionLegPeer::TRANSPORTATION, 'air_mission'); //$c->addAscendingOrderByColumn(); $c->setLimit(50); $this->pending_legs = MissionLegPeer::doSelectJoinMission($c); //ziyed // validity $person = PersonPeer::retrieveByPK($this->getUser()->getId()); //$this->forward404Unless($person); $member = $person->getMember(); //$this->forward404Unless($member); if ($member) { $pilot = $member->getPilot(); } else { $pilot = null; } // filter related $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text')); if ($pilot) { $this->personal_flights = $pilot->getPersonalFlights(); } else { $this->personal_flights = array(); } $this->wings = WingPeer::doSelect(new Criteria()); $this->idents = AirportPeer::doSelect(new Criteria()); $this->states = sfConfig::get('app_short_states'); $this->mission_types = MissionTypePeer::doSelect(new Criteria()); $this->member = $member; $this->pilot = $pilot; if ($pilot) { $this->airport = $pilot->getAirport(); } else { $this->airport = null; } if ($request) { $this->processFilterForm($request); } if ($request->getParameter('needs') == 1) { $this->needs_pilot = 1; } $this->pager = MissionPeer::getPilotAvailablePager($this->max, $this->airport, $this->page, $this->sort_by, $this->date_range1, $this->date_range2, $this->weekdays, $this->wing_id, $this->ident, $this->city, $this->state, $this->zip, $this->origin, $this->dest, $this->needs_pilot, $this->co_pilot, $this->ifr, $this->selected_types, $this->filled, $this->open, $this->max_pass, $this->max_weight, $this->max_distance, $this->min_efficiency, false, $this->ignore_availability); $this->miss_array = $this->pager->getResults(); $this->total_mission_available = $this->pager->getNbResults(); $this->missions = MissionPeer::getByMayInterested($this->airport, $this->min_efficiency); $ident = $request->getParameter('airport_ident'); if (!empty($ident)) { $this->airport_ident = $request->getParameter('airport_ident'); } else { $this->airport_ident = ""; } //end ziyed }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Member is new, it will return * an empty collection; or if this Member has previously * been saved, it will retrieve related MissionLegsRelatedByBackupCopilotId from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Member. */ public function getMissionLegsRelatedByBackupCopilotIdJoinMission($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(MemberPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collMissionLegsRelatedByBackupCopilotId === null) { if ($this->isNew()) { $this->collMissionLegsRelatedByBackupCopilotId = array(); } else { $criteria->add(MissionLegPeer::BACKUP_COPILOT_ID, $this->id); $this->collMissionLegsRelatedByBackupCopilotId = MissionLegPeer::doSelectJoinMission($criteria, $con, $join_behavior); } } else { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(MissionLegPeer::BACKUP_COPILOT_ID, $this->id); if (!isset($this->lastMissionLegRelatedByBackupCopilotIdCriteria) || !$this->lastMissionLegRelatedByBackupCopilotIdCriteria->equals($criteria)) { $this->collMissionLegsRelatedByBackupCopilotId = MissionLegPeer::doSelectJoinMission($criteria, $con, $join_behavior); } } $this->lastMissionLegRelatedByBackupCopilotIdCriteria = $criteria; return $this->collMissionLegsRelatedByBackupCopilotId; }