From 260c74a6a49f8a0beb673e3cff27dd7a1f45384e Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Tue, 6 Aug 2024 15:40:28 +0200 Subject: [PATCH] fix: output printing - with entity plugin param --- ajax/output/getEntityData.php | 10 +++++++--- bin/backend/controls/OutputDialog.js | 10 +++++++++- src/QUI/ERP/Processes.php | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ajax/output/getEntityData.php b/ajax/output/getEntityData.php index f529563..f67ad9d 100644 --- a/ajax/output/getEntityData.php +++ b/ajax/output/getEntityData.php @@ -13,13 +13,17 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_erp_ajax_output_getEntityData', - function ($entityId, $entityType) { + function ($entityId, $entityType, $entityPlugin) { $OutputProvider = ERPOutput::getOutputProviderByEntityType(Orthos::clear($entityType)); if (empty($OutputProvider)) { return false; } + if (empty($entityPlugin)) { + $entityPlugin = false; + } + $hideSystemDefaultTemplate = false; try { @@ -38,7 +42,7 @@ function ($entityId, $entityType) { } $Processes = new QUI\ERP\Processes(); - $Entity = $Processes->getEntity($entityId); + $Entity = $Processes->getEntity($entityId, $entityPlugin); return [ 'email' => $OutputProvider::getEmailAddress(Orthos::clear($entityId)), @@ -47,6 +51,6 @@ function ($entityId, $entityType) { 'prefixedNumber' => $Entity->getPrefixedNumber() ]; }, - ['entityId', 'entityType'], + ['entityId', 'entityType', 'entityPlugin'], 'Permission::checkAdminUser' ); diff --git a/bin/backend/controls/OutputDialog.js b/bin/backend/controls/OutputDialog.js index 9e5af3e..92885ed 100644 --- a/bin/backend/controls/OutputDialog.js +++ b/bin/backend/controls/OutputDialog.js @@ -48,6 +48,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ options: { entityId: false, // Clean entity ID WITHOUT prefix and suffix entityType: false, // Entity type (e.g. "Invoice") + entityPlugin: false, comments: false, // Comments as array [must be readble by package/quiqqer/erp/bin/backend/controls/Comments] @@ -161,6 +162,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ new OutputMailEditor({ entityId: self.getAttribute('entityId'), entityType: self.getAttribute('entityType'), + entityPlugin: self.getAttribute('entityPlugin'), mailSubject: self.$Mail.subject, mailContent: self.$Mail.content, @@ -453,6 +455,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ src: URL_OPT_DIR + 'quiqqer/erp/bin/output/backend/print.php?' + Object.toQueryString({ id: entityId, t: self.getAttribute('entityType'), + ep: self.getAttribute('entityPlugin'), oid: self.getId(), tpl: self.$Template.id, tplpr: self.$Template.provider @@ -510,6 +513,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ src: URL_OPT_DIR + 'quiqqer/erp/bin/output/backend/download.php?' + Object.toQueryString({ id: entityId, t: self.getAttribute('entityType'), + ep: self.getAttribute('entityPlugin'), oid: self.getId(), tpl: self.$Template.id, tplpr: self.$Template.provider @@ -629,6 +633,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ 'package': 'quiqqer/erp', entityId: self.getAttribute('entityId'), entityType: self.getAttribute('entityType'), + entityPlugin: self.getAttribute('entityPlugin'), onError: reject }); }); @@ -646,6 +651,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ QUIAjax.get('package_quiqqer_erp_ajax_output_getTemplates', resolve, { 'package': 'quiqqer/erp', entityType: self.getAttribute('entityType'), + entityPlugin: self.getAttribute('entityPlugin'), onError: reject }); }); @@ -664,7 +670,8 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ 'package': 'quiqqer/erp', entity: JSON.encode({ id: self.getAttribute('entityId'), - type: self.getAttribute('entityType') + type: self.getAttribute('entityType'), + plugin: self.getAttribute('entityPlugin') }), template: JSON.encode(self.$Template), onError: reject @@ -686,6 +693,7 @@ define('package/quiqqer/erp/bin/backend/controls/OutputDialog', [ 'package': 'quiqqer/erp', entityId: self.getAttribute('entityId'), entityType: self.getAttribute('entityType'), + entityPlugin: self.getAttribute('entityPlugin'), template: self.$Template.id, templateProvider: self.$Template.provider, mailSubject: self.$Mail.subject, diff --git a/src/QUI/ERP/Processes.php b/src/QUI/ERP/Processes.php index 4ca0154..8d3196d 100644 --- a/src/QUI/ERP/Processes.php +++ b/src/QUI/ERP/Processes.php @@ -66,7 +66,7 @@ public function getEntity($entityHash, $entityPlugin = false): ErpEntityInterfac if ( ($entityPlugin === false || $entityPlugin === 'quiqqer/invoice') - && class_exists('QUI\ERP\Accounting\Invoice\Handle') + && class_exists('QUI\ERP\Accounting\Invoice\Handler') ) { try { return QUI\ERP\Accounting\Invoice\Handler::getInstance()->getInvoiceByHash($entityHash); -- GitLab