<?php
namespace Modules\Bsp\Listing;

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

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

		// bsp date
		$bspPeriod = new \Engine\Form\Input\DateInterval($this->lang['index']['filters']['bspInterval'], 'filters[bspInterval]', $fieldsValues['bspInterval']);
		$form->addElement($bspPeriod);

		// office
		$office = new \App\Form\Input\Autocomplete_Office($this->lang['index']['filters']['idOffice'], 'filters[idOffice]', $fieldsValues['idOffice']);
		if (!\App\UserAccess\CurrentUserAccessFast::getInstance()->hasAccessToOption('Modules/Bsp/Listing-completeAccess')) {
			$office->setDisabled();
		}
		$form->addElement($office);

		// reset button
		$form->showResetButton(true);

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