Rev 16785 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
<?phpdeclare(strict_types=1);namespace LeadersLinked\Form\Planning;use Laminas\Form\Form;use Laminas\Db\Adapter\AdapterInterface;use LeadersLinked\Mapper\PlanningPeriodMapper;use LeadersLinked\Mapper\PlanningObjectiveMapper;class PlanningGoalHeaderForm extends Form{private int $first_period_id = 0;/**** @param AdapterInterface $dbAdapter* @param int $company_id*/public function __construct($dbAdapter, $company_id){parent::__construct();$this->setInputFilter(new PlanningGoalHeaderFilter());$this->add(['name' => 'period_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'period_id',],'options' => ['value_options' => $this->plannigPeriod($dbAdapter, $company_id)]]);$this->add(['name' => 'objective_id','type' => \Laminas\Form\Element\Select::class,'attributes' => ['id' => 'objective_id',],'options' => ['value_options' => $this->plannigObjective($dbAdapter, $company_id)]]);}/**** @param AdapterInterface $dbAdapter* @param int $company_id* return array*/private function plannigPeriod($dbAdapter, $company_id){$items = [];$planningPeriodMapper = PlanningPeriodMapper::getInstance($dbAdapter);$records = $planningPeriodMapper->fetchAllActiveByCompany($company_id);foreach($records as $record){if(empty($this->first_period_id)) {$this->first_period_id = $record->id;}$items[ $record->uuid ] = $record->title;}return $items;}/**** @param AdapterInterface $dbAdapter* @param int $company_id* return array*/private function plannigObjective($dbAdapter, $company_id){$items = [];$planningObjectiveMapper = PlanningObjectiveMapper::getInstance($dbAdapter);$records = $planningObjectiveMapper->fetchAllActiveByCompanyIdAndPeriodId($company_id, $this->first_period_id);foreach($records as $record){$items[ $record->uuid ] = $record->title;}return $items;}}