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