<?php
 namespace Modules\Orders\OrderForm\ServiceExtraInfo; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $serviceCode = null; $orderFormHandler = \Modules\Orders\OrderForm\Model_Handler::getInstance(); $offersDetails = $orderFormHandler->getServiceOffers($this->values['id']); if ($offersDetails['list']) { $offerEnt = $offersDetails['list'][$offersDetails['chosenOfferIndex']]; $serviceCode = $offerEnt->getField('serviceCode'); } $serviceEnt = $orderFormHandler->getServiceByIndex($this->values['id']); $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $offCfg = \App\Config\Services_OfferFields::getInstance()->get($serviceCode); $form = \Engine\Form\General::create(); if ($offCfg['formOfPayment']!='invisible') { $fieldsetFop = \Engine\Form\Container\Fieldset::create($this->lang['index']['form']['fopLegend']); $form->addContainer($fieldsetFop); $fopFld = new \App\Form\Input\Select_OfferFormOfPayment($this->lang['index']['form']['fop'], "formOfPayment", $this->values['formOfPayment']); $fopFld->showDefaultOption(); if ($offCfg['formOfPayment']=='mandatory') { $fopFld->setMandatory(); } $fieldsetFop->addElement($fopFld); $fopCcTypeFld = new \App\Form\Input\Select_CreditCards($this->lang['index']['form']['fopCcType'], "formOfPaymentCcType", $this->values['formOfPaymentCcType']); $fopCcTypeFld->addAgencyCards(true); $fopCcTypeFld->addCorporatesCards($orderFormHandler->getCorporates()); $fopCcTypeFld->addCustomersCards($serviceEnt->getField('idCustomers')); list($fopCcEntType, $fopCcEntId) = explode('_', (string)$this->values['formOfPaymentCcType']); if ($fopCcEntType=='manual' and $fopCcEntId) { $fopCcTypeFld->addManualCards( [ $fopCcEntId ] ); } $fopCcTypeFld->addNewCard(true); $fopCcTypeFld->showDefaultOption(); $fieldsetFop->addElement($fopCcTypeFld); $fopCcDetFld = new \App\Form\Input\CreditCardDetails($this->lang['index']['form']['fopCcDet'], "formOfPaymentCcDet", $this->values['formOfPaymentCcDet']); $fieldsetFop->addElement($fopCcDetFld); $fopCcTypeFld->setControlledElements( [ 'new'=>[$fopCcDetFld] ], 'disable' ); $fopCcApprFld = new \Engine\Form\Input\Text($this->lang['index']['form']['fopCcAppr'], "formOfPaymentCcApprovalCode", $this->values['formOfPaymentCcApprovalCode']); $fieldsetFop->addElement($fopCcApprFld); $fopCcValFld = new \App\Form\Input\Price($this->lang['index']['form']['fopCcVal'], "formOfPaymentCcPay", $this->values['formOfPaymentCcPay']); $fieldsetFop->addElement($fopCcValFld); $ctrlElem = []; foreach ($CFG['offers']['formOfPaymentWithCardDetails'] as $fopNeedsCc) { $ctrlElem[$fopNeedsCc] = [$fopCcTypeFld, $fopCcDetFld, $fopCcApprFld, $fopCcValFld]; } $fopFld->setControlledElements( $ctrlElem ); } if ($offCfg['formOfCashing']!='invisible') { $fieldsetFoc = \Engine\Form\Container\Fieldset::create($this->lang['index']['form']['focLegend']); $form->addContainer($fieldsetFoc); $focFld = new \App\Form\Input\Select_OfferFormOfCashing($this->lang['index']['form']['foc'], "formOfCashing", $this->values['formOfCashing']); $focFld->showDefaultOption(); if ($offCfg['formOfCashing']=='mandatory') { $focFld->setMandatory(); } $fieldsetFoc->addElement($focFld); $focCcTypeFld = new \App\Form\Input\Select_CreditCards($this->lang['index']['form']['focCcType'], "formOfCashingCcType", $this->values['formOfCashingCcType']); $focCcTypeFld->addCorporatesCards($orderFormHandler->getCorporates()); $focCcTypeFld->addCustomersCards($serviceEnt->getField('idCustomers')); list($focCcEntType, $focCcEntId) = explode('_', (string)$this->values['formOfCashingCcType']); if ($focCcEntType=='manual' and $focCcEntId) { $focCcTypeFld->addManualCards( [ $focCcEntId ] ); } $focCcTypeFld->addNewCard(true); $focCcTypeFld->showDefaultOption(); $fieldsetFoc->addElement($focCcTypeFld); $focCcDetFld = new \App\Form\Input\CreditCardDetails($this->lang['index']['form']['focCcDet'], "formOfCashingCcDet", $this->values['formOfCashingCcDet']); $fieldsetFoc->addElement($focCcDetFld); $focCcTypeFld->setControlledElements( [ 'new'=>[$focCcDetFld] ], 'disable' ); $focCcApprFld = new \Engine\Form\Input\Text($this->lang['index']['form']['focCcAppr'], "formOfCashingCcApprovalCode", $this->values['formOfCashingCcApprovalCode']); $fieldsetFoc->addElement($focCcApprFld); $ctrlElem = []; foreach ($CFG['offers']['formOfCashingWithCardDetails'] as $focNeedsCc) { $ctrlElem[$focNeedsCc] = [$focCcTypeFld, $focCcDetFld, $focCcApprFld]; } $focFld->setControlledElements( $ctrlElem ); } $form->addElement(\Engine\Form\Input\Hidden::create(null, $this->submitButtonName, 1)); return $form; } }