// Manage SQL upgrade for stock management + bug fix
This commit is contained in:
@@ -67,14 +67,14 @@
|
||||
<h4>{l s='Product reference(s)'}</h4>
|
||||
<div class="separation"></div>
|
||||
<p>{l s='You can specify product reference(s) for each supplier associated.'}</p>
|
||||
|
||||
|
||||
<div id="suppliers_accordion" style="margin-top:10px; display:block;">
|
||||
{foreach from=$associated_suppliers item=supplier}
|
||||
<h3 style="margin-bottom:0;"><a href="#">{$supplier->name}</a></h3>
|
||||
<div style="display:block;">
|
||||
|
||||
|
||||
<table cellpadding="10" cellspacing="0" class="table">
|
||||
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{l s='Product name'}</th>
|
||||
@@ -119,20 +119,20 @@
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var default_is_ok = false;
|
||||
|
||||
|
||||
var manageDefaultSupplier = function() {
|
||||
|
||||
|
||||
var availables_radio_buttons = [];
|
||||
var radio_buttons = $('input[name="default_supplier"]');
|
||||
|
||||
|
||||
for (i=0; i<radio_buttons.length; i++)
|
||||
{
|
||||
var item = $(radio_buttons[i]);
|
||||
|
||||
|
||||
if (item.is(':disabled'))
|
||||
{
|
||||
if (item.is(':checked'))
|
||||
@@ -146,30 +146,30 @@
|
||||
availables_radio_buttons.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (default_is_ok == false)
|
||||
{
|
||||
for (i=0; i<availables_radio_buttons.length; i++)
|
||||
{
|
||||
var item = $(availables_radio_buttons[i]);
|
||||
|
||||
|
||||
if (item.is(':disabled') == false)
|
||||
{
|
||||
item.attr("checked", "checked");
|
||||
default_is_ok = true;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$('.supplierCheckBox').click(function() {
|
||||
|
||||
|
||||
var check = $(this);
|
||||
|
||||
|
||||
var checkbox = $('#default_supplier_'+check.val());
|
||||
|
||||
|
||||
if (this.checked)
|
||||
{
|
||||
//enable default radio button associated
|
||||
@@ -180,16 +180,16 @@
|
||||
//enable default radio button associated
|
||||
checkbox.attr("disabled","disabled");
|
||||
}
|
||||
|
||||
|
||||
//manage default supplier check
|
||||
manageDefaultSupplier();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
$('#suppliers_accordion').accordion();
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{/if}
|
||||
@@ -33,13 +33,13 @@
|
||||
<p>{l s='It is also possible to specify for each product/product combinations its location in each warehouse.'}</p>
|
||||
</div>
|
||||
<p>{l s='Please choose the warehouses associated to this product, and the default one.'}</p>
|
||||
|
||||
|
||||
{assign var=confirm value="Are you sure you want to delete entered product information?"}
|
||||
|
||||
|
||||
<a class="button bt-icon" href="{$link->getAdminLink('AdminWarehouses')}&addwarehouse" onclick="return confirm(' {$confirm} ')">
|
||||
<img src="../img/admin/add.gif" alt="{l s='Create new warehouse'}" title="{l s='Create new warehouse'}" /><span>{l s='Create new warehouse'}</span>
|
||||
</a>
|
||||
|
||||
|
||||
<div id="warehouse_accordion" style="margin-top:10px; display:block;">
|
||||
{foreach from=$warehouses item=warehouse}
|
||||
<h3 style="margin-bottom:0;"><a href="#">{$warehouse['name']}</a></h3>
|
||||
@@ -85,19 +85,19 @@
|
||||
{/foreach}
|
||||
</div>
|
||||
<p> </p>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#check_all_suppliers').click(function() {
|
||||
var check = $(this);
|
||||
|
||||
|
||||
//get all checkboxes of current warehouse
|
||||
var checkboxes = $('input[name*="'+check.val()+'"]');
|
||||
|
||||
|
||||
for (i=0; i<checkboxes.length; i++)
|
||||
{
|
||||
var item = $(checkboxes[i]);
|
||||
|
||||
|
||||
if (item.is(':checked'))
|
||||
{
|
||||
item.attr("checked", "");
|
||||
@@ -108,7 +108,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
$('#warehouse_accordion').accordion();
|
||||
}, 500);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
function set_product_suppliers()
|
||||
{
|
||||
//Get all products with positive quantity
|
||||
$resource = Db::getInstance()->query('
|
||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||
SELECT id_supplier, id_product, supplier_reference, wholesale_price
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `id_supplier` > 0
|
||||
@@ -19,7 +19,7 @@ function set_product_suppliers()
|
||||
');
|
||||
|
||||
//Try to get product attribues
|
||||
$attributes = Db::getInstance()->ExecuteS('
|
||||
$attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT id_product_attribute, supplier_reference, wholesale_price
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.(int)$row['id_product']
|
||||
@@ -28,9 +28,6 @@ function set_product_suppliers()
|
||||
//Add each attribute to stock_available
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
// add to global quantity
|
||||
$quantity += $attribute['quantity'];
|
||||
|
||||
// set supplier for attribute
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_supplier`
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
function set_stock_available()
|
||||
{
|
||||
//Get all products with positive quantity
|
||||
$resource = Db::getInstance()->query('
|
||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||
SELECT quantity, id_product, out_of_stock
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `active` = 1
|
||||
@@ -13,7 +13,7 @@ function set_stock_available()
|
||||
$quantity = 0;
|
||||
|
||||
//Try to get product attribues
|
||||
$attributes = Db::getInstance()->ExecuteS('
|
||||
$attributes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT quantity, id_product_attribute
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.(int)$row['id_product']
|
||||
|
||||
@@ -4,7 +4,7 @@ function update_stock_mvt_reason()
|
||||
{
|
||||
//Get all stock mvts reasons already presents in the solution (from 1.4.x)
|
||||
//Remove standard movements to keep only custom movement
|
||||
$mvts = Db::getInstance()->ExecuteS('
|
||||
$mvts = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT smr.*
|
||||
FROM `'._DB_PREFIX_.'stock_mvt_reason`
|
||||
WHERE `id` > 5
|
||||
@@ -12,7 +12,7 @@ function update_stock_mvt_reason()
|
||||
|
||||
//Get all stock mvts reasons language traduction already presents in the solution (from 1.4.x)
|
||||
//Remove standard movements to keep only custom movement
|
||||
$mvts_lang = Db::getInstance()->ExecuteS('
|
||||
$mvts_lang = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||
SELECT smrl.*
|
||||
FROM `'._DB_PREFIX_.'stock_movement_reason_lang`
|
||||
WHERE `id_stock_mvt_reason` > 5
|
||||
|
||||
@@ -274,6 +274,9 @@ ALTER TABLE `PREFIX_supplier` ADD COLUMN `id_address` int(10) unsigned NOT NULL
|
||||
|
||||
ALTER TABLE `PREFIX_address` ADD COLUMN `id_warehouse` int(10) unsigned NOT NULL default '0' AFTER `id_supplier`;
|
||||
|
||||
ALTER TABLE `PREFIX_order_detail` ADD COLUMN `id_warehouse` int(10) unsigned NOT NULL default '0' AFTER `id_order_invoice`;
|
||||
|
||||
|
||||
/* Update records after alter tables */
|
||||
/* PHP:update_stock_mvt_reasons(); */;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user