dolibarr/htdocs/projet/index.php

134 lines
3.8 KiB
PHP
Raw Normal View History

2004-10-20 22:06:49 +02:00
<?php
2005-04-05 13:22:28 +02:00
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2010-02-15 02:21:47 +01:00
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
2003-09-04 13:08:03 +02:00
*
* 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
2011-08-01 01:19:04 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2003-09-04 13:08:03 +02:00
*/
2005-04-07 02:03:07 +02:00
/**
* \file htdocs/projet/index.php
* \ingroup projet
2010-02-15 02:21:47 +01:00
* \brief Main project home page
*/
require("../main.inc.php");
2010-04-29 16:34:21 +02:00
require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php");
$langs->load("projects");
2010-08-20 18:05:07 +02:00
$langs->load("companies");
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
// Security check
$socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id;
2010-02-15 02:21:47 +01:00
if (!$user->rights->projet->lire) accessforbidden();
2003-09-04 13:08:03 +02:00
/*
* View
*/
$socstatic=new Societe($db);
$projectstatic=new Project($db);
2009-10-17 00:46:16 +02:00
2011-04-20 01:21:10 +02:00
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:($user->rights->projet->all->lire?2:0)),1);
//var_dump($projectsListId);
2011-04-20 01:21:10 +02:00
2009-08-12 14:59:14 +02:00
llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos");
2004-07-21 16:26:46 +02:00
2009-01-15 00:36:51 +01:00
$text=$langs->trans("Projects");
if ($mine) $text=$langs->trans("MyProjects");
2009-01-15 00:36:51 +01:00
print_fiche_titre($text);
2003-09-04 13:08:03 +02:00
// Show description of content
if ($mine) print $langs->trans("MyProjectsDesc").'<br><br>';
2005-08-21 14:09:51 +02:00
else
{
if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'<br><br>';
else print $langs->trans("ProjectsPublicDesc").'<br><br>';
2005-08-21 14:09:51 +02:00
}
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td width="30%" valign="top" class="notopnoleft">';
2011-04-20 01:21:10 +02:00
print_projecttasks_array($db,$socid,$projectsListId);
2005-08-21 14:09:51 +02:00
2011-08-08 17:28:00 +02:00
print '</td><td width="70%" valign="top" class="notopnoleftnoright">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
2010-02-15 02:21:47 +01:00
print_liste_field_titre($langs->trans("ThirdParties"),"index.php","s.nom","","","",$sortfield,$sortorder);
2009-07-15 17:04:58 +02:00
print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
2003-09-04 13:08:03 +02:00
$sql = "SELECT count(p.rowid) as nb";
$sql.= ", 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";
$sql.= " WHERE p.entity = ".$conf->entity;
2011-04-20 01:34:29 +02:00
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
2010-09-18 15:38:43 +02:00
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " GROUP BY s.nom, s.rowid";
2003-09-04 13:08:03 +02:00
$var=true;
2005-04-05 13:22:28 +02:00
$resql = $db->query($sql);
if ( $resql )
2003-09-04 13:08:03 +02:00
{
2009-01-15 00:36:51 +01:00
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
2009-01-15 00:36:51 +01:00
$var=!$var;
print "<tr $bc[$var]>";
print '<td nowrap="nowrap">';
if ($obj->socid)
{
$socstatic->id=$obj->socid;
$socstatic->nom=$obj->nom;
print $socstatic->getNomUrl(1);
}
else
{
2010-02-15 02:21:47 +01:00
print $langs->trans("OthersNotLinkedToThirdParty");
}
print '</td>';
2009-10-17 00:46:16 +02:00
print '<td align="right"><a href="'.DOL_URL_ROOT.'/projet/liste.php?socid='.$obj->socid.'">'.$obj->nb.'</a></td>';
2009-01-15 00:36:51 +01:00
print "</tr>\n";
$i++;
}
$db->free($resql);
2003-09-04 13:08:03 +02:00
}
else
{
dol_print_error($db);
2003-09-04 13:08:03 +02:00
}
print "</table>";
2005-08-21 14:09:51 +02:00
print '</td></tr></table>';
2003-09-04 13:08:03 +02:00
$db->close();
llxFooter();
2003-09-04 13:08:03 +02:00
?>