AutorÃa | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\Survey;use Laminas\Form\Form;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Mapper\IndustryMapper;use LeadersLinked\Mapper\JobDescriptionMapper;use LeadersLinked\Mapper\SkillMapper;use LeadersLinked\Mapper\LanguageMapper;use LeadersLinked\Mapper\SurveyFormMapper;use LeadersLinked\Model\SurveyCampaign;use LeadersLinked\Model\SurveyForm;class SurveyCampaignForm extends Form{public function __construct($adapter, $company_id, $type){parent::__construct();$this->setInputFilter(new SurveyCampaignFilter($adapter, $company_id, $type));$this->add(['name' => 'name','type' => \Laminas\Form\Element\Text::class,'attributes' => ['maxlength' => 128,'id' => 'name',]]);$this->add(['name' => 'form_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'form_id',],'options' => ['value_options' => $this->getFormSelectOptions($adapter, $company_id, $type)]]);$this->add(['name' => 'start_date','type' => \Laminas\Form\Element\Date::class,'attributes' => ['id' => 'start_date',],'options' => ['format' => 'Y-m-d',]]);$this->add(['name' => 'end_date','type' => \Laminas\Form\Element\Date::class,'attributes' => ['id' => 'end_date',],'options' => ['format' => 'Y-m-d',]]);$this->add(['name' => 'status','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'status',],'options' => ['empty_option' => 'LABEL_SELECT','value_options' => [SurveyCampaign::STATUS_ACTIVE => 'LABEL_ACTIVE',SurveyCampaign::STATUS_INACTIVE => 'LABEL_INACTIVE',],],]);$this->add(['name' => 'identity','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'identity',],'options' => ['empty_option' => 'LABEL_SELECT','value_options' => [SurveyCampaign::IDENTITY_YES => 'LABEL_YES',SurveyCampaign::IDENTITY_NO => 'LABEL_NO',],],]);/*** FILTERS ***/if($type == SurveyCampaign::TYPE_ORGANIZATIONAL_CLIMATE) {$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','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'language','multiple' => 'yes',],'options' => ['disable_inarray_validator' => true,'value_options' => $this->getLanguageSelectOptions($adapter)]]);$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' => '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',]]);}/**** @param AdapterInterface $adapter*/private function getFormSelectOptions($adapter, $company_id, $type){$options = [];$mapper = SurveyFormMapper::getInstance($adapter);if($type == SurveyForm::TYPE_ORGANIZATIONAL_CLIMATE) {$records = $mapper->fetchAllActiveOrganizationalClimateByCompanyId($company_id);} else {$records = $mapper->fetchAllActiveNormalByCompanyId($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;}}