dolibarr/htdocs/projet/index.php

161 lines
4.7 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>
2009-07-15 17:04:58 +02:00
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 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
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
2005-04-07 02:03:07 +02:00
/**
* \file htdocs/projet/index.php
* \ingroup projet
* \brief Page d'accueil du module projet
* \version $Id$
*/
2003-09-04 13:08:03 +02:00
require("./pre.inc.php");
$langs->load("projects");
2005-08-21 14:09:51 +02:00
if (!$user->rights->projet->lire) accessforbidden();
// Security check
2009-01-15 00:36:51 +01:00
if ($user->societe_id > 0)
2003-09-04 13:08:03 +02:00
{
$socid = $user->societe_id;
2003-09-04 13:08:03 +02:00
}
/*
* View
*/
2009-10-17 00:46:16 +02:00
$company=new Societe($db);
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 ($_REQUEST["mode"]=='mine') $text=$langs->trans("MyProjects");
print_fiche_titre($text);
2003-09-04 13:08:03 +02:00
2005-08-21 21:40:40 +02:00
print '<table border="0" width="100%" class="notopnoleftnoright">';
print '<tr><td width="30%" valign="top" class="notopnoleft">';
2003-09-04 13:08:03 +02:00
2005-08-21 14:09:51 +02:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
2009-01-15 00:36:51 +01:00
print_liste_field_titre($langs->trans("Project"),"index.php","","","","",$sortfield,$sortorder);
2009-07-15 17:04:58 +02:00
print_liste_field_titre($langs->trans("NbOpenTasks"),"","","","",'align="right"',$sortfield,$sortorder);
2005-08-21 14:09:51 +02:00
print "</tr>\n";
2005-04-05 13:22:28 +02:00
2005-08-21 14:09:51 +02:00
$sql = "SELECT p.title, p.rowid, count(t.rowid)";
$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.entity = ".$conf->entity;
2009-01-15 00:36:51 +01:00
if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
2005-08-31 23:12:15 +02:00
$sql.= " GROUP BY p.rowid";
2003-09-04 13:08:03 +02:00
2005-08-21 14:09:51 +02:00
$var=true;
$resql = $db->query($sql);
if ( $resql )
{
2009-01-15 00:36:51 +01:00
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row( $resql);
$var=!$var;
print "<tr $bc[$var]>";
print '<td nowrap="nowrap"><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$row[1].'">'.img_object($langs->trans("ShowProject"),"project")." ".$row[0].'</a></td>';
print '<td align="right">'.$row[2].'</td>';
print "</tr>\n";
$i++;
}
$db->free($resql);
2005-08-21 14:09:51 +02:00
}
else
{
dol_print_error($db);
2005-08-21 14:09:51 +02:00
}
print "</table>";
2005-08-22 19:25:53 +02:00
print '</td><td width="70%" valign="top" class="notopnoleft">';
2004-11-23 20:15:22 +01:00
2009-01-15 00:36:51 +01:00
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Company"),"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, 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;
2009-01-15 00:36:51 +01:00
if ($_REQUEST["mode"]=='mine') $sql.=' AND p.fk_user_resp='.$user->id;
if ($socid) $sql.= " AND s.rowid = ".$socid;
$sql.= " GROUP BY s.nom";
2005-08-21 14:09:51 +02:00
//$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit, $offset);
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)
{
2009-10-17 00:46:16 +02:00
$company->id=$obj->socid;
$company->nom=$obj->nom;
print $company->getNomUrl(1);
}
else
{
print $langs->trans("Public");
}
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();
2009-01-15 00:36:51 +01:00
llxFooter('$Date$ - $Revision$');
2003-09-04 13:08:03 +02:00
?>