// Added one field in Product object, so one product can be managed independantly from the stock management (advanced) if necessary
This commit is contained in:
@@ -59,8 +59,16 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td valign="top" style="vertical-align:top;">
|
||||
<input {if $product->depends_on_stock == 1 && $stock_management_active == 1}checked="checked" {/if} {if $stock_management_active == 0}disabled="disabled" {/if} type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_1" value="1"/>
|
||||
<label style="float:none;font-weight:normal" for="depends_on_stock_1">{l s='Available quantities for current product and its combinations are based on stock in the warehouses'} {if $stock_management_active == 0} - <b>{l s='Not possible if stock management is not enabled'}</b>{/if}</label>
|
||||
<input {if $product->advanced_stock_management == 1 && $stock_management_active == 1}value="on" checked="checked" {/if} {if $stock_management_active == 0}disabled="disabled" {/if}
|
||||
type="checkbox" name="advanced_stock_management" class="advanced_stock_management" id="advanced_stock_management" />
|
||||
<label style="float:none;font-weight:normal" for="depends_on_stock_1">{l s='I want to use the advanced stock management system for this product'} {if $stock_management_active == 0} - <b>{l s='Not possible if stock management is not enabled'}</b>{/if}</label>
|
||||
<br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" style="vertical-align:top;">
|
||||
<input {if $product->depends_on_stock == 1 && $stock_management_active == 1}checked="checked" {/if} {if $stock_management_active == 0 || $product->advanced_stock_management == 0}disabled="disabled" {/if} type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_1" value="1"/>
|
||||
<label style="float:none;font-weight:normal" for="depends_on_stock_1">{l s='Available quantities for current product and its combinations are based on stock in the warehouses'} {if $stock_management_active == 0 || $product->advanced_stock_management == 0} - <b>{l s='Not possible if stock management is not enabled AND/OR if this product does not use the stock management'}</b>{/if}</label>
|
||||
<br /><br />
|
||||
</td>
|
||||
</tr>
|
||||
@@ -105,13 +113,13 @@
|
||||
<tr>
|
||||
<td class="col-left"><label>{l s='When out of stock:'}</label></td>
|
||||
<td style="padding-bottom:5px;">
|
||||
<input {if $product->out_of_stock == 0}checked="checked" {/if} id="out_of_stock_1" type="radio" checked="checked" value="0" class="out_of_stock" name="out_of_stock">
|
||||
<input {if $product->out_of_stock == 0} checked="checked" {/if} id="out_of_stock_1" type="radio" checked="checked" value="0" class="out_of_stock" name="out_of_stock">
|
||||
<label id="label_out_of_stock_1" class="t" for="out_of_stock_1">{l s='Deny orders'}</label>
|
||||
<br>
|
||||
<input {if $product->out_of_stock == 1} 'checked="checked" {/if} id="out_of_stock_2" type="radio" value="1" class="out_of_stock" name="out_of_stock">
|
||||
<input {if $product->out_of_stock == 1} checked="checked" {/if} id="out_of_stock_2" type="radio" value="1" class="out_of_stock" name="out_of_stock">
|
||||
<label id="label_out_of_stock_2" class="t" for="out_of_stock_2">{l s='Allow orders'}</label>
|
||||
<br>
|
||||
<input {if $product->out_of_stock == 2} 'checked="checked" {/if} id="out_of_stock_3" type="radio" value="2" class="out_of_stock" name="out_of_stock">
|
||||
<input {if $product->out_of_stock == 2} checked="checked" {/if} id="out_of_stock_3" type="radio" value="2" class="out_of_stock" name="out_of_stock">
|
||||
<label id="label_out_of_stock_3" class="t" for="out_of_stock_3">
|
||||
Default:
|
||||
<i>Deny orders</i>
|
||||
@@ -265,6 +273,27 @@
|
||||
if($(this).val() == 0)
|
||||
$('.available_quantity input').trigger('change');
|
||||
});
|
||||
|
||||
$('.advanced_stock_management').click(function(e)
|
||||
{
|
||||
var val = 0;
|
||||
if ($(this).attr('checked'))
|
||||
val = 1;
|
||||
|
||||
ajaxCall( { actionQty: 'advanced_stock_management', value: val } );
|
||||
if (val == 1)
|
||||
{
|
||||
$('#depends_on_stock_1').attr('disabled', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#depends_on_stock_1').attr('disabled', true);
|
||||
$('#depends_on_stock_0').attr('checked', true);
|
||||
ajaxCall( { actionQty: 'depends_on_stock', value: 0} );
|
||||
refreshQtyAvaibilityForm();
|
||||
}
|
||||
refreshQtyAvaibilityForm();
|
||||
});
|
||||
|
||||
// bind enter key event on search field
|
||||
$('.available_quantity').find('input').bind('keypress', function(e) {
|
||||
|
||||
@@ -188,6 +188,12 @@ class ProductCore extends ObjectModel
|
||||
/*** @var array Tags */
|
||||
public $tags;
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
* @var boolean Tells if the product uses the advanced stock management
|
||||
*/
|
||||
public $advanced_stock_management;
|
||||
|
||||
public $isFullyLoaded = false;
|
||||
|
||||
public $cache_is_pack;
|
||||
@@ -253,6 +259,7 @@ class ProductCore extends ObjectModel
|
||||
'cache_has_attachments' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat'),
|
||||
'advanced_stock_management' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||
|
||||
// Lang fields
|
||||
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
|
||||
|
||||
@@ -3552,6 +3552,17 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
StockAvailable::setQuantity($product->id, (int)Tools::getValue('id_product_attribute'), (int)Tools::getValue('value'));
|
||||
break;
|
||||
case 'advanced_stock_management' :
|
||||
if (Tools::getValue('value') === false)
|
||||
return Tools::jsonEncode(array('error' => 'Undefined value'));
|
||||
if ((int)Tools::getValue('value') != 1 && (int)Tools::getValue('value') != 0)
|
||||
return Tools::jsonEncode(array('error' => 'Uncorrect value'));
|
||||
$product->advanced_stock_management = (int)Tools::getValue('value');
|
||||
$product->save();
|
||||
if (StockAvailable::dependsOnStock($product->id) == 1 && (int)Tools::getValue('value') == 0)
|
||||
StockAvailable::setProductDependsOnStock($product->id, 0);
|
||||
break;
|
||||
|
||||
}
|
||||
die(Tools::jsonEncode(array('error' => false)));
|
||||
}
|
||||
|
||||
@@ -1336,6 +1336,7 @@ CREATE TABLE `PREFIX_product` (
|
||||
`cache_default_attribute` int(10) unsigned default NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
`advanced_stock_management` tinyint(1) default '0' NOT NULL,
|
||||
PRIMARY KEY (`id_product`),
|
||||
KEY `product_supplier` (`id_supplier`),
|
||||
KEY `product_manufacturer` (`id_manufacturer`),
|
||||
|
||||
@@ -276,6 +276,7 @@ ALTER TABLE `PREFIX_address` ADD COLUMN `id_warehouse` int(10) unsigned NOT NULL
|
||||
|
||||
ALTER TABLE `PREFIX_order_detail` ADD COLUMN `id_warehouse` int(10) unsigned NOT NULL default '0' AFTER `id_order_invoice`;
|
||||
|
||||
ALTER TABLE `PREFIX_product` ADD COLUMN `advanced_stock_management` tinyint(1) default '0' NOT NULL;
|
||||
|
||||
/* Update records after alter tables */
|
||||
/* PHP:update_stock_mvt_reasons(); */;
|
||||
|
||||
Reference in New Issue
Block a user