<?php
namespace Modules\Admin\Config\ImportedOrders\EntitiesMatch; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $form=\Engine\Form\General::create(); $form->setStyle('width', '250'); $form->setStyle('labelWidth', '35'); $form->addContainer(\Engine\Form\Container\Fieldset::create()); $fld = new \Engine\Form\Input\Select($this->lang['formFields']['entityType'], 'entityType', $this->values['entityType']); $fld->setMandatory(true); if ($this->controller->getAction() == 'update') { $fld->setDisabled(); $entityTypeHidden = new \Engine\Form\Input\Hidden(null, 'entityType', $this->values['entityType']); $form->addElement($entityTypeHidden); } $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'], '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'], 'agencyCostCenter' => $this->lang['formFields']['entityType_']['agencyCostCenter'], ]); $fld->onChange("
				$(this).up('form').down('input[name={$this->submitButtonName}]').value='';
				/* remove the idEntityTina td content, to avoid resubmitting data with different format than expected (autocompletes send a 2-key array for example, text fields send a single value) */
				$('idEntityTina').up('td').update('');
				$(this).up('form').submit();
		"); $form->addElement($fld); $fld = new \App\Form\Input\Select_OrdersExternalSystem($this->lang['formFields']['idSystem'], 'idSystem', $this->values['idSystem']); $fld->showDefaultOption(true); $fld->setMandatory(true); $form->addElement($fld); $fld = new \Engine\Form\Input\Text($this->lang['formFields']['idEntityExtSys'], 'idEntityExtSys', $this->values['idEntityExtSys']); $fld->setMandatory(true); $form->addElement($fld); switch ($this->values['entityType']) { case 'user': $fld = new \App\Form\Input\Autocomplete_User($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'office': $fld = new \App\Form\Input\Autocomplete_Office($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'customer': $fld = new \App\Form\Input\Autocomplete_Customer($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'customer_type': $fld = new \App\Form\Input\Select_CustomerType($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); $fld->showDefaultOption(); break; case 'customer_title': $fld = new \App\Form\Input\Select_CustomerTitle($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); $fld->showDefaultOption(); break; case 'corporate': $fld = new \App\Form\Input\Autocomplete_Corporate($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'supplier': $fld = new \App\Form\Input\Autocomplete_Supplier($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'supplierProduct': $fld = new \App\Form\Input\Autocomplete_SupplierProduct($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'city': $fld = new \App\Form\Input\Autocomplete_City($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'station': $fld = new \App\Form\Input\Autocomplete_Station($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'offerFormOfPayment': $fld = new \App\Form\Input\Select_OfferFormOfPayment($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); $fld->showDefaultOption(); break; case 'offerFormOfCashing': $fld = new \App\Form\Input\Select_OfferFormOfCashing($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); $fld->showDefaultOption(); break; case 'serviceCancelReason': $fld = new \Engine\Form\Input\Text($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); break; case 'miceProject': $fld = new \App\Form\Input\Autocomplete_MiceProject($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']['id']); break; case 'agencyCostCenter': $fld = new \App\Form\Input\Select_AgencyCostCenter($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); break; default: $fld = new \Engine\Form\Input\Text($this->lang['formFields']['idEntityTina'], 'idEntityTina', $this->values['idEntityTina']); } $fld->setMandatory(true); $form->addElement($fld); $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); return $form; } }