2006-03-09 12:35:25 +01:00
< ? php
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2016-01-28 20:04:02 +01:00
* Copyright ( C ) 2004 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-03-09 12:43:13 +01:00
* Copyright ( C ) 2005 Marc Bariley / Ocebo < marc @ ocebo . com >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2010 Regis Houssin < regis . houssin @ capnetworks . com >
2013-09-10 16:43:06 +02:00
* Copyright ( C ) 2013 Cédric Salvador < csalvador @ gpcsolutions . fr >
2015-04-14 12:21:23 +02:00
* Copyright ( C ) 2015 Claudio Aschieri < c . aschieri @ 19. coop >
2006-03-09 12:35:25 +01: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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2006-03-09 12:35:25 +01:00
* ( 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 />.
2006-03-09 12:35:25 +01:00
*/
2009-01-14 17:40:45 +01:00
/**
2014-09-18 20:33:37 +02:00
* \file htdocs / projet / list . php
2009-01-15 00:36:51 +01:00
* \ingroup projet
2010-01-05 00:33:23 +01:00
* \brief Page to list projects
2009-01-15 00:36:51 +01:00
*/
2006-03-09 12:35:25 +01:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2014-12-28 03:39:30 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
2015-01-29 18:17:43 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2015-06-30 01:34:17 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php' ;
2006-03-09 12:35:25 +01:00
2012-07-28 17:34:21 +02:00
$langs -> load ( 'projects' );
2015-12-06 01:19:27 +01:00
$langs -> load ( 'companies' );
$langs -> load ( 'commercial' );
2012-07-28 17:34:21 +02:00
2006-03-09 12:35:25 +01:00
$title = $langs -> trans ( " Projects " );
2008-09-10 22:49:21 +02:00
// Security check
2010-09-18 15:38:43 +02:00
$socid = ( is_numeric ( $_GET [ " socid " ]) ? $_GET [ " socid " ] : 0 );
2010-05-30 14:21:32 +02:00
if ( $user -> societe_id > 0 ) $socid = $user -> societe_id ;
2006-09-13 20:56:30 +02:00
if ( $socid > 0 )
2006-03-09 12:35:25 +01:00
{
2009-01-15 00:36:51 +01:00
$soc = new Societe ( $db );
$soc -> fetch ( $socid );
2014-10-04 17:20:17 +02:00
$title .= ' (<a href="list.php">' . $soc -> name . '</a>)' ;
2006-03-09 12:35:25 +01:00
}
2010-09-18 15:38:43 +02:00
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
2006-03-09 12:35:25 +01:00
2016-02-11 16:49:13 +01:00
$limit = GETPOST ( " limit " ) ? GETPOST ( " limit " , " int " ) : $conf -> liste_limit ;
2015-10-05 23:52:54 +02:00
$sortfield = GETPOST ( " sortfield " , " alpha " );
$sortorder = GETPOST ( " sortorder " );
$page = GETPOST ( " page " );
2006-03-09 12:35:25 +01:00
$page = is_numeric ( $page ) ? $page : 0 ;
$page = $page == - 1 ? 0 : $page ;
if ( ! $sortfield ) $sortfield = " p.ref " ;
if ( ! $sortorder ) $sortorder = " ASC " ;
$offset = $conf -> liste_limit * $page ;
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2015-06-22 11:55:21 +02:00
$search_all = GETPOST ( " search_all " );
2016-09-18 15:36:38 +02:00
$search_categ = GETPOST ( " search_categ " , 'alpha' );
2012-03-19 14:44:27 +01:00
$search_ref = GETPOST ( " search_ref " );
$search_label = GETPOST ( " search_label " );
$search_societe = GETPOST ( " search_societe " );
2014-12-28 03:39:30 +01:00
$search_year = GETPOST ( " search_year " );
2014-07-17 01:28:01 +02:00
$search_all = GETPOST ( " search_all " );
2015-01-29 18:17:43 +01:00
$search_status = GETPOST ( " search_status " , 'int' );
2015-08-31 15:52:54 +02:00
$search_opp_status = GETPOST ( " search_opp_status " , 'alpha' );
2016-01-28 20:04:02 +01:00
$search_opp_percent = GETPOST ( " search_opp_percent " , 'alpha' );
2016-02-11 16:49:13 +01:00
$search_opp_amount = GETPOST ( " search_opp_amount " , 'alpha' );
2016-06-16 12:42:21 +02:00
$search_budget_amount = GETPOST ( " search_budget_amount " , 'alpha' );
2015-01-29 18:17:43 +01:00
$search_public = GETPOST ( " search_public " , 'int' );
2015-01-30 11:08:49 +01:00
$search_user = GETPOST ( 'search_user' , 'int' );
$search_sale = GETPOST ( 'search_sale' , 'int' );
2015-10-04 10:45:57 +02:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2015-01-29 18:17:43 +01:00
2015-12-04 15:37:28 +01:00
$mine = $_REQUEST [ 'mode' ] == 'mine' ? 1 : 0 ;
2016-01-21 14:59:09 +01:00
if ( $mine ) { $search_user = $user -> id ; $mine = 0 ; }
2015-12-04 15:37:28 +01:00
2015-04-14 12:21:23 +02:00
$sday = GETPOST ( 'sday' , 'int' );
$smonth = GETPOST ( 'smonth' , 'int' );
$syear = GETPOST ( 'syear' , 'int' );
2016-01-19 23:45:03 +01:00
$day = GETPOST ( 'day' , 'int' );
$month = GETPOST ( 'month' , 'int' );
$year = GETPOST ( 'year' , 'int' );
2015-01-29 18:17:43 +01:00
2015-02-07 03:54:00 +01:00
if ( $search_status == '' ) $search_status =- 1 ; // -1 or 1
2012-03-19 14:44:27 +01:00
2016-01-21 14:59:09 +01:00
2016-06-07 14:06:00 +02:00
// Initialize context for list
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'projectlist' ;
2015-12-02 23:20:19 +01:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager -> initHooks ( array ( $contextpage ));
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2016-04-04 16:02:29 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( 'projet' );
2015-12-02 23:20:19 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $extralabels , '' , 'search_' );
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array (
'p.ref' => " Ref " ,
'p.title' => " Label " ,
's.nom' => " ThirdPartyName " ,
" p.note_public " => " NotePublic "
);
if ( empty ( $user -> socid )) $fieldstosearchall [ " p.note_private " ] = " NotePrivate " ;
$arrayfields = array (
'p.ref' => array ( 'label' => $langs -> trans ( " Ref " ), 'checked' => 1 ),
2015-12-06 01:19:27 +01:00
'p.title' => array ( 'label' => $langs -> trans ( " Label " ), 'checked' => 1 ),
2016-03-25 19:42:14 +01:00
's.nom' => array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 1 , 'enabled' => $conf -> societe -> enabled ),
2015-12-06 01:19:27 +01:00
'commercial' => array ( 'label' => $langs -> trans ( " SalesRepresentative " ), 'checked' => 1 ),
'p.dateo' => array ( 'label' => $langs -> trans ( " DateStart " ), 'checked' => 1 , 'position' => 100 ),
'p.datee' => array ( 'label' => $langs -> trans ( " DateEnd " ), 'checked' => 1 , 'position' => 101 ),
'p.public' => array ( 'label' => $langs -> trans ( " Visibility " ), 'checked' => 1 , 'position' => 102 ),
2016-05-21 12:06:33 +02:00
'p.opp_amount' => array ( 'label' => $langs -> trans ( " OpportunityAmountShort " ), 'checked' => 1 , 'enabled' => ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ? 1 : 0 ), 'position' => 103 ),
'p.fk_opp_status' => array ( 'label' => $langs -> trans ( " OpportunityStatusShort " ), 'checked' => 1 , 'enabled' => ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ? 1 : 0 ), 'position' => 104 ),
'p.opp_percent' => array ( 'label' => $langs -> trans ( " OpportunityProbabilityShort " ), 'checked' => 1 , 'enabled' => ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ? 1 : 0 ), 'position' => 105 ),
2016-06-16 12:42:21 +02:00
'p.budget_amount' => array ( 'label' => $langs -> trans ( " Budget " ), 'checked' => 0 , 'position' => 110 ),
2016-01-28 20:04:02 +01:00
'p.datec' => array ( 'label' => $langs -> trans ( " DateCreationShort " ), 'checked' => 0 , 'position' => 500 ),
2015-12-02 23:20:19 +01:00
'p.tms' => array ( 'label' => $langs -> trans ( " DateModificationShort " ), 'checked' => 0 , 'position' => 500 ),
2016-01-21 14:59:09 +01:00
'p.fk_statut' => array ( 'label' => $langs -> trans ( " Status " ), 'checked' => 1 , 'position' => 1000 ),
2015-12-02 23:20:19 +01:00
);
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
$arrayfields [ " ef. " . $key ] = array ( 'label' => $extrafields -> attribute_label [ $key ], 'checked' => $extrafields -> attribute_list [ $key ], 'position' => $extrafields -> attribute_pos [ $key ], 'enabled' => $extrafields -> attribute_perms [ $key ]);
}
}
/*
* Actions
*/
2016-11-02 12:48:50 +01:00
if ( GETPOST ( 'cancel' )) { $action = 'list' ; $massaction = '' ; }
if ( ! GETPOST ( 'confirmmassaction' ) && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills' ) { $massaction = '' ; }
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
if ( empty ( $reshook ))
{
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
2006-03-09 12:35:25 +01:00
2016-11-02 12:48:50 +01:00
// Purge search criteria
if ( GETPOST ( " button_removefilter_x " ) || GETPOST ( " button_removefilter.x " ) || GETPOST ( " button_removefilter " )) // Both test are required to be compatible with all browsers
{
$search_all = '' ;
$search_categ = '' ;
$search_ref = " " ;
$search_label = " " ;
$search_societe = " " ;
$search_year = " " ;
$search_status =- 1 ;
$search_opp_status =- 1 ;
$search_opp_amount = '' ;
$search_opp_percent = '' ;
$search_budget_amount = '' ;
$search_public = " " ;
$search_sale = " " ;
$search_user = '' ;
$sday = " " ;
$smonth = " " ;
$syear = " " ;
$day = " " ;
$month = " " ;
$year = " " ;
$search_array_options = array ();
}
}
2015-06-16 19:36:44 +02:00
2009-01-14 17:40:45 +01:00
/*
* View
2006-03-09 12:35:25 +01:00
*/
2009-01-15 00:36:51 +01:00
$projectstatic = new Project ( $db );
2010-02-04 16:30:42 +01:00
$socstatic = new Societe ( $db );
2015-01-29 18:17:43 +01:00
$form = new Form ( $db );
$formother = new FormOther ( $db );
2015-06-30 01:34:17 +02:00
$formproject = new FormProjets ( $db );
2008-03-02 23:20:44 +01:00
2016-01-21 14:59:09 +01:00
$title = $langs -> trans ( " Projects " );
if ( $search_user == $user -> id ) $title = $langs -> trans ( " MyProjects " );
2012-03-19 14:44:27 +01:00
2016-01-21 14:59:09 +01:00
// Get list of project id allowed to user (in a string list separated by coma)
if ( ! $user -> rights -> projet -> all -> lire ) $projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 , $socid );
// Get id of types of contacts for projects (This list never contains a lot of elements)
$listofprojectcontacttype = array ();
$sql = " SELECT ctc.rowid, ctc.code FROM " . MAIN_DB_PREFIX . " c_type_contact as ctc " ;
$sql .= " WHERE ctc.element = ' " . $projectstatic -> element . " ' " ;
$sql .= " AND ctc.source = 'internal' " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
while ( $obj = $db -> fetch_object ( $resql ))
{
$listofprojectcontacttype [ $obj -> rowid ] = $obj -> code ;
}
}
else dol_print_error ( $db );
if ( count ( $listofprojectcontacttype ) == 0 ) $listofprojectcontacttype [ 0 ] = '0' ; // To avoid sql syntax error if not found
2010-02-04 18:54:00 +01:00
2016-09-18 15:36:38 +02:00
2016-01-21 14:59:09 +01:00
$distinct = 'DISTINCT' ; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
$sql = " SELECT " . $distinct . " p.rowid as projectid, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat " ;
2016-06-22 20:22:22 +02:00
$sql .= " , p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount " ;
2014-10-04 17:20:17 +02:00
$sql .= " , s.nom as name, s.rowid as socid " ;
2015-06-30 01:34:17 +02:00
$sql .= " , cls.code as opp_status_code " ;
2016-09-18 15:36:38 +02:00
// We'll need these fields in order to filter by categ
if ( $search_categ ) $sql .= " , cs.fk_categorie, cs.fk_project " ;
2015-06-22 15:48:48 +02:00
// Add fields for extrafields
2016-10-01 18:00:17 +02:00
foreach ( $extrafields -> attribute_label as $key => $val ) $sql .= ( $extrafields -> attribute_type [ $key ] != 'separate' ? " ,ef. " . $key . ' as options_' . $key : '' );
2015-06-22 15:48:48 +02:00
// Add fields from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2009-11-29 20:05:22 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " projet as p " ;
2016-04-04 16:02:29 +02:00
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " projet_extrafields as ef on (p.rowid = ef.fk_object) " ;
2009-04-27 22:37:50 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on p.fk_soc = s.rowid " ;
2015-06-30 01:34:17 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_lead_status as cls on p.fk_opp_status = cls.rowid " ;
2016-09-18 15:36:38 +02:00
// We'll need this table joined to the select in order to filter by categ
if ( ! empty ( $search_categ )) $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . " categorie_project as cs ON p.rowid = cs.fk_project " ; // We'll need this table joined to the select in order to filter by categ
2015-01-30 11:08:49 +01:00
// We'll need this table joined to the select in order to filter by sale
2015-10-05 23:52:54 +02:00
if ( $search_sale > 0 || ( ! $user -> rights -> societe -> client -> voir && ! $socid )) $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON sc.fk_soc = s.rowid " ;
2015-01-30 11:08:49 +01:00
if ( $search_user > 0 )
{
2016-01-21 14:59:09 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " element_contact as ecp " ;
2015-01-30 11:08:49 +01:00
}
2016-03-22 16:48:51 +01:00
$sql .= " WHERE p.entity IN ( " . getEntity ( 'project' , 1 ) . ')' ;
2016-01-21 14:59:09 +01:00
if ( ! $user -> rights -> projet -> all -> lire ) $sql .= " AND p.rowid IN ( " . $projectsListId . " ) " ; // public and assigned to, or restricted to company for external users
2010-09-18 15:38:43 +02:00
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
if ( $socid ) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . " ) " ;
2016-09-18 15:36:38 +02:00
if ( $search_categ > 0 ) $sql .= " AND cs.fk_categorie = " . $db -> escape ( $search_categ );
if ( $search_categ == - 2 ) $sql .= " AND cs.fk_categorie IS NULL " ;
2015-06-22 15:48:48 +02:00
if ( $search_ref ) $sql .= natural_search ( 'p.ref' , $search_ref );
if ( $search_label ) $sql .= natural_search ( 'p.title' , $search_label );
if ( $search_societe ) $sql .= natural_search ( 's.nom' , $search_societe );
2016-02-11 16:49:13 +01:00
if ( $search_opp_amount ) $sql .= natural_search ( 'p.opp_amount' , $search_opp_amount , 1 );
if ( $search_opp_percent ) $sql .= natural_search ( 'p.opp_percent' , $search_opp_percent , 1 );
2015-04-14 12:21:23 +02:00
if ( $smonth > 0 )
{
if ( $syear > 0 && empty ( $sday ))
2016-01-18 16:46:54 +01:00
$sql .= " AND p.dateo BETWEEN ' " . $db -> idate ( dol_get_first_day ( $syear , $smonth , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $syear , $smonth , false )) . " ' " ;
2015-04-14 12:21:23 +02:00
else if ( $syear > 0 && ! empty ( $sday ))
2016-01-18 16:46:54 +01:00
$sql .= " AND p.dateo BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $smonth , $sday , $syear )) . " ' AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $smonth , $sday , $syear )) . " ' " ;
2015-04-14 12:21:23 +02:00
else
2016-01-18 16:46:54 +01:00
$sql .= " AND date_format(p.dateo, '%m') = ' " . $smonth . " ' " ;
2015-04-14 12:21:23 +02:00
}
else if ( $syear > 0 )
{
2016-01-18 16:46:54 +01:00
$sql .= " AND p.dateo BETWEEN ' " . $db -> idate ( dol_get_first_day ( $syear , 1 , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $syear , 12 , false )) . " ' " ;
2015-04-14 12:21:23 +02:00
}
2015-01-29 18:17:43 +01:00
if ( $month > 0 )
{
if ( $year > 0 && empty ( $day ))
$sql .= " AND p.datee BETWEEN ' " . $db -> idate ( dol_get_first_day ( $year , $month , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $year , $month , false )) . " ' " ;
else if ( $year > 0 && ! empty ( $day ))
$sql .= " AND p.datee BETWEEN ' " . $db -> idate ( dol_mktime ( 0 , 0 , 0 , $month , $day , $year )) . " ' AND ' " . $db -> idate ( dol_mktime ( 23 , 59 , 59 , $month , $day , $year )) . " ' " ;
else
$sql .= " AND date_format(p.datee, '%m') = ' " . $month . " ' " ;
2014-12-28 03:39:30 +01:00
}
2015-01-29 18:17:43 +01:00
else if ( $year > 0 )
{
$sql .= " AND p.datee BETWEEN ' " . $db -> idate ( dol_get_first_day ( $year , 1 , false )) . " ' AND ' " . $db -> idate ( dol_get_last_day ( $year , 12 , false )) . " ' " ;
}
2015-10-17 00:14:36 +02:00
if ( $search_all ) $sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
2016-10-18 12:16:12 +02:00
if ( $search_status >= 0 )
{
if ( $search_status == 99 ) $sql .= " AND p.fk_statut <> 2 " ;
else $sql .= " AND p.fk_statut = " . $db -> escape ( $search_status );
}
2015-08-31 15:52:54 +02:00
if ( $search_opp_status )
{
if ( is_numeric ( $search_opp_status ) && $search_opp_status > 0 ) $sql .= " AND p.fk_opp_status = " . $db -> escape ( $search_opp_status );
if ( $search_opp_status == 'all' ) $sql .= " AND p.fk_opp_status IS NOT NULL " ;
2016-09-30 11:45:36 +02:00
if ( $search_opp_status == 'openedopp' ) $sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status NOT IN (SELECT rowid FROM " . MAIN_DB_PREFIX . " c_lead_status WHERE code IN ('WON','LOST')) " ;
2015-08-31 15:52:54 +02:00
if ( $search_opp_status == 'none' ) $sql .= " AND p.fk_opp_status IS NULL " ;
}
2015-01-29 18:17:43 +01:00
if ( $search_public != '' ) $sql .= " AND p.public = " . $db -> escape ( $search_public );
2015-10-05 23:52:54 +02:00
if ( $search_sale > 0 ) $sql .= " AND sc.fk_user = " . $search_sale ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id . " ) OR (s.rowid IS NULL)) " ;
2016-01-21 14:59:09 +01:00
if ( $search_user > 0 ) $sql .= " AND ecp.fk_c_type_contact IN ( " . join ( ',' , array_keys ( $listofprojectcontacttype )) . " ) AND ecp.element_id = p.rowid AND ecp.fk_socpeople = " . $search_user ;
2016-06-16 12:42:21 +02:00
if ( $search_opp_amount != '' ) $sql .= natural_search ( 'p.opp_amount' , $search_opp_amount , 1 );
if ( $search_budget_amount != '' ) $sql .= natural_search ( 'p.budget_amount' , $search_budget_amount , 1 );
2016-04-04 16:02:29 +02:00
// Add where from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$typ = $extrafields -> attribute_type [ $tmpkey ];
$mode = 0 ;
if ( in_array ( $typ , array ( 'int' , 'double' ))) $mode = 1 ; // Search on a numeric
if ( $val && ( ( $crit != '' && ! in_array ( $typ , array ( 'select' ))) || ! empty ( $crit )))
{
$sql .= natural_search ( 'ef.' . $tmpkey , $crit , $mode );
}
}
2015-06-22 15:48:48 +02:00
// Add where from hooks
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2010-03-13 00:40:39 +01:00
$sql .= $db -> order ( $sortfield , $sortorder );
2016-01-21 14:59:09 +01:00
$nbtotalofrecords = 0 ;
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST ))
{
$result = $db -> query ( $sql );
$nbtotalofrecords = $db -> num_rows ( $result );
}
$sql .= $db -> plimit ( $limit + 1 , $offset );
2016-07-08 10:59:13 +02:00
//print $sql;
2014-06-12 11:31:53 +02:00
dol_syslog ( " list allowed project " , LOG_DEBUG );
2016-01-21 14:59:09 +01:00
//print $sql;
2006-03-09 12:35:25 +01:00
$resql = $db -> query ( $sql );
2016-11-02 12:48:50 +01:00
if ( ! $resql )
2006-03-09 12:35:25 +01:00
{
2016-11-02 12:48:50 +01:00
dol_print_error ( $db );
exit ;
}
2016-06-16 12:42:21 +02:00
2016-11-02 12:48:50 +01:00
$var = true ;
$num = $db -> num_rows ( $resql );
2015-02-07 03:54:00 +01:00
2016-11-02 12:48:50 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all )
{
$obj = $db -> fetch_object ( $resql );
$id = $obj -> projectid ;
header ( " Location: " . DOL_URL_ROOT . '/projet/card.php?id=' . $id );
exit ;
}
2015-06-22 11:55:21 +02:00
2016-11-02 12:48:50 +01:00
llxHeader ( " " , $title , " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " );
2016-09-18 15:57:53 +02:00
2016-11-02 12:48:50 +01:00
$param = '' ;
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) $param .= '&contextpage=' . $contextpage ;
if ( $limit > 0 && $limit != $conf -> liste_limit ) $param .= '&limit=' . $limit ;
if ( $sday ) $param .= '&sday=' . $day ;
if ( $smonth ) $param .= '&smonth=' . $smonth ;
if ( $syear ) $param .= '&syear=' . $syear ;
if ( $day ) $param .= '&day=' . $day ;
if ( $month ) $param .= '&month=' . $month ;
if ( $year ) $param .= '&year=' . $year ;
if ( $socid ) $param .= '&socid=' . $socid ;
if ( $search_all != '' ) $param .= '&search_all=' . $search_all ;
if ( $search_ref != '' ) $param .= '&search_ref=' . $search_ref ;
if ( $search_label != '' ) $param .= '&search_label=' . $search_label ;
if ( $search_societe != '' ) $param .= '&search_societe=' . $search_societe ;
if ( $search_status >= 0 ) $param .= '&search_status=' . $search_status ;
if (( is_numeric ( $search_opp_status ) && $search_opp_status >= 0 ) || in_array ( $search_opp_status , array ( 'all' , 'openedopp' , 'none' ))) $param .= '&search_opp_status=' . urlencode ( $search_opp_status );
if (( is_numeric ( $search_opp_percent ) && $search_opp_percent >= 0 ) || in_array ( $search_opp_percent , array ( 'all' , 'openedopp' , 'none' ))) $param .= '&search_opp_percent=' . urlencode ( $search_opp_percent );
if ( $search_public != '' ) $param .= '&search_public=' . $search_public ;
if ( $search_user > 0 ) $param .= '&search_user=' . $search_user ;
if ( $search_sale > 0 ) $param .= '&search_sale=' . $search_sale ;
if ( $search_opp_amount != '' ) $param .= '&search_opp_amount=' . $search_opp_amount ;
if ( $search_budget_amount != '' ) $param .= '&search_budget_amount=' . $search_budget_amount ;
if ( $optioncss != '' ) $param .= '&optioncss=' . $optioncss ;
// Add $param from extra fields
foreach ( $search_array_options as $key => $val )
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
if ( $val != '' ) $param .= '&search_options_' . $tmpkey . '=' . urlencode ( $val );
}
2016-09-18 15:48:29 +02:00
2016-11-02 12:48:50 +01:00
$text = $langs -> trans ( " Projects " );
if ( $search_user == $user -> id ) $text = $langs -> trans ( 'MyProjects' );
2015-02-07 03:54:00 +01:00
2016-11-02 12:48:50 +01:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
if ( $optioncss != '' ) print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">' ;
print '<input type="hidden" name="action" value="list">' ;
print '<input type="hidden" name="sortfield" value="' . $sortfield . '">' ;
print '<input type="hidden" name="sortorder" value="' . $sortorder . '">' ;
print '<input type="hidden" name="type" value="' . $type . '">' ;
print '<input type="hidden" name="contextpage" value="' . $contextpage . '">' ;
print_barre_liste ( $text , $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , " " , $num , $nbtotalofrecords , 'title_project' , 0 , '' , '' , $limit );
// Show description of content
if ( $search_user == $user -> id ) print $langs -> trans ( " MyProjectsDesc " ) . '<br><br>' ;
else
{
if ( $user -> rights -> projet -> all -> lire && ! $socid ) print $langs -> trans ( " ProjectsDesc " ) . '<br><br>' ;
else print $langs -> trans ( " ProjectsPublicDesc " ) . '<br><br>' ;
}
if ( $search_all )
{
foreach ( $fieldstosearchall as $key => $val ) $fieldstosearchall [ $key ] = $langs -> trans ( $val );
print $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall );
}
$moreforfilter = '' ;
// Filter on categories
if ( ! empty ( $conf -> categorie -> enabled ))
{
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'Categories' ) . ': ' ;
$moreforfilter .= $formother -> select_categories ( 'project' , $search_categ , 'search_categ' , 1 );
$moreforfilter .= '</div>' ;
}
// If the user can view user other than himself
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'ProjectsWithThisUserAsContact' ) . ': ' ;
$includeonly = '' ;
if ( empty ( $user -> rights -> user -> user -> lire )) $includeonly = array ( $user -> id );
$moreforfilter .= $form -> select_dolusers ( $search_user , 'search_user' , 1 , '' , 0 , $includeonly , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth300' );
$moreforfilter .= '</div>' ;
// If the user can view thirdparties other than his'
if ( $user -> rights -> societe -> client -> voir || $socid )
{
$langs -> load ( " commercial " );
$moreforfilter .= '<div class="divsearchfield">' ;
$moreforfilter .= $langs -> trans ( 'ThirdPartiesOfSaleRepresentative' ) . ': ' ;
$moreforfilter .= $formother -> select_salesrepresentatives ( $search_sale , 'search_sale' , $user , 0 , 1 , 'maxwidth300' );
$moreforfilter .= '</div>' ;
}
if ( ! empty ( $moreforfilter ))
{
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'printFieldPreListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2015-12-06 01:19:27 +01:00
print $hookmanager -> resPrint ;
2016-11-02 12:48:50 +01:00
print '</div>' ;
}
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
print '<table class="liste ' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' ;
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.ref' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.ref " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.title' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.title " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 's.nom' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.nom " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'commercial' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'commercial' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.dateo' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.dateo' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.dateo " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.datee' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.datee' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datee " , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.public' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.public' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.public " , " " , $param , " " , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.opp_amount' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.opp_amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.opp_amount' , " " , $param , 'align="right"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.fk_opp_status' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.fk_opp_status' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.fk_opp_status' , " " , $param , 'align="center"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.opp_percent' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.opp_percent' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.opp_percent' , " " , $param , 'align="right"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.budget_amount' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.budget_amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.budget_amount' , " " , $param , 'align="right"' , $sortfield , $sortorder );
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
$align = $extrafields -> getAlignFlag ( $key );
print_liste_field_titre ( $extralabels [ $key ], $_SERVER [ " PHP_SELF " ], " ef. " . $key , " " , $param ,( $align ? 'align="' . $align . '"' : '' ), $sortfield , $sortorder );
}
}
}
// Hook fields
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datec " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tms " , " " , $param , 'align="center" class="nowrap"' , $sortfield , $sortorder );
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) print_liste_field_titre ( $arrayfields [ 'p.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_statut " , " " , $param , 'align="right"' , $sortfield , $sortorder );
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , 'align="right"' , $sortfield , $sortorder , 'maxwidthsearch ' );
print " </tr> \n " ;
print '<tr class="liste_titre">' ;
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_ref" value="' . $search_ref . '" size="6">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_label" size="8" value="' . $search_label . '">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
print '<input type="text" class="flat" name="search_societe" size="8" value="' . $search_societe . '">' ;
print '</td>' ;
}
// Sale representative
if ( ! empty ( $arrayfields [ 'commercial' ][ 'checked' ]))
{
print '<td class="liste_titre"> </td>' ;
}
// Start date
if ( ! empty ( $arrayfields [ 'p.dateo' ][ 'checked' ]))
{
print '<td class="liste_titre center">' ;
if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) print '<input class="flat" type="text" size="1" maxlength="2" name="sday" value="' . $sday . '">' ;
print '<input class="flat" type="text" size="1" maxlength="2" name="smonth" value="' . $smonth . '">' ;
$formother -> select_year ( $syear ? $syear :- 1 , 'syear' , 1 , 20 , 5 );
print '</td>' ;
}
// End date
if ( ! empty ( $arrayfields [ 'p.datee' ][ 'checked' ]))
{
print '<td class="liste_titre center">' ;
if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="' . $day . '">' ;
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="' . $month . '">' ;
$formother -> select_year ( $year ? $year :- 1 , 'year' , 1 , 20 , 5 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.public' ][ 'checked' ]))
{
print '<td class="liste_titre">' ;
$array = array ( '' => '' , 0 => $langs -> trans ( " PrivateProject " ), 1 => $langs -> trans ( " SharedProject " ));
print $form -> selectarray ( 'search_public' , $array , $search_public );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.opp_amount' ][ 'checked' ]))
{
print '<td class="liste_titre nowrap right">' ;
print '<input type="text" class="flat" name="search_opp_amount" size="3" value="' . $search_opp_amount . '">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.fk_opp_status' ][ 'checked' ]))
{
print '<td class="liste_titre nowrap center">' ;
print $formproject -> selectOpportunityStatus ( 'search_opp_status' , $search_opp_status , 1 , 1 , 1 );
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.opp_percent' ][ 'checked' ]))
{
print '<td class="liste_titre nowrap right">' ;
print '<input type="text" class="flat" name="search_opp_percent" size="2" value="' . $search_opp_percent . '">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.budget_amount' ][ 'checked' ]))
{
print '<td class="liste_titre nowrap" align="right">' ;
print '<input type="text" class="flat" name="search_budget_amount" size="4" value="' . $search_budget_amount . '">' ;
print '</td>' ;
}
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
2015-12-06 01:19:27 +01:00
{
2016-11-02 12:48:50 +01:00
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
2015-12-06 01:19:27 +01:00
{
2016-11-02 12:48:50 +01:00
$align = $extrafields -> getAlignFlag ( $key );
$typeofextrafield = $extrafields -> attribute_type [ $key ];
print '<td class="liste_titre' . ( $align ? ' ' . $align : '' ) . '">' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'int' , 'double' , 'select' )))
{
$crit = $val ;
$tmpkey = preg_replace ( '/search_options_/' , '' , $key );
$searchclass = '' ;
if ( in_array ( $typeofextrafield , array ( 'varchar' , 'select' ))) $searchclass = 'searchstring' ;
if ( in_array ( $typeofextrafield , array ( 'int' , 'double' ))) $searchclass = 'searchnum' ;
print '<input class="flat' . ( $searchclass ? ' ' . $searchclass : '' ) . '" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . dol_escape_htmltag ( $search_array_options [ 'search_options_' . $tmpkey ]) . '">' ;
}
print '</td>' ;
2015-12-06 01:19:27 +01:00
}
}
2016-11-02 12:48:50 +01:00
}
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ]))
{
// Date creation
print '<td class="liste_titre">' ;
2016-02-07 15:50:48 +01:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ]))
{
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
}
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ]))
{
print '<td class="liste_titre nowrap" align="right">' ;
$arrayofstatus = array ();
foreach ( $projectstatic -> statuts_short as $key => $val ) $arrayofstatus [ $key ] = $langs -> trans ( $val );
$arrayofstatus [ '99' ] = $langs -> trans ( " NotClosed " ) . ' (' . $langs -> trans ( 'Draft' ) . '+' . $langs -> trans ( 'Opened' ) . ')' ;
print $form -> selectarray ( 'search_status' , $arrayofstatus , $search_status , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'maxwidth100' );
print '</td>' ;
}
// Action column
print '<td class="liste_titre" align="right">' ;
$searchpitco = $form -> showFilterAndCheckAddButtons ( 0 );
print $searchpitco ;
print '</td>' ;
print '</tr>' . " \n " ;
$i = 0 ;
$var = true ;
$totalarray = array ();
while ( $i < min ( $num , $limit ))
{
$obj = $db -> fetch_object ( $resql );
$projectstatic -> id = $obj -> projectid ;
$projectstatic -> user_author_id = $obj -> fk_user_creat ;
$projectstatic -> public = $obj -> public ;
$projectstatic -> ref = $obj -> ref ;
$projectstatic -> datee = $obj -> date_end ;
$projectstatic -> statut = $obj -> fk_statut ;
$projectstatic -> opp_status = $obj -> fk_opp_status ;
$userAccess = $projectstatic -> restrictedProjectArea ( $user ); // why this ?
if ( $userAccess >= 0 )
{
$var =! $var ;
print " <tr " . $bc [ $var ] . " > " ;
2009-01-15 00:36:51 +01:00
2016-11-02 12:48:50 +01:00
// Project url
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ]))
2015-04-14 12:21:23 +02:00
{
2016-11-02 12:48:50 +01:00
print '<td class="nowrap">' ;
print $projectstatic -> getNomUrl ( 1 );
if ( $projectstatic -> hasDelay ()) print img_warning ( $langs -> trans ( 'Late' ));
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Title
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ]))
{
print '<td>' ;
print dol_trunc ( $obj -> title , 80 );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Company
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ]))
{
print '<td>' ;
if ( $obj -> socid )
2015-12-06 01:19:27 +01:00
{
2016-11-02 12:48:50 +01:00
$socstatic -> id = $obj -> socid ;
$socstatic -> name = $obj -> name ;
print $socstatic -> getNomUrl ( 1 );
2015-12-06 01:19:27 +01:00
}
2016-11-02 12:48:50 +01:00
else
2015-12-06 01:19:27 +01:00
{
2016-11-02 12:48:50 +01:00
print ' ' ;
2015-12-06 01:19:27 +01:00
}
2016-11-02 12:48:50 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Sales Representatives
if ( ! empty ( $arrayfields [ 'commercial' ][ 'checked' ]))
{
print '<td>' ;
if ( $obj -> socid )
2015-12-06 01:19:27 +01:00
{
2016-11-02 12:48:50 +01:00
$socstatic -> id = $obj -> socid ;
$socstatic -> name = $obj -> name ;
$listsalesrepresentatives = $socstatic -> getSalesRepresentatives ( $user );
$nbofsalesrepresentative = count ( $listsalesrepresentatives );
if ( $nbofsalesrepresentative > 3 ) // We print only number
{
print '<a href="' . DOL_URL_ROOT . '/societe/commerciaux.php?socid=' . $socstatic -> id . '">' ;
print $nbofsalesrepresentative ;
print '</a>' ;
}
else if ( $nbofsalesrepresentative > 0 )
{
$userstatic = new User ( $db );
$j = 0 ;
foreach ( $listsalesrepresentatives as $val )
{
$userstatic -> id = $val [ 'id' ];
$userstatic -> lastname = $val [ 'lastname' ];
$userstatic -> firstname = $val [ 'firstname' ];
$userstatic -> email = $val [ 'email' ];
$userstatic -> statut = $val [ 'statut' ];
$userstatic -> entity = $val [ 'entity' ];
print $userstatic -> getNomUrl ( 1 );
$j ++ ;
if ( $j < $nbofsalesrepresentative ) print ', ' ;
}
}
//else print $langs->trans("NoSalesRepresentativeAffected");
2015-12-06 01:19:27 +01:00
}
2016-11-02 12:48:50 +01:00
else
2015-12-06 01:19:27 +01:00
{
2016-11-02 12:48:50 +01:00
print ' ' ;
2015-12-06 01:19:27 +01:00
}
2016-11-02 12:48:50 +01:00
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date start
if ( ! empty ( $arrayfields [ 'p.dateo' ][ 'checked' ]))
{
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_start ), 'day' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date end
if ( ! empty ( $arrayfields [ 'p.datee' ][ 'checked' ]))
{
print '<td class="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_end ), 'day' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Visibility
if ( ! empty ( $arrayfields [ 'p.public' ][ 'checked' ]))
{
print '<td align="left">' ;
if ( $obj -> public ) print $langs -> trans ( 'SharedProject' );
else print $langs -> trans ( 'PrivateProject' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
2015-04-14 12:21:23 +02:00
}
2016-11-02 12:48:50 +01:00
// Amount
if ( ! empty ( $arrayfields [ 'p.opp_amount' ][ 'checked' ]))
{
print '<td align="right">' ;
if ( $obj -> opp_status_code )
{
print price ( $obj -> opp_amount , 1 , '' , 1 , - 1 , - 1 , '' );
$totalarray [ 'totalopp' ] += $obj -> opp_amount ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totaloppfield' ] = $totalarray [ 'nbfield' ];
}
if ( ! empty ( $arrayfields [ 'p.fk_opp_status' ][ 'checked' ]))
{
print '<td align="middle">' ;
if ( $obj -> opp_status_code ) print $langs -> trans ( " OppStatusShort " . $obj -> opp_status_code );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
if ( ! empty ( $arrayfields [ 'p.opp_percent' ][ 'checked' ]))
{
print '<td align="right">' ;
if ( $obj -> opp_percent ) print price ( $obj -> opp_percent , 1 , '' , 1 , 0 ) . '%' ;
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
if ( ! empty ( $arrayfields [ 'p.budget_amount' ][ 'checked' ]))
{
print '<td align="right">' ;
if ( $obj -> budget_amount != '' )
{
print price ( $obj -> budget_amount , 1 , '' , 1 , - 1 , - 1 );
$totalarray [ 'totalbudget' ] += $obj -> budget_amount ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
if ( ! $i ) $totalarray [ 'totalbudgetfield' ] = $totalarray [ 'nbfield' ];
}
// Extra fields
if ( is_array ( $extrafields -> attribute_label ) && count ( $extrafields -> attribute_label ))
{
foreach ( $extrafields -> attribute_label as $key => $val )
{
if ( ! empty ( $arrayfields [ " ef. " . $key ][ 'checked' ]))
{
print '<td' ;
$align = $extrafields -> getAlignFlag ( $key );
if ( $align ) print ' align="' . $align . '"' ;
print '>' ;
$tmpkey = 'options_' . $key ;
print $extrafields -> showOutputField ( $key , $obj -> $tmpkey , '' , 1 );
print '</td>' ;
}
}
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Fields from hook
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj );
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
// Date creation
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Date modification
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ]))
{
print '<td align="center">' ;
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' );
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Status
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ]))
{
$projectstatic -> statut = $obj -> fk_statut ;
print '<td align="right">' . $projectstatic -> getLibStatut ( 5 ) . '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
}
// Action column
print '<td class="nowrap" align="center">' ;
if ( $massactionbutton || $massaction ) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0 ;
if ( in_array ( $obj -> rowid , $arrayofselected )) $selected = 1 ;
print '<input id="cb' . $obj -> rowid . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> rowid . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
if ( ! $i ) $totalarray [ 'nbfield' ] ++ ;
print " </tr> \n " ;
2015-04-14 12:21:23 +02:00
2016-11-02 12:48:50 +01:00
}
2015-06-16 19:36:44 +02:00
2016-11-02 12:48:50 +01:00
$i ++ ;
}
// Show total line
if ( isset ( $totalarray [ 'totaloppfield' ]) || isset ( $totalarray [ 'totalbudgetfield' ]))
{
print '<tr class="liste_total">' ;
$i = 0 ;
while ( $i < $totalarray [ 'nbfield' ])
2016-09-18 15:48:29 +02:00
{
2016-11-02 12:48:50 +01:00
$i ++ ;
if ( $i == 1 )
2016-09-18 15:48:29 +02:00
{
2016-11-02 12:48:50 +01:00
if ( $num < $limit ) print '<td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
else print '<td align="left">' . $langs -> trans ( " Totalforthispage " ) . '</td>' ;
2016-09-18 15:48:29 +02:00
}
2016-11-02 12:48:50 +01:00
elseif ( $totalarray [ 'totaloppfield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalopp' ]) . '</td>' ;
elseif ( $totalarray [ 'totalbudgetfield' ] == $i ) print '<td align="right">' . price ( $totalarray [ 'totalbudget' ]) . '</td>' ;
else print '<td></td>' ;
2016-09-18 15:48:29 +02:00
}
2016-11-02 12:48:50 +01:00
print '</tr>' ;
}
2015-06-16 19:36:44 +02:00
2016-11-02 12:48:50 +01:00
$db -> free ( $resql );
2009-01-15 00:36:51 +01:00
2016-11-02 12:48:50 +01:00
$parameters = array ( 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters ); // Note that $action and $object may have been modified by hook
print $hookmanager -> resPrint ;
2006-03-09 12:35:25 +01:00
2016-11-02 12:48:50 +01:00
print " </table> \n " ;
print " </form> \n " ;
2006-03-09 12:35:25 +01:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-04 18:34:52 +01:00
$db -> close ();