Rev 16784 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\JobDescription;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\JobDescriptionMapper;
use LeadersLinked\Mapper\JobDescriptionSubordinateMapper;
class JobDescriptionForm extends Form
{
/**
*
* @param AdapterInterface $adapter
* @param int $company_id
* @param int $id
*/
public function __construct($adapter, $company_id, $job_description_id = 0)
{
parent::__construct();
$this->setInputFilter(new JobDescriptionFilter($adapter));
$this->add([
'name' => 'competencies',
'type' => \Laminas\Form\Element\Hidden::class,
'attributes' => [
'id' => 'competencies',
]
]);
$this->add([
'name' => 'name',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 128,
'id' => 'name',
]
]);
$this->add([
'name' => 'functions',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'maxlength' => 1024,
'id' => 'functions',
'rows' => 10
]
]);
$this->add([
'name' => 'objectives',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'maxlength' => 1024,
'id' => 'objectives',
'rows' => 10
]
]);
$this->add([
'name' => 'status',
'type' => \Laminas\Form\Element\Checkbox::class,
'attributes' => [
'id' => 'status',
],
'options' => [
'use_hidden_element' => false,
'unchecked_value' => \LeadersLinked\Model\JobDescription::STATUS_INACTIVE,
'checked_value'=> \LeadersLinked\Model\JobDescription::STATUS_ACTIVE,
]
]);
$this->add([
'name' => 'job_description_id_boss',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'job_description_id_boss',
],
'options' => [
'empty_option' => 'LABEL_JOB_DESCRIPTION_BOSS_OPTION',
'value_options' => $this->getJobDescriptionIdBoss($adapter, $company_id, $job_description_id),
]
]);
}
private function getJobDescriptionIdBoss($adapter, $company_id, $job_description_id = 0)
{
$jobDescriptionMapper = JobDescriptionMapper::getInstance($adapter);
if($company_id) {
$records = $jobDescriptionMapper->fetchAllByCompanyId($company_id);
} else {
$records = $jobDescriptionMapper->fetchAllByDefault();
}
$items = [];
foreach($records as $record)
{
if($job_description_id == $record->id) {
continue;
}
$items[ $record->uuid ] = $record->name;
}
return $items;
}
}