* Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2010 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 3 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, see . */ /** * \file htdocs/projet/index.php * \ingroup projet * \brief Main project home page */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("projects"); $langs->load("companies"); $mine = GETPOST('mode')=='mine' ? 1 : 0; // Security check $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); /* * View */ $socstatic=new Societe($db); $projectstatic=new Project($db); $userstatic=new User($db); $form=new Form($db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,($mine?$mine:(empty($user->rights->projet->all->lire)?0:2)),1); //var_dump($projectsListId); llxHeader("",$langs->trans("Projects"),"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); $text=$langs->trans("ProjectsArea"); if ($mine) $text=$langs->trans("MyProjectsArea"); print load_fiche_titre($text,'','title_project.png'); // Show description of content if ($mine) print $langs->trans("MyProjectsDesc").'

'; else { if (! empty($user->rights->projet->all->lire) && ! $socid) print $langs->trans("ProjectsDesc").'

'; else print $langs->trans("ProjectsPublicDesc").'

'; } // Get list of ponderated percent for each status $listofoppstatus=array(); $listofopplabel=array(); $listofoppcode=array(); $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls"; $resql = $db->query($sql); if ( $resql ) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $listofoppstatus[$objp->rowid]=$objp->percent; $listofopplabel[$objp->rowid]=$objp->label; $listofoppcode[$objp->rowid]=$objp->code; $i++; } } else dol_print_error($db); print '
'; // Search project if (! empty($conf->projet->enabled) && $user->rights->projet->lire) { $listofsearchfields['search_project']=array('text'=>'Project'); } if (count($listofsearchfields)) { print '
'; print ''; print ''; $i=0; foreach($listofsearchfields as $key => $value) { if ($i == 0) print ''; print ''; print ''; if ($i == 0) print ''; print ''; $i++; } print '
'.$langs->trans("Search").'
'; print '
'; print '
'; } /* * Statistics */ include DOL_DOCUMENT_ROOT.'/projet/graph_opportunities.inc.php'; // List of draft projects print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 0, $listofoppstatus, array('projectlabel', 'plannedworkload', 'declaredprogress')); print '
'; print ''; print ''; print_liste_field_titre($langs->trans("OpenedProjectsByThirdparties"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder); print "\n"; $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; $sql.= ", s.nom as name, 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; $sql.= " AND p.fk_statut = 1"; if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; 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"; $sql.= $db->order($sortfield, $sortorder); $var=true; $resql = $db->query($sql); if ( $resql ) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); $var=!$var; print ""; print ''; print ''; print "\n"; $i++; } $db->free($resql); } else { dol_print_error($db); } print "
'; if ($obj->socid) { $socstatic->id=$obj->socid; $socstatic->name=$obj->name; print $socstatic->getNomUrl(1); } else { print $langs->trans("OthersNotLinkedToThirdParty"); } print ''.$obj->nb.'
"; if (! empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA)) { // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list print '
'; print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array()); } print '
'; llxFooter(); $db->close();