protected function processStep3Check(sfWebRequest $request) { $default_airport = AirportPeer::getByIdent(sfConfig::get('app_default_airport_ident')); $this->forward404Unless($default_airport); $app = $this->application_temp; $person = $this->person; if (!$person instanceof Person) { $person = new Person(); } /* @var $app ApplicationTemp */ /* @var $person Person */ // Person $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['evening_phone'] = $tmp_arr['eve_phone']; $tmp_arr['evening_comment'] = $tmp_arr['eve_comment']; unset($tmp_arr['id']); $person->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $person->save(); // Member $member = MemberPeer::getByPersonId($person->getId()); if (!$member instanceof Member) { $member = new Member(); } // Generate external id using last member is and external id $c = new Criteria(); $c->add(MemberPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL); $c->addDescendingOrderByColumn(MemberPeer::ID); $external_member = MemberPeer::doSelectOne($c); $external_id = $external_member->getExternalId(); $currentExternalId = $external_id + 1; //print_r($external_id); //print_r($currentExternalId); $member->setActive(1); $member->setCoPilot($app->getApplicantCopilot()); $member->setContact('By Email'); $member->setDateOfBirth($app->getDateOfBirth()); $member->setDriversLicenseState($app->getDriversLicenseState()); $member->setDriversLicenseNumber($app->getDriversLicenseNumber()); $member->setEmergencyContactName($app->getEmergencyContactName()); $member->setEmergencyContactPhone($app->getEmergencyContactPhone()); $member->setFlightStatus($app->getApplicantPilot() ? 'Verify Orientation' : 'Non-pilot'); $member->setJoinDate(time()); $member->setLanguages($app->getLanguagesSpoken()); //$member->setMasterMemberId($app->getMasterMemberId()); $member->setMemberClassId($app->getMemberClassId()); $member->setPersonId($person->getId()); $member->setRenewedDate(time()); $member->setRenewalDate(strtotime('+1 year')); $member->setSpouseName($app->getSpouseFirstName() . ' ' . $app->getSpouseLastName()); //external_id generate $member->setExternalId($currentExternalId); $member->setWingId($app->getWingId()); $member->save(); // Pilot if ($app->getApplicantPilot()) { $pilot = new Pilot(); $pilot->setMemberId($member->getId()); $airport = AirportPeer::getByIdent($app->getHomeBase()); if (!$airport instanceof Airport) { $airport = $default_airport; } $pilot->setPrimaryAirportId($airport->getId()); $pilot->setTotalHours($app->getTotalHours()); $pilot->setLicenseType('Private'); foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setLicenseType($key); } } $pilot->setIfr(stripos($app->getRatings(), 'ifr') !== false ? 1 : 0); $pilot->setMultiEngine(stripos($app->getRatings(), 'multi') !== false ? 1 : 0); $pilot->setSeInstructor('No'); // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($app->getRatings(), $key) !== false) { $pilot->setSeInstructor($key); } } $pilot->setMeInstructor($pilot->getSeInstructor()); $pilot->save(); // Availability $availability = new Availability(); $availability->setMemberId($member->getId()); $availability->setNotAvailable(0); $availability->setNoWeekday($app->getAvailabilityWeekdays() == 0); $availability->setNoNight($app->getAvailabilityWeeknights() == 0); $availability->setLastMinute($app->getAvailabilityLastMinute()); $availability->setAsMissionMssistant($app->getAvailabilityCopilot()); $availability->setNoWeekend($app->getAvailabilityWeekends() == 0); try { $availability->save(); } catch (Exception $e) { } // Primary aircraft if ($app->getAircraftPrimaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftPrimaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftPrimaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftPrimaryOwn()); $pilot_aircraft->setSeats($app->getAircraftPrimarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftPrimaryIce()); $pilot_aircraft->save(); } // Secondary aircraft if ($app->getAircraftSecondaryId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftSecondaryId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftSecondaryNNumber()); $pilot_aircraft->setOwn($app->getAircraftSecondaryOwn()); $pilot_aircraft->setSeats($app->getAircraftSecondarySeats()); $pilot_aircraft->setKnownIce($app->getAircraftSecondaryIce()); $pilot_aircraft->save(); } // Third aircraft if ($app->getAircraftThirdId() && ($aircraft = AircraftPeer::retrieveByPK($app->getAircraftThirdId()))) { $pilot_aircraft = new PilotAircraft(); $pilot_aircraft->setMemberId($member->getId()); $pilot_aircraft->setAircraftId($aircraft->getId()); $pilot_aircraft->setNNumber($app->getAircraftThirdNNumber()); $pilot_aircraft->setOwn($app->getAircraftThirdOwn()); $pilot_aircraft->setSeats($app->getAircraftThirdSeats()); $pilot_aircraft->setKnownIce($app->getAircraftThirdIce()); $pilot_aircraft->save(); } } // Application_temp $app->setPersonId($person->getId()); $app->setMemberId($member->getId()); $app->setProcessedDate(time()); $app->save(); // Application $tmp_arr = $app->toArray(BasePeer::TYPE_FIELDNAME); $tmp_arr['date'] = $tmp_arr['application_date']; $tmp_arr['company'] = $tmp_arr['company_name']; foreach (sfConfig::get('app_pilot_license_types') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['license_type'] = $key; } } $tmp_arr['ifr'] = stripos($tmp_arr['ratings'], 'ifr') !== false ? 1 : 0; $tmp_arr['multi_engine'] = stripos($tmp_arr['ratings'], 'multi') !== false ? 1 : 0; $tmp_arr['se_instructor'] = 'No'; // @see ApplicationForm foreach (sfConfig::get('app_pilot_se_instructor') as $key => $val) { if (stripos($tmp_arr['ratings'], $key) !== false) { $tmp_arr['se_instructor'] = $key; } } $tmp_arr['me_instructor'] = $tmp_arr['se_instructor']; $tmp_arr['other_ratings'] = $tmp_arr['ratings']; $tmp_arr['fbo'] = $tmp_arr['fbo_name']; $tmp_arr['member_meetings'] = 0; $tmp_arr['executive_board'] = 0; $tmp_arr['dues_amount_paid'] = $tmp_arr['dues_amount_paid'] ? $tmp_arr['dues_amount_paid'] : 0; unset($tmp_arr['id']); $application = new Application(); $application->fromArray($tmp_arr, BasePeer::TYPE_FIELDNAME); $application->save(); $where = $request->getParameter('step3_redirect'); //Ziyed save default role for new member $appTemp = $this->application_temp; if ($appTemp->getPersonId()) { $person_role = new PersonRole(); $person_role->setPersonId($appTemp->getPersonId()); if ($appTemp->getApplicantPilot() == 1) { $person_role->setRoleId(27); } else { $person_role->setRoleId(31); } $person_role->save(); } //Ziyed end save if ($where == 1) { $this->redirect('@member_view?id=' . $member->getId()); } else { /* if ($application->getEmail()) { # send email failure to payment $this->getComponent('mail', 'memberApplicationProcessed', array('email' => $application->getEmail(),'member_id'=>$member->getId(), 'name' => $application->getFirstName() . ' ' . $application->getLastName())); }*/ $this->redirect('pending_member/processComplete?id=' . $member->getId()); } }
/** * Mission Leg Edit * CODE: mission_leg_create */ public function executeUpdate(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'); } $this->errors = array(); // for validation $this->orig_set = ''; $this->dest_set = ''; if ($request->getParameter('id')) { $this->title = 'Edit Mission Leg'; $this->leg = MissionLegPeer::retrieveByPK($request->getParameter('id')); if ($this->leg->getFromAirportId()) { $this->fromAirport = $this->leg->getAirportRelatedByFromAirportId(); } if ($this->leg->getToAirportId()) { $this->toAirport = $this->leg->getAirportRelatedBytoAirportId(); } if ($this->leg->getCoordinatorId()) { $this->coordinator = CoordinatorPeer::retrieveByPK($this->leg->getCoordinatorId()); } //print_r($this->coordinator); if ($this->leg->getFboId()) { $this->fbo = FboPeer::retrieveByPK($this->leg->getFboId()); $this->fbo_address = $this->leg->getFboId(); } if ($this->leg->getBackupPilotId()) { $this->backup_pilot = PilotPeer::retrieveByPK($this->leg->getBackupPilotId()); if (isset($this->backup_pilot) && $this->backup_pilot instanceof Pilot) { $this->bp_person = $this->backup_pilot->getMember()->getPerson(); } } if ($this->leg->getBackupCopilotId()) { $this->backup_co_pilot = PilotPeer::retrieveByPK($this->leg->getBackupCopilotId()); if (isset($this->backup_co_pilot) && $this->backup_co_pilot instanceof Pilot) { $this->bp_co_person = $this->backup_co_pilot->getMember()->getPerson(); } } if ($this->leg->getWaiverReceived()) { $this->waiver_rec = $this->leg->getWaiverReceived(); } else { $this->waiver_rec = ''; } if ($this->leg->getFboAddressNew()) { $this->new_fbo_address = $this->leg->getFboAddressNew(); } else { $this->new_fbo_address = ''; } $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text')); $this->forward404Unless($this->leg); $this->mission = $this->leg->getMission(); $this->passenger = $this->mission->getPassenger(); $this->person = $this->passenger->getPerson(); $this->member = MemberPeer::getByPersonId($this->person->getId()); /*echo "<pre>"; print_r($this->member ); */ /* if(isset($this->member) && $this->member instanceof Member){ $this->pilot = PilotPeer::getByMemberId($this->member->getId()); } /* if(isset($this->leg) && $this->leg instanceof MissionLeg){ $this->pilot = PilotPeer::retrieveByPK($this->leg->getPilotId()); } * */ 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()); //echo "<pre>"; //print_r($this->mission_assistant); $this->back_up_mission_assistant = PilotPeer::retrieveByPK($this->leg->getBackupMissAssisId()); } if ($this->leg->getMissAssisId()) { $this->mission_assistant = PilotPeer::getByMemberId($this->leg->getMissAssisId()); } } //echo "<pre>"; //print_r($this->pilot_member); $is_pilot_requested = PilotRequestPeer::getByLegId($this->leg->getId()); if (isset($is_pilot_requested) && $is_pilot_requested instanceof PilotRequest) { $this->p_req = $is_pilot_requested; } /* echo "<pre>"; print_r($this->person->getId()); die(); */ $this->forward404Unless($this->mission); $mission_id = $this->mission->getId(); } else { $this->title = 'Add Mission Leg'; $this->leg = new MissionLeg(); $mission_id = $request->hasParameter('mis') ? $request->getParameter('mis') : $request->getParameter('mission_id'); $this->mission = MissionPeer::retrieveByPK($mission_id); $this->forward404Unless($this->mission); } if ($request->isMethod('post')) { if ($request->getParameter('transportation') == 'air_mission') { # AIR MISSION if ($request->getParameter('orgin_airport')) { $o_airport = AirportPeer::getByIdent($request->getParameter('orgin_airport')); if (!$o_airport instanceof Airport) { $this->errors[] = 'Origin airport not found in database'; } } else { $this->errors[] = 'Please specify origin airport'; } if ($request->getParameter('dest_airport')) { $d_airport = AirportPeer::getByIdent($request->getParameter('dest_airport')); if (!$d_airport instanceof Airport) { $this->errors[] = 'Destination airport not found in database'; } } else { $this->errors[] = 'Please specify destination airport'; } if (count($this->errors) == 0) { $mission_leg = $this->leg; $mission_leg->setMissionId($mission_id); $mission_leg->setCancelled($request->getParameter('cancelled')); if ($mission_leg->isNew()) { $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($mission_id) + 1); } $mission_leg->setFromAirportId($o_airport->getId()); $mission_leg->setToAirportId($d_airport->getId()); $o_air = AirportPeer::retrieveByPK($o_airport->getId()); $d_air = AirportPeer::retrieveByPK($d_airport->getId()); $distances = MissionLegPeer::getDistance($o_air->getIdent(), $d_air->getIdent()); //$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->save(); $id = $mission_leg->getId(); $leg = MissionLegPeer::retrieveByPK($id); $leg->setReverseFrom($id); $leg->save(); } } elseif ($request->getParameter('transportation') == 'ground_mission') { # GROUND MISSION $origin = $request->getParameter('ground_origin'); $destination = $request->getParameter('ground_destination'); $orgintset = $request->getParameter('orig_set'); $desttset = $request->getParameter('dest_set'); $fbo_address = $request->getParameter('fbo_address'); $this->orig_set = $orgintset; $this->dest_set = $desttset; $this->fbo_address = $fbo_address; if (empty($destination) && empty($desttset)) { $this->errors[] = 'Please specify destination address'; } if (empty($origin) && empty($orgintset)) { $this->errors[] = 'Please specify origin address'; } elseif ($destination == $origin && $destination != '') { $this->errors[] = 'Origin and Destination addresses conflict'; } if (empty($fbo_address)) { $this->errors[] = 'Please specify FBO name'; } if (count($this->errors) == 0) { $mission_leg = $this->leg; $mission_leg->setMissionId($mission_id); if ($mission_leg->isNew()) { $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($mission_id) + 1); } $mission_leg->setPassOnBoard(0); $mission_leg->setTransportation('ground_mission'); //get addresses by type $p = $this->passenger = $this->mission->getPassenger(); if ($p instanceof Passenger) { $this->person = $p->getPerson(); } $this->ground_addresses = array('patient' => '', 'facility' => '', 'lodging' => ''); $orgintsetsave = $request->getParameter('ground_origin'); if (empty($orgintsetsave)) { $orgintsetsave = $request->getParameter('orig_set'); } $desttsetsave = $request->getParameter('ground_destination'); if (empty($desttsetsave)) { $desttsetsave = $request->getParameter('dest_set'); } $mission_leg->setGroundOrigin($orgintsetsave); $mission_leg->setGroundDestination($desttsetsave); $mission_leg->setFboId($fbo_address); //ziyed $fbo_address_new = $request->getParameter('fbo_address_new'); $mission_leg->setFboAddressNew($fbo_address_new); //end ziyed $mission_leg->save(); $id = $mission_leg->getId(); $leg = MissionLegPeer::retrieveByPK($id); $leg->setReverseFrom($id); $leg->save(); } } elseif ($request->getParameter('transportation') == 'commercial_mission') { # COMMERCIAL MISSION $airline_id = $request->getParameter('airline_id'); if ($airline_id) { $custom = $request->getParameter('airline_custom'); if ($airline_id == 'other') { if (empty($custom)) { $this->errors[] = 'Please type a new airline name!'; } } else { $airline = AirlinePeer::retrieveByPK($airline_id = $request->getParameter('airline_id')); if (!$airline instanceof Airline) { $this->errors[] = 'Please select airline!'; } } } else { $this->errors[] = 'Please select airline!'; } $origin = $request->getParameter('origin'); $destination = $request->getParameter('destination'); if (empty($origin)) { $this->errors[] = 'Please specify origin'; } if (empty($destination)) { $this->errors[] = 'Please specify destination'; } if (count($this->errors) == 0) { $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); } $flight_number = $request->getParameter('flight_number'); $departure = $request->getParameter('departure'); $arrival = $request->getParameter('arrival'); $mission_leg = $this->leg; $mission_leg->setMissionId($this->mission->getId()); if ($mission_leg->isNew()) { $mission_leg->setLegNumber(MissionLegPeer::getMaxLegNumber($mission_id) + 1); } $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($destination); $mission_leg->setFlightNumber($flight_number); $v = $departure; if (empty($v[0]['hour']) || empty($v[0]['minute'])) { $v = null; } $mission_leg->setDeparture($v ? strtotime($v[0]['hour'] . ':' . $v[0]['minute'] . ' ' . $v[0]['period']) : null); $v = $arrival; if (empty($v[0]['hour']) || empty($v[0]['minute'])) { $v = null; } $mission_leg->setArrival($v ? strtotime($v[0]['hour'] . ':' . $v[0]['minute'] . ' ' . $v[0]['period']) : null); $mission_leg->setTransportation('commercial_mission'); $mission_leg->save(); } } else { $this->forward404(); } if (count($this->errors) == 0) { $this->getUser()->setFlash('success', 'New Mission leg has successfully created!'); if ($request->getParameter('add_another')) { $this->redirect('@leg_create?mis=' . $this->mission->getId()); } else { $this->redirect('@mission_view?id=' . $this->mission->getId()); } } } $this->date_widget = new widgetFormDate(array('format_date' => array('js' => 'mm/dd/yy', 'php' => 'm/d/Y')), array('class' => 'text')); //echo '<pre>';print_r($this->date_widget); $this->time_widget = new widgetFormTime(); $this->airport_list = AirportPeer::getMappable(); $this->airlines = AirlinePeer::doSelect(new Criteria()); $this->funds = FundPeer::doSelect(new Criteria()); $p = $this->passenger = $this->mission->getPassenger(); if ($p instanceof Passenger) { $this->person = $p->getPerson(); } else { unset($this->passenger); } $this->itinerary = $this->mission->getItinerary(); //echo '<pre>';print_r($this->itinerary); // 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(); } if ($this->passenger) { $this->ground_addresses['lodging'] = $this->passenger->getLodgingName() . ' ' . $this->ground_addresses['lodging']; $this->ground_addresses['facility'] = $this->passenger->getFacilityName() . ' ' . $this->ground_addresses['facility']; $this->ground_addresses['patient'] = $this->person->getAddress1() . ' ' . $this->person->getAddress2() . ' ' . $this->person->getCity() . ', ' . $this->person->getState() . ' ' . $this->person->getZipcode(); } }
/** * Add Pilot Aircraft * CODE: pilot_aircraft_create */ public function executeAircraft(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'); } if ($request->getParameter('req')) { $this->req_id = $request->getParameter('req'); } if ($request->getParameter('camp')) { $this->camp_id = $request->getParameter('camp'); } if ($request->getParameter('leg')) { $this->leg_id = $request->getParameter('leg'); } if ($request->getParameter('account')) { $this->account = $request->getParameter('account'); } $this->member = MemberPeer::getByPersonId($this->getUser()->getId()); if ($request->getParameter('member')) { $this->member = MemberPeer::retrieveByPK($request->getParameter('member')); } if ($this->member) { $pilot = PilotPeer::getByMemberId($this->member->getId()); } else { $this->getUser()->setFlash('success', 'You are not a member yet!'); $this->redirect($request->getReferer()); } if ($request->getParameter('id')) { $this->aircraft = PilotAircraftPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Pilot Aircraft'; } else { $this->aircraft = new PilotAircraft(); $this->title = 'Add New Pilot Aircraft'; } $this->referer = $request->getReferer(); $this->form = new PilotAircraftForm($this->aircraft); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); //echo $request->getParameter('a_id'); die; $taintedValues = $request->getParameter('pilot_aircraft'); $taintedValues['member_id'] = $request->getParameter('member_id'); $this->form->bind($taintedValues); //$back = ""; if ($this->form->isValid() && $request->getParameter('pilot_aircraft[aircraft_id]') != 0) { // $member = MemberPeer::retrieveByPK($request->getParameter('member_id')); //echo $this->form->getValue('aircraft_id'); die; $this->aircraft->setMemberId($request->getParameter('member_id')); $this->aircraft->setAircraftId($this->form->getValue('aircraft_id')); //$this->aircraft->setAircraftId(2); $this->aircraft->setNNumber($this->form->getValue('n_number')); if ($this->form->getValue('own') == null) { $this->aircraft->setOwn(0); } else { $this->aircraft->setOwn($this->form->getValue('own')); } if ($this->form->getValue('seats') == null) { $this->aircraft->setSeats(0); } else { $this->aircraft->setSeats($this->form->getValue('seats')); } if ($this->form->getValue('known_ice') == null) { $this->aircraft->setKnownIce(0); } else { $this->aircraft->setKnownIce($this->form->getValue('known_ice')); } $this->aircraft->save(); if ($request->getParameter('req_id')) { $back = '@pilot_request?id=' . $request->getParameter('req_id'); } if ($request->getParameter('camp_id')) { $back = '@request_group_mission?id=' . $request->getParameter('camp_id'); } if ($request->getParameter('referer')) { $back = $request->getParameter('referer'); } else { $back = $request->getReferer(); } $this->getUser()->setFlash('success', 'Aircraft has successfully created!'); if ($request->getParameter('leg_id') && $request->getParameter('member_id')) { $back = '@leg_edit?id=' . $request->getParameter('leg_id'); } else { $this->has_error = 1; } if ($request->getParameter('account')) { $back = 'account_pilot'; } $this->redirect($back); } } }
/** * 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; } } } } }
<h3>Other Stuff</h3> <ul> <li><a href="/itinerary/find?filter=1<?php //echo url_for('itinerary/find?filter=1') ?> "><span class="t-r"><span class="b-l"><span class="b-r">Itinerary</span></span></span></a></li> <li><a href="/itinerary/create?filter=1<?php //echo url_for('itinerary/create?filter=1') ?> "><span class="t-r"><span class="b-l"><span class="b-r">Add Itinerary</span></span></span></a></li> <li><a href="/update_medical_release?filter=1<?php //echo url_for('@update_medical_release?filter=1') ?> "><span class="t-r"><span class="b-l"><span class="b-r">Missions Medical Release Status</span></span></span></a></li> <?php $member = MemberPeer::getByPersonId($sf_user->getId()); ?> <?php if (isset($member)) { ?> <li><a href="/account/index<?php //echo url_for('account/index') ?> "><span class="t-r"><span class="b-l"><span class="b-r">Account Setting(pilot)</span></span></span></a></li> <?php } else { ?> <li><a href="/account<?php //echo url_for('account') ?> "><span class="t-r"><span class="b-l"><span class="b-r">Account Setting(personal)</span></span></span></a></li>
?> </table> </div> <?php } ?> <?php if ($sf_user->hasCredential(array('Administrator', 'Staff', 'Coordinator'), false)) { ?> <div class="person-table-data"> <h3>Data</h3> <table> <tr class="alt"> <td class="cell-1">Member</td> <?php $is_member = MemberPeer::getByPersonId($person->getId()); ?> <td width="100px"> <?php if (!$is_member) { ?> <?php $link = 'add'; ?> <?php } else { ?> <?php $link = 'active'; ?> <?php