From 89ac5e8803a66751d0d5293be7a62a4d6bf64661 Mon Sep 17 00:00:00 2001
From: Anthony Berton <34568357+bb2a@users.noreply.github.com>
Date: Sun, 17 Jan 2021 02:09:21 +0100
Subject: [PATCH] 1
---
htdocs/comm/card.php | 29 +++++++++----------
.../install/mysql/migration/13.0.0-14.0.0.sql | 4 +++
.../install/mysql/tables/llx_societe.key.sql | 4 +--
htdocs/societe/class/societe.class.php | 13 +++++++--
4 files changed, 31 insertions(+), 19 deletions(-)
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index fbf0f83acff..897dd48bea6 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -101,6 +101,17 @@ $now = dol_now();
/*
* Actions
*/
+$contactstatic = new Contact($db);
+$userstatic = new User($db);
+$form = new Form($db);
+$formcompany = new FormCompany($db);
+
+if ($id > 0 && empty($object->id))
+{
+ // Load data of third party
+ $res = $object->fetch($id);
+ if ($object->id < 0) dol_print_error($db, $object->error, $object->errors);
+}
$parameters = array('id' => $id, 'socid' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
@@ -230,7 +241,7 @@ if (empty($reshook))
// warehouse
if ($action == 'setwarehouse' && $user->rights->societe->creer)
{
- $result = $object->setWarehouse(GETPOST('warehouse_id', 'int'));
+ $result = $object->setWarehouse(GETPOST('fk_warehouse', 'int'));
}
}
@@ -239,18 +250,6 @@ if (empty($reshook))
* View
*/
-$contactstatic = new Contact($db);
-$userstatic = new User($db);
-$form = new Form($db);
-$formcompany = new FormCompany($db);
-
-if ($id > 0 && empty($object->id))
-{
- // Load data of third party
- $res = $object->fetch($id);
- if ($object->id < 0) dol_print_error($db, $object->error, $object->errors);
-}
-
$title = $langs->trans("CustomerCard");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name;
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
@@ -497,9 +496,9 @@ if ($object->id > 0)
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $user->rights->societe->creer);
print '
';
if ($action == 'editwarehouse') {
- $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
+ $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'fk_warehouse', 1);
} else {
- $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'none');
+ $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'none');
}
print ' | ';
print '';
diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
index 90839fe6e95..71af8930dd6 100644
--- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
+++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
@@ -105,3 +105,7 @@ ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse);
ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30);
ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30);
+ALTER TABLE llx_societe CHANGE fk_entrepot fk_warehouse INT NULL DEFAULT '0';
+ALTER TABLE llx_societe ADD CONSTRAINT llx_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
+ALTER TABLE llx_societe DROP INDEX idx_societe_entrepot;
+ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_societe.key.sql b/htdocs/install/mysql/tables/llx_societe.key.sql
index 5e5bf73dcac..7d4f1e743a7 100644
--- a/htdocs/install/mysql/tables/llx_societe.key.sql
+++ b/htdocs/install/mysql/tables/llx_societe.key.sql
@@ -33,7 +33,7 @@ ALTER TABLE llx_societe ADD INDEX idx_societe_prospectlevel(fk_prospectlevel);
ALTER TABLE llx_societe ADD INDEX idx_societe_typent(fk_typent);
ALTER TABLE llx_societe ADD INDEX idx_societe_forme_juridique(fk_forme_juridique);
ALTER TABLE llx_societe ADD INDEX idx_societe_shipping_method(fk_shipping_method);
-ALTER TABLE llx_societe ADD INDEX idx_societe_entrepot(fk_entrepot);
+ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse);
-- ALTER TABLE llx_societe ADD FOREIGN KEY fk_prospectlevel llx_c_prospectlevel(code);
-
+ALTER TABLE llx_societe ADD CONSTRAINT llx_propal_fk_warehouse FOREIGN KEY (fk_warehouse) REFERENCES llx_entrepot(rowid);
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index a6f8a9ff3fa..5dd5c36c75b 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -214,7 +214,7 @@ class Societe extends CommonObject
'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>1, 'visible'=>-1, 'position'=>440),
'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'Multicurrency code', 'enabled'=>1, 'visible'=>-1, 'position'=>445),
'fk_account' =>array('type'=>'integer', 'label'=>'Fk account', 'enabled'=>1, 'visible'=>-1, 'position'=>450),
- 'fk_entrepot' =>array('type'=>'integer', 'label'=>'Fk entrepot', 'enabled'=>1, 'visible'=>-1, 'position'=>455),
+ 'fk_warehouse' =>array('type'=>'integer', 'label'=>'warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>455),
'logo' =>array('type'=>'varchar(255)', 'label'=>'Logo', 'enabled'=>1, 'visible'=>-1, 'position'=>400),
'logo_squarred' =>array('type'=>'varchar(255)', 'label'=>'Logo squarred', 'enabled'=>1, 'visible'=>-1, 'position'=>401),
'status' =>array('type'=>'tinyint(4)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
@@ -709,6 +709,12 @@ class Societe extends CommonObject
*/
public $fk_multicurrency;
+ // Warehouse
+ /**
+ * @var int ID
+ */
+ public $fk_warehouse;
+
/**
* @var string Multicurrency code
*/
@@ -1551,7 +1557,7 @@ class Societe extends CommonObject
}
$sql = 'SELECT s.rowid, s.nom as name, s.name_alias, s.entity, s.ref_ext, s.address, s.datec as date_creation, s.prefix_comm';
- $sql .= ', s.status';
+ $sql .= ', s.status, s.fk_warehouse';
$sql .= ', s.price_level';
$sql .= ', s.tms as date_modification, s.fk_user_creat, s.fk_user_modif';
$sql .= ', s.phone, s.fax, s.email';
@@ -1757,6 +1763,9 @@ class Societe extends CommonObject
// multiprix
$this->price_level = $obj->price_level;
+
+ // warehouse
+ $this->fk_warehouse = $obj->fk_warehouse;
$this->import_key = $obj->import_key;