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 }