Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 66 | Autoría | Ultima modificación | Ver Log |

<?php

declare(strict_types=1);

namespace LeadersLinked\Form;

use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use Laminas\Log\LoggerInterface;
use LeadersLinked\Mapper\CompanySizeMapper;
use LeadersLinked\Mapper\IndustryMapper;
use LeadersLinked\Mapper\JobCategoryMapper;
use LeadersLinked\Model\Job;
use LeadersLinked\Mapper\JobDescriptionMapper;

class JobDescriptionForm extends Form
{
    /**
     * 
     * @param AdapterInterface $adapter
     * @param int $company_id
     * @param int $id
     */
    public function __construct($adapter, $company_id, $id = 0) 
    {
        parent::__construct();
        $this->setInputFilter(new JobDescriptionFilter($adapter));
        
        $this->add([
            'name' => 'name',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'maxlength'     => 128,
                'id'                    => 'name',
            ]
         ]);

       
        $this->add([
            'name' => 'job_description_id_boss',
            'type' => \Laminas\Form\Element\Select::class,
            'options' => [
                'empty_option' => 'LABEL_NA',
                'value_options' => $this->optionsJobDescriptions($adapter, $company_id, $id),
            ],
            'attributes' => [
                'id' => 'job_description_id_boss',
            ]
        ]);
        
        $this->add([
            'name' => 'functions',
            'type' => \Laminas\Form\Element\Textarea::class,
            'attributes' => [
                'id'    => 'functions',
            ]
        ]);


        $this->add([
            'name' => 'subordinates_selected',
            'type' => \Laminas\Form\Element\Textarea::class,
            'attributes' => [
                'id'    => 'subordinates_selected',
            ]
        ]);


        $this->add([
            'name' => 'competencies_selected',
            'type' => \Laminas\Form\Element\Textarea::class,
            'attributes' => [
                'id'    => 'competencies_selected',
            ]
        ]);
        
        $this->add([
            'name' => 'objectives',
            'type' => \Laminas\Form\Element\Textarea::class,
            'attributes' => [
                'id'    => 'objectives',
            ]
        ]);
        
      
        
        
        $this->add([
            'name' => 'status',
            'type' => \Laminas\Form\Element\Checkbox::class,
            'attributes' => [
                'id'                    => 'status',
            ],
            'options' => [
                'use_hidden_element' => 0,
                'unchecked_value' => \LeadersLinked\Model\JobDescription::STATUS_INACTIVE,
                'checked_value'=> \LeadersLinked\Model\JobDescription::STATUS_ACTIVE,
            ]
        ]);
        
        
    }
    
    /**
     *
     * @param AdapterInterface $adapter
     * @param int $company_id
     * @param int $id
     * @param LoggerInterface $logger
     * @return array
     */
    private function optionsJobDescriptions($adapter, $company_id, $id)
    {
        $jobDescriptionMapper = JobDescriptionMapper::getInstance($adapter);
        $jobsDescription = $jobDescriptionMapper->fetchAllActiveByCompanyIdWhereIdNotEqual($company_id, $id);
        
        $options = [];
        foreach($jobsDescription as $jobDescription)
        {
            $options[$jobDescription->uuid] = $jobDescription->name;
        }
        
        return $options;
    }
    
    
}