예제 #1
0
 function save($id = FALSE)
 {
     if ($_POST) {
         $agency = new Agency($id);
         $agency->from_array($_POST);
         $agency->save();
         set_notify('success', lang('save_data_complete'));
     }
     redirect($_POST['referer']);
 }
예제 #2
0
 public function postSaveagency()
 {
     $agency = new Agency();
     $agency->name = Input::get('name');
     $agency->email = Input::get('email');
     $agency->mobile = Input::get('mobile');
     $agency->city = Input::get('city');
     $agency->address1 = Input::get('address1');
     $agency->address2 = Input::get('address2');
     $agency->commission = Input::get('commission');
     $agency->save();
     return Response::json($agency);
 }
예제 #3
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Agency();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Agency'])) {
         $model->attributes = $_POST['Agency'];
         if ($model->save()) {
             date_default_timezone_set("Asia/Manila");
         }
         $activity = new Activity();
         $activity->act_desc = 'Added Another Agency';
         $activity->act_datetime = date('Y-m-d G:i:s');
         $activity->act_by = User::model()->findByPK(Yii::app()->user->name)->emp_id;
         $activity->save();
         $this->redirect(array('view', 'id' => $model->agency_id));
     }
     $this->render('create', array('model' => $model));
 }
예제 #4
0
 /**
  * [agencyAdd description]
  * @return [type] [description]
  */
 public function agencyAdd($flag = null)
 {
     if (!$flag) {
         $ministry = new Ministry();
         $ministry_list = $ministry->getAllMinistry('get');
         return View::make('agency.add')->with('ministry_list', $ministry_list);
     } else {
         $data = Input::all();
         $rules = array('ministry_id' => 'required', 'department_id' => 'required');
         // Build the custom messages array.
         $messages = array('ministry_id.required' => 'กรุณาระบุชื่อกระทรวง', 'department_id.required' => 'กรุณาระบุชื่อกรม');
         // Create a new validator instance.
         $validator = Validator::make($data, $rules, $messages);
         if ($validator->passes()) {
             $dep_obj = new Department();
             $agency = new Agency();
             $code = $dep_obj->getDepartmentCodeById($data['department_id']);
             $rs_check = $agency->checkAgency($code);
             if ($rs_check) {
                 $dep_info = $dep_obj->getDeparmentInfoById($data['department_id']);
                 $agency->tname = $dep_info[0]['full_th_name'];
                 $agency->ministry_id = $dep_info[0]['ministry_id'];
                 $agency->status = true;
                 $agency->code = $dep_info[0]['department_code'];
                 $agency->save();
                 return Redirect::to('agency/list')->with('success', 'บันทึกสำเร็จ');
             } else {
                 return Redirect::to('agency/add')->with('warning', 'มีชื่อข้อมูลอยู่ในระบบแล้ว');
             }
         } else {
             // $errors = $validator->messages();
             return Redirect::to('agency/add')->withErrors($validator);
         }
     }
     //end else
 }
