diff --git a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js index 27a10bfb5..6f7563ef6 100644 --- a/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js +++ b/src/PartKeepr/FrontendBundle/Resources/public/js/Components/Part/PartStockWindow.js @@ -161,11 +161,32 @@ Ext.define('PartKeepr.PartStockWindow', { price = this.priceField.getValue() / this.quantityField.getValue(); } - Ext.callback(this.callbackFn, + //Warn the user if they want to remove more than the current available + var current_stock = this.callbackScope.record.data.stockLevel; + if ((this.title == this.removePartText) & (this.quantityField.getValue() > current_stock)){ + + Ext.Msg.confirm(i18n("Not enough stock"), + i18n("You are removing more parts than are in stock. \ + If you continue a negative stock will be tracked.

\ + Are you sure you want to remove these parts?"), + function(buttonid){ + // if yes, submit data as normal + if (buttonid == "yes") { + Ext.callback(this.callbackFn, + this.callbackScope, + [this.quantityField.getValue(), price, this.commentField.getValue()]); + this.close(); + } + return; //otherwise, return without doing anything + }, this); + } + else { // add or remove stock normally + Ext.callback(this.callbackFn, this.callbackScope, [this.quantityField.getValue(), price, this.commentField.getValue()]); - this.close(); - } + this.close(); + } + } }, /** * Opens the window in "add stock" mode. The target callback receives three parameters: the value of the quantity @@ -201,7 +222,6 @@ Ext.define('PartKeepr.PartStockWindow', { this.priceField.hide(); this.priceCheckbox.hide(); this.okButton.setIconCls("web-icon brick_delete"); - this.quantityField.maxValue = this.callbackScope.record.data.stockLevel; this.show(); } });