Rev 6750 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
declare(strict_types=1);
namespace LeadersLinked\Form\UserProfile;
use Laminas\Form\Form;
use Laminas\Db\Adapter\AdapterInterface;
use LeadersLinked\Mapper\IndustryMapper;
use LeadersLinked\Mapper\CompanySizeMapper;
class ExperienceForm extends Form
{
/**
*
* @param AdapterInterface $adapter
*/
public function __construct($adapter)
{
parent::__construct();
$this->setInputFilter(new ExperienceFilter($adapter));
$this->add([
'name' => 'industry_id',
'type' => \Laminas\Form\Element\Select::class,
'options' => [
'value_options' => $this->optionsIndustry($adapter)
],
'attributes' => [
'id' => 'industry_id',
]
]);
$this->add([
'name' => 'company_size_id',
'type' => \Laminas\Form\Element\Select::class,
'options' => [
'value_options' => $this->optionsCompanySize($adapter)
],
'attributes' => [
'id' => 'company_size_id',
]
]);
$this->add([
'name' => 'company',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 128,
'id' => 'company',
]
]);
$this->add([
'name' => 'title',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 128,
'id' => 'title',
]
]);
$this->add([
'name' => 'from_month',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'from_month',
],
'options' => [
'value_options' => $this->optionsMonths()
],
]);
$this->add([
'name' => 'from_year',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'from_year',
],
'options' => [
'value_options' => $this->optionsYears()
],
]);
$this->add([
'name' => 'to_month',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'to_month',
],
'options' => [
'value_options' => $this->optionsMonths()
],
]);
$this->add([
'name' => 'to_year',
'type' => \Laminas\Form\Element\Select::class,
'attributes' => [
'id' => 'to_year',
],
'options' => [
'value_options' => $this->optionsYears()
],
]);
$this->add([
'name' => 'is_current',
'type' => \Laminas\Form\Element\Checkbox::class,
'attributes' => [
'id' => 'is_current',
],
'options' => [
'use_hidden_element' => false,
'unchecked_value' => \LeadersLinked\Model\UserExperience::IS_CURRENT_NO,
'checked_value'=> \LeadersLinked\Model\UserExperience::IS_CURRENT_YES,
]
]);
$this->add([
'name' => 'description',
'type' => \Laminas\Form\Element\Textarea::class,
'attributes' => [
'id' => 'description',
]
]);
$this->add([
'name' => 'experience_location_search',
'type' => \Laminas\Form\Element\Text::class,
'attributes' => [
'maxlength' => 250,
'id' => 'experience_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
* @return array
*/
private function optionsIndustry($adapter)
{
$mapper = IndustryMapper::getInstance($adapter);
$records = $mapper->fetchAllActive();
$items = [];
foreach($records as $record)
{
$items[$record->uuid] = $record->name;
}
return $items;
}
/**
*
* @param AdapterInterface $adapter
* @return array
*/
private function optionsCompanySize($adapter)
{
$mapper = CompanySizeMapper::getInstance($adapter);
$records = $mapper->fetchAllActive();
$items = [];
foreach($records as $record)
{
$items[$record->uuid] = $record->name . ' (' . $record->minimum_no_of_employee . '-' . $record->maximum_no_of_employee . ') ';
}
return $items;
}
/**
*
* @return array
*/
private function optionsMonths()
{
$options = [];
$options[0] = 'LABEL_MONTH_JANUARY';
$options[1] = 'LABEL_MONTH_JANUARY';
$options[2] = 'LABEL_MONTH_FEBRUARY';
$options[3] = 'LABEL_MONTH_MARCH';
$options[4] = 'LABEL_MONTH_APRIL';
$options[5] = 'LABEL_MONTH_MAY';
$options[6] = 'LABEL_MONTH_JUNE';
$options[7] = 'LABEL_MONTH_JULY';
$options[8] = 'LABEL_MONTH_AUGUST';
$options[9] = 'LABEL_MONTH_SEPTEMBER';
$options[10] = 'LABEL_MONTH_OCTOBER';
$options[11] = 'LABEL_MONTH_NOVEMBER';
$options[12] = 'LABEL_MONTH_DECEMBER';
return $options;
}
/**
*
* @return array
*/
private function optionsYears()
{
$y = date('Y');
$options = [];
for($i = 0 ; $i < 100; $i++)
{
$options[$y - $i] = $y - $i;
}
return $options;
}
}