コード例 #1
0
ファイル: matchSuccess.php プロジェクト: yasirgit/afids
</td>
                        </tr>
                        <tr>
                        <tr>
                            <td colspan="7" class="noborder">
<?php 
            #get passengers assigned to this pilot date
            if (isset($pilot_req) && $pilot_req instanceof PilotRequest) {
                if ($pilot_req->getGroupCampId()) {
                    $camp_id = $pilot_req->getGroupCampId();
                    #get Missions which has selected Camp
                    if (isset($camp_id)) {
                        //---get
                        $passengers = array();
                        foreach ($missions as $miss) {
                            $legs = MissionLegPeer::getbyMissId($miss->getId());
                            //echo '['.$miss->getMissionDate('m/d/Y').'] ['.$key.'<br/>';
                            if (isset($legs) && $legs[0]->getPilotId() == $pilot->getId() && $miss->getMissionDate('m/d/Y') == $key) {
                                $passengers[$miss->getPassengerId()] = $miss;
                            }
                        }
                        //$camp_pilot_passengers = CampPilotPassengerPeer::getByCampPilot($camp_id, $pilot_req->getMemberId());
                        ?>
                            <div id="<?php 
                        echo 'ps_' . $div_id2 . '_' . $pilot_req->getMemberId();
                        ?>
">
                                <table id="<?php 
                        echo 'passes' . $div_id2;
                        ?>
" class="pass">
コード例 #2
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * Show Itinerary details
  * CODE: itinerary_view
  */
 public function executeDetail(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');
     }
     $this->orginset = '';
     $this->destset = '';
     $this->orgintset = '';
     $this->desttset = '';
     if ($request->getParameter('add_passengers')) {
         $this->group_camp_id = $request->getParameter('add_passengers');
     }
     $this->mission;
     $this->mission2;
     $mission;
     $mission2;
     $this->ground_addr_sel = sfConfig::get('app_ground_address_type', array());
     $this->errors = array();
     $this->errors2 = array();
     if ($request->getParameter('id')) {
         $this->itinerary = ItineraryPeer::retrieveByPK($request->getParameter('id'));
         $this->back = $request->getReferer();
         //echo $this->itinerary->getId();
         if (strstr($this->back, '/mission/view')) {
             $this->frommission = 1;
         } else {
             $this->frommission = 0;
         }
         $this->mis = MissionPeer::getMissionByItineraryId($this->itinerary->getId(), 1);
         $mission = $this->mis;
         /*echo "<pre>";
           print_r($this->mis);
           echo "</pre>";
           die("ok");
           */
         $this->mission = $mission;
         //print_r($mission);      exit ();
         ///Show leges
         if (isset($mission)) {
             $this->mis_legs = MissionLegPeer::getbyMissId($mission->getId());
         }
         //echo "<pre>";
         //print_r($this->mis_legs);
         //echo $this->itinerary->getId();
         $this->mis2 = MissionPeer::getMissionByItineraryId($this->itinerary->getId(), 2);
         /*
         echo "<pre>";
         print_r($this->mis2);
         echo "</pre>";
         die("ok");
         */
         $mission2 = $this->mis2;
         $this->mission2 = $mission2;
         $this->ground_addresses = array('patient' => '', 'facility' => '', 'lodging' => '', 'airport' => '');
         $pass;
         $this->personnew;
         if ($this->itinerary) {
             $this->ground_addresses['lodging'] = $this->ground_addresses['facility'] = $this->itinerary->getDestCity() . ', ' . $this->itinerary->getDestState();
             $pass = PassengerPeer::retrieveByPK($this->itinerary->getPassengerId());
             $this->personnew = PersonPeer::retrieveByPK($pass->getPersonId());
         }
         if ($pass) {
             $this->ground_addresses['lodging'] = $pass->getLodgingName() . ' ' . $this->ground_addresses['lodging'];
             $this->ground_addresses['facility'] = $pass->getFacilityName() . ' ' . $this->ground_addresses['facility'];
             $this->ground_addresses['patient'] = $this->personnew->getAddress1() . ' ' . $this->personnew->getAddress2() . ' ' . $this->personnew->getCity() . ', ' . $this->personnew->getState() . ' ' . $this->personnew->getZipcode();
             $this->ground_addresses['airport'] = $this->personnew->getAddress1() . ' ' . $this->personnew->getAddress2() . ' ' . $this->personnew->getCity() . ', ' . $this->personnew->getState() . ' ' . $this->personnew->getZipcode();
         }
     }
     if ($request->isMethod('post')) {
         if ($request->getParameter('com')) {
             if ($request->getParameter('com') == 1) {
                 $mission->setComment($request->getParameter('mis_comment'));
                 $mission->save();
             } elseif ($request->getParameter('com') == 2) {
                 $mission2->setComment($request->getParameter('mist_comment'));
                 $mission2->save();
             }
             $this->getUser()->setFlash('success', 'Comment successfully saved.');
         } else {
             if ($request->getParameter('misstsave') == 1) {
                 switch ($request->getParameter('transportation')) {
                     case 'air_mission':
                         $origin_airports = (array) $request->getParameter('origint_idents');
                         $dest_airports = (array) $request->getParameter('destinationt_idents');
                         $idents = $dest_airports;
                         $tmp_arr = array();
                         foreach ($origin_airports as $i => $ident) {
                             $idents[] = $ident;
                             $v = $ident . ' to ' . $dest_airports[$i];
                             if (in_array($v, $tmp_arr)) {
                                 $this->errors2[] = 'Leg ' . $v . ' appeared more than one';
                             } else {
                                 $tmp_arr[] = $v;
                             }
                             if ($dest_airports[$i] == $ident) {
                                 $this->errors2[] = 'Leg ' . $ident . ' to ' . $dest_airports[$i] . ' is invalid';
                             }
                         }
                         $idents = array_unique($idents);
                         $c = new Criteria();
                         $c->add(AirportPeer::IDENT, $idents, Criteria::IN);
                         if (count($idents) != AirportPeer::doCount($c)) {
                             $this->errors2[] = 'Some airport idents are invalid';
                         }
                         break;
                     case 'ground_mission':
                         $origin = $request->getParameter('groundt_origin');
                         $destination = $request->getParameter('groundt_destination');
                         $orgintset = $request->getParameter('orgintset');
                         $desttset = $request->getParameter('desttset');
                         $this->desttset = $desttset;
                         $this->orgintset = $orgintset;
                         if (empty($destination) && empty($desttset)) {
                             $this->errors2[] = 'Please specify destination address';
                         }
                         if (empty($origin) && empty($orgintset)) {
                             $this->errors2[] = 'Please specify origin address';
                         } elseif ($destination == $origin && $destination != '') {
                             $this->errors2[] = 'Origin and Destination addresses conflict';
                         }
                         break;
                     case 'commercial_mission':
                         $mission_date = $request->getParameter('mission_date');
                         if (empty($mission_date)) {
                             $this->errors2[] = 'Mission date is required';
                         }
                         if ($v = $request->getParameter('airline_id')) {
                             $custom = $request->getParameter('airline_custom');
                             if ($v == 'other') {
                                 if (empty($custom)) {
                                     $this->errors2[] = 'Please type a new airline name!';
                                 }
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($v = $request->getParameter('airline_id'));
                                 if (!$airline instanceof Airline) {
                                     $this->errors2[] = 'Please select airline!';
                                 }
                             }
                         } else {
                             $this->errors2[] = 'Please select airline!';
                         }
                         break;
                     default:
                         $this->errors2[] = 'Please select Transportation Type';
                 }
                 if (count($this->errors2)) {
                     # error in form
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $this->origin_idents = $origin_airports;
                             $this->dest_idents = $dest_airports;
                             break;
                         case 'ground_mission':
                             break;
                         case 'commercial_mission':
                             break;
                     }
                     $this->erer = 2;
                 } else {
                     $missioncount = MissionLegPeer::getMaxLegNumber($mission2->getId());
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $aircount = MissionLegPeer::getCountbyMissIdAndType($mission2->getId(), 'air_mission');
                             for ($i = 0; $i < sizeof($origin_airports); $i++) {
                                 $airport_o = AirportPeer::getByIdent($origin_airports[$i]);
                                 $airport_d = AirportPeer::getByIdent($dest_airports[$i]);
                                 $missioncount++;
                                 $aircount++;
                                 $mission_leg = new MissionLeg();
                                 $mission_leg->setMissionId($mission2->getId());
                                 $mission_leg->setLegNumber($missioncount);
                                 $mission_leg->setFromAirportId($airport_o->getId());
                                 $mission_leg->setToAirportId($airport_d->getId());
                                 $mission_leg->setPrefix('air' . $aircount);
                                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 $mission_leg->setPassOnBoard(0);
                                 $mission_leg->setTransportation('air_mission');
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                             }
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'ground_mission':
                             $groundcount = MissionLegPeer::getCountbyMissIdAndType($mission2->getId(), 'ground_mission');
                             $mission_leg = new MissionLeg();
                             $orgintsetsave = $request->getParameter('groundt_origin');
                             if (empty($orgintsetsave)) {
                                 $orgintsetsave = $request->getParameter('orgintset');
                             }
                             $desttsetsave = $request->getParameter('groundt_destination');
                             if (empty($desttsetsave)) {
                                 $desttsetsave = $request->getParameter('desttset');
                             }
                             $groundcount++;
                             $sas = $missioncount + 1;
                             $mission_leg->setMissionId($mission2->getId());
                             $mission_leg->setLegNumber($sas);
                             $mission_leg->setPassOnBoard(0);
                             $mission_leg->setTransportation('ground_mission');
                             $mission_leg->setGroundOrigin($orgintsetsave);
                             $mission_leg->setGroundDestination($desttsetsave);
                             $mission_leg->setPrefix('g' . $groundcount);
                             $mission_leg->setCancelMissionLeg(1);
                             $mission_leg->save();
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'commercial_mission':
                             $comcount = MissionLegPeer::getCountbyMissIdAndType($mission2->getId(), 'commercial_mission');
                             $flight_time = $request->getParameter('flight_time');
                             if (empty($flight_time['hour']) || empty($flight_time['minute'])) {
                                 $flight_time = null;
                             }
                             $airline_id = $request->getParameter('airline_id');
                             if ($airline_id == 'other') {
                                 $airline = new Airline();
                                 $airline->setName($request->getParameter('airline_custom'));
                                 $airline->save();
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($airline_id);
                                 $this->forward404Unless($airline);
                             }
                             $origins = $request->getParameter('origin');
                             $destinations = $request->getParameter('destination');
                             $flight_numbers = $request->getParameter('flight_number');
                             $departures = $request->getParameter('departure');
                             $arrivals = $request->getParameter('arrival');
                             $mission->setFlightTime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']);
                             $missioncount++;
                             $n_leg = $missioncount;
                             foreach ($origins as $i => $origin) {
                                 if (empty($origin) || empty($destinations[$i])) {
                                     continue;
                                 }
                                 $mission_leg = new MissionLeg();
                                 $comcount++;
                                 $mission_leg->setMissionId($mission2->getId());
                                 $mission_leg->setLegNumber($n_leg++);
                                 $mission_leg->setFlightTime($flight_time ? strtotime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']) : null);
                                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 $mission_leg->setAirlineId($airline->getId());
                                 $mission_leg->setFundId($request->getParameter('fund_id'));
                                 $mission_leg->setConfirmCode($request->getParameter('confirm_code'));
                                 $mission_leg->setFlightCost($request->getParameter('flight_cost'));
                                 $mission_leg->setCommOrigin($origin);
                                 $mission_leg->setCommDest($destinations[$i]);
                                 $mission_leg->setFlightNumber($flight_numbers[$i]);
                                 $v = $departures[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $v = $arrivals[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $mission_leg->setTransportation('commercial_mission');
                                 $mission_leg->setPrefix('com' . $comcount);
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                                 $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                                 return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             }
                             break;
                     }
                 }
             } else {
                 switch ($request->getParameter('transportation')) {
                     case 'air_mission':
                         $origin_airports = (array) $request->getParameter('origin_idents');
                         $dest_airports = (array) $request->getParameter('destination_idents');
                         $idents = $dest_airports;
                         $tmp_arr = array();
                         foreach ($origin_airports as $i => $ident) {
                             $idents[] = $ident;
                             $v = $ident . ' to ' . $dest_airports[$i];
                             if (in_array($v, $tmp_arr)) {
                                 $this->errors[] = 'Leg ' . $v . ' appeared more than one';
                             } else {
                                 $tmp_arr[] = $v;
                             }
                             if ($dest_airports[$i] == $ident) {
                                 $this->errors[] = 'Leg ' . $ident . ' to ' . $dest_airports[$i] . ' is invalid';
                             }
                         }
                         $idents = array_unique($idents);
                         $c = new Criteria();
                         $c->add(AirportPeer::IDENT, $idents, Criteria::IN);
                         if (count($idents) != AirportPeer::doCount($c)) {
                             $this->errors[] = 'Some airport idents are invalid';
                         }
                         break;
                     case 'ground_mission':
                         $origin = $request->getParameter('ground_origin');
                         $destination = $request->getParameter('ground_destination');
                         //echo $destination; die();
                         $orginset = $request->getParameter('orginset');
                         $destset = $request->getParameter('destset');
                         $this->destset = $destset;
                         $this->orginset = $orginset;
                         if (empty($destination) && empty($destset)) {
                             $this->errors[] = 'Please specify destination address';
                         }
                         if (empty($origin) && empty($orginset)) {
                             $this->errors[] = 'Please specify origin address';
                         } elseif ($destination == $origin && $destination != '') {
                             $this->errors[] = 'Origin and Destination addresses conflict';
                         }
                         break;
                     case 'commercial_mission':
                         $mission_date = $request->getParameter('mission_date');
                         if (empty($mission_date)) {
                             $this->errors[] = 'Mission date is required';
                         }
                         if ($v = $request->getParameter('airline_id')) {
                             $custom = $request->getParameter('airline_custom');
                             if ($v == 'other') {
                                 if (empty($custom)) {
                                     $this->errors[] = 'Please type a new airline name!';
                                 }
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($v = $request->getParameter('airline_id'));
                                 if (!$airline instanceof Airline) {
                                     $this->errors[] = 'Please select airline!';
                                 }
                             }
                         } else {
                             $this->errors[] = 'Please select airline!';
                         }
                         break;
                     default:
                         $this->errors[] = 'Please select Transportation Type';
                 }
                 if (count($this->errors)) {
                     # error in form
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $this->origin_idents = $origin_airports;
                             $this->dest_idents = $dest_airports;
                             break;
                         case 'ground_mission':
                             break;
                         case 'commercial_mission':
                             break;
                     }
                 } else {
                     $missioncount = MissionLegPeer::getMaxLegNumber($mission->getId());
                     switch ($request->getParameter('transportation')) {
                         case 'air_mission':
                             $aircount = MissionLegPeer::getCountbyMissIdAndType($mission->getId(), 'air_mission');
                             for ($i = 0; $i < sizeof($origin_airports); $i++) {
                                 $airport_o = AirportPeer::getByIdent($origin_airports[$i]);
                                 $airport_d = AirportPeer::getByIdent($dest_airports[$i]);
                                 $missioncount++;
                                 $aircount++;
                                 $mission_leg = new MissionLeg();
                                 $mission_leg->setMissionId($mission->getId());
                                 $mission_leg->setLegNumber($missioncount);
                                 $mission_leg->setFromAirportId($airport_o->getId());
                                 $mission_leg->setToAirportId($airport_d->getId());
                                 $mission_leg->setPrefix('air' . $aircount);
                                 //$mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 //$mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 $mission_leg->setPassOnBoard(0);
                                 $mission_leg->setTransportation('air_mission');
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                             }
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'ground_mission':
                             $groundcount = MissionLegPeer::getCountbyMissIdAndType($mission->getId(), 'ground_mission');
                             $mission_leg = new MissionLeg();
                             $orginsetsave = $request->getParameter('ground_origin');
                             if (empty($orginsetsave)) {
                                 $orginsetsave = $request->getParameter('orginset');
                             }
                             $destsetsave = $request->getParameter('ground_destination');
                             if (empty($destsetsave)) {
                                 $destsetsave = $request->getParameter('destset');
                             }
                             $groundcount++;
                             $missioncount++;
                             $sa = $missioncount;
                             $mission_leg->setMissionId($mission->getId());
                             $mission_leg->setLegNumber($sa);
                             $mission_leg->setPassOnBoard(0);
                             $mission_leg->setTransportation('ground_mission');
                             $mission_leg->setGroundOrigin($orginsetsave);
                             $mission_leg->setGroundDestination($destsetsave);
                             $mission_leg->setPrefix('g' . $groundcount);
                             $mission_leg->setCancelMissionLeg(1);
                             $mission_leg->save();
                             $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                             return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             break;
                         case 'commercial_mission':
                             $comcount = MissionLegPeer::getCountbyMissIdAndType($mission->getId(), 'commercial_mission');
                             $flight_time = $request->getParameter('flight_time');
                             if (empty($flight_time['hour']) || empty($flight_time['minute'])) {
                                 $flight_time = null;
                             }
                             $airline_id = $request->getParameter('airline_id');
                             if ($airline_id == 'other') {
                                 $airline = new Airline();
                                 $airline->setName($request->getParameter('airline_custom'));
                                 $airline->save();
                             } else {
                                 $airline = AirlinePeer::retrieveByPK($airline_id);
                                 $this->forward404Unless($airline);
                             }
                             $origins = $request->getParameter('origin');
                             $destinations = $request->getParameter('destination');
                             $flight_numbers = $request->getParameter('flight_number');
                             $departures = $request->getParameter('departure');
                             $arrivals = $request->getParameter('arrival');
                             $mission->setFlightTime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']);
                             $missioncount++;
                             $n_leg = $missioncount;
                             foreach ($origins as $i => $origin) {
                                 if (empty($origin) || empty($destinations[$i])) {
                                     continue;
                                 }
                                 $mission_leg = new MissionLeg();
                                 $comcount++;
                                 $mission_leg->setMissionId($mission->getId());
                                 $mission_leg->setLegNumber($n_leg++);
                                 $mission_leg->setFlightTime($flight_time ? strtotime($flight_time['hour'] . ':' . $flight_time['minute'] . ' ' . $flight_time['period']) : null);
                                 $mission_leg->setBaggageDesc($request->getParameter('baggage_desc'));
                                 $mission_leg->setBaggageWeight($request->getParameter('baggage_weight'));
                                 $mission_leg->setAirlineId($airline->getId());
                                 $mission_leg->setFundId($request->getParameter('fund_id'));
                                 $mission_leg->setConfirmCode($request->getParameter('confirm_code'));
                                 $mission_leg->setFlightCost($request->getParameter('flight_cost'));
                                 $mission_leg->setCommOrigin($origin);
                                 $mission_leg->setCommDest($destinations[$i]);
                                 $mission_leg->setFlightNumber($flight_numbers[$i]);
                                 $v = $departures[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $v = $arrivals[$i];
                                 if (empty($v['hour']) || empty($v['minute'])) {
                                     $v = null;
                                 }
                                 $mission_leg->setDeparture($v ? strtotime($v['hour'] . ':' . $v['minute'] . ' ' . $v['period']) : null);
                                 $mission_leg->setTransportation('commercial_mission');
                                 $mission_leg->setPrefix('com' . $comcount);
                                 $mission_leg->setCancelMissionLeg(1);
                                 $mission_leg->save();
                                 $this->getUser()->setFlash('success', 'Mission and Leg #' . $mission_leg->getMissionId() . '-' . $mission_leg->getLegNumber() . ' has successfully created!');
                                 return $this->redirect('/itinerary/detail/' . $this->itinerary->getId());
                             }
                             break;
                     }
                 }
             }
         }
     }
     if ($request->getParameter('id')) {
         //$this->itinerary = ItineraryPeer::retrieveByPK($request->getParameter('id'));
         //$this->mis  = MissionPeer::getMissionByItineraryId($this->itinerary->getId(), 'Home');
         //$mission = $this->mis;
         if (isset($mission)) {
             $this->mis_comment = $mission->getComment();
         }
         //$this->mis_legs = MissionLegPeer::getbyMissId($mission->getId());
         if ($mission2) {
             $this->mis2_legs = MissionLegPeer::getbyMissId($mission2->getId());
             $this->mist_comment = $mission2->getComment();
         }
         $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text'));
         $this->time_widget = new widgetFormTime();
         $this->airport_list = AirportPeer::getMappable();
         $this->ground_addresses = $this->getGroundAddresses();
         $this->airlines = AirlinePeer::doSelect(new Criteria());
         $this->funds = FundPeer::doSelect(new Criteria());
         $this->miss_ids = array();
         $c = 0;
         $count = 0;
         $count2 = 0;
         if (isset($this->itinerary)) {
             $this->missions = MissionPeer::getByItiId($this->itinerary->getId());
             if (isset($this->missions)) {
                 foreach ($this->missions as $mi) {
                     $this->miss_ids[$c] = $mi->getId();
                     $legs = MissionLegPeer::getbyMissId($mi->getId());
                 }
             }
         }
         $this->title = '#' . $this->itinerary->getId() . ' Itinerary Details';
     }
 }
コード例 #3
0
ファイル: maPilotSuccess.php プロジェクト: yasirgit/afids
                <a class="btn-dtls" href="javascript:getLegs(<?php 
            echo $mission->getId();
            ?>
)">
                  <span>Details</span>
                </a>
              </div>
<!--              END BG-->
            </div>
<!--            End FRAME-->
          </div>
<!--          END interest-missions-info-->
<!--        END HOLDER-->
        <?php 
            if (isset($mission)) {
                $o_mission_legs = MissionLegPeer::getbyMissId($mission->getId());
            }
            ?>
<!--   START INTEREST"S LEGS -->
        <div class="location-matches-info" id="<?php 
            echo 'other_leg' . $mission->getId();
            ?>
" style="display:none">
          <div class="frame">
            <div class="bg">
               <div class="route">
                <strong>TO TREATMENT:</strong>
                <ul>
                  <li>
                    <img alt="ico" src="/images/ico-home.gif"/>
                  </li>
コード例 #4
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * Mission Leg
  * CODE:mission_leg_delete
  */
 public function executeDelete(sfWebRequest $request)
 {
     #Security
     if (!$this->getUser()->hasCredential(array('Administrator'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     if ($request->getParameter('id')) {
         $suc = '';
         $suc2 = '';
         $mission_leg = MissionLegPeer::retrieveByPK($request->getParameter('id'));
         if (isset($mission_leg)) {
             $has_pilot_req = PilotRequestPeer::getByLegId($mission_leg->getId());
             if (isset($has_pilot_req) && $has_pilot_req instanceof PilotRequest) {
                 //try{
                 $has_pilot_req->delete();
                 $suc = ' And Pilot request #' . $has_pilot_req->getId() . ' has deleted!';
                 //}catch (Exception $e){echo "exception-1";}
             }
             $has_discussions = DiscussionPeer::getByLegID($mission_leg->getId());
             if (isset($has_discussions)) {
                 foreach ($has_discussions as $dis) {
                     //try{
                     $dis->delete();
                     //}catch (Exception $e){echo "exception-2";}
                 }
                 $suc2 = ' And Leg\'s Discussion(s) has deleted!';
             }
         }
         if (isset($mission_leg) && $mission_leg instanceof MissionLeg) {
             try {
                 $miss_id = $mission_leg->getMissionId();
                 $miss_leg_d = $mission_leg->getLegNumber();
                 $mission_leg->delete();
                 $mission_legs = MissionLegPeer::getbyMissId($miss_id);
                 if ($mission_legs) {
                     foreach ($mission_legs as $mleg) {
                         if ($mleg->getLegNumber() > $miss_leg_d) {
                             $mleg->setLegNumber($mleg->getLegNumber() - 1);
                             $mleg->save();
                         }
                     }
                 }
             } catch (Exception $e) {
                 $this->getUser()->setFlash('warning', "There are related persons to this mission leg. Please remove them first.");
             }
             $this->getUser()->setFlash('success', 'Missin Leg # ' . $mission_leg->getId() . ' has successfully deleted!' . $suc . $suc2);
             //}catch (Exception $e){ echo "exception-3";}
             if ($request->getReferer()) {
                 $this->redirect($request->getReferer());
             } else {
                 $this->redirect('leg');
             }
         }
     }
 }
コード例 #5
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * Pilot Request Thanks =  Other Mission legs for Pilot
  * CODE:
  */
 public function executePilotThanks(sfWebRequest $request)
 {
     if ($request->getParameter('id')) {
         $this->cur_leg = MissionLegPeer::retrieveByPK($request->getParameter('id'));
         $mission = MissionPeer::retrieveByPK($this->cur_leg->getMissionId());
         $this->other_legs = MissionLegPeer::getbyMissId($mission->getId());
         $member = MemberPeer::retrieveByPK($this->getUser()->getMemberId());
         if ($member) {
             $pilot = $member->getPilot();
         } else {
             $pilot = null;
         }
         $this->pilot = $pilot;
         if ($pilot) {
             $this->airport = $pilot->getAirport();
         } else {
             $this->airport = null;
         }
     }
 }
コード例 #6
0
ファイル: actions.class.php プロジェクト: yasirgit/afids
 /**
  * Request a group Missions 
  * CODE:mission_request_group_create
  */
 public function executeRequestGroupMission(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');
     }
     $camp = CampPeer::retrieveByPK($request->getParameter('id'));
     if (isset($camp) && $camp instanceof Camp) {
         $this->camp_id = $camp->getId();
         $missions = MissionPeer::getByCampId($camp->getId());
     }
     $this->dates = array();
     $this->home_base = null;
     $this->number_of_seats = null;
     $this->total_carry = null;
     $this->multi_pick = null;
     $this->date_choice = null;
     $this->comment = null;
     $this->request_as = null;
     $this->acc_cre = null;
     $this->pilot_ma = null;
     $this->IFR = null;
     $this->aircraft = null;
     $this->tail = null;
     $this->other_pilot = null;
     $miss_dates = array();
     //$appt_dates = array();
     //$count = 0;
     //$count2 = 0;
     foreach ($missions as $mission) {
         if ($mission->getMissionDate()) {
             $miss_dates[$mission->getMissionDate('m/d/Y')] = $mission->getMissionDate();
             //$count++;
             //it may change
             $this->mission_date = $mission->getMissionDate();
             $this->appt_date = $mission->getApptDate();
             //
         }
         /*
               if($mission->getApptDate()){
                 $appt_dates[$count2] = $mission->getApptDate();
                 $count2++;
               }*/
         $miss_id = $mission->getId();
     }
     $this->mission_dates = array();
     $this->mission_dates = $miss_dates;
     if (isset($miss_id)) {
         $legs = MissionLegPeer::getbyMissId($miss_id);
         $this->mission = MissionPeer::retrieveByPK($miss_id);
         foreach ($legs as $leg) {
             if ($leg->getToAirportId()) {
                 $this->leg = $leg;
                 $airport = AirportPeer::retrieveByPK($leg->getToAirportId());
                 if (isset($airport) && $airport instanceof Airport) {
                     $this->destination_airport = $airport;
                 }
             }
         }
     }
     /*
     if(isset($miss_dates[$count-1])){
       $this->mission_date = $miss_dates[$count-1];
     }
     if(isset($appt_dates[$count2-1])){
       $this->appt_date = $appt_dates[$count2-1];
     }
     */
     //$this->mission_leg = MissionLegPeer::retrieveByPK($request->getParameter('id'));
     $member = MemberPeer::getByPersonId($this->getUser()->getId());
     if (isset($member)) {
         $this->pilot = PilotPeer::getByMemberId($member->getId());
         $this->pilot_aircrafts = PilotAircraftPeer::getByMemberId($member->getId());
         $this->pre_requests = PilotRequestPeer::getByMemnerIdLegIdCamp($member->getId(), $this->leg->getId());
     }
     if ($request->isMethod('post')) {
         if ($request->getParameter('id')) {
             //set post variables
             $this->dates = $request->getParameter('dates[]', array());
             $this->home_base = $request->getParameter('home_base');
             $this->number_of_seats = $request->getParameter('number_of_seats');
             $this->total_carry = $request->getParameter('total_carry');
             $this->multi_pick = $request->getParameter('multi_pick');
             $this->date_choice = $request->getParameter('date_choice');
             $this->comment = $request->getParameter('comment');
             $this->request_as = $request->getParameter('request_as');
             $this->acc_cre = $request->getParameter('acc_cre');
             $this->pilot_ma = $request->getParameter('pilot_ma');
             $this->IFR = $request->getParameter('IFR');
             $this->aircraft = $request->getParameter('aircraft');
             $this->tail = $request->getParameter('tail');
             $this->other_pilot = $request->getParameter('other_pilot');
             if (count($this->dates) > 0 && $request->getParameter('home_base') && $request->getParameter('number_of_seats') && $request->getParameter('total_carry')) {
                 //check if this pilot requested this camp already?
                 $c = $has_requested = PilotRequestPeer::getByMemberIdCampId($member->getId(), $request->getParameter('camp_id'));
                 if (!$has_requested) {
                     $pilot_request = new PilotRequest();
                     if ($member) {
                         $pilot_request->setMemberId($member->getId());
                     }
                     $pilot_request->setGroupCampId($request->getParameter('camp_id'));
                     if ($request->getParameter('home_base')) {
                         $airport_hb = AirportPeer::getByIdent($request->getParameter('home_base'));
                         if (isset($airport_hb) && $airport_hb instanceof Airport) {
                             $pilot_request->setHomeBase($airport_hb->getIdent());
                         } else {
                             $this->getUser()->setFlash('warning', 'Home Base is not found!');
                             $this->redirect($request->getReferer());
                         }
                     }
                     if ($request->getParameter('number_of_seats')) {
                         if (is_integer((int) $request->getParameter('number_of_seats'))) {
                             $pilot_request->setNumberSeats((int) $request->getParameter('number_of_seats'));
                         } else {
                             $this->getUser()->setFlash('warning', 'Number of seats is in wrong format!');
                             $this->redirect($request->getReferer());
                         }
                     }
                     if ($request->getParameter('total_carry')) {
                         if (is_int((int) $request->getParameter('total_carry'))) {
                             $pilot_request->setTotalWeight((int) $request->getParameter('total_carry'));
                         } else {
                             $this->getUser()->setFlash('success', 'Total of carry value is in wrong format!');
                             $this->redirect($request->getReferer());
                         }
                     }
                     $pilot_request->setMultiplePick($request->getParameter('multi_pick'));
                     $pilot_request->save();
                     if (count($this->dates) > 0) {
                         #check is has Pilot Date
                         //$has_pilot_date = PilotDatePeer::getByMemberId($member->getId());
                         for ($y = 0; $y < count($this->dates); $y++) {
                             $pilot_date = new PilotDate();
                             $pilot_date->setMemberId($member->getId());
                             $pilot_date->setDate($this->dates[$y]);
                             $pilot_date->setPilotRequestId($pilot_request->getId());
                             $pilot_date->save();
                         }
                     }
                     if (count($this->dates) == 0) {
                         $pilot_request->setDate($this->dates[0]);
                     }
                     $pilot_request->setNumberDateAssign($request->getParameter('date_choice', 1));
                     $pilot_request->setPilotType($request->getParameter('request_as'));
                     $pilot_request->setComment($request->getParameter('comment'));
                     $pilot_request->setAircraftId($request->getParameter('aircraft'));
                     $pilot_request->setTail($request->getParameter('tail'));
                     //check pilot_type
                     if ($request->getParameter('other_pilot') == 1) {
                         ////mission assistant,earth angel
                         $pilot_request->setMissionAssistantWanted(0);
                         $pilot_request->setIfrBackupWanted(0);
                         $pilot_request->setAccepted(0);
                         $pilot_request->setProcessed(0);
                         $pilot_request->setOnHold(0);
                     } else {
                         ////command pilot
                         $pilot_request->setProcessed(1);
                         if ($request->getParameter('acc_cre') == 1) {
                             $pilot_request->setMissionAssistantWanted(0);
                             #set pilot as mission assistant
                             if ($member->getPerson()) {
                                 $pilot_request->setMissionAssistantName($member->getPerson()->getLastName() . ' ' . $member->getPerson()->getFirstName());
                             }
                         } else {
                             $pilot_request->setMissionAssistantWanted(0);
                             #set pilot's mission assistant as mission assistant
                             if ($request->getParameter('pilot_ma')) {
                                 $pilot_request->setMissionAssistantName($request->getParameter('pilot_ma'));
                             }
                         }
                         if ($request->getParameter('IFR') == 0) {
                             $pilot_request->setIfrBackupWanted(0);
                         } else {
                             $pilot_request->setIfrBackupWanted(1);
                         }
                     }
                     $pilot_request->setCreatedAt(date('m/d/y'));
                     $pilot_request->save();
                     $this->getUser()->setFlash('success', 'Your request has been saved on Camp ID#' . $request->getParameter('camp_id'));
                     //            $this->redirect('@pilot_thanks?id='.$request->getParameter('id'));
                 } else {
                     $this->getUser()->setFlash('success', 'You have already requested this Camp Mission!');
                     //            $this->redirect('@pilot_thanks?id='.$request->getParameter('id'));
                 }
             } else {
                 if (count($this->dates) < 1) {
                     $this->date_other_e = 1;
                     $this->type = $request->getParameter('request_as');
                 }
                 if (!$request->getParameter('home_base')) {
                     $this->home = 1;
                 }
                 if (!$request->getParameter('number_of_seats')) {
                     $this->number_of = 1;
                 }
                 if (!$request->getParameter('total_carry')) {
                     $this->carry = 1;
                 }
             }
         }
     }
 }