<?php
 namespace Modules\Documents\ImportedDocuments\SplitByInvoiceSign; class Controller extends \App\Mvc\Controller\Form\PopupAbstract { protected function initialize() { parent::initialize(); $this->actionsCfg['index'] = [ 'checkSection' => false, 'checkOption' => false ] ; } protected function getDefaultFormData($R) { return [ 'id' => $R['id'] ]; } protected function processFormData(Array $formData, \App\MessagesCollector $msgs) { try { \DB::startTransaction(); $docSplit = new Model($formData['id']); $docSplit->process(); \DB::commitTransaction(); $msgs->addSuccess($this->lang['index']['msgs']['saveOk']); } catch (\App\MessagesException $e) { \DB::rollbackTransaction(); $msgs->appendMessages($e->getMessagesCollector()); } catch (\App\Entity\Exception $e) { \DB::rollbackTransaction(); $msgs->appendMessages($e->getMessagesCollector()); } return !$msgs->hasErrorOrWarning(); } protected function preRenderOperations(\App\Mvc\ViewAbstract $view, array $formData) { $formData = $view->getInput('formData'); if ($formData['save']) { return ; } try { $model = new Model($formData['id']); $model->isAvailable(false); $formData['positiveInvoicesIds'] = $model->getPositiveInvoicesIds(); $formData['positiveInvoicesTotal'] = $model->getPositiveInvoicesTotal(); $formData['negativeInvoicesIds'] = $model->getNegativeInvoicesIds(); $formData['negativeInvoicesTotal'] = $model->getNegativeInvoicesTotal(); } catch (\App\MessagesException $e) { $view->getMessagesCollector()->appendMessages($e->getMessagesCollector()); } $view->addInput('formData', $formData); } } 