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 >
2006-06-03 18:50:58 +02:00
* Copyright ( C ) 2004 - 2006 Laurent Destailleur < eldy @ users . sourceforge . net >
2007-11-01 21:39:36 +01:00
* Copyright ( C ) 2005 - 2006 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 .
*/
2004-08-14 15:16:01 +02:00
2005-04-07 02:03:07 +02:00
/**
2008-09-10 22:49:21 +02:00
* \file htdocs / projet / index . php
* \ingroup projet
* \brief Page d ' accueil du module projet
* \version $Id $
*/
2004-08-14 15:16:01 +02:00
2003-09-04 13:08:03 +02:00
require ( " ./pre.inc.php " );
2004-08-07 03:25:00 +02:00
$langs -> load ( " projects " );
2005-08-21 14:09:51 +02:00
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
2008-09-10 22:49:21 +02:00
// Security check
2003-09-04 13:08:03 +02:00
if ( $user -> societe_id > 0 )
{
2008-09-10 22:49:21 +02:00
$socid = $user -> societe_id ;
2003-09-04 13:08:03 +02:00
}
2008-09-10 22:49:21 +02:00
/*
* View
*/
2004-11-12 02:17:41 +01:00
llxHeader ( " " , $langs -> trans ( " Projects " ), " Projet " );
2004-07-21 16:26:46 +02:00
2005-08-21 21:40:40 +02:00
print_fiche_titre ( $langs -> trans ( " ProjectsArea " ));
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
/*
*
* Affichage de la liste des projets
*
*/
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2007-11-11 16:55:45 +01:00
print_liste_field_titre ( $langs -> trans ( " Project " ), " index.php " , " s.nom " , " " , " " , " " , $sortfield , $sortorder );
2005-08-31 23:12:15 +02:00
print '<td align="right">' . $langs -> trans ( " NbOpenTasks " ) . '</td>' ;
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) " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2008-03-21 01:27:37 +01:00
$sql .= " FROM " ;
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'<27> tait en commentaire ? => Si on laisse ce lien, les projet sans taches se retrouvent invisibles
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " projet_task as t ON p.rowid = t.fk_projet " ;
2008-03-31 08:29:10 +02:00
$sql .= " WHERE 1 = 1 " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2005-08-21 14:09:51 +02:00
{
2006-09-13 20:56:30 +02:00
$sql .= " AND p.fk_soc = " . $socid ;
2005-08-21 14:09:51 +02:00
}
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 )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
while ( $i < $num )
{
$row = $db -> fetch_row ( $resql );
$var =! $var ;
print " <tr $bc[$var] > " ;
2008-06-18 22:01:01 +02:00
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>' ;
2005-08-31 23:12:15 +02:00
print '<td align="right">' . $row [ 2 ] . '</td>' ;
2005-08-21 14:09:51 +02:00
print " </tr> \n " ;
$i ++ ;
}
$db -> free ( $resql );
}
else
{
dolibarr_print_error ( $db );
}
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
2003-09-04 13:08:03 +02:00
/*
*
2004-11-23 20:15:22 +01:00
* Affichage de la liste des projets
2003-09-04 13:08:03 +02:00
*
*/
2004-10-31 14:32:01 +01:00
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2007-11-11 16:55:45 +01:00
print_liste_field_titre ( $langs -> trans ( " Company " ), " index.php " , " s.nom " , " " , " " , " " , $sortfield , $sortorder );
2008-09-10 22:49:21 +02:00
print '<td align="right">' . $langs -> trans ( " NbOfProjects " ) . '</td>' ;
2004-10-31 14:32:01 +01:00
print " </tr> \n " ;
2003-09-04 13:08:03 +02:00
2007-06-12 00:51:47 +02:00
$sql = " SELECT s.nom, s.rowid as socid, count(p.rowid) " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
2004-02-01 02:33:59 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " projet as p " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE p.fk_soc = s.rowid " ;
2008-03-01 02:26:41 +01:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-09-13 20:56:30 +02:00
if ( $socid )
2003-09-04 13:08:03 +02:00
{
2007-06-12 00:51:47 +02:00
$sql .= " AND s.rowid = " . $socid ;
2003-09-04 13:08:03 +02:00
}
2005-04-05 13:22:28 +02:00
$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
2004-08-07 03:25:00 +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
{
2005-04-05 13:22:28 +02:00
$num = $db -> num_rows ( $resql );
2003-09-04 13:08:03 +02:00
$i = 0 ;
while ( $i < $num )
{
2005-04-05 13:22:28 +02:00
$row = $db -> fetch_row ( $resql );
2003-09-04 13:08:03 +02:00
$var =! $var ;
2004-04-10 21:04:14 +02:00
print " <tr $bc[$var] > " ;
2008-06-18 22:01:01 +02:00
print '<td nowrap="nowrap"><a href="' . DOL_URL_ROOT . '/projet/liste.php?socid=' . $row [ 1 ] . '">' . img_object ( $langs -> trans ( " ShowCompany " ), " company " ) . " " . $row [ 0 ] . '</a></td>' ;
2005-08-31 23:12:15 +02:00
print '<td align="right">' . $row [ 2 ] . '</td>' ;
2003-09-04 13:12:30 +02:00
print " </tr> \n " ;
2003-09-04 13:08:03 +02:00
$i ++ ;
}
2005-04-05 13:22:28 +02:00
$db -> free ( $resql );
2003-09-04 13:08:03 +02:00
}
else
{
2004-11-12 02:17:41 +01:00
dolibarr_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 ();
2004-11-12 02:17:41 +01:00
2003-09-04 13:08:03 +02:00
llxFooter ( " <em>Dernière modification $Date $ révision $Revision $ </em> " );
?>