From 467ec4a64116f6fc0ce41120f3f34aed1c1131da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 30 Apr 2009 11:29:32 +0000 Subject: [PATCH] New: early development of multi-company module --- htdocs/expedition/commande.php | 3 +-- htdocs/expedition/fiche.php | 16 ++++++++------ htdocs/livraison/fiche.php | 6 ++--- mysql/migration/2.6.0-2.7.0.sql | 5 ++++- mysql/tables/llx_expedition.key.sql | 8 +++---- mysql/tables/llx_expedition.sql | 34 ++++++++++++++++------------- 6 files changed, 40 insertions(+), 32 deletions(-) diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index 687977e185d..b730a8b5219 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -49,9 +49,8 @@ $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action' // Security check $socid=0; -$comid = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'commande',$comid,''); +$result=restrictedArea($user,'commande',$id,''); // Chargement des permissions $error = $user->load_entrepots(); diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 861dd76de81..0895d15cb86 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -37,8 +37,6 @@ if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php" if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); -if (! $user->rights->expedition->lire) accessforbidden(); - $langs->load("companies"); $langs->load("bills"); $langs->load('deliveries'); @@ -47,16 +45,20 @@ $langs->load('stocks'); $langs->load('other'); $langs->load('propal'); -// Security check -$id = isset($_GET["id"])?$_GET["id"]:''; -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'expedition',$id,''); - +$origin = "expedition"; +$origin_id = isset($_GET["id"])?$_GET["id"]:''; +$id = $origin_id; $origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; // Example: commande, propal $origin_id = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"]; // Id of order or propal +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,$origin,$origin_id,''); + + + /* * Actions */ diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index a943cc60d34..194a316a5b8 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -44,7 +44,7 @@ $langs->load('deliveries'); // Security check $id = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'expedition',$id,'','livraison'); +$result=restrictedArea($user,'expedition',$id,'livraison','livraison'); /* @@ -67,8 +67,8 @@ if ($_POST["action"] == 'add') $expedition->entrepot_id = $_POST["entrepot_id"]; } - // On boucle sur chaque ligne de commande pour compl�ter objet livraison - // avec qt� � livrer + // On boucle sur chaque ligne de commande pour completer objet livraison + // avec qte a livrer $commande = new Commande($db); $commande->fetch($livraison->commande_id); $commande->fetch_lines(); diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql index e4c9f31e377..5fe8164a3ec 100644 --- a/mysql/migration/2.6.0-2.7.0.sql +++ b/mysql/migration/2.6.0-2.7.0.sql @@ -28,6 +28,7 @@ ALTER TABLE llx_commande ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_commande_fournisseur ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_product_fournisseur ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref_fourn; ALTER TABLE llx_facture ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER facnumber; +ALTER TABLE llx_expedition ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref; ALTER TABLE llx_rights_def DROP PRIMARY KEY; ALTER TABLE llx_user_param DROP INDEX fk_user; @@ -45,6 +46,7 @@ ALTER TABLE llx_commande_fournisseur DROP INDEX uk_commande_fournisseur_ref; ALTER TABLE llx_product_fournisseur DROP INDEX fk_product; ALTER TABLE llx_product_fournisseur DROP INDEX fk_soc; ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber; +ALTER TABLE llx_expedition DROP INDEX idx_expedition_uk_ref; ALTER TABLE llx_rights_def ADD PRIMARY KEY (id, entity); ALTER TABLE llx_user_param ADD UNIQUE INDEX uk_user_param (fk_user,param,entity); @@ -62,4 +64,5 @@ ALTER TABLE llx_commande_fournisseur ADD UNIQUE INDEX uk_commande_fournisseur_re ALTER TABLE llx_product_fournisseur ADD UNIQUE INDEX uk_product_fournisseur_ref (ref_fourn, fk_soc, entity); ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_product (fk_product, entity); ALTER TABLE llx_product_fournisseur ADD INDEX idx_product_fourn_fk_soc (fk_soc, entity); -ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber, entity); \ No newline at end of file +ALTER TABLE llx_facture ADD UNIQUE INDEX idx_facture_uk_facnumber (facnumber, entity); +ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref, entity); \ No newline at end of file diff --git a/mysql/tables/llx_expedition.key.sql b/mysql/tables/llx_expedition.key.sql index 845a649b828..f275ea9b50b 100644 --- a/mysql/tables/llx_expedition.key.sql +++ b/mysql/tables/llx_expedition.key.sql @@ -1,6 +1,6 @@ -- =================================================================== --- Copyright (C) 2005 Laurent Destailleur --- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2008-2009 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -20,6 +20,8 @@ -- =================================================================== +ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref, entity); + ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc); ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author); ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid); @@ -31,5 +33,3 @@ ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FO ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_adresse_livraison FOREIGN KEY (fk_adresse_livraison) REFERENCES llx_societe_adresse_livraison (rowid); ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid); - -ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref); \ No newline at end of file diff --git a/mysql/tables/llx_expedition.sql b/mysql/tables/llx_expedition.sql index a397b65441d..19d6d97fbbb 100644 --- a/mysql/tables/llx_expedition.sql +++ b/mysql/tables/llx_expedition.sql @@ -1,6 +1,6 @@ -- =================================================================== -- Copyright (C) 2003-2008 Rodolphe Quiedeville --- Copyright (C) 2008 Regis Houssin +-- Copyright (C) 2008-2009 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -23,23 +23,27 @@ create table llx_expedition ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, - ref varchar(30) NOT NULL, - fk_soc integer NOT NULL, - date_creation datetime, -- date de creation - fk_user_author integer, -- createur - date_valid datetime, -- date de validation - fk_user_valid integer, -- valideur - date_expedition date, -- date de l'expedition - fk_adresse_livraison integer DEFAULT NULL, -- adresse de livraison + ref varchar(30) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_soc integer NOT NULL, + + date_creation datetime, -- date de creation + fk_user_author integer, -- createur + date_valid datetime, -- date de validation + fk_user_valid integer, -- valideur + date_expedition date, -- date de lexpedition + fk_adresse_livraison integer DEFAULT NULL, -- adresse de livraison fk_expedition_methode integer, tracking_number varchar(50), fk_statut smallint DEFAULT 0, - height integer, - width integer, - size_units integer, - size integer, - weight_units integer, - weight integer, + + height integer, + width integer, + size_units integer, + size integer, + weight_units integer, + weight integer, note text, model_pdf varchar(50) + )type=innodb;