From 7fd5a74742fd4675aa19ed9fa1dbcf505a4c37f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 6 Apr 2011 13:04:56 +0000 Subject: [PATCH] Fix: use entity in action table if action is not linked with a third party --- htdocs/comm/action/class/actioncomm.class.php | 5 ++-- htdocs/comm/action/listactions.php | 8 ++--- htdocs/comm/action/rapport/index.php | 7 ++--- htdocs/includes/boxes/box_actions.php | 6 ++-- .../install/mysql/migration/3.0.0-3.1.0.sql | 2 ++ .../install/mysql/tables/llx_actioncomm.sql | 30 ++++++++++--------- 6 files changed, 30 insertions(+), 28 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 0464e93baaf..1ce4d4208c1 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 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 @@ -430,8 +430,9 @@ class ActionComm extends CommonObject $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= ")"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid AND s.entity in (0, ".$conf->entity.")"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid AND s.entity IN (0, ".$conf->entity.")"; $sql.= " WHERE a.percent >= 0 AND a.percent < 100"; + $sql.= " AND a.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND a.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id; //print $sql; diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index 9783180780d..12c255c3223 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2003 Eric Seigne * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 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 @@ -133,14 +133,14 @@ $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c,"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; $sql.= " ".MAIN_DB_PREFIX.'user as u,'; $sql.= " ".MAIN_DB_PREFIX."actioncomm as a)"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid AND s.entity IN (0, ".$conf->entity.")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON a.fk_user_author = ua.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ut ON a.fk_user_action = ut.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ud ON a.fk_user_done = ud.rowid"; $sql.= " WHERE c.id = a.fk_action"; -$sql.= ' AND a.fk_user_author = u.rowid'; // To limit to entity -$sql.= ' AND u.entity in (0,'.$conf->entity.')'; // To limit to entity +$sql.= ' AND a.fk_user_author = u.rowid'; +$sql.= ' AND a.entity = '.$conf->entity; // To limit to entity if ($pid) $sql.=" AND a.fk_project=".$db->escape($pid); if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index d4a52016c61..775ebc2997b 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2003 Eric Seigne * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 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 @@ -76,10 +76,7 @@ $sql.= " date_format(a.datep, '%Y') as year"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a,"; $sql.= " ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE a.fk_user_author = u.rowid"; -if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) -{ - $sql.= " AND u.entity in (0, ".$conf->entity.")"; -} +$sql.= " AND a.entity = ".$conf->entity; $sql.= " AND percent = 100"; $sql.= " GROUP BY year, month, df"; $sql.= " ORDER BY year DESC, month DESC, df DESC"; diff --git a/htdocs/includes/boxes/box_actions.php b/htdocs/includes/boxes/box_actions.php index bfa8b7e7956..66f29599cc5 100644 --- a/htdocs/includes/boxes/box_actions.php +++ b/htdocs/includes/boxes/box_actions.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2011 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 @@ -76,10 +76,10 @@ class box_actions extends ModeleBoxes { $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, "; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " ".MAIN_DB_PREFIX."societe_commerciaux AS sc, "; $sql.= MAIN_DB_PREFIX."actioncomm AS a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe AS s ON a.fk_soc = s.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid AND s.entity IN (0, ".$conf->entity.")"; $sql.= " WHERE a.fk_action = ta.id"; + $sql.= " AND a.entity = ".$conf->entity; $sql.= " AND a.percent <> 100"; - $sql.= " AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id; $sql.= " ORDER BY a.datec DESC"; diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index fa8f4e83ba5..9901f287259 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -66,3 +66,5 @@ INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (2, 'AV_1W', 'O INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', 'Two weeks', 1); INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', 'Three weeks', 1); +ALTER TABLE llx_actioncomm ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; + diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index d2a733f1c85..bb307db0636 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -1,6 +1,7 @@ -- ======================================================================== -- Copyright (C) 2001-2003 Rodolphe Quiedeville -- Copyright (C) 2005-2010 Laurent Destailleur +-- Copyright (C) 2011 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 @@ -24,33 +25,34 @@ create table llx_actioncomm ( id integer AUTO_INCREMENT PRIMARY KEY, - datep datetime, -- date debut planifiee - datep2 datetime, -- deprecated - datea datetime, -- date debut realisation - datea2 datetime, -- deprecated + entity integer DEFAULT 1 NOT NULL, -- multi company id + datep datetime, -- date debut planifiee + datep2 datetime, -- deprecated + datea datetime, -- date debut realisation + datea2 datetime, -- deprecated - fk_action integer, -- type de l'action - label varchar(128) NOT NULL, -- libelle de l'action + fk_action integer, -- type de l'action + label varchar(128) NOT NULL, -- libelle de l'action - datec datetime, -- date creation - tms timestamp, -- date modif - fk_user_author integer, -- id user qui a cree l'action - fk_user_mod integer, -- id dernier user qui a modifier l'action + datec datetime, -- date creation + tms timestamp, -- date modif + fk_user_author integer, -- id user qui a cree l'action + fk_user_mod integer, -- id dernier user qui a modifier l'action fk_project integer, fk_soc integer, fk_contact integer, fk_parent integer NOT NULL default 0, - fk_user_action integer, -- id de la personne qui doit effectuer l'action - fk_user_done integer, -- id de la personne qui a effectue l'action + fk_user_action integer, -- id de la personne qui doit effectuer l'action + fk_user_done integer, -- id de la personne qui a effectue l'action priority smallint, fulldayevent smallint NOT NULL default 0, punctual smallint NOT NULL default 1, percent smallint NOT NULL default 0, location varchar(128), - durationp real, -- duree planifiee - durationa real, -- deprecated + durationp real, -- duree planifiee + durationa real, -- deprecated note text, propalrowid integer,