Skip to content
Code-Schnipsel Gruppen Projekte
Commit fc1cff38 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'next-3.x' into 'main'

feat: new ErpCopyInterface and erp entity copy dialog

See merge request !115
Übergeordnete a0515296 1990eb21
No related branches found
Tags 1.12.1
2 Merge Requests!140Update 'next-4.x' with latest changes from 'main',!115feat: new ErpCopyInterface and erp entity copy dialog
Pipeline #8929 mit Warnungen bestanden mit Phasen
in 54 Sekunden
<?php
/**
* This file contains package_quiqqer_erp_ajax_copyEntity
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_erp_ajax_copyEntity',
function ($uuid, $processKeepStatus) {
$Instance = (new QUI\ERP\Processes())->getEntity($uuid);
if (!($Instance instanceof QUI\ERP\ErpCopyInterface)) {
throw new QUI\Exception('This entity can not be copied!');
}
if ($processKeepStatus === 'existing') {
$Copy = $Instance->copy(
null,
$Instance->getGlobalProcessId()
);
} else {
$Copy = $Instance->copy();
}
return $Copy->toArray();
},
['uuid', 'processKeepStatus'],
'Permission::checkAdminUser'
);
<?php
/**
* This file contains package_quiqqer_erp_ajax_getEntity
*/
QUI::$Ajax->registerFunction(
'package_quiqqer_erp_ajax_getEntity',
function ($uuid) {
$Instance = (new QUI\ERP\Processes())->getEntity($uuid);
return $Instance->toArray();
},
['uuid'],
'Permission::checkAdminUser'
);
/**
* Create a copy of an erp entity
*
* @module package/quiqqer/erp/bin/backend/controls/dialogs/CopyErpEntityDialog
* @author www.pcsg.de (Henning)
*
* @event onSuccess [self, newCopy] - Fires if a copy has been successfully created
* @event onError [self] - Fires if an error occurs during copy creation
*/
define('package/quiqqer/erp/bin/backend/controls/dialogs/CopyErpEntityDialog', [
'qui/controls/windows/Confirm',
'Ajax',
'Locale'
], function(QUIConfirm, QUIAjax, QUILocale) {
'use strict';
const lg = 'quiqqer/erp';
return new Class({
Extends: QUIConfirm,
type: 'package/quiqqer/erp/bin/backend/controls/dialogs/CopyErpEntityDialog',
Binds: [
'$onOpen',
'$onSubmit'
],
options: {
hash: false,
maxHeight: 400,
maxWidth: 700,
icon: 'fa fa-copy',
texticon: 'fa fa-copy',
text: QUILocale.get(lg, 'controls.elements.copyDialog.text'),
autoclose: false,
ok_button: {
text: QUILocale.get(lg, 'controls.elements.copyDialog.ok_btn'),
textimage: 'fa fa-copy'
}
},
initialize: function(options) {
this.parent(options);
this.$CopyHistoryCheckbox = null;
this.addEvents({
onOpen: this.$onOpen,
onSubmit: this.$onSubmit
});
},
getData: function() {
return new Promise((resolve, reject) => {
QUIAjax.get('package_quiqqer_erp_ajax_getEntity', resolve, {
'package': 'quiqqer/erp',
uuid: this.getAttribute('hash'),
onError: reject
});
});
},
/**
* event: on open
*/
$onOpen: function() {
this.Loader.show();
this.getData().then((erpEntity) => {
this.setAttributes({
title: QUILocale.get(lg, 'controls.elements.copyDialog.title', {
prefixedNumber: erpEntity.prefixedNumber
})
});
this.getContent().getElement('.text').innerHTML = QUILocale.get(
lg,
'controls.elements.copyDialog.text',
{prefixedNumber: erpEntity.prefixedNumber}
);
this.getContent().getElement('.information').innerHTML = QUILocale.get(
lg,
'controls.elements.copyDialog.information',
{prefixedNumber: erpEntity.prefixedNumber}
);
this.refresh();
new Element('label', {
styles: {
display: 'block',
minWidth: 500,
width: '80%'
},
html: '' +
'<span class="quiqqer-contracts-dialog-copy-option-title">' +
QUILocale.get(lg, 'controls.elements.copyDialog.option.title') +
'</span>' +
'<span class="quiqqer-contracts-dialog-copy-option-info" style="display: none">' +
QUILocale.get(lg, 'controls.elements.copyDialog.option.info') +
'</span>' +
'<select name="copy-option" required style="width: 100%; margin-top: 10px">' +
' <option value=""></option>' +
' <option value="new">' +
'' + QUILocale.get(lg, 'controls.elements.copyDialog.option.new') +
' </option>' +
' <option value="existing">' +
'' + QUILocale.get(lg, 'controls.elements.copyDialog.option.existing') +
' </option>' +
'</select>'
}).inject(this.getContent().getElement('.information'));
this.Loader.hide();
this.getContent().getElement('[name="copy-option"]').focus();
});
},
/**
* event: on submit
*/
$onSubmit: function() {
const Copy = this.getContent().getElement('[name="copy-option"]');
if ('reportValidity' in Copy) {
Copy.reportValidity();
if ('checkValidity' in Copy) {
if (Copy.checkValidity() === false) {
return;
}
}
}
// no html5 support
if (Copy.value === '') {
return;
}
this.Loader.show();
QUIAjax.post('package_quiqqer_erp_ajax_copyEntity', (newCopy) => {
this.close();
this.fireEvent('success', [this, newCopy]);
require([
'package/quiqqer/erp/bin/backend/utils/ERPEntities'
], function(ErpUtils) {
ErpUtils.openPanelByUUID(newCopy.hash);
});
}, {
'package': 'quiqqer/erp',
uuid: this.getAttribute('hash'),
processKeepStatus: Copy.value,
onError: () => {
this.fireEvent('error', [self]);
this.Loader.hide();
}
});
}
});
});
\ No newline at end of file
......@@ -7,11 +7,12 @@ define('package/quiqqer/erp/bin/backend/controls/process/ProcessGrid', [
'qui/controls/Control',
'qui/controls/buttons/Button',
'qui/controls/loader/Loader',
'package/quiqqer/erp/bin/backend/utils/ERPEntities',
'controls/grid/Grid',
'Locale',
'Ajax'
], function(QUI, QUIControl, QUIButton, QUILoader, Grid, QUILocale, QUIAjax) {
], function(QUI, QUIControl, QUIButton, QUILoader, ERPEntityUtils, Grid, QUILocale, QUIAjax) {
'use strict';
const lg = 'quiqqer/erp';
......@@ -182,38 +183,8 @@ define('package/quiqqer/erp/bin/backend/controls/process/ProcessGrid', [
},
$click: function(Btn) {
let panel;
const uuid = Btn.getAttribute('uuid');
switch (Btn.getAttribute('entityType')) {
case 'QUI\\ERP\\Order\\Order':
panel = 'package/quiqqer/order/bin/backend/controls/panels/Order';
break;
case 'QUI\\ERP\\Accounting\\Invoice\\Invoice':
panel = 'package/quiqqer/invoice/bin/backend/controls/panels/Invoice';
break;
case 'QUI\\ERP\\Accounting\\Invoice\\InvoiceTemporary':
panel = 'package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice';
break;
case 'QUI\\ERP\\SalesOrders\\SalesOrder':
panel = 'package/quiqqer/salesorders/bin/js/backend/controls/panels/SalesOrder';
break;
case 'QUI\\ERP\\Accounting\\Offers\\Offer':
panel = 'package/quiqqer/offers/bin/js/backend/controls/panels/Offer';
break;
case 'QUI\\ERP\\Accounting\\Offers\\OfferTemporary':
panel = 'package/quiqqer/offers/bin/js/backend/controls/panels/TemporaryOffer';
break;
default:
console.error('missing', uuid, Btn.getAttribute('entityType'));
return;
}
const panel = ERPEntityUtils.getPanelByEntity(Btn.getAttribute('entityType'));
require(['utils/Panels', panel], (PanelUtils, Panel) => {
PanelUtils.openPanelInTasks(
......
......@@ -27,6 +27,15 @@ define('package/quiqqer/erp/bin/backend/utils/ERPEntities', function() {
case 'QUI\\ERP\\SalesOrders\\SalesOrder':
return 'package/quiqqer/salesorders/bin/js/backend/controls/panels/SalesOrder';
case 'QUI\\ERP\\Accounting\\Offers\\Offer':
return 'package/quiqqer/offers/bin/js/backend/controls/panels/Offer';
case 'QUI\\ERP\\Accounting\\Offers\\OfferTemporary':
return 'package/quiqqer/offers/bin/js/backend/controls/panels/TemporaryOffer';
case 'QUI\\ERP\\Accounting\\Contracts\\Contract':
return 'package/quiqqer/contracts/bin/backend/controls/panels/Contract';
default:
console.error('missing', entityType);
}
......
......@@ -1635,5 +1635,65 @@ Allowed characters: Letters, numbers and _ ä ö ü ß]]></en>
<en><![CDATA[Process history]]></en>
</locale>
<locale name="controls.elements.copyDialog.title">
<de><![CDATA[[prefixedNumber] kopieren]]></de>
<en><![CDATA[Copy [prefixedNumber]]]></en>
</locale>
<locale name="controls.elements.copyDialog.text">
<de><![CDATA[Soll eine Kopie von [prefixedNumber] erstellt werden?]]></de>
<en><![CDATA[Should a copy of [prefixedNumber] be made?]]></en>
</locale>
<locale name="controls.elements.copyDialog.information" html="true">
<de>
<![CDATA[Es wird eine Kopie mit den Daten von <b>[prefixedNumber]</b> erstellt.]]></de>
<en><![CDATA[A new copy will be created with the data of <b>[prefixedNumber]</b>.]]></en>
</locale>
<locale name="controls.elements.copyDialog.ok_btn">
<de><![CDATA[Kopie erstellen]]></de>
<en><![CDATA[Create copy]]></en>
</locale>
<locale name="controls.elements.copyDialog.option.title">
<de><![CDATA[Bitte wähle hierzu eine der folgenden Optionen, wie die Daten kopiert werden sollen:]]></de>
<en><![CDATA[Please select one of the following options for how the data should be copied:]]></en>
</locale>
<locale name="controls.elements.copyDialog.option.info" html="true">
<de><![CDATA[
<ul>
<li>
Als neuen Vorgang kopieren: Diese Option kopiert alle Daten der Entität, jedoch ohne die Prozess-ID.
Die kopierte Entität wird somit nicht dem aktuellen Prozess zugeordnet und kann als unabhängiger Vorgang bearbeitet werden.
</li>
<li>
In vorhandenen Vorgang kopieren: Bei dieser Option werden ebenfalls alle Daten der Entität kopiert,
jedoch bleibt die Verbindung zum aktuellen Prozess erhalten. Dies ermöglicht es,
die Daten innerhalb desselben Prozesses zu duplizieren, ohne neue Prozess-IDs zu erstellen.
</li>
</ul>
]]></de>
<en><![CDATA[
<ul>
<li>
Copy as new process: Diese Option kopiert alle Daten der Entität, jedoch ohne die Prozess-ID.
The copied entity is therefore not assigned to the current process and can be edited as an independent process.
</li>
<li>
Copy to existing process: With this option, all of the entity's data is also copied,
but the connection to the current process is retained.
This makes it possible to duplicate the data within the same process without creating new process IDs.
</li>
</ul>
]]></en>
</locale>
<locale name="controls.elements.copyDialog.option.new">
<de><![CDATA[Als neuen Vorgang kopieren]]></de>
<en><![CDATA[Copy as new process]]></en>
</locale>
<locale name="controls.elements.copyDialog.option.existing">
<de><![CDATA[In vorhandenen Vorgang kopieren]]></de>
<en><![CDATA[Copy to existing process]]></en>
</locale>
</groups>
</locales>
<?php
namespace QUI\ERP;
use QUI\Interfaces\Users\User;
/**
* The ErpCopyInterface
*
* When a class implements this interface, it signals that instances of this class have the ability to duplicate its data.
* This is particularly useful for handling ERP entities that often need to be reused or replicated
* in different contexts within the same system.
*/
interface ErpCopyInterface
{
public function copy(
User $PermissionUser = null,
bool|string $globalProcessId = false
): ErpEntityInterface;
}
......@@ -4,6 +4,14 @@
use QUI\ERP\Accounting\Payments\Transactions\Transaction;
/**
* The ErpTransactionsInterface is a PHP interface that specifies
* that an ERP entity is able to receive and process transactions.
*
* The implementation of this interface in a class indicates that the instances
* of this class are suitable for transactions, which is typically required for financial
* and accounting processes within the ERP system.
*/
interface ErpTransactionsInterface
{
public function linkTransaction(Transaction $Transaction): void;
......
......@@ -47,6 +47,7 @@ public function getEntity($entityHash): ErpEntityInterface
//'quiqqer/contracts',
try {
return QUI\ERP\Accounting\Contracts\Handler::getInstance()->get($entityHash);
} catch (\Exception) {
}
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren