public function configure() { $empNumber = $this->getOption('empNumber'); $employee = $this->getOption('employee'); $this->fullName = $employee->getFullName(); $jobTitleId = $employee->job_title_code; $empTerminatedId = $employee->termination_id; $jobTitles = $this->_getJobTitles($jobTitleId); $employeeStatuses = $this->_getEmpStatuses(); $eeoCategories = $this->_getEEOCategories(); $subDivisions = $this->_getSubDivisions(); $locations = $this->_getLocations($employee); $empService = new EmployeeService(); $attachmentList = $empService->getAttachments($empNumber, 'contract'); if (count($attachmentList) > 0) { $this->attachment = $attachmentList[0]; } $contractUpdateChoices = array(self::CONTRACT_KEEP => __('Keep Current'), self::CONTRACT_DELETE => __('Delete Current'), self::CONTRACT_UPLOAD => __('Replace Current')); // Note: Widget names were kept from old non-symfony version $this->setWidgets(array('emp_number' => new sfWidgetFormInputHidden(), 'job_title' => new sfWidgetFormSelect(array('choices' => $jobTitles)), 'emp_status' => new sfWidgetFormSelect(array('choices' => $employeeStatuses)), 'terminated_date' => new ohrmWidgetDatePickerNew(array(), array('id' => 'job_terminated_date')), 'termination_reason' => new sfWidgetFormTextarea(), 'eeo_category' => new sfWidgetFormSelect(array('choices' => $eeoCategories)), 'sub_unit' => new sfWidgetFormSelect(array('choices' => $subDivisions)), 'location' => new sfWidgetFormSelect(array('choices' => $locations)), 'joined_date' => new ohrmWidgetDatePickerNew(array(), array('id' => 'job_joined_date')), 'contract_start_date' => new ohrmWidgetDatePickerNew(array(), array('id' => 'job_contract_start_date')), 'contract_end_date' => new ohrmWidgetDatePickerNew(array(), array('id' => 'job_contract_end_date')), 'contract_file' => new sfWidgetFormInputFile(), 'contract_update' => new sfWidgetFormChoice(array('expanded' => true, 'choices' => $contractUpdateChoices)))); // Default values $this->setDefault('emp_number', $empNumber); $this->setDefault('emp_status', $employee->emp_status); if (!empty($jobTitleId)) { $this->setDefault('job_title', $jobTitleId); $jobTitle = $this->getJobTitleService()->getJobTitleById($jobTitleId); $this->jobSpecAttachment = $jobTitle->getJobSpecificationAttachment(); } if (!empty($empTerminatedId)) { $this->empTermination = $employee->getEmpTermination(); } $this->setDefault('eeo_category', $employee->eeo_cat_code); $inputDatePattern = sfContext::getInstance()->getUser()->getDateFormat(); sfContext::getInstance()->getConfiguration()->loadHelpers('OrangeDate'); $this->setDefault('sub_unit', $employee->work_station); // Assign first location $locationList = $employee->locations; if (count($locationList) > 0) { $this->setDefault('location', $locationList[0]->id); } $contracts = $employee->contracts; if (count($contracts) > 0) { $contract = $contracts[0]; $this->setDefault('contract_start_date', set_datepicker_date_format($contract->start_date)); $this->setDefault('contract_end_date', set_datepicker_date_format($contract->end_date)); } $this->setDefault('joined_date', set_datepicker_date_format($employee->joined_date)); $this->setDefault('contract_update', self::CONTRACT_KEEP); $this->setValidators(array('emp_number' => new sfValidatorString(array('required' => true)), 'job_title' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys($jobTitles))), 'emp_status' => new sfValidatorString(array('required' => false)), 'terminated_date' => new ohrmDateValidator(array('date_format' => $inputDatePattern, 'required' => false), array('invalid' => 'Date format should be ' . $inputDatePattern)), 'termination_reason' => new sfValidatorString(array('required' => false)), 'eeo_category' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys($eeoCategories))), 'sub_unit' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys($subDivisions))), 'location' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys($locations))), 'joined_date' => new ohrmDateValidator(array('date_format' => $inputDatePattern, 'required' => false), array('invalid' => 'Date format should be ' . $inputDatePattern)), 'contract_start_date' => new ohrmDateValidator(array('date_format' => $inputDatePattern, 'required' => false), array('invalid' => 'Date format should be ' . $inputDatePattern)), 'contract_end_date' => new ohrmDateValidator(array('date_format' => $inputDatePattern, 'required' => false), array('invalid' => 'Date format should be ' . $inputDatePattern)), 'contract_file' => new sfValidatorFile(array('required' => false, 'max_size' => 1000000), array('max_size' => __(TopLevelMessages::FILE_SIZE_SAVE_FAILURE))), 'contract_update' => new sfValidatorString(array('required' => false)))); $this->widgetSchema->setNameFormat('job[%s]'); // set up post validator method $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'postValidate')))); }