Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15457 | Autoría | Comparar con el anterior | 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\IndustryMapper;
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
use LeadersLinked\Model\RecruitmentSelectionCandidate;

class RecruitmentSelectionCandidateFormForm extends Form
{

    /**
     * 
     * @param AdapterInterface $adapter
     * @param int $company_id
     */
    public function __construct($adapter, $company_id) 
    {
        parent::__construct();
        $this->setInputFilter(new RecruitmentSelectionCandidateFormFilter($adapter));

        $this->add([
            'name' => 'user_id',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'id'                    => 'user_id',
            ]
        ]);
        
        $this->add([
            'name' => 'first_name',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'maxlength'     => 128,
                'id'                    => 'first_name',
            ]
         ]);

         $this->add([
            'name' => 'last_name',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'maxlength'     => 128,
                'id'                    => 'last_name',
            ]
         ]);

         $this->add([
            'name' => 'email',
            'type' => \Laminas\Form\Element\Text::class,
             'attributes' => [
                'maxlength'     => 250,
                'id'                    => 'email',
            ]
         ]);
       
        $this->add([
            'name' => 'form_uuid',
            'type' => \Laminas\Form\Element\Select::class,
            'attributes' => [
                'id' => 'form_uuid',
            ],
            'options' => [
                'value_options' => $this->getSelectFormOptions($adapter, $company_id)
            ]
        ]);

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

         $this->add([
            'name' => 'status',
            'type' => \Laminas\Form\Element\Select::class,
            'options' => [
                'empty_option' => 'LABEL_STATUS',
                'value_options' => [
                    RecruitmentSelectionCandidate::STATUS_ACEPTED => 'LABEL_ACCEPTED',
                    RecruitmentSelectionCandidate::STATUS_REJECTED => 'LABEL_REJECTED',
                ],
            ],
            'attributes' => [
                'id' => 'status',
            ]
        ]);

        $this->add([
            'name' => 'coment',
            'type' => \Laminas\Form\Element\Textarea::class,
             'attributes' => [
                'id'                    => 'coment',
             ],
        ]);
       
        $this->add([
            'name' => 'evaluation',
            'type' => \Laminas\Form\Element\Select::class,
            'options' => [
                'empty_option' => 'LABEL_EVALUATION',
                'value_options' => [
                    RecruitmentSelectionCandidate::EVALUATION_0 => 'LABEL_ANOTHER',
                    RecruitmentSelectionCandidate::EVALUATION_1 => '25%',
                    RecruitmentSelectionCandidate::EVALUATION_2 => '50%',
                    RecruitmentSelectionCandidate::EVALUATION_3 => '75%',
                    RecruitmentSelectionCandidate::EVALUATION_4 => '100%',
                
                ],
            ],
            'attributes' => [
                'id' => 'evaluation',
            ]
        ]);


    }
    
    /**
     *
     * @param AdapterInterface $adapter
     */
    private function getSelectFormOptions($adapter, $company_id)
    {
        $options = [];
        
        $mapper = RecruitmentSelectionVacancyMapper::getInstance($adapter);
        $records = $mapper->fetchAllByCompanyId($company_id); 
        
        foreach($records as $record)
        {
            $options[$record->uuid] = $record->name;    
        }
        return $options;
    }
    
    
}