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

feat: #54 - comments for temporary invoices & invoices

Übergeordneter 91243873
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -14,7 +14,21 @@
'package_quiqqer_invoice_ajax_invoices_addComment',
function ($invoiceId, $comment) {
$Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
$Invoice = $Invoices->getInvoice($invoiceId);
$Invoice = null;
try {
$Invoice = $Invoices->getInvoice($invoiceId);
} catch (\Exception $Exception) {
QUI\System\Log::addDebug($Exception->getMessage());
}
if ($Invoice === null) {
try {
$Invoice = $Invoices->getTemporaryInvoice($invoiceId);
} catch (\Exception $Exception) {
QUI\System\Log::addDebug($Exception->getMessage());
}
}
$Invoice->addComment($comment);
},
......
......@@ -15,6 +15,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
'qui/utils/Form',
'controls/users/address/Select',
'package/quiqqer/invoice/bin/Invoices',
'package/quiqqer/erp/bin/backend/controls/Comments',
'package/quiqqer/invoice/bin/backend/controls/articles/Text',
'package/quiqqer/payments/bin/backend/Payments',
'utils/Lock',
......@@ -30,7 +31,7 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
'css!package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice.css'
], function (QUI, QUIPanel, QUIButton, QUIButtonMultiple, QUISeparator, QUIConfirm, QUIFormUtils,
AddressSelect, Invoices, TextArticle,
AddressSelect, Invoices, Comments, TextArticle,
Payments, Locker, QUILocale, Mustache, Users, Editors,
templateData, templatePost, templateMissing) {
"use strict";
......@@ -47,6 +48,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
'post',
'openData',
'openArticles',
'openComments',
'openAddCommentDialog',
'openVerification',
'$openCategory',
'$closeCategory',
......@@ -140,6 +143,32 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
this.parent();
},
/**
* Refresh the invoice data
*/
doRefresh: function () {
var self = this,
invoiceId = this.getAttribute('invoiceId');
return Invoices.getTemporaryInvoice(invoiceId).then(function (data) {
self.setAttributes(data);
if (data.articles.articles.length) {
self.$serializedList = {
articles: data.articles.articles
};
self.setAttribute('articles', data.articles.articles);
}
if (data.invoice_address) {
self.setAttribute('invoice_address', data.invoice_address);
}
self.refresh();
});
},
/**
* Saves the current data
*
......@@ -549,6 +578,51 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
});
},
/**
* open the comments
*
* @return {Promise<Promise>}
*/
openComments: function () {
var self = this;
this.Loader.show();
this.getCategory('comments').setActive();
return this.$closeCategory().then(function () {
self.refreshComments();
}).then(function () {
return self.$openCategory();
}).then(function () {
self.Loader.hide();
});
},
/**
* Refresh the comment display
*/
refreshComments: function () {
var Container = this.getContent().getElement('.container');
Container.set('html', '');
new QUIButton({
textimage: 'fa fa-comments',
text : QUILocale.get(lg, 'invoice.panel.comment.add'),
styles : {
'float' : 'right',
marginBottom: 10
},
events : {
onClick: this.openAddCommentDialog
}
}).inject(Container);
new Comments({
comments: this.getAttribute('comments')
}).inject(Container);
},
/**
* Open the verification category
*
......@@ -1073,6 +1147,15 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
}
});
this.addCategory({
name : 'comments',
icon : 'fa fa-comments',
text : QUILocale.get(lg, 'erp.panel.temporary.invoice.category.comments'),
events: {
onClick: this.openComments
}
});
this.addCategory({
name : 'verification',
icon : 'fa fa-check',
......@@ -1114,24 +1197,8 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
self.$getLockGroups()
);
}).then(function () {
return Invoices.getTemporaryInvoice(invoiceId);
}).then(function (data) {
self.setAttributes(data);
if (data.articles.articles.length) {
self.$serializedList = {
articles: data.articles.articles
};
self.setAttribute('articles', data.articles.articles);
}
if (data.invoice_address) {
self.setAttribute('invoice_address', data.invoice_address);
}
self.refresh();
return self.doRefresh();
}).then(function () {
return Invoices.getMissingAttributes(invoiceId);
}).then(function (missing) {
if (Object.getLength(missing)) {
......@@ -1394,6 +1461,70 @@ define('package/quiqqer/invoice/bin/backend/controls/panels/TemporaryInvoice', [
}
this.$ArticleSort.setNormal();
},
//region comments
/**
* Open the add dialog window
*/
openAddCommentDialog: function () {
var self = this;
new QUIConfirm({
title : QUILocale.get(lg, 'dialog.add.comment.title'),
icon : 'fa fa-edit',
maxHeight: 600,
maxWidth : 800,
events : {
onOpen: function (Win) {
Win.getContent().set('html', '');
Win.Loader.show();
require([
'Editors'
], function (Editors) {
Editors.getEditor(null).then(function (Editor) {
Win.$Editor = Editor;
Win.$Editor.addEvent('onLoaded', function () {
Win.$Editor.switchToWYSIWYG();
Win.$Editor.showToolbar();
Win.$Editor.setContent(self.getAttribute('content'));
Win.Loader.hide();
});
Win.$Editor.inject(Win.getContent());
Win.$Editor.setHeight(200);
});
});
},
onSubmit: function (Win) {
Win.Loader.show();
self.addComment(Win.$Editor.getContent()).then(function () {
return self.doRefresh();
}).then(function () {
Win.$Editor.destroy();
Win.close();
self.refreshComments();
});
}
}
}).open();
},
/**
* add a comment to the order
*
* @param {String} message
*/
addComment: function (message) {
return Invoices.addComment(this.getAttribute('invoiceId'), message);
}
//endregion
});
});
......@@ -714,6 +714,10 @@
<de><![CDATA[Zusätzlicher Rechnungstext]]></de>
<en><![CDATA[Additional invoice text]]></en>
</locale>
<locale name="erp.panel.temporary.invoice.category.comments">
<de><![CDATA[Kommentare]]></de>
<en><![CDATA[Comments]]></en>
</locale>
<locale name="erp.panel.temporary.invoice.deleteButton.title">
<de><![CDATA[Rechnung löschen]]></de>
<en><![CDATA[Delete Invoice]]></en>
......@@ -1139,6 +1143,11 @@
<en><![CDATA[Date]]></en>
</locale>
<locale name="dialog.add.comment.title">
<de><![CDATA[Kommentar hinzufügen]]></de>
<en><![CDATA[Add new comment]]></en>
</locale>
<locale name="exception.post.invoices.missing.attributes">
<de><![CDATA[Die Rechnungen können leider nicht gebucht werden, einige besitzen Fehler.]]></de>
<en><![CDATA[Unfortunately, the invoices cannot be posted, some have errors.]]></en>
......
......@@ -1320,6 +1320,11 @@ public function getComments()
*/
public function addComment($message)
{
$message = \strip_tags($message, '<div><span><pre><p><br><hr>
<ul><ol><li><dl><dt><dd><strong><em><b><i><u>
<img><table><tbody><td><tfoot><th><thead><tr>'
);
$this->Comments->addComment($message);
$this->save();
......@@ -1327,6 +1332,19 @@ public function addComment($message)
'quiqqerInvoiceTemporaryInvoiceAddComment',
[$this, $message]
);
$User = QUI::getUserBySession();
$this->addHistory(
QUI::getLocale()->get(
'quiqqer/invoice',
'history.message.addComment',
[
'username' => $User->getName(),
'uid' => $User->getId()
]
)
);
}
//endregion
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren