// Manage SQL upgrade for stock management
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
function add_stock_tab()
|
||||
{
|
||||
// Patch for the 1.0.1 sql update
|
||||
Db::getInstance()->query('
|
||||
DELETE
|
||||
FROM `'._DB_PREFIX_.'tab`
|
||||
WHERE id_parent = 1
|
||||
AND class_name = "AdminStocks"');
|
||||
|
||||
// Create new tabs
|
||||
$id_parent = add_new_tab(
|
||||
'AdminStock',
|
||||
'en:Stock|fr:Stock|es:Stock|de:Stock|it:Stock',
|
||||
0,
|
||||
true);
|
||||
|
||||
add_new_tab(
|
||||
'AdminWarehouses',
|
||||
'en:Warehouses|fr:Entrepôts|es:Warehouses|de:Warehouses|it:Warehouses',
|
||||
$id_parent);
|
||||
|
||||
add_new_tab(
|
||||
'AdminStockManagement',
|
||||
'en:Stock Management|fr:Gestion du stock|es:Stock Management|de:Stock Management|it:Stock Management',
|
||||
$id_parent);
|
||||
|
||||
add_new_tab(
|
||||
'AdminStockMvt',
|
||||
'en:Stock Movement|fr:Mouvements de Stock|es:Stock Movement|de:Stock Movement|it:Stock Movement',
|
||||
$id_parent);
|
||||
|
||||
add_new_tab(
|
||||
'AdminStockInstantState',
|
||||
'en:Stock instant state|fr:Etat instantané du stock|es:Stock instant state|de:Stock instant state|it:Stock instant state',
|
||||
$id_parent);
|
||||
|
||||
add_new_tab(
|
||||
'AdminStockCover',
|
||||
'en:Stock cover|fr:Couverture du stock|es:Stock cover|de:Stock cover|it:Stock cover',
|
||||
$id_parent);
|
||||
|
||||
add_new_tab(
|
||||
'AdminSupplyOrders',
|
||||
'en:Supply orders|fr:Commandes fournisseurs|es:Supply orders|de:Supply orders|it:Supply orders',
|
||||
$id_parent);
|
||||
|
||||
add_new_tab(
|
||||
'AdminStockConfiguration',
|
||||
'en:Configuration|fr:Configuration|es:Configuration|de:Configuration|it:Configuration',
|
||||
$id_parent);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
function set_product_suppliers()
|
||||
{
|
||||
//Get all products with positive quantity
|
||||
$resource = Db::getInstance()->query('
|
||||
SELECT id_supplier, id_product, supplier_reference, wholesale_price
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `id_supplier` > 0
|
||||
');
|
||||
|
||||
while ($row = Db::getInstance()->nextRow($resource))
|
||||
{
|
||||
//Set default supplier for product
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'product_supplier`
|
||||
(`id_product`, `id_product_attribute`, `id_supplier`, `product_supplier_reference`, `product_supplier_price_te`, `id_currency`)
|
||||
VALUES
|
||||
("'.(int)$row['id_product'].'", "0", "'.(int)$row['id_supplier'].'", "'.(int)$row['supplier_reference'].'", "'.(int)$row['wholesale_price'].'", "'.(int)Configuration::get('PS_CURRENCY_DEFAULT').'")
|
||||
');
|
||||
|
||||
//Try to get product attribues
|
||||
$attributes = Db::getInstance()->ExecuteS('
|
||||
SELECT id_product_attribute, supplier_reference, wholesale_price
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.(int)$row['id_product']
|
||||
);
|
||||
|
||||
//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`
|
||||
(`id_product`, `id_product_attribute`, `id_supplier`, `product_supplier_reference`, `product_supplier_price_te`, `id_currency`)
|
||||
VALUES
|
||||
("'.(int)$row['id_product'].'", "'.(int)$attribute['id_product_attribute'].'", "'.(int)$row['id_supplier'].'", "'.(int)$attribute['supplier_reference'].'", "'.(int)$attribute['wholesale_price'].'", "'.(int)Configuration::get('PS_CURRENCY_DEFAULT').'")
|
||||
');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
function set_stock_available()
|
||||
{
|
||||
//Get all products with positive quantity
|
||||
$resource = Db::getInstance()->query('
|
||||
SELECT quantity, id_product, out_of_stock
|
||||
FROM `'._DB_PREFIX_.'product`
|
||||
WHERE `active` = 1
|
||||
');
|
||||
|
||||
while ($row = Db::getInstance()->nextRow($resource))
|
||||
{
|
||||
$quantity = 0;
|
||||
|
||||
//Try to get product attribues
|
||||
$attributes = Db::getInstance()->ExecuteS('
|
||||
SELECT quantity, id_product_attribute
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.(int)$row['id_product']
|
||||
);
|
||||
|
||||
//Add each attribute to stock_available
|
||||
foreach ($attributes as $attribute)
|
||||
{
|
||||
// add to global quantity
|
||||
$quantity += $attribute['quantity'];
|
||||
|
||||
//add stock available for attributes
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'stock_available`
|
||||
(`id_product`, `id_product_attribute`, `id_shop`, `id_group_shop`, `quantity`, `depends_on_stock`, `out_of_stock`)
|
||||
VALUES
|
||||
("'.(int)$row['id_product'].'", "'.(int)$attribute['id_product_attribute'].'", "1", "0", "'.(int)$attribute['quantity'].'", "0", "'.(int)$row['out_of_stock'].'")
|
||||
');
|
||||
}
|
||||
|
||||
if (count($attributes) == 0)
|
||||
$quantity = (int)$row['quantity'];
|
||||
|
||||
if ($quantity == 0)
|
||||
continue;
|
||||
|
||||
//Add stock available for product
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'stock_available`
|
||||
(`id_product`, `id_product_attribute`, `id_shop`, `id_group_shop`, `quantity`, `depends_on_stock`, `out_of_stock`)
|
||||
VALUES
|
||||
("'.(int)$row['id_product'].'", "0", "1", "0", "'.(int)$quantity.'", "0", "'.(int)$row['out_of_stock'].'")
|
||||
');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
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('
|
||||
SELECT smr.*
|
||||
FROM `'._DB_PREFIX_.'stock_mvt_reason`
|
||||
WHERE `id` > 5
|
||||
');
|
||||
|
||||
//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('
|
||||
SELECT smrl.*
|
||||
FROM `'._DB_PREFIX_.'stock_movement_reason_lang`
|
||||
WHERE `id_stock_mvt_reason` > 5
|
||||
');
|
||||
|
||||
//Clean table
|
||||
Db::getInstance()->query('TRUNCATE TABLE `'._DB_PREFIX_.'stock_movement_reason`');
|
||||
Db::getInstance()->query('TRUNCATE TABLE `'._DB_PREFIX_.'stock_movement_reason_lang`');
|
||||
|
||||
//Recreate new standards movements
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `PREFIX_stock_mvt_reason` (`id_stock_mvt_reason`, `sign`, `date_add`, `date_upd`)
|
||||
VALUES
|
||||
(1, 1, NOW(), NOW()),
|
||||
(2, -1, NOW(), NOW()),
|
||||
(3, -1, NOW(), NOW()),
|
||||
(4, -1, NOW(), NOW()),
|
||||
(5, 1, NOW(), NOW()),
|
||||
(6, -1, NOW(), NOW()),
|
||||
(7, 1, NOW(), NOW()),
|
||||
(8, 1, NOW(), NOW())
|
||||
');
|
||||
|
||||
Db::getInstance()->execute("
|
||||
INSERT INTO `PREFIX_stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `name`)
|
||||
VALUES
|
||||
(1, 1, 'Increase'),
|
||||
(1, 2, 'Augmenter'),
|
||||
(1, 3, 'Aumentar'),
|
||||
(1, 4, 'Erhöhen'),
|
||||
(1, 5, 'Increase'),
|
||||
(2, 1, 'Decrease'),
|
||||
(2, 2, 'Diminuer'),
|
||||
(2, 3, 'Disminuir'),
|
||||
(2, 4, 'Reduzieren'),
|
||||
(2, 5, 'Decrease'),
|
||||
(3, 1, 'Customer Order'),
|
||||
(3, 2, 'Commande client'),
|
||||
(3, 3, 'Pedido'),
|
||||
(3, 4, 'Bestellung'),
|
||||
(3, 5, 'Ordine'),
|
||||
(4, 1, 'Regulation following an inventory of stock'),
|
||||
(4, 2, 'Régularisation du stock suite à un inventaire'),
|
||||
(4, 3, 'Regulation following an inventory of stock'),
|
||||
(4, 4, 'Regulation following an inventory of stock'),
|
||||
(4, 5, 'Regulation following an inventory of stock'),
|
||||
(5, 1, 'Regulation following an inventory of stock'),
|
||||
(5, 2, 'Régularisation du stock suite à un inventaire'),
|
||||
(5, 3, 'Regulation following an inventory of stock'),
|
||||
(5, 4, 'Regulation following an inventory of stock'),
|
||||
(5, 5, 'Regulation following an inventory of stock'),
|
||||
(6, 1, 'Transfer to another warehouse'),
|
||||
(6, 2, 'Transfert vers un autre entrepôt'),
|
||||
(6, 3, 'Transfer to another warehouse'),
|
||||
(6, 4, 'Transfer to another warehouse'),
|
||||
(6, 5, 'Transfer to another warehouse'),
|
||||
(7, 1, 'Transfer from another warehouse'),
|
||||
(7, 2, 'Transfert depuis un autre entrepôt'),
|
||||
(7, 3, 'Transfer from another warehouse'),
|
||||
(7, 4, 'Transfer from another warehouse'),
|
||||
(7, 5, 'Transfer from another warehouse'),
|
||||
(8, 1, 'Supply Order'),
|
||||
(8, 2, 'Commande fournisseur'),
|
||||
(8, 3, 'Supply Order'),
|
||||
(8, 4, 'Supply Order'),
|
||||
(8, 5, 'Supply Order')
|
||||
");
|
||||
|
||||
//Add custom movements
|
||||
foreach ($mvts as $mvt)
|
||||
{
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `PREFIX_stock_mvt_reason` (`sign`, `date_add`, `date_upd`)
|
||||
VALUES ("'.(int)$mvt['sign'].'", "'.pSQL($mvt['date_add']).'", "'.pSQL($mvt['date_upd']).'")
|
||||
');
|
||||
|
||||
$row_id = Db::getInstance()->Insert_ID();
|
||||
|
||||
foreach ($mvts_lang as $mvt_lang)
|
||||
{
|
||||
if ($mvt_lang['id_stock_mvt_reason'] != $mvt['id'])
|
||||
continue;
|
||||
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `PREFIX_stock_mvt_reason_lang` (`id_stock_mvt_reason`, `id_lang`, `name`)
|
||||
VALUES ("'.(int)$row_id.'", "'.(int)$mvt_lang['id_lang'].'", "'.pSQL($mvt_lang['name']).'")
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1615,7 +1615,7 @@ CREATE TABLE `PREFIX_subdomain` (
|
||||
|
||||
CREATE TABLE `PREFIX_supplier` (
|
||||
`id_supplier` int(10) unsigned NOT NULL auto_increment,
|
||||
`id_address` int(10) unsigned NOT NULL,
|
||||
`id_address` int(10) unsigned NOT NULL default 0,
|
||||
`name` varchar(64) NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
|
||||
@@ -1080,7 +1080,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(4, 97, 'Stock Management'),
|
||||
(4, 98, 'Stock instant state'),
|
||||
(4, 99, 'Stock cover'),
|
||||
(4, 100, 'Supplier orders'),
|
||||
(4, 100, 'Supply orders'),
|
||||
(4, 101, 'Combinations generator'),
|
||||
(4, 102, 'Accounting'),
|
||||
(4, 103, 'Account Number Management'),
|
||||
@@ -1111,7 +1111,7 @@ INSERT INTO `PREFIX_tab_lang` (`id_lang`, `id_tab`, `name`) VALUES
|
||||
(5, 97, 'Stock Management'),
|
||||
(5, 98, 'Stock instant state'),
|
||||
(5, 99, 'Stock cover'),
|
||||
(5, 100, 'Supplier orders'),
|
||||
(5, 100, 'Supply orders'),
|
||||
(5, 101, 'Combinations generator'),
|
||||
(5, 102, 'Accounting'),
|
||||
(5, 103, 'Account Number Management'),
|
||||
@@ -1159,7 +1159,7 @@ INSERT INTO `PREFIX_meta` (`id_meta`, `page`) VALUES
|
||||
(7, 'password'),
|
||||
(8, 'prices-drop'),
|
||||
(9, 'sitemap'),
|
||||
(10, 'supplier'),
|
||||
(10, 'supply'),
|
||||
(11, 'address'),
|
||||
(12, 'addresses'),
|
||||
(13, 'authentication'),
|
||||
|
||||
@@ -45,3 +45,236 @@ ALTER TABLE `PREFIX_orders` DROP COLUMN `id_warehouse`;
|
||||
ALTER TABLE `PREFIX_order_detail` ADD COLUMN `id_warehouse` int(10) unsigned DEFAULT 0 AFTER `id_order_invoice`;
|
||||
ALTER TABLE `PREFIX_suplier` ADD COLUMN `id_address` int(10) unsigned NOT NULL AFTER `id_supplier`;
|
||||
ALTER TABLE `PREFIX_address` ADD COLUMN `id_warehouse` int(10) unsigned NOT NULL DEFAULT 0 AFTER `id_supplier`;
|
||||
|
||||
|
||||
/************************
|
||||
* STOCK MANAGEMENT
|
||||
*************************/
|
||||
|
||||
/* PHP:add_stock_tab(); */;
|
||||
|
||||
/* New tables */
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_product_supplier` (
|
||||
`id_product_supplier` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(11) unsigned NOT NULL,
|
||||
`id_product_attribute` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`id_supplier` int(11) unsigned NOT NULL,
|
||||
`product_supplier_reference` varchar(32) DEFAULT NULL,
|
||||
`product_supplier_price_te` decimal(20,6) NOT NULL DEFAULT '0.000000',
|
||||
`id_currency` int(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_product_supplier`),
|
||||
UNIQUE KEY `id_product` (`id_product`,`id_product_attribute`,`id_supplier`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_stock_available` (
|
||||
`id_stock_available` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(11) unsigned NOT NULL,
|
||||
`id_product_attribute` int(11) unsigned NOT NULL,
|
||||
`id_shop` int(11) unsigned NOT NULL,
|
||||
`id_group_shop` int(11) unsigned NOT NULL,
|
||||
`quantity` int(10) NOT NULL DEFAULT '0',
|
||||
`depends_on_stock` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`out_of_stock` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id_stock_available`),
|
||||
KEY `id_shop` (`id_shop`),
|
||||
KEY `id_group_shop` (`id_group_shop`),
|
||||
KEY `id_product` (`id_product`),
|
||||
KEY `id_product_attribute` (`id_product_attribute`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_supply_order` (
|
||||
`id_supply_order` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_supplier` int(11) unsigned NOT NULL,
|
||||
`supplier_name` varchar(64) NOT NULL,
|
||||
`id_lang` int(11) unsigned NOT NULL,
|
||||
`id_warehouse` int(11) unsigned NOT NULL,
|
||||
`id_supply_order_state` int(11) unsigned NOT NULL,
|
||||
`id_currency` int(11) unsigned NOT NULL,
|
||||
`id_ref_currency` int(11) unsigned NOT NULL,
|
||||
`reference` varchar(32) NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
`date_upd` datetime NOT NULL,
|
||||
`date_delivery_expected` datetime DEFAULT NULL,
|
||||
`total_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`total_with_discount_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`total_tax` decimal(20,6) DEFAULT '0.000000',
|
||||
`total_ti` decimal(20,6) DEFAULT '0.000000',
|
||||
`discount_rate` decimal(20,6) DEFAULT '0.000000',
|
||||
`discount_value_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`is_template` tinyint(1) DEFAULT '0',
|
||||
PRIMARY KEY (`id_supply_order`),
|
||||
KEY `id_supplier` (`id_supplier`),
|
||||
KEY `id_warehouse` (`id_warehouse`),
|
||||
KEY `reference` (`reference`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_supply_order_detail` (
|
||||
`id_supply_order_detail` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_supply_order` int(11) unsigned NOT NULL,
|
||||
`id_currency` int(11) unsigned NOT NULL,
|
||||
`id_product` int(11) unsigned NOT NULL,
|
||||
`id_product_attribute` int(11) unsigned NOT NULL,
|
||||
`reference` varchar(32) NOT NULL,
|
||||
`supplier_reference` varchar(32) NOT NULL,
|
||||
`name` varchar(128) NOT NULL,
|
||||
`ean13` varchar(13) DEFAULT NULL,
|
||||
`upc` varchar(12) DEFAULT NULL,
|
||||
`exchange_rate` decimal(20,6) DEFAULT '0.000000',
|
||||
`unit_price_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`quantity_expected` int(11) unsigned NOT NULL,
|
||||
`quantity_received` int(11) unsigned NOT NULL,
|
||||
`price_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`discount_rate` decimal(20,6) DEFAULT '0.000000',
|
||||
`discount_value_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`price_with_discount_te` decimal(20,6) DEFAULT '0.000000',
|
||||
`tax_rate` decimal(20,6) DEFAULT '0.000000',
|
||||
`tax_value` decimal(20,6) DEFAULT '0.000000',
|
||||
`price_ti` decimal(20,6) DEFAULT '0.000000',
|
||||
`tax_value_with_order_discount` decimal(20,6) DEFAULT '0.000000',
|
||||
`price_with_order_discount_te` decimal(20,6) DEFAULT '0.000000',
|
||||
PRIMARY KEY (`id_supply_order_detail`),
|
||||
KEY `id_supply_order` (`id_supply_order`),
|
||||
KEY `id_product` (`id_product`),
|
||||
KEY `id_product_attribute` (`id_product_attribute`),
|
||||
KEY `id_product_product_attribute` (`id_product`,`id_product_attribute`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_supply_order_history` (
|
||||
`id_supply_order_history` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_supply_order` int(11) unsigned NOT NULL,
|
||||
`id_employee` int(11) unsigned NOT NULL,
|
||||
`employee_lastname` varchar(32) DEFAULT '',
|
||||
`employee_firstname` varchar(32) DEFAULT '',
|
||||
`id_state` int(11) unsigned NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_supply_order_history`),
|
||||
KEY `id_supply_order` (`id_supply_order`),
|
||||
KEY `id_employee` (`id_employee`),
|
||||
KEY `id_state` (`id_state`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_supply_order_receipt_history` (
|
||||
`id_supply_order_receipt_history` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_supply_order_detail` int(11) unsigned NOT NULL,
|
||||
`id_employee` int(11) unsigned NOT NULL,
|
||||
`employee_lastname` varchar(32) DEFAULT '',
|
||||
`employee_firstname` varchar(32) DEFAULT '',
|
||||
`id_supply_order_state` int(11) unsigned NOT NULL,
|
||||
`quantity` int(11) unsigned NOT NULL,
|
||||
`date_add` datetime NOT NULL,
|
||||
PRIMARY KEY (`id_supply_order_receipt_history`),
|
||||
KEY `id_supply_order_detail` (`id_supply_order_detail`),
|
||||
KEY `id_supply_order_state` (`id_supply_order_state`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_supply_order_state` (
|
||||
`id_supply_order_state` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`delivery_note` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`editable` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`receipt_state` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`pending_receipt` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`enclosed` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`color` varchar(32) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_supply_order_state`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_supply_order_state_lang` (
|
||||
`id_supply_order_state` int(11) unsigned NOT NULL,
|
||||
`id_lang` int(11) unsigned NOT NULL,
|
||||
`name` varchar(128) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_supply_order_state`,`id_lang`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_warehouse` (
|
||||
`id_warehouse` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_currency` int(11) unsigned NOT NULL,
|
||||
`id_address` int(11) unsigned NOT NULL,
|
||||
`id_employee` int(11) unsigned NOT NULL,
|
||||
`reference` varchar(32) DEFAULT NULL,
|
||||
`name` varchar(45) NOT NULL,
|
||||
`management_type` enum('WA','FIFO','LIFO') NOT NULL DEFAULT 'WA',
|
||||
`deleted` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id_warehouse`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_warehouse_carrier` (
|
||||
`id_carrier` int(11) unsigned NOT NULL,
|
||||
`id_warehouse` int(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_warehouse`,`id_carrier`),
|
||||
KEY `id_warehouse` (`id_warehouse`),
|
||||
KEY `id_carrier` (`id_carrier`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_warehouse_product_location` (
|
||||
`id_warehouse_product_location` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`id_product` int(11) unsigned NOT NULL,
|
||||
`id_product_attribute` int(11) unsigned NOT NULL,
|
||||
`id_warehouse` int(11) unsigned NOT NULL,
|
||||
`location` varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (`id_warehouse_product_location`),
|
||||
UNIQUE KEY `id_product` (`id_product`,`id_product_attribute`,`id_warehouse`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_warehouse_shop` (
|
||||
`id_shop` int(11) unsigned NOT NULL,
|
||||
`id_warehouse` int(11) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id_warehouse`,`id_shop`),
|
||||
KEY `id_warehouse` (`id_warehouse`),
|
||||
KEY `id_shop` (`id_shop`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
/* Update records before alter tables */
|
||||
/* PHP:set_stock_available(); */;
|
||||
/* PHP:set_product_suppliers(); */;
|
||||
|
||||
/* Update tables */
|
||||
DROP TABLE IF EXISTS `PREFIX_stock`;
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_stock` (
|
||||
`id_stock` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_warehouse` INT(11) UNSIGNED NOT NULL,
|
||||
`id_product` INT(11) UNSIGNED NOT NULL,
|
||||
`id_product_attribute` INT(11) UNSIGNED NOT NULL,
|
||||
`reference` VARCHAR(32) NOT NULL,
|
||||
`ean13` VARCHAR(13) DEFAULT NULL,
|
||||
`upc` VARCHAR(12) DEFAULT NULL,
|
||||
`physical_quantity` INT(11) UNSIGNED NOT NULL,
|
||||
`usable_quantity` INT(11) UNSIGNED NOT NULL,
|
||||
`price_te` DECIMAL(20,6) DEFAULT '0.000000',
|
||||
PRIMARY KEY (`id_stock`),
|
||||
KEY `id_warehouse` (`id_warehouse`),
|
||||
KEY `id_product` (`id_product`),
|
||||
KEY `id_product_attribute` (`id_product_attribute`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP TABLE IF EXISTS `PREFIX_stock_mvt`;
|
||||
CREATE TABLE IF NOT EXISTS `PREFIX_stock_mvt` (
|
||||
`id_stock_mvt` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_stock` INT(11) UNSIGNED NOT NULL,
|
||||
`id_order` INT(11) UNSIGNED DEFAULT NULL,
|
||||
`id_supply_order` INT(11) UNSIGNED DEFAULT NULL,
|
||||
`id_stock_mvt_reason` INT(11) UNSIGNED NOT NULL,
|
||||
`id_employee` INT(11) UNSIGNED NOT NULL,
|
||||
`employee_lastname` varchar(32) DEFAULT '',
|
||||
`employee_firstname` varchar(32) DEFAULT '',
|
||||
`physical_quantity` INT(11) UNSIGNED NOT NULL,
|
||||
`date_add` DATETIME NOT NULL,
|
||||
`sign` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`price_te` DECIMAL(20,6) DEFAULT '0.000000',
|
||||
`last_wa` DECIMAL(20,6) DEFAULT '0.000000',
|
||||
`current_wa` DECIMAL(20,6) DEFAULT '0.000000',
|
||||
`referer` bigint UNSIGNED DEFAULT NULL,
|
||||
PRIMARY KEY (`id_stock_mvt`),
|
||||
KEY `id_stock` (`id_stock`),
|
||||
KEY `id_stock_mvt_reason` (`id_stock_mvt_reason`)
|
||||
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `PREFIX_stock_mvt_reason` ADD COLUMN `deleted` tinyint(1) unsigned NOT NULL default '0' AFTER `date_upd`;
|
||||
|
||||
ALTER TABLE `PREFIX_supplier` ADD COLUMN `id_address` 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`;
|
||||
|
||||
/* Update records after alter tables */
|
||||
/* PHP:update_stock_mvt_reasons(); */;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user