예제 #1
0
 /**
  * Available missions for a pilot
  * CODE: mission_view
  * CODE: mission_available
  */
 public function executeRequestLegs(sfWebRequest $request)
 {
     #security
     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->getUri());
         $this->redirect('dashboard/index');
     }
     // 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;
     }
     $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->pager = MissionPeer::getMissionsAvailable();
     $this->miss_array = $this->pager->getResults();
     //echo "<pre>";
     //print_r($this->miss_array);exit;
     $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 = "";
     }
 }
예제 #2
0
 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
 }
예제 #3
0
 /**
  * Mission Available with camps Pilot view
  * CODE:mission_available_camp
  */
 public function executeAvailableCamp(sfWebRequest $request)
 {
     #security
     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');
     }
     // validity
     $person = PersonPeer::retrieveByPK($this->getUser()->getId());
     $this->forward404Unless($person);
     $member = $person->getMember();
     //      $this->forward404Unless($member);
     if ($member) {
         $pilot = $member->getPilot();
     } else {
         $pilot = null;
     }
     //      $this->forward404Unless($pilot);
     if ($pilot && $pilot->getPrimaryAirportId() === null) {
         $this->getUser()->setFlash('warning', 'Please confirm Primary Airport!');
         $this->redirect('account/index');
     }
     // 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());
     if ($member) {
         $this->av = $member->getAvailability();
     } else {
         $this->av = null;
     }
     $this->member = $member;
     $this->pilot = $pilot;
     if ($pilot) {
         $this->primary_airport_id = $pilot->getPrimaryAirportId();
     } else {
         $this->primary_airport_id = null;
     }
     if ($pilot) {
         $this->airport = $pilot->getAirport();
     } else {
         $this->airport = null;
     }
     $this->processFilterForm($request);
     $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, true, $this->ignore_availability);
     $this->miss_array = $this->pager->getResults();
     $this->missions = MissionPeer::getByMayInterested();
     /*
     
             if(isset($pilot) && $pilot->getPrimaryAirportId() != null && $pilot instanceof Pilot){
     
               #get the Pilot's nearest Mission Legs with camps
               $this->mission_legs = MissionLegPeer::getPilotNearWithCamp($pilot->getPrimaryAirportId());
     
               echo var_dump($this->mission_legs);die();
               
               $this->missions = array();
               $this->camps = array();
               $count=0;
     
               foreach ($this->mission_legs as $leg){
                 if($leg->getToAirportId()){
                   $this->destination_airport = $leg->getToAirportId();
                 }
                 $this->missions[$count] = MissionPeer::retrieveByPK($leg->getMissionId());
                 $this->camps[$count] = CampPeer::retrieveByPK(MissionPeer::retrieveByPK($leg->getMissionId())->getCampId());
                 $count++;
               }
     
               #get Missions Pilot may interested
               $this->imissions = MissionPeer::getByMayInterested();
     
               $this->miss_pre = array();
               $this->miss_array = array();
               $this->miss_ids = array();
               $count_pre = 0;
               $count = 0;
               $check = 0;
     
               foreach ($this->mission_legs as $leg){
                 $this->miss_ids[$leg->getMissionId()] = $leg->getMissionId();
               }
     
               foreach ($this->mission_legs as $leg){
                 if($this->miss_ids[$leg->getMissionId()] == $leg->getMissionId()){
                   $this->miss_array[$leg->getMissionId()] = $leg->getMissionId();
                   $count++;
                 }
               }
             }else{
               if($pilot->getPrimaryAirportId() == null && isset($pilot)){
                 $this->getUser()->setFlash('success','Pilot has not confirm Primary Airport!!');
                 $this->redirect('@pilot_view?id='.$pilot->getId());
               }
               $this->getUser()->setFlash('success','You are not Pilot yet!');
               $this->redirect($request->getReferer());
             }
           }else{
             $this->mission_legs = MissionLegPeer::doSelect(new Criteria());
     
             $this->missions = MissionPeer::getByMayInterested();
     
             $this->miss_pre = array();
             $this->miss_array = array();
             $this->miss_ids = array();
             $count_pre = 0;
             $count = 0;
             $check = 0;
     
             foreach ($this->mission_legs as $leg){
               $this->miss_ids[$leg->getMissionId()] = $leg->getMissionId();
             }
     
             foreach ($this->mission_legs as $leg){
               if($this->miss_ids[$leg->getMissionId()] == $leg->getMissionId()){
                 $this->miss_array[$leg->getMissionId()] = $leg->getMissionId();
                 $count++;
               }
             }
           }
         }*/
 }