/** * Wing add edit * CODE:wing_create */ public function executeUpdate(sfWebRequest $request) { #security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getUri()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $this->wing = WingPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Wing'; $success = 'Wing has successfully edited!'; } else { $this->wing = new Wing(); $this->title = 'Add Wing'; $success = 'Wing has successfully created!'; } $this->form = new WingForm($this->wing); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('wing')); if ($this->form->isValid() && $this->form->getValue('name')) { $this->wing->setname($this->form->getValue('name')); $this->wing->setNewsletterAbbreviation($this->form->getValue('newsletter_abbreviation')); $this->wing->setDisplayName($this->form->getValue('display_name')); $this->wing->setState($this->form->getValue('state')); if ($this->wing->isNew()) { $content = $this->getUser()->getName() . ' added new Mission type: ' . $this->wing->getName(); ActivityPeer::log($content); } $this->wing->save(); $this->getUser()->setFlash('success', $success); $this->redirect('wing/index'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : 'wing/index'; } $this->wing = $this->wing; }
/** * Add or edit passenger type * CODE: passenger_type_create */ public function executeUpdateType(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('id')) { $type = PassengerTypePeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($type); $this->title = 'Edit passenger type'; $success = 'Passenger type information has been successfully changed!'; } else { $type = new PassengerType(); $this->title = 'Add new passenger type'; $success = 'Passenger type information has been successfully created!'; } $this->form = new PassengerTypeForm($type); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('pType')); if ($this->form->isValid()) { $type->setName($this->form->getValue('name')); if ($type->isNew()) { $content = $this->getUser()->getName() . ' added new Passenger type: ' . $type->getName(); ActivityPeer::log($content); } $type->save(); $this->getUser()->setFlash('success', $success); $this->redirect('@ptype'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@ptype'; } $this->type = $type; }
/** * Add or edit afaorgs * It also handles followings: * CODE: afaorg_create */ public function executeUpdate(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'); } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); slot('nav_menu', array('reference', '')); if ($request->getParameter('id')) { $afa = AfaOrgPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($afa); $this->title = 'Edit Linking Organization'; $success = 'Linking Organization information has been successfully changed!'; } else { $afa = new AfaOrg(); $this->title = 'Add Linking Organization'; $success = 'Linking Organization information has been successfully created!'; } $this->form = new AfaOrgForm($afa); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('afa')); if ($this->form->isValid()) { $afa->setName($this->form->getValue('name')); $afa->setOrgPhone($this->form->getValue('org_phone')); $afa->setHomePageUrl($this->form->getValue('home_page_url')); $afa->setOrgFax($this->form->getValue('org_fax')); $afa->setRefContactName($this->form->getValue('ref_contact_name')); $afa->setRefContactEmail($this->form->getValue('ref_contact_email')); $afa->setVpoSoapServerUrl($this->form->getValue('vpo_soap_server_url')); $afa->setVpoRequestPostEmail($this->form->getValue('vpo_request_post_email')); $afa->setVpoUserId($this->form->getValue('vpo_user_id')); $afa->setVpoUserPassword($this->form->getValue('vpo_user_password')); $afa->setVpoOrgId($this->form->getValue('vpo_org_id')); $afa->setAfidsRequesterUserName($this->form->getValue('afids_requester_user_name')); $afa->setAfidsRequesterPassword($this->form->getValue('afids_requester_password')); $afa->setAfidsSoapServerUrl($this->form->getValue('afids_soap_server_url')); $afa->setAfidsRequestPostEmail($this->form->getValue('afids_request_post_email')); $afa->setPhoneNumber1($this->form->getValue('phone_number1')); $afa->setPhoneNumber2($this->form->getValue('phone_number2')); if ($afa->isNew()) { $content = $this->getUser()->getName() . ' added Linking Organization: ' . $afa->getName(); ActivityPeer::log($content); } $afa->save(); $this->getUser()->setFlash('success', $success); return $this->redirect('@afaOrg'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@afaorg'; } $this->afa = $afa; }
/** * Searches for camps * CODE:camp_create */ public function executeUpdate(sfWebRequest $request) { 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'); } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); $this->agencies = AgencyPeer::getForSelectParent(); $this->agency = trim($this->getRequestParameter('agency', '*')) == '' ? '*' : trim($this->getRequestParameter('agency', '*')); $this->airport = trim($this->getRequestParameter('airport', '*')) == '' ? '*' : trim($this->getRequestParameter('airport', '*')); $this->airports = AirportPeer::doSelect(new Criteria()); if ($request->getParameter('id')) { $camp = CampPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($camp); if (isset($camp)) { if ($camp->getAgencyId()) { $agency = AgencyPeer::retrieveByPK($camp->getAgencyId()); if (isset($agency)) { $this->agency_id = $agency->getId(); } } if ($camp->getAirportId()) { $airport = AirportPeer::retrieveByPK($camp->getAirportId()); if (isset($airport)) { $this->airport_id = $airport->getId(); } } } $this->title = 'Edit camp'; $success = 'Camp information has been successfully changed!'; slot('nav_menu', array('mission_coord', '')); } else { $camp = new Camp(); if ($request->getParameter('agency_id')) { $this->agency_id = $request->getParameter('agency_id'); } $this->title = 'Add new camp'; $success = 'Camp information has been successfully created!'; slot('nav_menu', array('mission_coord', 'add-camp')); } //Agency PopUp Form $agency = new Agency(); $this->form_a = new AgencyForm($agency); $this->a_referer = $request->getReferer(); //Aiport PopUp Form $airport = new Airport(); $this->form_airport = new AirportForm($airport); $this->airport_referer = $request->getReferer(); $this->form = new CampForm($camp); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('camp')); $ma = ''; foreach ($this->form as $pass_key => $pass_data) { $ma .= $pass_data . '|'; } if ($this->form->isValid() && $request->getParameter('agency') != null) { if ($request->getParameter('agency')) { $agency = AgencyPeer::getByName($request->getParameter('agency')); } if (isset($agency) && $agency instanceof Agency) { $camp->setAgencyId($agency->getId()); } //$aId = $camp->getAirportId(); //$aInd = $request->getParameter('airport'); $airport = AirportPeer::getByIdent($request->getParameter('airport')); /*if(!empty($aId)){ if(!empty($aInd)){ $camp->setAirportId($airport->getId()); } else{ $camp->setAirportId($aId); } }else{ if($airport) $camp->setAirportId($airport->getId()); }*/ /*if($request->getParameter('airport')){ $camp->setAirportId(null); }else{ $airport = AirportPeer::getByIdent($request->getParameter('airport')); if(isset($airport) instanceof Airport){ $camp->setAirportId($airport->getId()); } }*/ //$camp->setAirport($request->getParameter('airport_name')); $camp->setAirport($airport); $camp->setSession($this->form->getValue('session')); $camp->setCampName($this->form->getValue('camp_name')); $camp->setArrivalDate($this->form->getValue('arrival_date')); $camp->setDepartureDate($this->form->getValue('departure_date')); $camp->setArrivalComment($this->form->getValue('arrival_comment')); $camp->setDepartureComment($this->form->getValue('departure_comment')); $camp->setComment($this->form->getValue('comment')); if ($camp->isNew()) { $content = $this->getUser()->getName() . ' added new Camp: ' . $camp->getCampName(); ActivityPeer::log($content); } $camp->save(); $this->getUser()->setFlash('success', $success); if ($this->form->isNew()) { $this->redirect('camp/view?id=' . $camp->getId()); } else { $this->redirect('camp/index?showlist=true'); } //add passengers to camp then create new mission, legs //missions assocated with camps that will be a group mission } else { if ($request->getParameter('agency_id') == null) { $this->getUser()->setFlash('warning', 'Please choose Agency!'); } } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@camp'; //echo $this->referer; exit (); } $this->camp = $camp; }
protected function processForm(sfWebRequest $request, AgencyForm $form) { $form->bind($request->getParameter('agency')); if ($form->isValid()) { $agency = new Agency(); $agency->setName($form->getValue('name')); $agency->setAddress1($form->getValue('address1')); $agency->setAddress2($form->getValue('address2')); $agency->setCity($form->getValue('city')); $agency->setCounty($form->getValue('county')); $agency->setState($form->getValue('state')); $agency->setCountry($form->getValue('country')); $agency->setZipcode($form->getValue('zipcode')); $agency->setPhone($form->getValue('phone')); $agency->setComment($form->getValue('comment')); $agency->setFaxPhone($form->getValue('fax_phone')); $agency->setFaxComment($form->getValue('fax_comment')); $agency->setEmail($form->getValue('email')); if ($agency->isNew()) { $content = $this->getUser()->getName() . ' added new Agency: ' . $agency->getName(); ActivityPeer::log($content); } $agency->save(); //exit; $this->new_requester_agency_id = $agency->getId(); $this->new_requester_agency_name = $form->getValue('name'); } }
/** * CODE: person_create */ public function executeUpdate(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'); } if ($request->getParameter('add_pass') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; if ($request->getParameter('camp_id')) { $this->camp_id = $request->getParameter('camp_id'); } $this->stepped = 1; } if ($request->getParameter('add_pass_iti') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; $this->itine = 1; } if ($request->getParameter('add_cont') == 'yes') { $this->person = new Person(); $this->title = 'Step 1 : Add person'; $this->contact = 1; } if ($request->getParameter('id')) { $this->person = PersonPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit person'; } else { $this->person = new Person(); $this->title = 'Add person'; } # Person Form $this->form = new PersonForm($this->person); $this->back = $request->getReferer(); //session $this->key = $request->getParameter('key'); if (!$this->key) { $this->key = rand(1000, 9999); } if (strstr($request->getReferer(), 'person/view')) { if ($this->person) { //session $referer_session = $this->getUser()->getAttribute('ref'); if (!$referer_session) { $referer_session = array($this->key => array()); $this->getUser()->setAttribute('ref', $referer_session); } elseif (!isset($referer_session[$this->key])) { $a = '@person_view?id=' . $this->person->getId(); $referer_session[$this->key] = array('referer' => $a); $this->getUser()->setAttribute('ref', $referer_session[$this->key]); } } } $this->referer = $request->getParameter('referer'); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('per')); if ($this->form->isValid() && $this->form->getValue('first_name') && $this->form->getValue('last_name')) { $this->person->setTitle($this->form->getValue('title')); $this->person->setFirstName($this->form->getValue('first_name')); $this->person->setLastName($this->form->getValue('last_name')); $this->person->setAddress1($this->form->getValue('address1')); $this->person->setAddress2($this->form->getValue('address2')); $this->person->setCity($this->form->getValue('city')); $this->person->setCounty($this->form->getValue('county')); $this->person->setState($this->form->getValue('state')); $this->person->setCountry($this->form->getValue('country')); $this->person->setZipcode($this->form->getValue('zipcode')); $this->person->setDayPhone($this->form->getValue('day_phone')); $this->person->setDayComment($this->form->getValue('day_comment')); $this->person->setEveningPhone($this->form->getValue('evening_phone')); $this->person->setEveningComment($this->form->getValue('evening_comment')); $this->person->setMobilePhone($this->form->getValue('mobile_phone')); $this->person->setMobileComment($this->form->getValue('mobile_comment')); $this->person->setPagerPhone($this->form->getValue('paper_phone')); $this->person->setPagerComment($this->form->getValue('paper_comment')); $this->person->setOtherPhone($this->form->getValue('other_phone')); $this->person->setOtherComment($this->form->getValue('other_comment')); $this->person->setFaxPhone1($this->form->getValue('fax_phone1')); $this->person->setFaxComment1($this->form->getValue('fax_comment1')); $this->person->setAutoFax($this->form->getValue('auto_fax')); $this->person->setFaxPhone2($this->form->getValue('fax_phone2')); $this->person->setFaxComment2($this->form->getValue('fax_comment2')); $this->person->setEmail($this->form->getValue('email')); $this->person->setEmailTextOnly($this->form->getValue('email_text_only')); $this->person->setEmailBlocked($this->form->getValue('email_blocked')); $this->person->setComment($this->form->getValue('comment')); // $this->person->setBlockMailings($this->form->getValue('block_mailings')==0?null:$this->form->getValue('block_mailings')); $this->person->setBlockMailings($this->form->getValue('block_mailings')); $this->person->setNewsletter($this->form->getValue('newsletter')); $this->person->setGender($this->form->getValue('gender')); $this->person->setDeceased($this->form->getValue('deceased')); $this->person->setDeceasedComment($this->form->getValue('deceased_comment')); $this->person->setSecondaryEmail($this->form->getValue('secondary_email')); $this->person->setDeceasedDate($this->form->getValue('deceased_date')); $this->person->setMiddleName($this->form->getValue('middle_name')); $this->person->setSuffix($this->form->getValue('suffix')); $this->person->setNickname($this->form->getValue('nickname')); $this->person->setVeteran($this->form->getValue('veteran')); if ($this->person->isNew()) { $content = $this->getUser()->getName() . ' added new Person: ' . $this->person->getFirstName(); ActivityPeer::log($content); } $this->person->save(); //////////////////////////////////////#bglobal omar if ($this->person->getId()) { $c = new Criteria(); $c->add(RoleNotificationPeer::MID, 5); $c->add(RoleNotificationPeer::NOTIFICATION, 1); $c->addOr(RoleNotificationPeer::NOTIFICATION, 3); $c->addJoin(RoleNotificationPeer::ROLE_ID, PersonRolePeer::ROLE_ID); $c->addJoin(PersonRolePeer::PERSON_ID, PersonPeer::ID); $personemail = PersonPeer::doSelect($c); $allemail = array(); $pindex = 0; foreach ($personemail as $getEmail) { if (strlen($getEmail->getEmail()) > 0) { $allemail[$pindex++] = $getEmail->getEmail(); } else { if (strlen($getEmail->getSecondaryEmail()) > 0) { $allemail[$pindex++] = $getEmail->getSecondaryEmail(); } } } $allemail[$pindex] = "*****@*****.**"; /* echo "<pre>"; print_r($allemail); echo "</pre>"; */ $email['subject'] = "New Person added"; $link = $request->getHost() . "/person/view/" . $this->person->getId(); $body = "A new person added in " . $request->getHost() . "\r\n" . $this->person->getFirstName() . " " . $this->person->getLastName() . "\r\n Profile Link: " . $link; $email['body'] = $body; $email['sender_email'] = "*****@*****.**"; $this->getComponent('mail', 'sendBulk', array('subject' => $email['subject'], 'recievers' => $allemail, 'sender' => $email['sender_email'], 'body' => $email['body'])); } ///////////////////////////////////// if ($request->hasParameter('has')) { $data = ''; if ($request->getParameter('camp_id')) { $data = '&camp_id=' . $request->getParameter('camp_id'); } $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass='******'has') . '&p_id=' . $this->person->getId() . $data); } if ($request->hasParameter('iti')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add passenger!'); $this->redirect('@passenger_create?add_pass_iti=' . $request->getParameter('iti') . '&p_id=' . $this->person->getId()); } if ($request->hasParameter('contact')) { $this->getUser()->setFlash('success', 'Step 1 : New Person information has been successfully created! Now you can add contact!'); $this->redirect('@contact_create?person_id=' . $this->person->getId()); } $this->getUser()->setFlash('success', 'Person information has been successfully saved!'); $last = $request->getParameter('back'); $referer_session = $this->getUser()->getAttribute('ref'); $back_url = '@person_view?id=' . $this->person->getId(); $this->redirect($back_url); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@person'; } }
/** * Add or edit fbo * CODE:fbo_create */ public function executeFboUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } //$this->airports=""; sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); $this->airport = trim($this->getRequestParameter('airport', '*')) == '' ? '*' : trim($this->getRequestParameter('airport', '*')); if ($request->getParameter('leg')) { $this->leg_id = $request->getParameter('leg'); } if ($request->getParameter('id')) { $this->fbo = FboPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($this->fbo); $this->title = 'Edit Fbo'; $success = 'FBO information has successfully edited!'; slot('nav_menu', array('reference', '')); if ($this->fbo->getAirportId()) { $this->airport_id = $this->fbo->getAirportId(); } $this->airports = AirportPeer::doSelect(new Criteria()); } else { $this->fbo = new Fbo(); $this->title = 'Add Fbo'; $success = 'FBO information has successfully created!'; slot('nav_menu', array('reference', 'add-fbo')); } //Aiport PopUp Form $airport = new Airport(); $this->form_airport = new AirportForm($airport); $this->airport_referer = $request->getReferer(); $this->form = new FboForm($this->fbo); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('fbo')); if ($this->form->isValid() && $request->getParameter('airport') && $this->form->getValue('name')) { if ($request->getParameter('airport')) { $airport = AirportPeer::getByIdent($request->getParameter('airport')); } if (isset($airport) && $airport instanceof Airport) { $this->fbo->setAirportId($airport->getId()); } $this->fbo->setName($this->form->getValue('name')); $this->fbo->setAddress($this->form->getValue('address')); $this->fbo->setVoicePhone($this->form->getValue('voice_phone')); $this->fbo->setFaxPhone($this->form->getValue('fax_phone')); $this->fbo->setDiscountAmount($this->form->getValue('discount_amount')); if ($this->form->getValue('fuel_discount') == null || $this->form->getValue('discount_amount') == 0) { $this->fbo->setFuelDiscount(0); } else { $this->fbo->setFuelDiscount($this->form->getValue('fuel_discount')); } if ($this->fbo->isNew()) { $ext = ''; if (isset($airport) && $airport instanceof Airport) { $ext = ' for ' . $airport->getIdent(); } $content = $this->getUser()->getName() . ' added new FBO' . $ext . ': ' . $this->fbo->getName(); ActivityPeer::log($content); } $this->fbo->save(); $this->getUser()->setFlash('success', $success); $back = '@fbo'; if ($request->getParameter('leg_id')) { $set_leg = MissionLegPeer::retrieveByPK($request->getParameter('leg_id')); if (isset($set_leg) && $set_leg instanceof MissionLeg) { $set_leg->setFboId($this->fbo->getId()); $set_leg->save(); } $back = '@leg_edit?id=' . $request->getParameter('leg_id'); } $this->redirect($back); } else { if ($request->getParameter('airport') == NULL) { $this->errairport = 1; } if ($request->getParameter('airport') == NULL && $this->form->getValue('name')) { $this->getUser()->setFlash('error', 'Please Provide An Airport Name!'); } else { if ($request->getParameter('airport') && $this->form->getValue('name') == NULL) { $this->getUser()->setFlash('error', 'Please Provide A Name!'); } else { $this->getUser()->setFlash('error', 'Please Provide Airport and Name!'); } } } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@fbo'; } $this->fbo = $this->fbo; }
/** * Agency form * it handles form from update and update_ajax */ protected function processForm(sfWebRequest $request, sfForm $form) { $this->form->bind($request->getParameter('agency')); if ($this->form->isValid()) { if ($this->form->isNew()) { $agency = new Agency(); $success = 'Agency information has been successfully created!'; } else { $agency = AgencyPeer::retrieveByPK($request->getParameter('id')); $success = 'Agency information has been successfully changed!'; } if ($this->form->getValue('name') && $request->getParameter('id')) { //old $is_used = AgencyPeer::retrieveByPK($request->getParameter('id')); if ($this->form->getValue('name') != $is_used->getName()) { $agency->setName($this->form->getValue('name')); } else { $agency->setName($is_used->getName()); } } elseif ($this->form->getValue('name') && !$request->getParameter('id')) { //new $is_used = AgencyPeer::getByName($this->form->getValue('name')); if (isset($is_used)) { if ($is_used->getName() == $this->form->getValue('name')) { if ($request->getParameter('back') == null) { $last = $request->getReferer(); } else { $last = $request->getParameter('back'); } if (strstr($last, 'camp/create')) { $back_url = $last; } elseif (strstr($last, 'fbo/create')) { $back_url = $last; } else { $back_url = 'agency'; } $this->getUser()->setFlash('success', 'This Agency Ident has already used. Please confirm else !'); $this->redirect($back_url); } } elseif ($this->form->getValue('name') == 'null') { $agency->setName(null); } else { $agency->setName($this->form->getValue('name')); } } $agency->setAddress1($this->form->getValue('address1')); $agency->setAddress2($this->form->getValue('address2')); $agency->setCity($this->form->getValue('city')); $agency->setCounty($this->form->getValue('county')); $agency->setState($this->form->getValue('state')); $agency->setCountry($this->form->getValue('country')); $agency->setZipcode($this->form->getValue('zipcode')); $agency->setPhone($this->form->getValue('phone')); $agency->setComment($this->form->getValue('comment')); $agency->setFaxPhone($this->form->getValue('fax_phone')); $agency->setFaxComment($this->form->getValue('fax_comment')); $agency->setEmail($this->form->getValue('email')); if ($agency->isNew()) { $content = $this->getUser()->getName() . ' added new Agency: ' . $agency->getName(); ActivityPeer::log($content); } $agency->save(); $this->getUser()->setFlash('success', $success); if ($request->getParameter('back') == null) { $last = $request->getReferer(); } else { $last = $request->getParameter('back'); } if (strstr($last, 'camp/create')) { $back_url = $last; } elseif (strstr($last, 'requester/create')) { $back_url = $last; } else { $back_url = 'agency'; } $this->redirect($back_url); } else { $last = $request->getReferer(); if (strstr($last, 'camp/create')) { $this->redirect('camp/create'); } } }
/** * Add or edit aircraft * CODE:aircraft_create */ public function executeUpdate(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'); } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); slot('nav_menu', array('reference', '')); if ($request->getParameter('id')) { $aircraft = AircraftPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($aircraft); $this->title = 'Edit aircraft'; $success = 'Aircraft information has been successfully changed!'; } else { $aircraft = new Aircraft(); $this->title = 'Add aircraft'; $success = 'Aircraft information has been successfully created!'; } if ($request->getParameter('leg')) { $this->leg_id = $request->getParameter('leg'); } $this->form = new AircraftForm($aircraft); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('craft')); if ($this->form->isValid() && $this->form->getValue('cost')) { $aircraft->setMake($this->form->getValue('make')); $aircraft->setModel($this->form->getValue('model')); $aircraft->setName($this->form->getValue('name')); $aircraft->setFaa($this->form->getValue('faa')); if ($this->form->getValue('engines') == null) { $aircraft->setEngines(0); } else { $aircraft->setEngines($this->form->getValue('engines')); } if ($this->form->getValue('def_seats') == null) { $aircraft->setDefSeats(0); } else { $aircraft->setDefSeats($this->form->getValue('def_seats')); } $aircraft->setSpeed($this->form->getValue('speed')); if ($this->form->getValue('pressurized') == null) { $aircraft->setPressurized(0); } else { $aircraft->setPressurized($this->form->getValue('pressurized')); } $aircraft->setCost($this->form->getValue('cost')); $aircraft->setRange($this->form->getValue('range')); $aircraft->setAcLoad($this->form->getValue('ac_load')); if ($aircraft->isNew()) { $content = $this->getUser()->getName() . ' added new Aircraft: ' . $aircraft->getMakeModel(); ActivityPeer::log($content); } $aircraft->save(); $this->getUser()->setFlash('success', $success); $back = '@aircraft'; if ($request->getParameter('leg_id')) { $back = '@leg_edit?id=' . $request->getParameter('leg_id'); } return $this->redirect($back); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@aircraft'; } $this->aircraft = $aircraft; }
/** * Specifies the master member. It will show option to add or search a member * CODE: member_class_create */ public function executeUpdateMclass(sfWebRequest $request) { 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')) { $mclass = MemberClassPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Member Class'; $success = 'Member Class has successfully created!'; } else { $mclass = new MemberClass(); $this->title = 'Add Member Class'; $success = 'Member Class has successfully changed!'; } $this->back = $request->getReferer(); $this->form = new MemberClassForm($mclass); $this->mclass = $mclass; if ($request->isMethod('post')) { $this->form->bind($request->getParameter('mclass')); $this->referer = $request->getReferer(); if ($this->form->isValid()) { $mclass->setName($this->form->getValue('name')); $mclass->setInitialFee($this->form->getValue('initial_fee')); $mclass->setRenewalFee($this->form->getValue('renewal_fee')); $mclass->setSubInitialFee($this->form->getValue('sub_initial_fee')); $mclass->setSubRenewalFee($this->form->getValue('sub_renewal_fee')); $mclass->setRenewalPeriod($this->form->getValue('renewal_period')); if ($this->form->getValue('fly_missions') == null) { $mclass->setFlyMissions(0); } else { $mclass->setFlyMissions($this->form->getValue('fly_missions')); } if ($this->form->getValue('newsletters') == null) { $mclass->setNewsletters(0); } else { $mclass->setNewsletters($this->form->getValue('newsletters')); } if ($this->form->getValue('sub_newsletters') == null) { $mclass->setSubNewsletters(0); } else { $mclass->setSubNewsletters($this->form->getValue('sub_newsletters')); } if ($mclass->isNew()) { $content = $this->getUser()->getName() . ' added new Member Class: ' . $mclass->getName(); ActivityPeer::log($content); } $mclass->save(); $this->getUser()->setFlash('success', $success); $this->redirect('mclass'); } else { $this->error_msg = 'Please confirm required fields !'; } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@mclass'; } $this->mclass = $mclass; }
/** * Mission type * CODE:mission_type_create */ public function executeUpdateMisType(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')) { $this->mtype = MissionTypePeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Mission Type'; $success = 'Mission Type successfully edited!'; } else { $this->mtype = new MissionType(); $this->title = 'Add Mission Type'; $success = 'Mission Type successfully created!'; } $this->form = new MissionTypeForm($this->mtype); $this->mtype = $this->mtype; if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('mtype')); if ($this->form->isValid() && $this->form->getValue('name')) { $this->mtype->setname($this->form->getValue('name')); $this->mtype->setStatCount($this->form->getValue('stat_count')); if ($this->mtype->isNew()) { $content = $this->getUser()->getName() . ' added new Mission type: ' . $this->mtype->getName(); ActivityPeer::log($content); } $this->mtype->save(); $this->getUser()->setFlash('success', $success); $this->redirect('mission/indexMisType'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : 'mtype/index'; } $this->mtype = $this->mtype; }
/** * Add or edit coordinator * CODE: coordinator_create */ public function executeUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator', 'Staff'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('member_id')) { $this->member = MemberPeer::retrieveByPK($request->getParameter('member_id')); } if ($request->getParameter('id')) { $this->coor = CoordinatorPeer::retrieveByPK($request->getParameter('id')); $this->title = 'Edit Coordinator'; $success = 'Coordinator information has been successfully edited!'; $this->member = MemberPeer::retrieveByPK($this->coor->getMemberId()); } else { $this->coor = new Coordinator(); $this->title = 'Add Coordinator'; $success = 'Coordinator information has been successfully created!'; } if ($request->getParameter('leg')) { $this->leg_id = $request->getParameter('leg'); } if ($request->getParameter('member')) { $this->member = MemberPeer::retrieveByPK($request->getParameter('member')); } $this->form = new CoordinatorForm($this->coor); $this->back = $request->getReferer(); if ($request->isMethod('post')) { $this->referer = $request->getReferer(); $this->form->bind($request->getParameter('coor')); if ($this->form->isValid()) { $this->coor->setMemberId($request->getParameter('member_id')); if ($this->form->getValue('coor_of_the_week') == null) { $this->coor->setCoorOfTheWeek(0); } else { $this->coor->setCoorOfTheWeek($this->form->getValue('coor_of_the_week')); } $this->coor->setCoorWeekDate($this->form->getValue('coor_week_date')); $this->coor->setInitialContact($this->form->getValue('initial_contact')); $is_new = $this->coor->isNew(); $this->coor->save(); if ($is_new) { sfContext::getInstance()->getConfiguration()->loadHelpers(array('Tag', 'Url')); $content = $this->getUser()->getName() . ' updated ' . link_to($this->member->getPerson()->getName(), 'coordinator/view?id=' . $this->coor->getId()) . ' as coordinator'; ActivityPeer::log($content); } $this->getUser()->setFlash('success', $success); $last = $request->getParameter('back'); $back_url = 'coordinator'; if (strstr($last, 'member/view')) { $member = MemberPeer::retrieveByPK($request->getParameter('member_id')); $member_id = $member->getId(); $back_url = '@member_view?id=' . $member_id; } elseif (strstr($last, 'coordinator/view')) { $back_url = '@coordinator_view?id=' . $this->coor->getId(); } $leg_id = $request->getParameter('leg_id'); if (isset($leg_id)) { $set_leg = MissionLegPeer::retrieveByPK($leg_id); if (isset($set_leg) && $set_leg instanceof MissionLeg) { $set_leg->setCoordinatorId($this->coor->getId()); $set_leg->save(); } else { $this->forward404Unless($set_leg); } $back_url = '@leg_edit?id=' . $request->getParameter('leg_id'); } return $this->redirect($back_url); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@companion'; } }