<?php

namespace Modules\Admin\Config\Documents\IssueDocs;

class View_Utils_FormFilters extends \App\Mvc\View_Utils_FormAbstract
{

	/**
	 * Creates the form for filters
	 * @see \App\Mvc\View_Utils_FormAbstract::getForm()
	 */
	public function getForm()
	{
		$fieldsValues = $this->values['listingParams']->getFilters();

		$form=\Engine\Form\Filters::create();
		$form->setColumns(3);

		// text
		$nameFld=new \Engine\Form\Input\Text($this->lang['index']['filters']['text'], 'filters[text]', $fieldsValues['text']);
		$nameFld->setTooltip($this->lang['index']['filters']['textTooltip']);
		$form->addElement($nameFld);

		// pivot
		$pivotFld=new \Engine\Form\Input\Select($this->lang['index']['filters']['pivot'], 'filters[pivot]', $fieldsValues['pivot']);
		$pivotFld->setPossibleValues( [
			'invoice'			=> $this->lang['pivotName']['invoice'],
			'cashing'			=> $this->lang['pivotName']['cashing'],
			'payment'			=> $this->lang['pivotName']['payment'],
			'importedDocument'	=> $this->lang['pivotName']['importedDocument'],
			'cashBookDoc'		=> $this->lang['pivotName']['cashBookDoc'],
			'balance'			=> $this->lang['pivotName']['balance'],
			'order'				=> $this->lang['pivotName']['order'],
			'service'			=> $this->lang['pivotName']['service'],
			'importedService'	=> $this->lang['pivotName']['importedService'],
		]);
		$pivotFld->showDefaultOption();
		$form->addElement($pivotFld);

		// active
		$activeFld=new \Engine\Form\Input\Select($this->lang['index']['filters']['active'], 'filters[active]', $fieldsValues['active']);
		$activeFld->setPossibleValues( [
			'2'=>$this->lang['index']['filters']['active_2'],
			'1'=>$this->lang['index']['filters']['active_1'],
			'0'=>$this->lang['index']['filters']['active_0']
		]);
		$form->addElement($activeFld);

		$form->setJsCallback('MVC.listing.installedHandlers["listing"].reloadAndResetListing');
		$form->loadMissingDefaultValues($this->values['listingParams']->getDefaultFilters());
		return $form;
	}

}
