diff --git a/ajax/process/getProcess.php b/ajax/process/getProcess.php new file mode 100644 index 0000000000000000000000000000000000000000..7293dd74e772f6ac4ac26539817d3327b17225b2 --- /dev/null +++ b/ajax/process/getProcess.php @@ -0,0 +1,27 @@ +<?php + +/** + * This file contains package_quiqqer_erp_ajax_process_getProcess + */ + +use QUI\ERP\Process; +use QUI\ERP\Processes; + +QUI::$Ajax->registerFunction( + 'package_quiqqer_erp_ajax_process_getProcess', + function ($globalProcessId, $hash) { + if (!empty($hash) && empty($globalProcessId)) { + $Entity = (new Processes())->getEntity($hash); + $globalProcessId = $Entity->getGlobalProcessId(); + } + + $Process = new Process($globalProcessId); + + return [ + 'globalProcessId' => $Process->getUUID(), + 'history' => $Process->getCompleteHistory()->toArray() + ]; + }, + ['globalProcessId', 'hash'], + ['Permission::checkAdminUser'] +); diff --git a/bin/backend/controls/articles/Text.css b/bin/backend/controls/articles/Text.css index a9ea26da00ebd5e1e86aa5235602fed3036d83d3..5221c6b7ef2ed71231132fe93f8cef5df1303d4e 100644 --- a/bin/backend/controls/articles/Text.css +++ b/bin/backend/controls/articles/Text.css @@ -5,6 +5,7 @@ clear: both; display: flex; flex-direction: row; + flex-wrap: wrap; float: left; min-height: 50px; position: relative; @@ -63,26 +64,26 @@ text-align: center; } + + + .quiqqer-erp-backend-erpArticleText-buttons { - background: #fff; - bottom: 0; - opacity: 0; - padding: 10px; - position: absolute; - right: 0; - text-align: right; - transition: opacity 0.2s; - width: 75px; - z-index: 10; + background: #DEDEDE; + display: none; + width: 100%; } .quiqqer-erp-backend-erpArticleText-buttons button { - padding: 0 5px; + background: transparent; + border: none; + cursor: pointer; line-height: 20px; - margin-left: 5px; } -.quiqqer-erp-backend-erpArticleText:hover .quiqqer-erp-backend-erpArticleText-buttons { - opacity: 1; - transition: opacity 0.2s; +.quiqqer-erp-backend-erpArticle-select .quiqqer-erp-backend-erpArticleText-buttons { + display: inline-block; +} + +.quiqqer-erp-backend-erpArticleText-buttons button:hover { + background: #eaeaea; } diff --git a/bin/backend/controls/articles/Text.html b/bin/backend/controls/articles/Text.html index b88b7a2cd97951785d1cea3944806d872a927b7a..74fe100b37cb41d1a4e97989ebef48923c1de87a 100644 --- a/bin/backend/controls/articles/Text.html +++ b/bin/backend/controls/articles/Text.html @@ -1,3 +1,13 @@ <div class="quiqqer-erp-backend-erpArticleText-pos cell"></div> <div class="quiqqer-erp-backend-erpArticleText-text cell"></div> -<div class="quiqqer-erp-backend-erpArticleText-buttons"></div> + +<div class="quiqqer-erp-backend-erpArticleText-buttons"> + <button name="replace"> + <span class="fa fa-retweet"></span> + <span>{{buttonReplace}}</span> + </button> + <button name="delete"> + <span class="fa fa-trash"></span> + <span>{{buttonDelete}}</span> + </button> +</div> \ No newline at end of file diff --git a/bin/backend/controls/articles/Text.js b/bin/backend/controls/articles/Text.js index 2303928de7459fc51530cc2f9de29d87ab790bf4..408ad51d4b00d4537ac0b8cf2a638243c4ee276e 100644 --- a/bin/backend/controls/articles/Text.js +++ b/bin/backend/controls/articles/Text.js @@ -16,22 +16,22 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ 'text!package/quiqqer/erp/bin/backend/controls/articles/Text.html', 'css!package/quiqqer/erp/bin/backend/controls/articles/Text.css' -], function (Article, QUIButton, QUILocale, Mustache, template) { - "use strict"; +], function(Article, QUIButton, QUILocale, Mustache, template) { + 'use strict'; const lg = 'quiqqer/erp'; return new Class({ Extends: Article, - Type : 'package/quiqqer/erp/bin/backend/controls/articles/Text', + Type: 'package/quiqqer/erp/bin/backend/controls/articles/Text', Binds: [ '$onEditTitle', '$onEditDescription' ], - initialize: function (options) { + initialize: function(options) { this.parent(options); this.setAttributes({ @@ -44,13 +44,16 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ * * @returns {HTMLDivElement} */ - create: function () { + create: function() { this.$Elm = new Element('div'); this.$Elm.addClass('quiqqer-erp-backend-erpArticleText'); this.$Elm.set({ - html : Mustache.render(template), + html: Mustache.render(template, { + buttonReplace: QUILocale.get(lg, 'articleList.article.button.replace'), + buttonDelete: QUILocale.get(lg, 'articleList.article.button.delete') + }), events: { click: this.select } @@ -61,15 +64,15 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ this.$Buttons = this.$Elm.getElement('.quiqqer-erp-backend-erpArticleText-buttons'); this.$Loader = new Element('div', { - html : '<span class="fa fa-spinner fa-spin"></span>', + html: '<span class="fa fa-spinner fa-spin"></span>', styles: { background: '#fff', - display : 'none', - left : 0, - padding : 10, - position : 'absolute', - top : 0, - width : '100%' + display: 'none', + left: 0, + padding: 10, + position: 'absolute', + top: 0, + width: '100%' } }).inject(this.$Position); @@ -94,28 +97,8 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ this.setTitle(this.getAttribute('title')); this.setDescription(this.getAttribute('description')); - // edit buttons - new QUIButton({ - title : QUILocale.get(lg, 'erp.articleList.article.button.replace'), - icon : 'fa fa-retweet', - styles: { - 'float': 'none' - }, - events: { - onClick: this.$onReplaceClick - } - }).inject(this.$Buttons); - - new QUIButton({ - title : QUILocale.get(lg, 'erp.articleList.article.button.delete'), - icon : 'fa fa-trash', - styles: { - 'float': 'none' - }, - events: { - onClick: this.openDeleteDialog - } - }).inject(this.$Buttons); + this.$Buttons.getElement('[name="replace"]').addEvent('click', this.$onReplaceClick); + this.$Buttons.getElement('[name="delete"]').addEvent('click', this.openDeleteDialog); this.$created = true; @@ -128,7 +111,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ * * @return {Promise} */ - calc: function () { + calc: function() { return Promise.resolve(); }, @@ -137,7 +120,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ * * @param {String} title */ - setTitle: function (title) { + setTitle: function(title) { this.setAttribute('title', title); this.$Title.set('html', title); @@ -151,7 +134,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ * * @param {String} description */ - setDescription: function (description) { + setDescription: function(description) { this.setAttribute('description', description); this.$Description.set('html', description); @@ -165,7 +148,7 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ * * @return {Promise} */ - setQuantity: function () { + setQuantity: function() { return Promise.resolve(); }, @@ -173,28 +156,28 @@ define('package/quiqqer/erp/bin/backend/controls/articles/Text', [ * Set the product unit price * */ - setUnitPrice: function () { + setUnitPrice: function() { return Promise.resolve(); }, /** * Set the product unit price **/ - setVat: function () { + setVat: function() { return Promise.resolve(); }, /** * Show the loader */ - showLoader: function () { + showLoader: function() { this.$Loader.setStyle('display', null); }, /** * Hide the loader */ - hideLoader: function () { + hideLoader: function() { this.$Loader.setStyle('display', 'none'); } }); diff --git a/bin/backend/controls/process/ProcessGrid.js b/bin/backend/controls/process/ProcessGrid.js index 0487e5345d44b815309dbe4e76dee0364412ef53..65b2d196f9b42a69cfffd28bb5ef418e90b5be19 100644 --- a/bin/backend/controls/process/ProcessGrid.js +++ b/bin/backend/controls/process/ProcessGrid.js @@ -28,7 +28,8 @@ define('package/quiqqer/erp/bin/backend/controls/process/ProcessGrid', [ options: { globalProcessId: false, - entityHash: false + entityHash: false, + hideUuids: [] }, initialize: function(options) { @@ -95,9 +96,13 @@ define('package/quiqqer/erp/bin/backend/controls/process/ProcessGrid', [ QUIAjax.get('package_quiqqer_erp_ajax_process_getEntities', (result) => { const data = []; - console.log(result); + const hideUuids = this.getAttribute('hideUuids') || []; result.forEach((entry) => { + if (hideUuids.indexOf(entry.uuid) !== -1) { + return; + } + const Type = new QUIButton({ events: { click: this.$click diff --git a/bin/backend/controls/process/ProcessWindow.css b/bin/backend/controls/process/ProcessWindow.css new file mode 100644 index 0000000000000000000000000000000000000000..f409ee31ea3f287d3bbad7d4c57d4379278345bb --- /dev/null +++ b/bin/backend/controls/process/ProcessWindow.css @@ -0,0 +1,18 @@ +.quiqqer-erp-process-window-header { + background: #f7f7f7; + display: inline-block; + padding: 20px; + width: 100%; +} + +.quiqqer-erp-process-window { + display: flex; + flex-direction: column; +} + +.quiqqer-erp-process-window-comments { + overflow: auto; + flex-shrink: 0; + flex-grow: 1; + height: 200px; +} \ No newline at end of file diff --git a/bin/backend/controls/process/ProcessWindow.js b/bin/backend/controls/process/ProcessWindow.js new file mode 100644 index 0000000000000000000000000000000000000000..eb46d85d385fc046ed7d1ffe00b55a3812ca6b34 --- /dev/null +++ b/bin/backend/controls/process/ProcessWindow.js @@ -0,0 +1,123 @@ +/** + * @module package/quiqqer/erp/bin/backend/controls/process/ProcessWindow + * @author www.pcsg.de (Henning Leutz) + */ +define('package/quiqqer/erp/bin/backend/controls/process/ProcessWindow', [ + + 'qui/QUI', + 'qui/controls/windows/Popup', + 'Locale', + 'Ajax', + + 'css!package/quiqqer/erp/bin/backend/controls/process/ProcessWindow.css' + +], function(QUI, QUIPopup, QUILocale, QUIAjax) { + 'use strict'; + + const lg = 'quiqqer/erp'; + + return new Class({ + + Extends: QUIPopup, + Type: 'package/quiqqer/erp/bin/backend/controls/process/ProcessWindow', + + Binds: [ + '$onCreate', + '$onOpen' + ], + + options: { + globalProcessId: false, + hash: false, + buttons: false + }, + + initialize: function(options) { + this.setAttributes({ + icon: 'fa fa-timeline', + title: '', + maxHeight: 900, + maxWidth: 750, + }); + + this.parent(options); + + this.$Comments = null; + + this.addEvents({ + onCreate: this.$onCreate, + onOpen: this.$onOpen + }); + }, + + $onCreate: function() { + if (!this.getAttribute('globalProcessId') && !this.getAttribute('hash')) { + this.close(); + return; + } + + this.Loader.show(); + this.refresh(); + + this.getContent().setStyle('padding', 0); + this.getContent().addClass('quiqqer-erp-process-window'); + + new Element('div', { + 'class': 'quiqqer-erp-process-window-header', + html: '<div class="quiqqer-erp-process-window-header-filter">' + + ' <input type="text" name="filter" placeholder="Filter (Nachricht, Type, ID) ...">' + + ' </div>' + }).inject(this.getContent()); + + require(['package/quiqqer/erp/bin/backend/controls/Comments'], (Comments) => { + const CommentContainer = new Element('div', { + 'class': 'quiqqer-erp-process-window-comments', + styles: { + padding: 20 + } + }).inject(this.getContent()); + + const Filter = this.getContent().getElement('[name="filter"]'); + this.$Comments = new Comments().inject(CommentContainer); + + Filter.addEvent('keyup', () => { + this.$Comments.filter(Filter.value); + }); + + this.$onOpen(); + }); + }, + + $onOpen: function() { + if (!this.getAttribute('globalProcessId') && !this.getAttribute('hash')) { + this.close(); + return; + } + + if (!this.$Comments) { + return; + } + + this.Loader.show(); + + QUIAjax.get('package_quiqqer_erp_ajax_process_getProcess', (result) => { + this.setAttributes({ + icon: 'fa fa-timeline', + title: QUILocale.get(lg, 'panel.globalProcess.title', { + globalProcessId: result.globalProcessId + }) + }); + + this.refresh(); + + this.$Comments.clear(); + this.$Comments.unserialize(result.history); + this.Loader.hide(); + }, { + 'package': 'quiqqer/erp', + globalProcessId: this.getAttribute('globalProcessId'), + hash: this.getAttribute('hash'), + }); + } + }); +}); diff --git a/bin/backend/controls/process/ProcessWindowButton.js b/bin/backend/controls/process/ProcessWindowButton.js new file mode 100644 index 0000000000000000000000000000000000000000..f8df0f26dca3b15afd871ba36dfd4fb14f5b8ff5 --- /dev/null +++ b/bin/backend/controls/process/ProcessWindowButton.js @@ -0,0 +1,54 @@ +/** + * Button which opens the window for the process + */ +define('package/quiqqer/erp/bin/backend/controls/process/ProcessWindowButton', [ + + 'qui/QUI', + 'qui/controls/buttons/Button', + 'package/quiqqer/erp/bin/backend/controls/process/ProcessWindow', + 'Locale' + +], function(QUI, QUIButton, ProcessWindow, QUILocale) { + 'use strict'; + + const lg = 'quiqqer/erp'; + + return new Class({ + + Extends: QUIButton, + Type: 'package/quiqqer/erp/bin/backend/controls/process/ProcessWindowButton', + + options: { + globalProcessId: false, + hash: false + }, + + initialize: function(options) { + this.setAttributes({ + styles: { + 'border-left-width': 1, + 'border-right-width': 1, + 'float': 'right', + width: 40 + } + }); + + this.parent(options); + + this.setAttributes({ + icon: 'fa fa-timeline', + alt: QUILocale.get(lg, 'process.button.alt'), + title: QUILocale.get(lg, 'process.button.title') + }); + + this.addEvents({ + click: () => { + new ProcessWindow({ + globalProcessId: this.getAttribute('globalProcessId'), + hash: this.getAttribute('hash') + }).open(); + } + }); + } + }); +}); diff --git a/src/QUI/ERP/Process.php b/src/QUI/ERP/Process.php index 8c4a3240f544a41347320f39033347aee8e5c532..7d3d786458804f8d3332f66f60ef1ed88274f17f 100644 --- a/src/QUI/ERP/Process.php +++ b/src/QUI/ERP/Process.php @@ -60,6 +60,11 @@ protected function table(): string return QUI::getDBTableName('process'); } + public function getUUID(): string + { + return $this->processId; + } + /** * Return all entities which are connected to this process *