<?php

namespace Modules\Admin\Config\InvoiceCashings\DocsList;

class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract
{

	/**
	 * Creates the form for insert/update.
	 * @see \App\Mvc\View_Utils_FormAbstract::getForm()
	 */
	public function getForm()
	{

		// NEW FORM ///////////////////////////////////////////////////////////////////////////////
		$form = \Engine\Form\General::create();

		// NEW CONTAINER --------------------------------------------------------------------------
		$fieldset1=\Engine\Form\Container\Fieldset::create($this->lang['form']['fieldsets']['details']);
		$form->addContainer($fieldset1);

		// name
		$fld = new \Engine\Form\Input\Text($this->lang['form']['fields']['name'], 'name', $this->values['name']);
		$fld->setTooltip($this->lang['form']['fields']['nameTooltip']);
		$fld->setMandatory();
		$fld->setValidator(['maxLength'=>50]);
		$fieldset1->addElement($fld);

		// id/code
		$fld = new \Engine\Form\Input\Text($this->lang['form']['fields']['id'], 'id', $this->values['id']);
		$fld->setTooltip($this->lang['form']['fields']['idTooltip']);
		$fld->setMandatory();
		$fld->setValidator(['maxLength'=>25]);
		if ($this->controller->getAction()=='update') {
			$fld->setDisabled();
		}
		$fieldset1->addElement($fld);
		if ($this->controller->getAction()=='update') {
			$fld = new \Engine\Form\Input\Hidden('', 'id', $this->values['id']);
			$fieldset1->addElement($fld);
		}

		// active
		$fld = new \Engine\Form\Input\Checkbox($this->lang['form']['fields']['active'], 'active', $this->values['active']);
		$fieldset1->addElement($fld);

		// number
		$fld = new \Engine\Form\Input\Select($this->lang['form']['fields']['number'], 'number', $this->values['number']);
		$fld->setPossibleValues( [
			'hidden'	=> $this->lang['form']['fields']['general_h'],
			'optional'	=> $this->lang['form']['fields']['general_o'],
			'mandatory'	=> $this->lang['form']['fields']['general_m'],
			'series'	=> $this->lang['form']['fields']['general_s'],
		]);
		$fld->showDefaultOption();
		$fld->setMandatory();
		$form->addElement($fld);

		// sign
		$fld_pivot = new \Engine\Form\Input\Select($this->lang['form']['fields']['sign'], 'sign', $this->values['sign']);
		$fld_pivot->setPossibleValues( [
			'1'			=> $this->lang['form']['fields']['sign_p'],
			'-1'		=> $this->lang['form']['fields']['sign_n'],
			'2'			=> $this->lang['form']['fields']['sign_b'],
		]);
		$fld_pivot->showDefaultOption();
		$fld_pivot->setMandatory();
		$form->addElement($fld_pivot);

		// bank account
		$fld = new \Engine\Form\Input\Select($this->lang['form']['fields']['bankAccount'], 'bankAccount', $this->values['bankAccount']);
		$fld->setPossibleValues( [
			'hidden'	=> $this->lang['form']['fields']['general_h'],
			'optional'	=> $this->lang['form']['fields']['general_o'],
			'mandatory'	=> $this->lang['form']['fields']['general_m'],
		]);
		$fld->showDefaultOption();
		$fld->setMandatory();
		$form->addElement($fld);

		// explanations
		$fld = new \Engine\Form\Input\Select($this->lang['form']['fields']['explanations'], 'explanations', $this->values['explanations']);
		$fld->setPossibleValues( [
			'hidden'	=> $this->lang['form']['fields']['general_h'],
			'optional'	=> $this->lang['form']['fields']['general_o'],
			'mandatory'	=> $this->lang['form']['fields']['general_m'],
		]);
		$fld->showDefaultOption();
		$fld->setMandatory();
		$form->addElement($fld);

		// comments
		$fld = new \Engine\Form\Input\Select($this->lang['form']['fields']['comments'], 'comments', $this->values['comments']);
		$fld->setPossibleValues( [
			'hidden'	=> $this->lang['form']['fields']['general_h'],
			'optional'	=> $this->lang['form']['fields']['general_o'],
			'mandatory'	=> $this->lang['form']['fields']['general_m'],
		]);
		$fld->showDefaultOption();
		$fld->setMandatory();
		$form->addElement($fld);

		// submit button
		$form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1));

		return $form;

	}
}