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

kein sofortiges create bei hinzufügen

Übergeordneter 244dd7c2
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
Pipeline-Nr.
......@@ -35,8 +35,7 @@
<span class="field-container-item">
Rabatt
</span>
<input type="text" name="discount"
class="field-container-field"/>
<input type="text" name="discount" class="field-container-field"/>
<select name="discount_type"
class="field-container-item"
style="width: 100px;"
......
......@@ -9,6 +9,7 @@
* @require qui/controls/desktop/Panel
* @require qui/controls/buttons/Button
* @require qui/controls/windows/Confirm
* @require qui/controls/windows/Prompt
* @require controls/grid/Grid
* @require Locale
* @require package/quiqqer/discount/bin/classes/Handler
......@@ -19,11 +20,12 @@ define('package/quiqqer/discount/bin/controls/Discounts', [
'qui/controls/desktop/Panel',
'qui/controls/buttons/Button',
'qui/controls/windows/Confirm',
'qui/controls/windows/Prompt',
'controls/grid/Grid',
'Locale',
'package/quiqqer/discount/bin/classes/Handler'
], function (QUI, QUIPanel, QUIButton, QUIConfirm, Grid, QUILocale, Handler) {
], function (QUI, QUIPanel, QUIButton, QUIConfirm, QUIPrompt, Grid, QUILocale, Handler) {
"use strict";
var lg = 'quiqqer/discount';
......@@ -300,15 +302,39 @@ define('package/quiqqer/discount/bin/controls/Discounts', [
createChild: function () {
var self = this;
this.Loader.show();
return Discounts.createChild().then(function (discountId) {
// this.Loader.show();
new QUIPrompt({
title : QUILocale.get(lg, 'discount.window.create.title'),
titleicon : 'fa fa-plus',
icon : false,
information: QUILocale.get(lg, 'discount.window.create.information'),
autoclose : false,
maxHeight : 300,
maxWidth : 450,
events : {
onSubmit: function (value, Win) {
Win.Loader.show();
return self.refresh().then(function () {
self.Loader.hide();
return self.editChild(discountId);
});
});
Discounts.createChild({
title: value
}).then(function (discountId) {
require([
'package/quiqqer/translator/bin/classes/Translator'
], function (Translator) {
new Translator().publish(lg).then(function () {
return self.refresh();
}).then(function () {
Win.close();
self.editChild(discountId);
});
});
}, function () {
// reject
Win.Loader.hide();
});
}
}
}).open();
},
/**
......
<?xml version="1.0" encoding="UTF-8"?>
<events>
<event on="onQuiqqerProductsPriceFactorsInit" fire="\QUI\ERP\Discount\EventHandling::onQuiqqerProductsPriceFactorsInit"/>
</events>
\ No newline at end of file
......@@ -98,6 +98,29 @@
<de><![CDATA[Zur Suche]]></de>
<en><![CDATA[Back to search]]></en>
</locale>
<locale name="discount.window.delete.title">
<de><![CDATA[Rabatt löschen?]]></de>
<en><![CDATA[Delete the discount?]]></en>
</locale>
<locale name="discount.window.delete.text">
<de><![CDATA[Rabatt löschen?]]></de>
<en><![CDATA[Delete the discount?]]></en>
</locale>
<locale name="discount.window.delete.information">
<de><![CDATA[Folgende Rabatte werden gelöscht: [ids]]]></de>
<en><![CDATA[The following discount IDs would be deleted: [ids]]]></en>
</locale>
<locale name="discount.window.create.title">
<de><![CDATA[Neuen Rabatt anlegen]]></de>
<en><![CDATA[Create new discount]]></en>
</locale>
<locale name="discount.window.create.information">
<de><![CDATA[Bitte geben Sie einen neuen Titel für den Rabett an]]></de>
<en><![CDATA[Please insert a new discount title]]></en>
</locale>
</groups>
</locales>
\ No newline at end of file
......@@ -18,6 +18,7 @@ class Discount extends QUI\CRUD\Child
{
/**
* Discount constructor.
*
* @param int $id
* @param Handler $Factory
*/
......@@ -42,7 +43,7 @@ public function __construct($id, Handler $Factory)
if ($this->getAttribute('date_from')
&& !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_from'))
) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.date_from.wrong'
));
......@@ -51,7 +52,7 @@ public function __construct($id, Handler $Factory)
if ($this->getAttribute('date_until')
&& !Orthos::checkMySqlDatetimeSyntax($this->getAttribute('date_until'))
) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.date_until.wrong'
));
......@@ -66,17 +67,17 @@ public function __construct($id, Handler $Factory)
if ($purchaseQuantityFrom === false
|| $purchaseQuantityFrom < 0
) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.purchase_quantity_from.wrong'
));
}
if ($purchaseQuantityUntil === false
|| $purchaseQuantityUntil < 0
) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.purchase_quantity_until.wrong'
));
......@@ -85,7 +86,7 @@ public function __construct($id, Handler $Factory)
if ($purchaseValueFrom === false
|| $purchaseValueFrom < 0
) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.purchase_value_from.wrong'
));
......@@ -94,7 +95,7 @@ public function __construct($id, Handler $Factory)
if ($purchaseValueUntil === false
|| $purchaseValueUntil < 0
) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.purchase_value_until.wrong'
));
......@@ -198,12 +199,12 @@ public function canUsedBy(User $User)
* Verify the combination between the discounts
*
* @param Discount $Discount
* @throws QUI\Exception
* @throws QUI\ERP\Discount\Exception
*/
public function verifyCombinationWith(Discount $Discount)
{
if ($this->canCombinedWith($Discount) === false) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.not.combinable',
array(
......@@ -218,12 +219,12 @@ public function verifyCombinationWith(Discount $Discount)
* Verify the usage of the discount by the user
*
* @param User $User
* @throws QUI\Exception
* @throws QUI\ERP\Discount\Exception
*/
public function verifyUser(User $User)
{
if ($this->canUsedBy($User) === false) {
throw new QUI\Exception(array(
throw new QUI\ERP\Discount\Exception(array(
'quiqqer/discount',
'exception.discount.user.cant.use.discount',
array(
......
<?php
/**
* This file contains QUI\ERP\Discount\EventHandling
*/
namespace QUI\ERP\Discount;
use QUI;
use QUI\ERP\Products\Utils\PriceFactor;
use QUI\ERP\Products\Utils\PriceFactors;
use QUI\ERP\Products\Product\UniqueProduct;
/**
* Class EventHandling
*
* @package QUI\ERP\Discount
*/
class EventHandling
{
/**
* event - on price factor init
*
* @param PriceFactors $List
* @param UniqueProduct $Product
*/
public static function onQuiqqerProductsPriceFactorsInit(PriceFactors $List, UniqueProduct $Product)
{
// QUI\System\Log::writeRecursive(1);
// QUI\System\Log::writeRecursive($Product->getId());
}
}
<?php
/**
* This file contains QUI\ERP\Discount\Exception
*/
namespace QUI\ERP\Discount;
use QUI;
/**
* Class Exception
* @package QUI\ERP\Discount
*/
class Exception extends QUI\Exception
{
}
......@@ -27,13 +27,17 @@ public function __construct()
});
// create new translation var for the discount
$this->Events->addEvent('onCreateEnd', function ($New) {
$this->Events->addEvent('onCreateEnd', function ($New, $data) {
/* @var $New QUI\ERP\Discount\Discount */
$newVar = 'discount.' . $New->getId() . '.title';
$current = QUI::getLocale()->getCurrent();
$title = $New->getAttribute('title');
if (!$title && isset($data['title'])) {
$title = QUI\Utils\Security\Orthos::clear($data['title']);
}
if (QUI::getLocale()->isLocaleString($title)) {
$parts = QUI::getLocale()->getPartsOfLocaleString($title);
$title = QUI::getLocale()->get($parts[0], $parts[1]);
......
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