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

feat: Rechnungsstatus für Bestellungen

Übergeordneter 4b6d388a
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -5,7 +5,7 @@
*
* @require package/quiqqer/order/bin/backend/classes/ProcessingStatus
*/
define('package/quiqqer/order/bin/ProcessingStatus', [
define('package/quiqqer/order/bin/backend/ProcessingStatus', [
'package/quiqqer/order/bin/backend/classes/ProcessingStatus'
], function (ProcessingStatus) {
"use strict";
......
.quiqqer-order-processing-status-window table {
border: none;
}
.quiqqer-order-processing-status-window td {
padding: 8px 0;
}
.quiqqer-order-processing-status-window [type="color"] {
padding: 0;
height: 31px;
border: none;
}
.quiqqer-order-processing-status-color {
display: block;
left: -5px;
line-height: 27px;
padding: 0 0 0 5px;
position: relative;
width: calc(100% + 5px);
}
\ No newline at end of file
<form>
<table class="data-table data-table-flexbox">
<tbody>
<tr>
<td>
<label class="field-container">
<span class="field-container-item" title="">
Title
</span>
<input name="title" data-qui="controls/lang/InputMultiLang"/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item" title="">
Status Nr.
</span>
<input type="number" name="id" min="0" class="field-container-field"/>
</label>
</td>
</tr>
<tr>
<td>
<label class="field-container">
<span class="field-container-item" title="">
Farbe
</span>
<input type="color" name="color" class="field-container-field"/>
</label>
</td>
</tr>
</tbody>
</table>
</form>
\ No newline at end of file
/**
* @module package/quiqqer/order/bin/backend/controls/settings/ProcessingStatus
* @author www.pcsg.de (Henning Leutz)
*/
define('package/quiqqer/order/bin/backend/controls/settings/ProcessingStatus', [
'qui/QUI',
'qui/controls/Control',
'qui/controls/windows/Confirm',
'package/quiqqer/order/bin/backend/ProcessingStatus',
'controls/grid/Grid',
'Locale',
'Mustache',
'text!package/quiqqer/order/bin/backend/controls/settings/ProcessingStatus.html',
'css!package/quiqqer/order/bin/backend/controls/settings/ProcessingStatus.css'
], function (QUI, QUIControl, QUIConfirm, ProcessingStatus, Grid, QUILocale, Mustache, template) {
"use strict";
var lg = 'quiqqer/order';
return new Class({
Extends: QUIControl,
Type : 'package/quiqqer/order/bin/backend/controls/settings/ProcessingStatus',
Binds: [
'$onChange',
'$onImport',
'refresh',
'$refreshButtonStatus',
'openCreateDialog',
'openDeleteDialog',
'$onEditClick',
'$onDeleteClick'
],
initialize: function (options) {
this.parent(options);
this.$Elm = null;
this.$Input = null;
this.$Grid = null;
this.addEvents({
onImport: this.$onImport
});
},
/**
* Refresh
*/
refresh: function () {
var self = this;
ProcessingStatus.getList().then(function (result) {
for (var i = 0, len = result.data.length; i < len; i++) {
result.data[i].colorNode = new Element('span', {
html : result.data[i].color,
'class': 'quiqqer-order-processing-status-color',
styles : {
backgroundColor: result.data[i].color
}
});
}
self.$Grid.setData(result);
self.$refreshButtonStatus();
});
},
/**
* event: on import
*/
$onImport: function () {
this.$Input = this.getElm();
this.$Elm = new Element('div').wraps(this.$Input);
this.$Elm.setStyles({
width: '100%'
});
var Container = new Element('div', {
styles: {
height: 300,
width : '100%'
}
}).inject(this.$Elm);
this.$Grid = new Grid(Container, {
height : 300,
buttons : [{
name : 'add',
text : QUILocale.get('quiqqer/system', 'add'),
events: {
onClick: this.openCreateDialog
}
}, {
type: 'separator'
}, {
name : 'edit',
text : QUILocale.get('quiqqer/system', 'edit'),
disabled: true,
events : {
onClick: this.$onEditClick
}
}, {
name : 'delete',
text : QUILocale.get('quiqqer/system', 'remove'),
disabled: true,
events : {
onClick: this.$onDeleteClick
}
}],
columnModel: [{
header : QUILocale.get(lg, 'processingStatus.grid.id'),
dataIndex: 'id',
dataType : 'integer',
width : 60
}, {
header : QUILocale.get(lg, 'processingStatus.grid.color'),
dataIndex: 'colorNode',
dataType : 'node',
width : 60
}, {
header : QUILocale.get('quiqqer/system', 'title'),
dataIndex: 'title',
dataType : 'integer',
width : 200
}]
});
this.$Grid.addEvents({
onRefresh : this.refresh,
onClick : this.$refreshButtonStatus,
onDblClick: this.$onEditClick
});
this.$Grid.refresh();
},
/**
* Refresh the grid button status (disabled/enabled)
*/
$refreshButtonStatus: function () {
var selected = this.$Grid.getSelectedIndices();
var Edit = this.$Grid.getButtons().filter(function (Button) {
return Button.getAttribute('name') === 'edit';
})[0];
var Delete = this.$Grid.getButtons().filter(function (Button) {
return Button.getAttribute('name') === 'delete';
})[0];
if (!selected.length) {
Edit.disable();
Delete.disable();
return;
}
Edit.enable();
Delete.enable();
},
// region Dialogs
/**
* Opens the add dialog
* - Create a Processing Status
*/
openCreateDialog: function () {
var self = this;
new QUIConfirm({
icon : 'fa fa-plus',
title : QUILocale.get(lg, 'dialog.processingStatus.create.title'),
maxHeight: 400,
maxWidth : 600,
autoclose: false,
events : {
onOpen: function (Win) {
var Content = Win.getContent();
Win.Loader.show();
Content.addClass('quiqqer-order-processing-status-window');
Content.set('html', Mustache.render(template));
var Form = Content.getElement('form');
ProcessingStatus.getNextId().then(function (nextId) {
Form.elements.id.value = nextId;
return QUI.parse(Content);
}).then(function () {
Win.Loader.hide();
});
},
onSubmit: function (Win) {
Win.Loader.show();
var Form = Win.getContent().getElement('form');
require([
'qui/utils/Form',
'package/quiqqer/order/bin/backend/ProcessingStatus'
], function (FormUtils, ProcessingStatus) {
var data = FormUtils.getFormData(Form),
title = {};
try {
title = JSON.decode(data.title);
} catch (e) {
}
ProcessingStatus.createProcessingStatus(
data.id,
data.color,
title
).then(function () {
return Win.close();
}).then(function () {
self.refresh();
});
});
}
}
}).open();
},
/**
* Opens the dialog to edit a status
*
* @param {Number|String} statusId - ID of the Status
*/
openEditDialog: function (statusId) {
var self = this;
var data = this.$Grid.getData().filter(function (entry) {
return entry.id === statusId;
});
if (!data.length) {
return;
}
data = data[0];
new QUIConfirm({
icon : 'fa fa-edit',
title : QUILocale.get(lg, 'dialog.processingStatus.edit.title'),
maxHeight: 400,
maxWidth : 600,
autoclose: false,
ok_button: {
text : QUILocale.get('quiqqer/quiqqer', 'edit'),
textimage: 'fa fa-edit'
},
events : {
onOpen: function (Win) {
var Content = Win.getContent();
Win.Loader.show();
Content.addClass('quiqqer-order-processing-status-window');
Content.set('html', Mustache.render(template));
var Form = Content.getElement('form');
ProcessingStatus.getProcessingStatus(data.id).then(function (details) {
Form.elements.id.value = details.id;
Form.elements.color.value = details.color;
Form.elements.title.value = JSON.encode(details.title);
return QUI.parse(Content);
}).then(function () {
Win.Loader.hide();
});
},
onSubmit: function (Win) {
Win.Loader.show();
var Form = Win.getContent().getElement('form');
require([
'qui/utils/Form',
'package/quiqqer/order/bin/backend/ProcessingStatus'
], function (FormUtils, ProcessingStatus) {
var data = FormUtils.getFormData(Form),
title = {};
try {
title = JSON.decode(data.title);
} catch (e) {
}
ProcessingStatus.updateProcessingStatus(
data.id,
data.color,
title
).then(function () {
return Win.close();
}).then(function () {
self.refresh();
});
});
}
}
}).open();
},
/**
* Opens the dialog to delete a status
*
* @param {Number|String} statusId - ID of the Status
*/
openDeleteDialog: function (statusId) {
var self = this;
var data = this.$Grid.getData().filter(function (entry) {
return entry.id === statusId;
});
if (!data.length) {
return;
}
new QUIConfirm({
icon : 'fa fa-trash',
texticon : 'fa fa-trash',
title : QUILocale.get(lg, 'dialog.processingStatus.delete.title'),
text : QUILocale.get(lg, 'dialog.processingStatus.delete.text'),
information: QUILocale.get(lg, 'dialog.processingStatus.delete.information', {
id : data[0].id,
title: data[0].title
}),
maxHeight : 400,
maxWidth : 600,
autoclose : false,
ok_button : {
text : QUILocale.get('quiqqer/quiqqer', 'remove'),
textimage: 'fa fa-trash'
},
events : {
onSubmit: function (Win) {
Win.Loader.show();
ProcessingStatus.deleteProcessingStatus(statusId).then(function () {
Win.close();
self.refresh();
});
}
}
}).open();
},
// endregion
//region Buttons Events
/**
* event : on edit click
*/
$onEditClick: function () {
var data = this.$Grid.getSelectedData();
if (data.length) {
this.openEditDialog(data[0].id);
}
},
/**
* event : on delete click
*/
$onDeleteClick: function () {
var data = this.$Grid.getSelectedData();
if (data.length) {
this.openDeleteDialog(data[0].id);
}
}
// endregion
});
});
\ No newline at end of file
......@@ -461,6 +461,10 @@
<de><![CDATA[Bestimmung durch Bezahlungsmethode]]></de>
<en><![CDATA[Determination by payment method]]></en>
</locale>
<locale name="order.settings.processingStatus.title">
<de><![CDATA[Rechnungsstatus]]></de>
<en><![CDATA[Invoice status]]></en>
</locale>
<locale name="exception.order.process.not.found">
<de><![CDATA[Keinen Bestellprozess gefunden. Bitte legen Sie einen Bestellprozess an.]]></de>
......@@ -702,6 +706,15 @@
<en><![CDATA[Unique ID]]></en>
</locale>
<locale name="processingStatus.grid.id">
<de><![CDATA[ID]]></de>
<en><![CDATA[ID]]></en>
</locale>
<locale name="processingStatus.grid.color">
<de><![CDATA[Farbe]]></de>
<en><![CDATA[Color]]></en>
</locale>
<locale name="order.address.confirm.title">
<de><![CDATA[Bitte wählen Sie eine Adresse aus]]></de>
<en><![CDATA[Please choose an address]]></en>
......
......@@ -78,6 +78,18 @@
label="false"
/>
</settings>
<settings>
<title>
<locale group="quiqqer/order" var="order.settings.processingStatus.title"/>
</title>
<input type="hidden"
label="false"
data-qui="package/quiqqer/order/bin/backend/controls/settings/ProcessingStatus"
/>
</settings>
</category>
</categories>
</window>
......
......@@ -79,7 +79,12 @@ public function createProcessingStatus($id, $color, array $title)
public function getNextId()
{
$list = Handler::getInstance()->getList();
$max = max(array_keys($list));
if (!count($list)) {
return 1;
}
$max = max(array_keys($list));
return $max + 1;
}
......
......@@ -36,10 +36,10 @@ public function __construct($id)
$list = Handler::getInstance()->getList();
if (!isset($list[$id])) {
throw new Exception(array(
throw new Exception([
'quiqqer/order',
'exception.processingStatus.not.found'
));
]);
}
$this->id = (int)$id;
......@@ -70,7 +70,7 @@ public function getTitle($Locale = null)
$Locale = QUI::getLocale();
}
return $Locale->get('quiqqer/order', 'processing.status.' . $this->id);
return $Locale->get('quiqqer/order', 'processing.status.'.$this->id);
}
/**
......@@ -96,7 +96,7 @@ public function toArray($Locale = null)
$title = $this->getTitle($Locale);
if ($Locale === null) {
$title = array();
$title = [];
$Locale = QUI::getLocale();
$languages = QUI::availableLanguages();
......@@ -104,15 +104,15 @@ public function toArray($Locale = null)
$title[$language] = $Locale->getByLang(
$language,
'quiqqer/order',
'processing.status.' . $this->getId()
'processing.status.'.$this->getId()
);
}
}
return array(
return [
'id' => $this->getId(),
'title' => $title,
'color' => $this->getColor()
);
];
}
}
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