<?php

namespace Modules\EtatStatistiques\Service;

use Helpers\Form\FormBuilder;
use Helpers\Trad\ITrad;

class EtatStatImportForm extends FormBuilder
{
    public function __construct(ITrad $trad)
    {
        parent::__construct();
        
        $this->addTable(
            'ListEtat',
            (new class($trad) extends EtatStatForm {
                
                /**
                 * @return \stdClass[]
                 */
                protected function getFormReqRequete(ITrad $trad)
                {
                    $form = parent::getFormReqRequete($trad);

                    unset($form['WherePillable']);
                    
                    return $form + [
                        'Where' => $this->simpleText('Where', 3000),
    
                        'REQ_LIBRE' => $this->switch('REQ_LIBRE'),
                        'ReqLibre' => $this->simpleText('ReqLibre', 3000),
                    ];
                }

                protected function getFormSelect(ITrad $trad)
                {
                    return parent::getFormSelect($trad)
                        + ['ELEM_NORD' => $this->simpleInteger('ELEM_NORD')];
                }
                
                protected function getFormJoin(ITrad $trad) :array
                {
                    return parent::getFormJoin($trad)
                        + ['RFRO_NO_ORDRE' => $this->simpleInteger('RFRO_NO_ORDRE')];
                }
            })->getFormView($trad),
            ['item_label' => $trad->t('État @1@')]
        );
    }
}
