Rev 7539 | AutorÃa | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form;use LeadersLinked\Mapper\IndustryMapper;use LeadersLinked\Mapper\JobDescriptionMapper;use LeadersLinked\Mapper\SkillMapper;use LeadersLinked\Mapper\LanguageMapper;use LeadersLinked\Mapper\CompanyMapper;use Laminas\Form\Form;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Mapper\OrganizationalClimateMapper;use LeadersLinked\Mapper\OrganizationalClimateFormMapper;use LeadersLinked\Model\OrganizationalClimate;class OrganizationalClimateForm extends Form{public function __construct($adapter, $company_id){parent::__construct();$this->setInputFilter(new OrganizationalClimateFilter($adapter, $company_id));$this->add(['name' => 'name','type' => \Laminas\Form\Element\Text::class,'attributes' => ['maxlength' => 128,'id' => 'name',]]);$this->add(['name' => 'segmented','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'segmented',],'options' => ['disable_inarray_validator' => true,'empty_option' => 'LABEL_SEGMENTED','value_options' => ['description' => 'LABEL_JOB_DESCRIPTION','skill' => 'LABEL_SKILLS','industry' => 'LABEL_INDUSTRY','location' => 'LABEL_LOCATION','languages' => 'LABEL_LANGUAGES',],],]);$this->add(['name' => 'form_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'form_id',],'options' => ['value_options' => $this->getFormSelectOptions($adapter, $company_id)]]);$this->add(['name' => 'job_description_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'job_description_id','multiple' => 'yes',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->getDescriptionSelectOptions($adapter, $company_id)]]);$this->add(['name' => 'skill_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'skill_id','multiple' => 'yes',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->getSkillSelectOptions($adapter)]]);$this->add(['name' => 'language_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'language_id','multiple' => 'yes',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->getLanguageSelectOptions($adapter)]]);$this->add(['name' => 'since_date','type' => \Laminas\Form\Element\Date::class,'attributes' => ['id' => 'since_date',],]);$this->add(['name' => 'last_date','type' => \Laminas\Form\Element\Date::class,'attributes' => ['id' => 'last_date',],]);$this->add(['name' => 'location_search','type' => \Laminas\Form\Element\Text::class,'attributes' => ['maxlength' => 250,'id' => 'location_search',]]);$this->add(['name' => 'formatted_address','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'formatted_address',]]);$this->add(['name' => 'address1','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'address1',]]);$this->add(['name' => 'address2','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'address2',]]);$this->add(['name' => 'country','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'country',]]);$this->add(['name' => 'state','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'state',]]);$this->add(['name' => 'city1','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'city1',]]);$this->add(['name' => 'city2','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'city2',]]);$this->add(['name' => 'postal_code','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'postal_code',]]);$this->add(['name' => 'latitude','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'latitude',]]);$this->add(['name' => 'longitude','type' => \Laminas\Form\Element\Hidden::class,'attributes' => ['id' => 'longitude',]]);$this->add(['name' => 'industry_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'industry_id','multiple' => 'yes',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->getIndustrySelectOptions($adapter)]]);$this->add(['name' => 'target','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'target',],'options' => ['empty_option' => 'LABEL_SEGMENT','value_options' => [OrganizationalClimate::TARGET_SEGMENTED => 'LABEL_SEGMENTED',OrganizationalClimate::TARGET_NON_SEGMENTED => 'LABEL_NON_SEGMENTED',],],]);$this->add(['name' => 'status','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'status',],'options' => ['empty_option' => 'LABEL_STATUS','value_options' => [OrganizationalClimate::STATUS_ACTIVE => 'LABEL_ACTIVE',OrganizationalClimate::STATUS_INACTIVE => 'LABEL_INACTIVE',],],]);$this->add(['name' => 'identity','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'identity',],'options' => ['empty_option' => 'LABEL_STATUS','value_options' => [OrganizationalClimate::IDENTITY_YES => 'LABEL_YES',OrganizationalClimate::IDENTITY_NO => 'LABEL_NO',],],]);}/**** @param AdapterInterface $adapter*/private function getFormSelectOptions($adapter, $company_id){$options = [];$mapper = OrganizationalClimateFormMapper::getInstance($adapter);$records = $mapper->fetchAllByCompanyId($company_id);foreach($records as $record){$options[$record->uuid] = $record->name;}return $options;}private function getDescriptionSelectOptions($adapter, $company_id){$options = [];$mapper = JobDescriptionMapper::getInstance($adapter);$records = $mapper->fetchAllActiveByCompanyId($company_id);foreach($records as $record){$options[$record->uuid] = $record->name;}return $options;}function getSkillSelectOptions($adapter){$options = [];$mapper = SkillMapper::getInstance($adapter);$records = $mapper->fetchAllActive();foreach($records as $record){$options[$record->uuid] = $record->name;}return $options;}function getIndustrySelectOptions($adapter){$options = [];$mapper = IndustryMapper::getInstance($adapter);$records = $mapper->fetchAllActive();foreach($records as $record){$options[$record->uuid] = $record->name;}return $options;}function getLanguageSelectOptions($adapter){$options = [];$mapper = LanguageMapper::getInstance($adapter);$records = $mapper->fetchAll();foreach($records as $record){$options[$record->id] = $record->name;}return $options;}}