diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php
index 34d08c0aeb0..29abfaa2c92 100644
--- a/htdocs/projet/activity/index.php
+++ b/htdocs/projet/activity/index.php
@@ -71,7 +71,7 @@ if ($mode == 'mine') $sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as pta";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.fk_soc = s.rowid";
-$sql.= " AND s.entity = ".$conf->entity;
+$sql.= " AND p.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
if ($mode == 'mine') $sql.=" AND t.rowid = pta.fk_projet_task";
@@ -295,7 +295,7 @@ else
}
print "";
-/* Affichage de la liste des projets de l'année */
+/* Affichage de la liste des projets de l'ann�e */
print '
';
print '';
print '| '.$langs->trans("ActivityOnProjectThisYear").': '.strftime("%Y", $now).' | ';
diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php
index 3343a64ace4..779f42f573c 100644
--- a/htdocs/projet/index.php
+++ b/htdocs/projet/index.php
@@ -57,15 +57,12 @@ print ''.$langs->trans("NbOpenTasks").' | ';
print "
\n";
$sql = "SELECT p.title, p.rowid, count(t.rowid)";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
-$sql.= ", ".MAIN_DB_PREFIX."projet as p";
-//$sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; // pourquoi est-ce que c'était en commentaire ? => Si on laisse ce lien, les projet sans taches se retrouvent invisibles
+$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
+if (!$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t ON p.rowid = t.fk_projet";
-$sql.= " WHERE p.fk_soc = s.rowid";
-$sql.= " AND s.entity = ".$conf->entity;
+$sql.= " WHERE p.entity = ".$conf->entity;
if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id;
-if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
$sql.= " GROUP BY p.rowid";
@@ -105,14 +102,12 @@ print_liste_field_titre($langs->trans("Company"),"index.php","s.nom","","","",$s
print ''.$langs->trans("NbOfProjects").' | ';
print "\n";
-$sql = "SELECT s.nom, s.rowid as socid, count(p.rowid)";
-$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
-$sql.= ", ".MAIN_DB_PREFIX."projet as p";
-if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
-$sql.= " WHERE p.fk_soc = s.rowid";
-$sql.= " AND s.entity = ".$conf->entity;
+$sql = "SELECT count(p.rowid) as nb, s.nom, s.rowid as socid";
+$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
+if (!$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+$sql.= " WHERE p.entity = ".$conf->entity;
if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id;
-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;
$sql.= " GROUP BY s.nom";
//$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
@@ -126,11 +121,20 @@ if ( $resql )
while ($i < $num)
{
- $row = $db->fetch_row( $resql);
+ $obj = $db->fetch_object($resql);
$var=!$var;
print "";
- print '| '.img_object($langs->trans("ShowCompany"),"company")." ".$row[0].' | ';
- print ''.$row[2].' | ';
+ print '';
+ if ($obj->socid)
+ {
+ print ''.img_object($langs->trans("ShowCompany"),"company")." ".$obj->nom.'';
+ }
+ else
+ {
+ print $langs->trans("Public");
+ }
+ print ' | ';
+ print ''.$obj->nb.' | ';
print "
\n";
$i++;
diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php
index 6fd09d39a54..345887b8a17 100644
--- a/htdocs/projet/liste.php
+++ b/htdocs/projet/liste.php
@@ -77,7 +77,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX
$sql.= ")";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on p.fk_user_resp = u.rowid";
-$sql.= " WHERE s.entity = ".$conf->entity;
+$sql.= " WHERE p.entity = ".$conf->entity;
if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id;
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/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql
index 9d595334426..3368b6afadd 100644
--- a/mysql/migration/2.6.0-2.7.0.sql
+++ b/mysql/migration/2.6.0-2.7.0.sql
@@ -84,6 +84,7 @@ ALTER TABLE llx_dolibarr_modules ADD COLUMN entity integer DEFAULT 1 NOT NULL AF
ALTER TABLE llx_bank_categ ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER label;
ALTER TABLE llx_bordereau_cheque ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER number;
ALTER TABLE llx_prelevement_bons ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER ref;
+ALTER TABLE llx_projet 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;
@@ -108,6 +109,7 @@ ALTER TABLE llx_livraison DROP INDEX idx_livraison_uk_ref;
ALTER TABLE llx_fichinter DROP INDEX ref;
ALTER TABLE llx_dolibarr_modules DROP PRIMARY KEY;
ALTER TABLE llx_prelevement_bons DROP INDEX ref;
+ALTER TABLE llx_projet DROP INDEX 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);
@@ -134,6 +136,11 @@ ALTER TABLE llx_contrat ADD UNIQUE INDEX uk_contrat_ref (ref, entity);
ALTER TABLE llx_dolibarr_modules ADD PRIMARY KEY pk_dolibarr_modules (numero, entity);
ALTER TABLE llx_bordereau_cheque ADD UNIQUE INDEX uk_bordereau_cheque (number, entity);
ALTER TABLE llx_prelevement_bons ADD UNIQUE INDEX uk_prelevement_bons_ref (ref, entity);
+ALTER TABLE llx_projet ADD UNIQUE INDEX uk_projet_ref (ref, entity);
+
+ALTER TABLE llx_projet ADD INDEX idx_projet_fk_soc (fk_soc);
+ALTER TABLE llx_projet ADD CONSTRAINT fk_projet_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
+
UPDATE llx_const SET entity=0 WHERE name='MAIN_MODULE_USER' AND entity=1;
UPDATE llx_const SET entity=0 WHERE name='MAIN_POPUP_CALENDAR' AND entity=1;
diff --git a/mysql/tables/llx_projet.key.sql b/mysql/tables/llx_projet.key.sql
new file mode 100644
index 00000000000..552a985abd4
--- /dev/null
+++ b/mysql/tables/llx_projet.key.sql
@@ -0,0 +1,27 @@
+-- ============================================================================
+-- Copyright (C) 2002-2004 Rodolphe Quiedeville
+-- Copyright (C) 2004-2009 Laurent Destailleur
+-- Copyright (C) 2005-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
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program; if not, write to the Free Software
+-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--
+-- $Id$
+-- ============================================================================
+
+
+ALTER TABLE llx_projet ADD UNIQUE INDEX uk_projet_ref (ref, entity);
+
+ALTER TABLE llx_projet ADD INDEX idx_projet_fk_soc (fk_soc);
+ALTER TABLE llx_projet ADD CONSTRAINT fk_projet_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
diff --git a/mysql/tables/llx_projet.sql b/mysql/tables/llx_projet.sql
index d3465fd8190..7fdb45fbe9c 100644
--- a/mysql/tables/llx_projet.sql
+++ b/mysql/tables/llx_projet.sql
@@ -26,11 +26,9 @@ create table llx_projet
tms timestamp,
dateo date, -- date d'ouverture du projet
ref varchar(50),
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
title varchar(255),
fk_user_resp integer, -- responsable du projet
fk_user_creat integer, -- createur du projet
- note text,
-
- UNIQUE INDEX(ref)
-
+ note text
)type=innodb;