<?php
namespace Modules\Documents\BulkDownload; class View_Utils_FormAdmin extends \App\Mvc\View_Utils_FormAbstract { public function getForm() { $form = \Engine\Form\General::create(); $fs = \Engine\Form\Container\Fieldset::create($this->lang['index']['fieldSet']['label']); $form->addContainer($fs); $checkboxesDocTypes = new \Engine\Form\Input\Checkboxes($this->lang['index']['formFields']['docType'], 'docTypes', $this->values['docTypes']); $checkboxesDocTypes->setPossibleValues( $this->documentsList($this->values['ids'], $this->values['pivot']) ); $checkboxesDocTypes->setStyle('renderMode', 'block'); $fs->addElement($checkboxesDocTypes); $form->addElement(new \Engine\Form\Input\Hidden('', $this->submitButtonName, 1)); return $form; } private function documentsList($entityIds, $pivot) { if (in_array($pivot, ['service', 'cashing', 'cashBookDoc', 'importedDocument', 'payment'])) { $entityDocs = []; foreach ($entityIds as $idEntity) { switch ($pivot) { case 'service': $entityServiceCode = \Entity\Service::select($idEntity)->serviceCode; $entityDocs[] = \App\Config\IssueDocuments::getInstance()->getServiceDocsList($entityServiceCode); break; case 'cashing': $entityDocType = \Entity\InvoiceCashing::select($idEntity)->docTypeCode; $entityDocs[] = \App\Config\IssueDocuments::getInstance()->getCashingDocsList($entityDocType); break; case 'cashBookDoc': $entityDocType = \Entity\CashBookDocument::select($idEntity)->type; $entityDocs[] = \App\Config\IssueDocuments::getInstance()->getCashBookDocsList($entityDocType); break; case 'importedDocument': $entityDocType = \Entity\ImportedDocument::select($idEntity)->docType; $entityDocs[] = \App\Config\IssueDocuments::getInstance()->getImportedDocsList($entityDocType); break; case 'payment': $entityDocType = \Entity\SupplierInvoicePayment::select($idEntity)->docType; $entityDocs[] = \App\Config\IssueDocuments::getInstance()->getPaymentDocsList($entityDocType); break; } } $documentsList = call_user_func_array('array_merge', $entityDocs); } else { $documentsList = \App\Config\IssueDocuments::getInstance()->getDocsByPivot($pivot); } return $documentsList; } } 