New: early development of multi-company module

This commit is contained in:
Regis Houssin 2009-04-30 11:29:32 +00:00
parent 38047abe4d
commit 467ec4a641
6 changed files with 40 additions and 32 deletions

View File

@ -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();

View File

@ -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
*/

View File

@ -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<EFBFBD>ter objet livraison
// avec qt<EFBFBD> <20> 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();

View File

@ -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);
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);

View File

@ -1,6 +1,6 @@
-- ===================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2008-2009 Regis Houssin <regis@dolibarr.fr>
--
-- 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);

View File

@ -1,6 +1,6 @@
-- ===================================================================
-- Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
-- Copyright (C) 2008-2009 Regis Houssin <regis@dolibarr.fr>
--
-- 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;