<?php
namespace Modules\Admin\Config\ImportedOrders\EntitiesMatch;

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

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

		// idSystem
		$fld = new \App\Form\Input\Select_OrdersExternalSystem($this->lang['index']['filters']['idSystem'], 'filters[idSystem]', $fieldsValues['idSystem']);
		$fld->showDefaultOption(true);
		$fld->setMandatory(true);
		$form->addElement($fld);

		// entityType
		$fld = new \Engine\Form\Input\Select($this->lang['index']['filters']['entityType'], 'filters[entityType]', $fieldsValues['entityType']);
		$fld->setMandatory(true);
		$fld->setPossibleValues([
			'' => 					'-',
			'user' => 				$this->lang['formFields']['entityType_']['user'],
			'office' => 			$this->lang['formFields']['entityType_']['office'],
			'customer' => 			$this->lang['formFields']['entityType_']['customer'],
			'customer_type' => 		$this->lang['formFields']['entityType_']['customer_type'],
			'customer_title' => 	$this->lang['formFields']['entityType_']['customer_title'],
			'corporate' => 			$this->lang['formFields']['entityType_']['corporate'],
			'supplier' => 			$this->lang['formFields']['entityType_']['supplier'],
			'supplierProduct' => 	$this->lang['formFields']['entityType_']['supplierProduct'],
			#'serviceType' => 		$this->lang['formFields']['entityType_']['serviceType'],
			#'service_category' => 	$this->lang['formFields']['entityType_']['service_category'],
			#'service_productType' =>$this->lang['formFields']['entityType_']['service_productType'],
			#'service_multiplier' => $this->lang['formFields']['entityType_']['service_multiplier'],
			'city' => 				$this->lang['formFields']['entityType_']['city'],
			'station' => 			$this->lang['formFields']['entityType_']['station'],
			'offerFormOfPayment' => $this->lang['formFields']['entityType_']['offerFormOfPayment'],
			'offerFormOfCashing' => $this->lang['formFields']['entityType_']['offerFormOfCashing'],
			'serviceCancelReason' =>$this->lang['formFields']['entityType_']['serviceCancelReason'],
			'miceProject' => 		$this->lang['formFields']['entityType_']['miceProject'],
		]);
		$form->addElement($fld);

		// idEntityExtSys
		$fld = new \Engine\Form\Input\Text($this->lang['index']['filters']['idEntityExtSys'], 'filters[idEntityExtSys]', $fieldsValues['idEntityExtSys']);
		$fld->setMandatory(true);
		$form->addElement($fld);

		// idEntityTina Corporate
		$fld = new \App\Form\Input\Autocomplete_Corporate($this->lang['index']['filters']['idEntityTina']['corporate'], 'filters[idEntityTina][corporate]', $fieldsValues['idEntityTina']['corporate']);
		$form->addElement($fld);

		// idEntityTina Supplier
		$fld = new \App\Form\Input\Autocomplete_Supplier($this->lang['index']['filters']['idEntityTina']['supplier'], 'filters[idEntityTina][supplier]', $fieldsValues['idEntityTina']['supplier']);
		$form->addElement($fld);

		// idEntityTina User
		$fld = new \App\Form\Input\Autocomplete_User($this->lang['index']['filters']['idEntityTina']['user'], 'filters[idEntityTina][user]', $fieldsValues['idEntityTina']['user']);
		$form->addElement($fld);

		// idEntityTina Office
		$fld = new \App\Form\Input\Autocomplete_Office($this->lang['index']['filters']['idEntityTina']['office'], 'filters[idEntityTina][office]', $fieldsValues['idEntityTina']['office']);
		$form->addElement($fld);

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

}

