Skip to content
Snippets Groups Projects
Commit 7fd5a747 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: use entity in action table if action is not linked with a third party

parent 369c5038
No related branches found
No related tags found
No related merge requests found
<?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 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
......@@ -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;
......
......@@ -2,7 +2,7 @@
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 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
......@@ -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;
......
......@@ -2,7 +2,7 @@
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Eric Seigne <erics@rycks.com>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 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
......@@ -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";
......
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 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
......@@ -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";
......
......@@ -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;
-- ========================================================================
-- Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2011 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
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment