Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\RecruitmentSelection;
use LeadersLinked\Mapper\IndustryMapper;
use LeadersLinked\Mapper\JobDescriptionMapper;
use LeadersLinked\Mapper\JobCategoryMapper;
use LeadersLinked\Mapper\CompanyMapper;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
class RecruitmentSelectionVacancyForm extends Form
{
public function __construct($adapter, $company_id)
{
parent::__construct();
$this->setInputFilter(new RecruitmentSelectionVacancyFilter($adapter));
$this->add([
'name' => 'name',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 128,
'id' => 'name',
]
]);
$this->add([
'name' => 'job_description_id',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'job_description_id',
],
'options' => [
'value_options' => $this->getDescriptionSelectOptions($adapter, $company_id)
]
]);
$this->add([
'name' => 'job_category_id',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'job_category_id',
],
'options' => [
'value_options' => $this->getCategorySelectOptions($adapter, $company_id)
]
]);
$this->add([
'name' => 'description',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'description',
],
]);
$this->add([
'name' => 'location_search',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'id' => 'location_search',
],
]);
$this->add([
'name' => 'last_date',
'type' => \Laminas\Form\Element\Text::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',
],
'options' => [
'value_options' => $this->getIndustrySelectOptions($adapter)
]
]);
$this->add([
'name' => 'status',
'type' => \Laminas\Form\Element\Checkbox::class,
'attributes' => [
'id' => 'status',
],
'options' => [
'use_hidden_element' => 0,
'unchecked_value' => \LeadersLinked\Model\RecruitmentSelectionVacancy::STATUS_INACTIVE,
'checked_value'=> \LeadersLinked\Model\RecruitmentSelectionVacancy::STATUS_ACTIVE,
]
]);
}
/**
*
* @param AdapterInterface $adapter
*/
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 getCategorySelectOptions($adapter)
{
$options = [];
$mapper = JobCategoryMapper::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;
}
}