예제 #5
0
파일: BaseCamp.php 프로젝트: yasirgit/afids
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aAgency !== null) {
             if ($this->aAgency->isModified() || $this->aAgency->isNew()) {
                 $affectedRows += $this->aAgency->save($con);
             }
             $this->setAgency($this->aAgency);
         }
         if ($this->aAirport !== null) {
             if ($this->aAirport->isModified() || $this->aAirport->isNew()) {
                 $affectedRows += $this->aAirport->save($con);
             }
             $this->setAirport($this->aAirport);
         }
         if ($this->aFbo !== null) {
             if ($this->aFbo->isModified() || $this->aFbo->isNew()) {
                 $affectedRows += $this->aFbo->save($con);
             }
             $this->setFbo($this->aFbo);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CampPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CampPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CampPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collCampPassengers !== null) {
             foreach ($this->collCampPassengers as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMissions !== null) {
             foreach ($this->collMissions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collPilotRequests !== null) {
             foreach ($this->collPilotRequests as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
예제 #6
0
 public function execute()
 {
     PHPWS_Core::initModClass('intern', 'Internship.php');
     PHPWS_Core::initModClass('intern', 'Agency.php');
     PHPWS_Core::initModClass('intern', 'Department.php');
     PHPWS_Core::initModClass('intern', 'Faculty.php');
     /**************
      * Sanity Checks
      */
     // Required fields check
     $missing = self::checkRequest();
     if (!is_null($missing) && !empty($missing)) {
         // checkRequest returned some missing fields.
         $url = 'index.php?module=intern&action=edit_internship';
         $url .= '&missing=' . implode('+', $missing);
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, 'Please fill in the highlighted fields.');
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check the Banner ID
     if (!preg_match('/^\\d{9}$/', $_REQUEST['banner'])) {
         $url = 'index.php?module=intern&action=edit_internship&missing=banner';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The Banner ID you entered is not valid. No changes were saved. The student's Banner ID should be nine digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check student email
     if (isset($_REQUEST['student_email']) && preg_match("/@/", $_REQUEST['student_email'])) {
         $url = 'index.php?module=intern&action=edit_internship&missing=student_email';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The student's email address is invalid. No changes were saved. Enter only the username portion of the student's email address. The '@appstate.edu' portion is not necessary.");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check student zip
     if (isset($_REQUEST['student_zip']) && $_REQUEST['student_zip'] != "" && (strlen($_REQUEST['student_zip']) != 5 || !is_numeric($_REQUEST['student_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=student_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The student's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Course start date must be before end date
     if (!empty($_REQUEST['start_date']) && !empty($_REQUEST['end_date'])) {
         $start = strtotime($_REQUEST['start_date']);
         $end = strtotime($_REQUEST['end_date']);
         if ($start > $end) {
             $url = 'index.php?module=intern&action=edit_internship&missing=start_date+end_date';
             // Restore the values in the fields the user already entered
             unset($_POST['start_date']);
             unset($_POST['end_date']);
             foreach ($_POST as $key => $val) {
                 $url .= "&{$key}={$val}";
             }
             NQ::simple('intern', INTERN_WARNING, 'The internship start date must be before the end date.');
             NQ::close();
             return PHPWS_Core::reroute($url);
         }
     }
     // Sanity check internship location zip
     if (isset($_REQUEST['loc_zip']) && $_REQUEST['loc_zip'] != "" && (strlen($_REQUEST['loc_zip']) != 5 || !is_numeric($_REQUEST['loc_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=loc_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The internship location's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check agency zip
     if (isset($_REQUEST['agency_zip']) && $_REQUEST['agency_zip'] != "" && (strlen($_REQUEST['agency_zip']) != 5 || !is_numeric($_REQUEST['agency_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check supervisor's zip
     if (isset($_REQUEST['agency_sup_zip']) && $_REQUEST['agency_sup_zip'] != "" && (strlen($_REQUEST['agency_sup_zip']) != 5 || !is_numeric($_REQUEST['agency_sup_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_sup_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency supervisor's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check course number
     if (isset($_REQUEST['course_no']) && $_REQUEST['course_no'] != '' && (strlen($_REQUEST['course_no']) > 20 || !is_numeric($_REQUEST['course_no']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=course_no';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The course number provided is invalid. No changes were saved. Course numbers should be less than 20 digits (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     PHPWS_DB::begin();
     // Create/Save agency
     $agency = new Agency();
     if (isset($_REQUEST['agency_id'])) {
         // User is editing internship
         try {
             $agency = new Agency($_REQUEST['agency_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     }
     $agency->name = $_REQUEST['agency_name'];
     $agency->address = $_REQUEST['agency_address'];
     $agency->city = $_REQUEST['agency_city'];
     $agency->zip = $_REQUEST['agency_zip'];
     $agency->phone = $_REQUEST['agency_phone'];
     if ($_REQUEST['location'] == 'internat') {
         /* Location is INTERNATIONAL. Country is required. Province was typed in. */
         $agency->state = $_REQUEST['agency_state'];
         $agency->province = $_REQUEST['agency_province'];
         $agency->country = $_REQUEST['agency_country'];
         $agency->supervisor_state = $_REQUEST['agency_sup_state'];
         $agency->supervisor_province = $_REQUEST['agency_sup_province'];
         $agency->supervisor_country = $_REQUEST['agency_sup_country'];
     } else {
         /* Location is DOMESTIC. Country is U.S. State was chosen from drop down */
         $agency->state = $_REQUEST['agency_state'] == -1 ? null : $_REQUEST['agency_state'];
         $agency->country = 'United States';
         $agency->supervisor_state = $_REQUEST['agency_sup_state'] == -1 ? null : $_REQUEST['agency_sup_state'];
         $agency->supervisor_country = 'United States';
     }
     $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name'];
     $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name'];
     $agency->supervisor_title = $_REQUEST['agency_sup_title'];
     $agency->supervisor_phone = $_REQUEST['agency_sup_phone'];
     $agency->supervisor_email = $_REQUEST['agency_sup_email'];
     $agency->supervisor_fax = $_REQUEST['agency_sup_fax'];
     $agency->supervisor_address = $_REQUEST['agency_sup_address'];
     $agency->supervisor_city = $_REQUEST['agency_sup_city'];
     $agency->supervisor_zip = $_REQUEST['agency_sup_zip'];
     $agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f';
     try {
         $agencyId = $agency->save();
     } catch (Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         PHPWS_DB::rollback();
         throw $e;
     }
     /**********************************
      * Create and/or save the Internship
      */
     if (isset($_REQUEST['internship_id']) && $_REQUEST['internship_id'] != '') {
         // User is editing internship
         try {
             PHPWS_Core::initModClass('intern', 'InternshipFactory.php');
             $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     } else {
         $i = new Internship();
     }
     $i->term = $_REQUEST['term'];
     $i->agency_id = $agencyId;
     $i->faculty_id = $_REQUEST['faculty_id'] > 0 ? $_REQUEST['faculty_id'] : null;
     $i->department_id = $_REQUEST['department'];
     $i->start_date = !empty($_REQUEST['start_date']) ? strtotime($_REQUEST['start_date']) : 0;
     $i->end_date = !empty($_REQUEST['end_date']) ? strtotime($_REQUEST['end_date']) : 0;
     // Credit hours must be an integer (because of database column type),
     // so round the credit hours to nearest int
     if (isset($_REQUEST['credits'])) {
         $i->credits = round($_REQUEST['credits']);
     }
     $avg_hours_week = (int) $_REQUEST['avg_hours_week'];
     $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null;
     $i->paid = $_REQUEST['payment'] == 'paid';
     $i->stipend = isset($_REQUEST['stipend']) && $i->paid;
     $i->unpaid = $_REQUEST['payment'] == 'unpaid';
     $i->pay_rate = $_REQUEST['pay_rate'];
     // Internship experience type
     if (isset($_REQUEST['experience_type'])) {
         $i->setExperienceType($_REQUEST['experience_type']);
     }
     // Set fields depending on domestic/international
     if ($_REQUEST['location'] == 'domestic') {
         // Set Flags
         $i->domestic = 1;
         $i->international = 0;
         // Set state
         if ($_POST['loc_state'] != '-1') {
             $i->loc_state = strip_tags($_POST['loc_state']);
         } else {
             $i->loc_state = null;
         }
         // Clear province, country
         $i->loc_province = '';
         $i->loc_country = '';
     } else {
         if ($_REQUEST['location'] == 'internat') {
             // Set flags
             $i->domestic = 0;
             $i->international = 1;
             // Set province, country
             $i->loc_province = $_POST['loc_province'];
             $i->loc_country = strip_tags($_POST['loc_country']);
             // Clear state
             $i->loc_state = null;
         }
     }
     // Address, city, zip are always set (no matter domestic or international)
     $i->loc_address = strip_tags($_POST['loc_address']);
     $i->loc_city = strip_tags($_POST['loc_city']);
     $i->loc_zip = strip_tags($_POST['loc_zip']);
     if (isset($_POST['course_subj']) && $_POST['course_subj'] != '-1') {
         $i->course_subj = strip_tags($_POST['course_subj']);
     } else {
         $i->course_subj = null;
     }
     // Course info
     $i->course_no = strip_tags($_POST['course_no']);
     $i->course_sect = strip_tags($_POST['course_sect']);
     $i->course_title = strip_tags($_POST['course_title']);
     // Multipart course
     if (isset($_POST['multipart'])) {
         $i->multi_part = 1;
     } else {
         $i->multi_part = 0;
     }
     if (isset($_POST['multipart']) && isset($_POST['secondary_part'])) {
         $i->secondary_part = 1;
     } else {
         $i->secondary_part = 0;
     }
     // Corequisite Course Info
     if (isset($_POST['corequisite_course_num'])) {
         $i->corequisite_number = $_POST['corequisite_course_num'];
     }
     if (isset($_POST['corequisite_course_sect'])) {
         $i->corequisite_section = $_POST['corequisite_course_sect'];
     }
     // Student Information
     $i->first_name = $_REQUEST['student_first_name'];
     $i->middle_name = $_REQUEST['student_middle_name'];
     $i->last_name = $_REQUEST['student_last_name'];
     $i->setFirstNameMetaphone($_REQUEST['student_first_name']);
     $i->setLastNameMetaphone($_REQUEST['student_last_name']);
     $i->banner = $_REQUEST['banner'];
     $i->phone = $_REQUEST['student_phone'];
     $i->email = $_REQUEST['student_email'];
     $i->level = $_REQUEST['student_level'];
     // Check the level and record the major/program for this level.
     // Be sure to set/clear the other leve's major/program to null
     // in case the user is switching levels.
     if ($i->getLevel() == 'ugrad') {
         $i->ugrad_major = $_REQUEST['ugrad_major'];
         $i->grad_prog = null;
     } else {
         if ($i->getLevel() == 'grad') {
             $i->grad_prog = $_REQUEST['grad_prog'];
             $i->ugrad_major = null;
         }
     }
     $i->gpa = $_REQUEST['student_gpa'];
     $i->campus = $_REQUEST['campus'];
     $i->student_address = $_REQUEST['student_address'];
     $i->student_city = $_REQUEST['student_city'];
     if ($_REQUEST['student_state'] != '-1') {
         $i->student_state = $_REQUEST['student_state'];
     } else {
         $i->student_state = "";
     }
     $i->student_zip = $_REQUEST['student_zip'];
     /*
     $i->emergency_contact_name = $_REQUEST['emergency_contact_name'];
     $i->emergency_contact_relation = $_REQUEST['emergency_contact_relation'];
     $i->emergency_contact_phone = $_REQUEST['emergency_contact_phone'];
     */
     /************
      * OIED Certification
      */
     // If OIED certification has changed, then double check permissions
     $cert = $i->oied_certified == 1 ? true : false;
     $certSubmitted = $_POST['oied_certified_hidden'] == 'true' ? true : false;
     $certChanged = $cert != $certSubmitted;
     if ($certChanged && !Current_User::allow('intern', 'oied_certify')) {
         $url = "index.php?module=intern&action=edit_internship&internship_id={$i->getId()}";
         NQ::simple('intern', INTERN_ERROR, "You do not have permission to change the OIED certification checkbox. No changes were saved.");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Check if this has changed from non-certified->certified so we can log it later
     if ($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true') {
         // note the change for later
         $oiedCertified = true;
     } else {
         $oiedCertified = false;
     }
     if ($_POST['oied_certified_hidden'] == 'true') {
         $i->oied_certified = 1;
     } else {
         if ($_POST['oied_certified_hidden'] == 'false') {
             $i->oied_certified = 0;
         } else {
             $i->oied_certified = 0;
         }
     }
     // If we don't have a state and this is a new internship,
     // the set an initial state
     if ($i->id == 0 && is_null($i->state)) {
         PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
         $state = WorkflowStateFactory::getState('CreationState');
         $i->setState($state);
         // Set this initial value
     }
     try {
         $i->save();
     } catch (Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         PHPWS_DB::rollback();
         throw $e;
     }
     PHPWS_DB::commit();
     /***************************
      * State/Workflow Handling *
      ***************************/
     PHPWS_Core::initModClass('intern', 'WorkflowController.php');
     PHPWS_Core::initModClass('intern', 'WorkflowTransitionFactory.php');
     $t = WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']);
     $workflow = new WorkflowController($i, $t);
     try {
         $workflow->doTransition(isset($_POST['notes']) ? $_POST['notes'] : null);
     } catch (MissingDataException $e) {
         NQ::simple('intern', INTERN_ERROR, $e->getMessage());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     }
     // Create a ChangeHisotry for the OIED certification.
     if ($oiedCertified) {
         $currState = WorkflowStateFactory::getState($i->getStateName());
         $ch = new ChangeHistory($i, Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED');
         $ch->save();
     }
     $workflow->doNotification(isset($_POST['notes']) ? $_POST['notes'] : null);
     if (isset($_REQUEST['internship_id'])) {
         // Show message if user edited internship
         NQ::simple('intern', INTERN_SUCCESS, 'Saved internship for ' . $i->getFullName());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     } else {
         NQ::simple('intern', INTERN_SUCCESS, 'Added internship for ' . $i->getFullName());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     }
 }
예제 #7
0
 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');
     }
 }
예제 #8
0
 /**
  * missionRequests save all data into corresponding tables
  * CODE:mission_request_create
  */
 public function executeSave(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');
     }
     $miss_req_session = $this->getUser()->getAttribute('miss_req');
     if (!$miss_req_session) {
         return $this->forward('passenger', 'step3');
     }
     //set Requester Person
     $req_person = new Person();
     $req_person->setFirstName($miss_req_session->getReqFirstname());
     $req_person->setLastName($miss_req_session->getReqLastname());
     $req_person->setAddress1($miss_req_session->getReqAddress1());
     $req_person->setAddress2($miss_req_session->getReqAddress2());
     $req_person->setCity($miss_req_session->getReqCity());
     $req_person->setCounty($miss_req_session->getReqCounty());
     $req_person->setState($miss_req_session->getReqState());
     $req_person->setCountry($miss_req_session->getReqCountry());
     $req_person->setZipcode($miss_req_session->getReqZipcode());
     $req_person->setEmail($miss_req_session->getReqEmail());
     $req_person->setSecondaryEmail($miss_req_session->getReqSecondaryEmail());
     $req_person->setPagerEmail($miss_req_session->getReqPagerEmail());
     $req_person->setDayPhone($miss_req_session->getReqDayPhone());
     $req_person->setDayComment($miss_req_session->getReqDayComment());
     $req_person->setEveningPhone($miss_req_session->getReqEvePhone());
     $req_person->setEveningComment($miss_req_session->getReqEveComment());
     $req_person->setMobilePhone($miss_req_session->getReqMobilePhone());
     $req_person->setMobileComment($miss_req_session->getReqMobileComment());
     $req_person->setPagerPhone($miss_req_session->getReqPagerPhone());
     $req_person->setPagerComment($miss_req_session->getReqPagerComment());
     $req_person->setOtherPhone($miss_req_session->getReqOtherPhone());
     $req_person->setOtherComment($miss_req_session->getReqOtherComment());
     $req_person->save();
     //end of Requester Person
     // set Requester Agency
     $agency = AgencyPeer::getByNamePhone(trim($miss_req_session->getAgencyName()));
     if ($agency) {
         # nothing
     } else {
         $agency = new Agency();
         $agency->setName(trim($miss_req_session->getAgencyName()));
         $agency->save();
     }
     //set Requester
     $requester = new Requester();
     $requester->setPersonId($req_person->getId());
     $requester->setAgencyId($agency->getId());
     //$requester->setDischarge($miss_req_session->getReqDischarge());
     $requester->save();
     if (isset($miss_req_session->passenger_id)) {
         $passenger = PassengerPeer::retrieveByPK($miss_req_session->passenger_id);
         if (!$passenger instanceof Passenger) {
             $passenger = new Passenger();
         }
     } else {
         $passenger = new Passenger();
     }
     if ($passenger->isNew()) {
         $person = new Person();
     } else {
         $person = $passenger->getPerson();
     }
     //set Person to Passenger
     $person->setTitle($miss_req_session->getPassTitle());
     $person->setFirstName($miss_req_session->getPassFirstName());
     $person->setLastName($miss_req_session->getPassLastName());
     $person->setGender($miss_req_session->getPassGender());
     $person->setAddress1($miss_req_session->getPassAddress1());
     $person->setAddress2($miss_req_session->getPassAddress2());
     $person->setCity($miss_req_session->getPassCity());
     $person->setState($miss_req_session->getPassState());
     $person->setZipcode($miss_req_session->getPassZipcode());
     $person->setCountry($miss_req_session->getPassCountry());
     $person->setEmail($miss_req_session->getPassEmail());
     $person->setDayPhone($miss_req_session->getPassDayPhone());
     $person->setDayComment($miss_req_session->getPassDayComment());
     $person->setEveningPhone($miss_req_session->getPassEvePhone());
     $person->setEveningComment($miss_req_session->getPassEveComment());
     $person->setMobilePhone($miss_req_session->getPassMobilePhone());
     $person->setMobileComment($miss_req_session->getPassMobileComment());
     $person->setPagerPhone($miss_req_session->getPassPagerPhone());
     $person->setPagerComment($miss_req_session->getPassPagerComment());
     $person->setOtherPhone($miss_req_session->getPassOtherPhone());
     $person->setOtherComment($miss_req_session->getPassOtherComment());
     $person->save();
     //set Passenger
     $passenger->setPersonId($person->getId());
     $passenger->setPassengerTypeId($miss_req_session->getPassType());
     $passenger->setDateOfBirth($miss_req_session->getPassDateOfBirth());
     $passenger->setIllness($miss_req_session->getIllness());
     $passenger->setFinancial($miss_req_session->getFinancial());
     $passenger->setPublicConsiderations($miss_req_session->getPassPublicCons());
     $passenger->setPrivateConsiderations($miss_req_session->getPassPrivateCons());
     $passenger->setReleasingPhysician($miss_req_session->getReleasingPhysician());
     $passenger->setReleasingPhone($miss_req_session->getReleasePhone());
     $passenger->setReleasingFax1($miss_req_session->getReleaseFax());
     $passenger->setReleasingFax1Comment($miss_req_session->getReleaseFaxComment());
     $passenger->setLodgingName($miss_req_session->getLodgingName());
     $passenger->setLodgingPhone($miss_req_session->getLodgingPhone());
     $passenger->setLodgingPhoneComment($miss_req_session->getLodgingPhoneComment());
     $passenger->setFacilityName($miss_req_session->getFacilityName());
     $passenger->setFacilityPhone($miss_req_session->getFacilityPhone());
     $passenger->setFacilityPhoneComment($miss_req_session->getFacilityPhoneComment());
     $passenger->setReleasingEmail($miss_req_session->getReleaseEmail());
     $passenger->setTreatingPhysician($miss_req_session->getTreatingPhysician());
     $passenger->setTreatingPhone($miss_req_session->getTreatingPhone());
     $passenger->setTreatingFax1($miss_req_session->getTreatingFax());
     $passenger->setTreatingFax1Comment($miss_req_session->getTreatingFaxComment());
     $passenger->setTreatingEmail($miss_req_session->getTreatingEmail());
     $passenger->setLanguageSpoken($miss_req_session->getPassLanguage());
     $passenger->setBestContactMethod($miss_req_session->getBestContact());
     $passenger->setEmergencyContactName($miss_req_session->getEmergencyName());
     $passenger->setEmergencyContactPrimaryPhone($miss_req_session->getEmergencyPhone1());
     $passenger->setEmergencyContactPrimaryComment($miss_req_session->getEmergencyPhone1Comment());
     $passenger->setEmergencyContactSecondaryPhone($miss_req_session->getEmergencyPhone2());
     $passenger->setEmergencyContactSecondaryComment($miss_req_session->getEmergencyPhone2Comment());
     $passenger->setNeedMedicalRelease($miss_req_session->getPassMedical());
     $passenger->save();
     //set Companions
     if ($passenger && $miss_req_session->getCom1Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom1Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom1Phone());
         $person->setDayComment($miss_req_session->getCom1Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom1Name());
         $companion->setRelationship($miss_req_session->getCom1Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom1DateOfBirth());
         $companion->setWeight($miss_req_session->getCom1Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom1Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom1Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom2Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom2Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom2Phone());
         $person->setDayComment($miss_req_session->getCom2Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom2Name());
         $companion->setRelationship($miss_req_session->getCom2Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom2DateOfBirth());
         $companion->setWeight($miss_req_session->getCom2Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom2Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom2Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom3Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom3Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom3Phone());
         $person->setDayComment($miss_req_session->getCom3Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom3Name());
         $companion->setRelationship($miss_req_session->getCom3Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom3DateOfBirth());
         $companion->setWeight($miss_req_session->getCom3Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom3Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom3Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom4Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom4Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom4Phone());
         $person->setDayComment($miss_req_session->getCom4Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom4Name());
         $companion->setRelationship($miss_req_session->getCom4Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom4DateOfBirth());
         $companion->setWeight($miss_req_session->getCom4Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom4Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom4Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     if ($passenger && $miss_req_session->getCom5Name()) {
         $person = new Person();
         $names[] = split(" ", $miss_req_session->getCom5Name());
         //echo var_dump($names); die();
         $person->setFirstName($names[0][0]);
         $person->setLastName($names[0][1]);
         $person->setDayPhone($miss_req_session->getCom5Phone());
         $person->setDayComment($miss_req_session->getCom5Comment());
         $person->save();
         $companion = new Companion();
         $companion->setPassengerId($passenger->getId());
         $companion->setName($miss_req_session->getCom5Name());
         $companion->setRelationship($miss_req_session->getCom5Relationship());
         $companion->setDateOfBirth($miss_req_session->getCom5DateOfBirth());
         $companion->setWeight($miss_req_session->getCom5Weigth());
         $companion->setCompanionPhone($miss_req_session->getCom5Phone());
         $companion->setCompanionPhoneComment($miss_req_session->getCom5Comment());
         $companion->setPersonId($person->getId());
         $companion->save();
     }
     //set Itinerary
     $itinerary = ItineraryPeer::getByMissReqId($miss_req_session->getId());
     if (!$itinerary) {
         $new_itinerary = new Itinerary();
         $new_itinerary->setDateRequested(date('m/d/Y'));
         $new_itinerary->setMissionRequestId($miss_req_session->getId());
         $new_itinerary->setMissionTypeId($miss_req_session->getMissionRequestTypeId());
         $new_itinerary->setApointTime($miss_req_session->getApptDate());
         $new_itinerary->setPassengerId($passenger->getId());
         $new_itinerary->setRequesterId($requester->getId());
         $new_itinerary->setFacility($miss_req_session->getFacilityName());
         $new_itinerary->setLodging($miss_req_session->getLodgingName());
         $new_itinerary->setOrginCity($miss_req_session->getOrginCity());
         $new_itinerary->setOrginState($miss_req_session->getOrginState());
         $new_itinerary->setDestCity($miss_req_session->getDestCity());
         $new_itinerary->setDestState($miss_req_session->getDestState());
         $new_itinerary->setWaiverNeed(0);
         $new_itinerary->setNeedMedicalRelease($miss_req_session->getPassMedical());
         $new_itinerary->setComment($miss_req_session->getComment());
         $new_itinerary->setAgencyId($agency->getId());
         $new_itinerary->save();
     }
     //set default Mission to Mission table
     //get Passenger
     //$passenger = PassengerPeer::getByPersonId($person->getId());
     $misson = new Mission();
     $misson->setRequestId($miss_req_session->getId());
     $misson->setItineraryId($new_itinerary->getId());
     $misson->setMissionTypeId($miss_req_session->getMissionRequestTypeId());
     $misson->setDateRequested($miss_req_session->getRequesterDate());
     if ($passenger) {
         $misson->setPassengerId($passenger->getId());
     }
     if ($requester) {
         $misson->setRequesterId($requester->getId());
     }
     if ($agency) {
         $misson->setAgencyId($agency->getId());
     }
     // Farazi Mission 1 externa ID
     $c = new Criteria();
     $c->add(MissionPeer::EXTERNAL_ID, NULL, Criteria::ISNOTNULL);
     $c->addDescendingOrderByColumn(MissionPeer::ID);
     $external_mission = MissionPeer::doSelectOne($c);
     $external_id = $external_mission->getExternalId();
     $currentExternalId = $external_id + 1;
     $misson->setExternalId($currentExternalId);
     $misson->setApptDate($miss_req_session->getApptDate());
     $misson->setFlightTime($miss_req_session->getFlightTime());
     $misson->setMissionDate($miss_req_session->getMissionDate());
     $misson->setMissionCount(1);
     $misson->save();
     $missLeg = new MissionLeg();
     $missLeg->setMissionId($misson->getId());
     $missLeg->setLegNumber(1);
     if ($miss_req_session->getOrginState() && $miss_req_session->getOrginZipcode()) {
         //echo $miss_req_session->getOrginState().'-'.$miss_req_session->getOrginZipcode();die();
         $fromairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getOrginState(), $miss_req_session->getOrginZipcode());
         if ($fromairport) {
             $missLeg->setFromAirportId($fromairport->getId());
         }
     }
     if ($miss_req_session->getDestState() && $miss_req_session->getDestZipcode()) {
         //echo $miss_req_session->getDestState().'--'.$miss_req_session->getDestZipcode();die();
         $toairport = AirportPeer::getAirportByStateAndZipcode($miss_req_session->getDestState(), $miss_req_session->getDestZipcode());
         if ($toairport) {
             $missLeg->setToAirportId($toairport->getId());
         }
     }
     //echo "oder";die();
     $missLeg->setPassOnBoard(0);
     $missLeg->setWebCoordinated(0);
     $missLeg->setTransportation('air_mission');
     $missLeg->save();
     //end set Mission
     $this->getUser()->setFlash('success', 'New mission has successfully created!');
     $miss_req_session->setProcessedDate(time());
     $miss_req_session->save();
     $this->getUser()->setAttribute('miss_req', null);
     //$this->redirect('miss_req');
     //$this->getUser()->setFlash('success',$success);
     //$request->getParameter('back')
     $this->redirect('/itinerary/detail/' . $new_itinerary->getId());
 }
예제 #9
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aMissionRequest !== null) {
             if ($this->aMissionRequest->isModified() || $this->aMissionRequest->isNew()) {
                 $affectedRows += $this->aMissionRequest->save($con);
             }
             $this->setMissionRequest($this->aMissionRequest);
         }
         if ($this->aItinerary !== null) {
             if ($this->aItinerary->isModified() || $this->aItinerary->isNew()) {
                 $affectedRows += $this->aItinerary->save($con);
             }
             $this->setItinerary($this->aItinerary);
         }
         if ($this->aMissionType !== null) {
             if ($this->aMissionType->isModified() || $this->aMissionType->isNew()) {
                 $affectedRows += $this->aMissionType->save($con);
             }
             $this->setMissionType($this->aMissionType);
         }
         if ($this->aPassenger !== null) {
             if ($this->aPassenger->isModified() || $this->aPassenger->isNew()) {
                 $affectedRows += $this->aPassenger->save($con);
             }
             $this->setPassenger($this->aPassenger);
         }
         if ($this->aRequesterRelatedByRequesterId !== null) {
             if ($this->aRequesterRelatedByRequesterId->isModified() || $this->aRequesterRelatedByRequesterId->isNew()) {
                 $affectedRows += $this->aRequesterRelatedByRequesterId->save($con);
             }
             $this->setRequesterRelatedByRequesterId($this->aRequesterRelatedByRequesterId);
         }
         if ($this->aAgencyRelatedByAgencyId !== null) {
             if ($this->aAgencyRelatedByAgencyId->isModified() || $this->aAgencyRelatedByAgencyId->isNew()) {
                 $affectedRows += $this->aAgencyRelatedByAgencyId->save($con);
             }
             $this->setAgencyRelatedByAgencyId($this->aAgencyRelatedByAgencyId);
         }
         if ($this->aRequesterRelatedByOtherRequesterId !== null) {
             if ($this->aRequesterRelatedByOtherRequesterId->isModified() || $this->aRequesterRelatedByOtherRequesterId->isNew()) {
                 $affectedRows += $this->aRequesterRelatedByOtherRequesterId->save($con);
             }
             $this->setRequesterRelatedByOtherRequesterId($this->aRequesterRelatedByOtherRequesterId);
         }
         if ($this->aAgencyRelatedByOtherAgencyId !== null) {
             if ($this->aAgencyRelatedByOtherAgencyId->isModified() || $this->aAgencyRelatedByOtherAgencyId->isNew()) {
                 $affectedRows += $this->aAgencyRelatedByOtherAgencyId->save($con);
             }
             $this->setAgencyRelatedByOtherAgencyId($this->aAgencyRelatedByOtherAgencyId);
         }
         if ($this->aCamp !== null) {
             if ($this->aCamp->isModified() || $this->aCamp->isNew()) {
                 $affectedRows += $this->aCamp->save($con);
             }
             $this->setCamp($this->aCamp);
         }
         if ($this->aCoordinator !== null) {
             if ($this->aCoordinator->isModified() || $this->aCoordinator->isNew()) {
                 $affectedRows += $this->aCoordinator->save($con);
             }
             $this->setCoordinator($this->aCoordinator);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = MissionPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = MissionPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += MissionPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         if ($this->collMissionCompanions !== null) {
             foreach ($this->collMissionCompanions as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMissionLegs !== null) {
             foreach ($this->collMissionLegs as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->collMissionPhotos !== null) {
             foreach ($this->collMissionPhotos as $referrerFK) {
                 if (!$referrerFK->isDeleted()) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
예제 #10
0
    /**
     * Get agency by ajax in popup
     * CODE: agency_create
     */
    public function executeUpdateAjax(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->setLayout(false);
        $agency = new Agency();
        $this->form = new AgencyForm($agency);
        $this->back = $request->getReferer();
        $this->backurl = "";
        $this->is_camp = 0;
        $this->person_ids = 1;
        if ($request->getParameter('camp') == 1) {
            $this->backurl = '/camp/create';
            $this->is_camp = 1;
        } elseif ($request->getParameter('req') == 1) {
            $this->backurl = '/requester/create?person_id=' . $request->getParameter('person_id');
            $this->person_ids = $request->getParameter('person_id');
        }
        if ($request->isMethod('post')) {
            $this->referer = $request->getReferer();
            $this->form->bind($request->getParameter('agency'));
            if ($this->form->isValid()) {
                $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('new_agency', $this->form->getValue('name'));
                $b_u = $request->getParameter('backurl');
                //        if($request->getReferer()){
                //          $back = $request->getReferer();
                //          if(isset($back)){
                //            if(strstr($back,'requester/edit')){
                //              $req =1;
                //            }elseif(strstr($back,'camp/create')){
                //              $camp =1;
                //            }
                //          }
                //        }
                $id = $agency->getId();
                $str = <<<XYZ
        <script type="text/javascript">
          var a = {$id};
           if(window.jQuery('#back_agency_id')){
             window.jQuery('#back_agency_id').val('');
           }
           if(window.jQuery('#back_agency_id')){
             window.jQuery('#back_agency_id').val(a);
           }
           if(window.jQuery('#pre_agency_id')){
             window.jQuery('#pre_agency_id').val('');
           }
           if(window.jQuery('#pre_agency_id')){
             window.jQuery('#pre_agency_id').val(a);
           }
           location.href='{$b_u}?agency_id={$id}';
        </script>
XYZ;
                $this->getUser()->setFlash('success', 'New Agency has added!');
                return $this->renderText($str);
            }
        } else {
            # Set referer URL
            $this->referer = $request->getReferer() ? $request->getReferer() : '@agency';
        }
        $this->agency = $agency;
    }