2006-03-09 12:35:25 +01:00
< ? php
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2019-12-21 17:11:21 +01:00
* Copyright ( C ) 2004 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-03-09 12:43:13 +01:00
* Copyright ( C ) 2005 Marc Bariley / Ocebo < marc @ ocebo . com >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2010 Regis Houssin < regis . houssin @ inodbox . 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 >
2018-04-20 10:38:16 +02:00
* Copyright ( C ) 2018 Ferran Marcet < fmarcet @ 2 byte . es >
2019-05-11 16:36:35 +02:00
* Copyright ( C ) 2019 Juanjo Menent < jmenent @ 2 byte . es >
2020-11-10 15:03:35 +01:00
* Copyright ( C ) 2020 Tobias Sean < tobias . sekan @ startmail . com >
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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// 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
2021-06-14 19:58:12 +02:00
* \ingroup project
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
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
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' ;
2022-11-08 14:59:22 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
2006-03-09 12:35:25 +01:00
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'categorie' )) {
2020-04-12 13:30:02 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcategory.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
}
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2017-04-11 02:48:16 +02:00
$langs -> loadLangs ( array ( 'projects' , 'companies' , 'commercial' ));
2022-08-31 22:38:53 +02:00
if ( isModEnabled ( 'eventorganization' ) && $conf -> eventorganization -> enabled ) {
2021-02-21 12:32:16 +01:00
$langs -> loadLangs ( array ( 'eventorganization' ));
}
2017-04-11 02:48:16 +02:00
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2019-11-12 09:46:08 +01:00
$massaction = GETPOST ( 'massaction' , 'alpha' );
$show_files = GETPOST ( 'show_files' , 'int' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
2017-04-11 02:48:16 +02:00
$toselect = GETPOST ( 'toselect' , 'array' );
2023-02-19 16:12:28 +01:00
$optioncss = GETPOST ( 'optioncss' , 'alpha' );
2019-11-12 09:46:08 +01:00
$contextpage = GETPOST ( 'contextpage' , 'aZ' ) ? GETPOST ( 'contextpage' , 'aZ' ) : 'projectlist' ;
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
2021-09-01 18:39:35 +02:00
$socid = GETPOST ( 'socid' , 'int' );
2019-10-31 20:46:31 +01:00
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2021-02-26 18:49:22 +01:00
if ( $socid > 0 ) {
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
}
2021-02-26 18:49:22 +01:00
if ( ! $user -> rights -> projet -> lire ) {
accessforbidden ();
}
2006-03-09 12:35:25 +01:00
2022-06-14 17:53:17 +02:00
$diroutputmassaction = $conf -> project -> dir_output . '/temp/massgeneration/' . $user -> id ;
2006-03-09 12:35:25 +01:00
2019-11-12 09:46:08 +01:00
$limit = GETPOST ( 'limit' , 'int' ) ? GETPOST ( 'limit' , 'int' ) : $conf -> liste_limit ;
2022-09-19 18:57:39 +02:00
$sortfield = GETPOST ( 'sortfield' , 'aZ09comma' );
$sortorder = GETPOST ( 'sortorder' , 'aZ09comma' );
2020-03-13 13:07:11 +01:00
$page = GETPOSTISSET ( 'pageplusone' ) ? ( GETPOST ( 'pageplusone' ) - 1 ) : GETPOST ( " page " , 'int' );
2021-02-26 18:49:22 +01:00
if ( empty ( $page ) || $page < 0 || GETPOST ( 'button_search' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) {
2021-09-01 18:39:35 +02:00
// If $page is not defined, or '' or -1 or if we click on clear filters
2021-02-26 18:49:22 +01:00
$page = 0 ;
2021-09-01 18:39:35 +02:00
}
2021-02-26 18:49:22 +01:00
if ( ! $sortfield ) {
$sortfield = " p.ref " ;
}
if ( ! $sortorder ) {
$sortorder = " ASC " ;
}
2019-11-12 09:46:08 +01:00
$offset = $limit * $page ;
2006-03-09 12:35:25 +01:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2019-11-12 09:46:08 +01:00
$search_all = GETPOST ( 'search_all' , 'alphanohtml' ) ? GETPOST ( 'search_all' , 'alphanohtml' ) : GETPOST ( 'sall' , 'alphanohtml' );
$search_ref = GETPOST ( " search_ref " , 'alpha' );
$search_label = GETPOST ( " search_label " , 'alpha' );
$search_societe = GETPOST ( " search_societe " , 'alpha' );
2022-06-21 17:57:00 +02:00
$search_societe_alias = GETPOST ( " search_societe_alias " , 'alpha' );
2019-11-12 09:46:08 +01:00
$search_status = GETPOST ( " search_status " , 'int' );
$search_opp_status = GETPOST ( " search_opp_status " , 'alpha' );
$search_opp_percent = GETPOST ( " search_opp_percent " , 'alpha' );
$search_opp_amount = GETPOST ( " search_opp_amount " , 'alpha' );
$search_budget_amount = GETPOST ( " search_budget_amount " , 'alpha' );
$search_public = GETPOST ( " search_public " , 'int' );
$search_project_user = GETPOST ( 'search_project_user' , 'int' );
2022-01-05 14:35:11 +01:00
$search_project_contact = GETPOST ( 'search_project_contact' , 'int' );
2019-11-12 09:46:08 +01:00
$search_sale = GETPOST ( 'search_sale' , 'int' );
$search_usage_opportunity = GETPOST ( 'search_usage_opportunity' , 'int' );
$search_usage_task = GETPOST ( 'search_usage_task' , 'int' );
$search_usage_bill_time = GETPOST ( 'search_usage_bill_time' , 'int' );
2021-02-15 12:18:08 +01:00
$search_usage_event_organization = GETPOST ( 'search_usage_event_organization' , 'int' );
2021-02-22 21:00:54 +01:00
$search_accept_conference_suggestions = GETPOST ( 'search_accept_conference_suggestions' , 'int' );
$search_accept_booth_suggestions = GETPOST ( 'search_accept_booth_suggestions' , 'int' );
2021-02-21 12:32:16 +01:00
$search_price_registration = GETPOST ( " search_price_registration " , 'alpha' );
$search_price_booth = GETPOST ( " search_price_booth " , 'alpha' );
2022-06-29 17:32:50 +02:00
$search_login = GETPOST ( 'search_login' , 'alpha' );
2023-02-19 16:12:28 +01:00
$search_import_key = GETPOST ( 'search_import_key' , 'alpha' );
2022-04-22 17:10:24 +02:00
$searchCategoryCustomerOperator = 0 ;
if ( GETPOSTISSET ( 'formfilteraction' )) {
$searchCategoryCustomerOperator = GETPOST ( 'search_category_customer_operator' , 'int' );
} elseif ( ! empty ( $conf -> global -> MAIN_SEARCH_CAT_OR_BY_DEFAULT )) {
$searchCategoryCustomerOperator = $conf -> global -> MAIN_SEARCH_CAT_OR_BY_DEFAULT ;
}
$searchCategoryCustomerList = GETPOST ( 'search_category_customer_list' , 'array' );
2023-02-19 16:12:28 +01:00
2015-01-29 18:17:43 +01:00
2021-09-01 18:39:35 +02:00
$mine = (( GETPOST ( 'mode' ) == 'mine' ) ? 1 : 0 );
2021-02-26 18:49:22 +01:00
if ( $mine ) {
$search_project_user = $user -> id ; $mine = 0 ;
}
2015-12-04 15:37:28 +01:00
2019-01-27 11:55:16 +01:00
$search_sday = GETPOST ( 'search_sday' , 'int' );
$search_smonth = GETPOST ( 'search_smonth' , 'int' );
$search_syear = GETPOST ( 'search_syear' , 'int' );
$search_eday = GETPOST ( 'search_eday' , 'int' );
$search_emonth = GETPOST ( 'search_emonth' , 'int' );
$search_eyear = GETPOST ( 'search_eyear' , 'int' );
2015-01-29 18:17:43 +01:00
2021-08-25 12:46:56 +02:00
$search_date_start_startmonth = GETPOST ( 'search_date_start_startmonth' , 'int' );
$search_date_start_startyear = GETPOST ( 'search_date_start_startyear' , 'int' );
$search_date_start_startday = GETPOST ( 'search_date_start_startday' , 'int' );
$search_date_start_start = dol_mktime ( 0 , 0 , 0 , $search_date_start_startmonth , $search_date_start_startday , $search_date_start_startyear ); // Use tzserver
$search_date_start_endmonth = GETPOST ( 'search_date_start_endmonth' , 'int' );
$search_date_start_endyear = GETPOST ( 'search_date_start_endyear' , 'int' );
$search_date_start_endday = GETPOST ( 'search_date_start_endday' , 'int' );
$search_date_start_end = dol_mktime ( 23 , 59 , 59 , $search_date_start_endmonth , $search_date_start_endday , $search_date_start_endyear ); // Use tzserver
$search_date_end_startmonth = GETPOST ( 'search_date_end_startmonth' , 'int' );
$search_date_end_startyear = GETPOST ( 'search_date_end_startyear' , 'int' );
$search_date_end_startday = GETPOST ( 'search_date_end_startday' , 'int' );
$search_date_end_start = dol_mktime ( 0 , 0 , 0 , $search_date_end_startmonth , $search_date_end_startday , $search_date_end_startyear ); // Use tzserver
$search_date_end_endmonth = GETPOST ( 'search_date_end_endmonth' , 'int' );
$search_date_end_endyear = GETPOST ( 'search_date_end_endyear' , 'int' );
$search_date_end_endday = GETPOST ( 'search_date_end_endday' , 'int' );
$search_date_end_end = dol_mktime ( 23 , 59 , 59 , $search_date_end_endmonth , $search_date_end_endday , $search_date_end_endyear ); // Use tzserver
2023-02-19 16:12:28 +01:00
2023-02-02 21:36:41 +01:00
if ( isModEnabled ( 'categorie' )) {
$search_category_array = GETPOST ( " search_category_ " . Categorie :: TYPE_PROJECT . " _list " , " array " );
}
2021-08-25 12:46:56 +02:00
2021-02-26 18:49:22 +01:00
if ( $search_status == '' ) {
$search_status = - 1 ; // -1 or 1
}
2012-03-19 14:44:27 +01:00
2020-04-12 13:30:02 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2018-03-31 18:48:27 +02:00
$object = new Project ( $db );
$hookmanager -> initHooks ( array ( 'projectlist' ));
2015-12-02 23:20:19 +01:00
$extrafields = new ExtraFields ( $db );
// fetch optionals attributes and labels
2019-10-06 14:41:52 +02:00
$extrafields -> fetch_name_optionals_label ( $object -> table_element );
2019-11-12 09:46:08 +01:00
$search_array_options = $extrafields -> getOptionalsFromPost ( $object -> table_element , '' , 'search_' );
2015-12-02 23:20:19 +01:00
// List of fields to search into when doing a "search in all"
2020-09-29 10:00:14 +02:00
$fieldstosearchall = array ();
2020-09-30 14:54:24 +02:00
foreach ( $object -> fields as $key => $val ) {
2020-09-29 10:00:14 +02:00
if ( empty ( $val [ 'searchall' ])) {
continue ;
}
2020-09-29 12:00:54 +02:00
// Don't allow search in private notes for external users when doing "search in all"
2020-09-29 10:00:14 +02:00
if ( ! empty ( $user -> socid ) && $key == " note_private " ) {
continue ;
}
$fieldstosearchall [ 'p.' . $key ] = $val [ 'label' ];
}
2020-12-17 22:52:42 +01:00
// Add name object fields to "search in all"
2020-09-29 10:00:14 +02:00
$fieldstosearchall [ 's.nom' ] = " ThirdPartyName " ;
2020-12-17 22:52:42 +01:00
// Definition of array of fields for columns
2020-09-29 10:00:14 +02:00
$arrayfields = array ();
2020-09-30 14:54:24 +02:00
foreach ( $object -> fields as $key => $val ) {
2020-09-29 10:00:14 +02:00
// If $val['visible']==0, then we never show the field
2020-12-17 22:52:42 +01:00
if ( ! empty ( $val [ 'visible' ])) {
2022-03-01 16:38:06 +01:00
$visible = dol_eval ( $val [ 'visible' ], 1 , 1 , '1' );
2020-12-17 22:52:42 +01:00
$arrayfields [ 'p.' . $key ] = array (
'label' => $val [ 'label' ],
'checked' => (( $visible < 0 ) ? 0 : 1 ),
2022-03-01 16:38:06 +01:00
'enabled' => ( $visible != 3 && dol_eval ( $val [ 'enabled' ], 1 , 1 , '1' )),
2020-12-17 22:52:42 +01:00
'position' => $val [ 'position' ],
2021-07-05 14:51:34 +02:00
'help' => isset ( $val [ 'help' ]) ? $val [ 'help' ] : ''
2020-12-17 22:52:42 +01:00
);
}
2020-09-29 10:00:14 +02:00
}
2020-12-17 22:52:42 +01:00
// Extra fields
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php' ;
2020-09-29 10:00:14 +02:00
2021-06-26 15:39:52 +02:00
// Add non object fields to fields for list
2022-08-29 09:29:11 +02:00
$arrayfields [ 's.nom' ] = array ( 'label' => $langs -> trans ( " ThirdParty " ), 'checked' => 1 , 'position' => 21 , 'enabled' => ( ! isModEnabled ( 'societe' ) ? 0 : 1 ));
2022-06-21 18:06:58 +02:00
$arrayfields [ 's.name_alias' ] = array ( 'label' => " AliasNameShort " , 'checked' => 0 , 'position' => 22 );
2020-12-17 22:52:42 +01:00
$arrayfields [ 'commercial' ] = array ( 'label' => $langs -> trans ( " SaleRepresentativesOfThirdParty " ), 'checked' => 0 , 'position' => 23 );
2023-01-17 12:31:53 +01:00
$arrayfields [ 'c.assigned' ] = array ( 'label' => $langs -> trans ( " AssignedTo " ), 'checked' => 1 , 'position' => 120 );
2023-01-31 20:45:32 +01:00
$arrayfields [ 'opp_weighted_amount' ] = array ( 'label' => $langs -> trans ( 'OpportunityWeightedAmountShort' ), 'checked' => 0 , 'enabled' => ( empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) ? 0 : 1 ), 'position' => 106 );
2023-01-17 12:31:53 +01:00
$arrayfields [ 'u.login' ] = array ( 'label' => " Author " , 'checked' =>- 1 , 'position' => 165 );
2021-06-26 15:39:52 +02:00
// Force some fields according to search_usage filter...
if ( GETPOST ( 'search_usage_opportunity' )) {
//$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough
//$arrayfields['p.usage_opportunity']['checked'] = 1; // Not require, filter on search_opp_status is enough
}
if ( GETPOST ( 'search_usage_event_organization' )) {
$arrayfields [ 'p.fk_opp_status' ][ 'enabled' ] = 0 ;
$arrayfields [ 'p.opp_amount' ][ 'enabled' ] = 0 ;
$arrayfields [ 'p.opp_percent' ][ 'enabled' ] = 0 ;
$arrayfields [ 'opp_weighted_amount' ][ 'enabled' ] = 0 ;
$arrayfields [ 'p.usage_organize_event' ][ 'visible' ] = 1 ;
$arrayfields [ 'p.usage_organize_event' ][ 'checked' ] = 1 ;
}
2020-09-29 10:00:14 +02:00
2020-12-17 22:52:42 +01:00
$object -> fields = dol_sort_array ( $object -> fields , 'position' );
2019-10-22 17:08:37 +02:00
$arrayfields = dol_sort_array ( $arrayfields , 'position' );
2015-12-02 23:20:19 +01:00
2017-05-24 22:48:44 +02:00
2015-12-02 23:20:19 +01:00
/*
* Actions
*/
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'cancel' , 'alpha' )) {
2022-09-19 18:57:39 +02:00
$action = 'list' ;
$massaction = '' ;
2021-02-26 18:49:22 +01:00
}
2022-04-25 14:28:57 +02:00
if ( ! GETPOST ( 'confirmmassaction' , 'alpha' ) && $massaction != 'presend' && $massaction != 'confirm_presend' ) {
2021-02-26 18:49:22 +01:00
$massaction = '' ;
}
2016-11-02 12:48:50 +01:00
2019-11-12 09:46:08 +01:00
$parameters = array ( 'socid' => $socid );
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2021-02-26 18:49:22 +01:00
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
}
2016-11-02 12:48:50 +01:00
2021-02-26 18:49:22 +01:00
if ( empty ( $reshook )) {
2017-10-07 13:09:31 +02:00
// Selection of new fields
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php' ;
// Purge search criteria
2021-02-26 18:49:22 +01:00
if ( GETPOST ( 'button_removefilter_x' , 'alpha' ) || GETPOST ( 'button_removefilter.x' , 'alpha' ) || GETPOST ( 'button_removefilter' , 'alpha' )) { // All tests are required to be compatible with all browsers
2019-11-12 09:46:08 +01:00
$search_all = '' ;
$search_ref = " " ;
$search_label = " " ;
$search_societe = " " ;
2022-06-21 17:57:00 +02:00
$search_societe_alias = '' ;
2019-11-12 09:46:08 +01:00
$search_status = - 1 ;
$search_opp_status = - 1 ;
$search_opp_amount = '' ;
$search_opp_percent = '' ;
$search_budget_amount = '' ;
$search_public = " " ;
$search_sale = " " ;
$search_project_user = '' ;
2022-01-05 14:35:11 +01:00
$search_project_contact = '' ;
2019-11-12 09:46:08 +01:00
$search_sday = " " ;
$search_smonth = " " ;
$search_syear = " " ;
$search_eday = " " ;
$search_emonth = " " ;
$search_eyear = " " ;
2021-08-25 12:46:56 +02:00
$search_date_start_startmonth = " " ;
$search_date_start_startyear = " " ;
$search_date_start_startday = " " ;
$search_date_start_start = " " ;
$search_date_start_endmonth = " " ;
$search_date_start_endyear = " " ;
$search_date_start_endday = " " ;
$search_date_start_end = " " ;
$search_date_end_startmonth = " " ;
$search_date_end_startyear = " " ;
$search_date_end_startday = " " ;
$search_date_end_start = " " ;
$search_date_end_endmonth = " " ;
$search_date_end_endyear = " " ;
$search_date_end_endday = " " ;
$search_date_end_end = " " ;
2019-11-12 09:46:08 +01:00
$search_usage_opportunity = '' ;
$search_usage_task = '' ;
$search_usage_bill_time = '' ;
2021-02-15 12:18:08 +01:00
$search_usage_event_organization = '' ;
2021-02-22 21:00:54 +01:00
$search_accept_conference_suggestions = '' ;
$search_accept_booth_suggestions = '' ;
2021-02-21 12:32:16 +01:00
$search_price_registration = '' ;
$search_price_booth = '' ;
2022-06-29 17:32:50 +02:00
$search_login = '' ;
2023-02-19 16:12:28 +01:00
$search_import_key = '' ;
2022-05-08 18:25:22 +02:00
$toselect = array ();
2019-11-12 09:46:08 +01:00
$search_array_options = array ();
2020-05-31 20:57:16 +02:00
$search_category_array = array ();
2017-10-07 13:09:31 +02:00
}
// Mass actions
2019-11-12 09:46:08 +01:00
$objectclass = 'Project' ;
$objectlabel = 'Project' ;
2019-11-04 15:33:49 +01:00
$permissiontoread = $user -> rights -> projet -> lire ;
$permissiontodelete = $user -> rights -> projet -> supprimer ;
2020-12-24 00:48:22 +01:00
$permissiontoadd = $user -> rights -> projet -> creer ;
2022-06-14 17:53:17 +02:00
$uploaddir = $conf -> project -> dir_output ;
2017-10-07 13:09:31 +02:00
include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php' ;
2018-03-16 15:24:49 +01:00
2020-10-07 15:01:28 +02:00
// Close records
2021-02-26 18:49:22 +01:00
if ( ! $error && $massaction == 'close' && $user -> rights -> projet -> creer ) {
2020-10-07 15:01:28 +02:00
$db -> begin ();
$objecttmp = new $objectclass ( $db );
$nbok = 0 ;
2021-02-26 18:49:22 +01:00
foreach ( $toselect as $toselectid ) {
2020-10-07 15:01:28 +02:00
$result = $objecttmp -> fetch ( $toselectid );
2021-02-26 18:49:22 +01:00
if ( $result > 0 ) {
2020-10-31 14:32:18 +01:00
$userWrite = $object -> restrictedProjectArea ( $user , 'write' );
2020-10-07 15:01:28 +02:00
if ( $userWrite > 0 && $objecttmp -> statut == 1 ) {
$result = $objecttmp -> setClose ( $user );
if ( $result <= 0 ) {
setEventMessages ( $objecttmp -> error , $objecttmp -> errors , 'errors' );
$error ++ ;
break ;
2021-02-26 18:49:22 +01:00
} else {
$nbok ++ ;
}
2020-10-07 15:01:28 +02:00
} elseif ( $userWrite <= 0 ) {
setEventMessages ( $langs -> trans ( " DontHavePermissionForCloseProject " , $objecttmp -> ref ), null , 'warnings' );
} else {
setEventMessages ( $langs -> trans ( " DontHaveTheValidateStatus " , $objecttmp -> ref ), null , 'warnings' );
}
} else {
setEventMessages ( $objecttmp -> error , $objecttmp -> errors , 'errors' );
$error ++ ;
break ;
}
}
2021-02-26 18:49:22 +01:00
if ( ! $error ) {
if ( $nbok > 1 ) {
setEventMessages ( $langs -> trans ( " RecordsClosed " , $nbok ), null , 'mesgs' );
} else {
setEventMessages ( $langs -> trans ( " RecordsClosed " , $nbok ), null , 'mesgs' );
}
2020-10-07 15:01:28 +02:00
$db -> commit ();
} else {
$db -> rollback ();
}
}
2016-11-02 12:48:50 +01:00
}
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
*/
2015-01-29 18:17:43 +01:00
$form = new Form ( $db );
2022-11-08 14:59:22 +01:00
$formcompany = new FormCompany ( $db );
2022-11-08 15:02:51 +01:00
2023-02-19 16:12:28 +01:00
$now = dol_now ();
2022-09-19 18:57:39 +02:00
$companystatic = new Societe ( $db );
2022-11-08 14:59:22 +01:00
$taskstatic = new Task ( $db );
2015-01-29 18:17:43 +01:00
$formother = new FormOther ( $db );
2015-06-30 01:34:17 +02:00
$formproject = new FormProjets ( $db );
2008-03-02 23:20:44 +01:00
2020-12-17 22:52:42 +01:00
$help_url = " EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos " ;
2022-09-19 18:57:39 +02:00
$title = $langs -> trans ( " LeadsOrProjects " );
if ( empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
$title = $langs -> trans ( " Projects " );
}
if ( isset ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) && $conf -> global -> PROJECT_USE_OPPORTUNITIES == 2 ) { // 2 = leads only
$title = $langs -> trans ( " Leads " );
}
$morejs = array ();
$morecss = array ();
2017-03-14 13:49:04 +01:00
2012-03-19 14:44:27 +01:00
2020-10-12 17:41:03 +02:00
// Get list of project id allowed to user (in a string list separated by comma)
2019-11-12 09:46:08 +01:00
$projectsListId = '' ;
2021-10-24 10:02:12 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2021-02-26 18:49:22 +01:00
$projectsListId = $object -> getProjectsAuthorizedForUser ( $user , 0 , 1 , $socid );
}
2016-01-21 14:59:09 +01:00
// Get id of types of contacts for projects (This list never contains a lot of elements)
2019-11-12 09:46:08 +01:00
$listofprojectcontacttype = array ();
2022-01-05 14:35:11 +01:00
$listofprojectcontacttypeexternal = array ();
$sql = " SELECT ctc.rowid, ctc.code, ctc.source FROM " . MAIN_DB_PREFIX . " c_type_contact as ctc " ;
2020-09-20 03:32:43 +02:00
$sql .= " WHERE ctc.element = ' " . $db -> escape ( $object -> element ) . " ' " ;
2016-01-21 14:59:09 +01:00
$resql = $db -> query ( $sql );
2021-02-26 18:49:22 +01:00
if ( $resql ) {
while ( $obj = $db -> fetch_object ( $resql )) {
2022-01-05 15:33:05 +01:00
if ( $obj -> source == 'internal' ) $listofprojectcontacttype [ $obj -> rowid ] = $obj -> code ;
2022-01-05 14:35:11 +01:00
else $listofprojectcontacttypeexternal [ $obj -> rowid ] = $obj -> code ;
2017-10-07 13:09:31 +02:00
}
2021-02-26 18:49:22 +01:00
} else {
dol_print_error ( $db );
}
if ( count ( $listofprojectcontacttype ) == 0 ) {
$listofprojectcontacttype [ 0 ] = '0' ; // To avoid sql syntax error if not found
}
2022-01-05 14:35:11 +01:00
if ( count ( $listofprojectcontacttypeexternal ) == 0 ) {
$listofprojectcontacttypeexternal [ 0 ] = '0' ; // To avoid sql syntax error if not found
}
2010-02-04 18:54:00 +01:00
2022-12-07 10:11:57 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage ); // This also change content of $arrayfields
2023-02-19 16:12:28 +01:00
$distinct = 'DISTINCT' ; // We add distinct until we have added a protection to be sure a contact of a project and task is only once.
2021-05-17 23:27:33 +02:00
$sql = " SELECT " . $distinct . " p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat, " ;
$sql .= " p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount, " ;
$sql .= " p.usage_opportunity, p.usage_task, p.usage_bill_time, p.usage_organize_event, " ;
2022-12-05 15:31:05 +01:00
$sql .= " p.email_msgid, p.import_key, " ;
2022-06-29 17:32:50 +02:00
$sql .= " p.accept_conference_suggestions, p.accept_booth_suggestions, p.price_registration, p.price_booth, " ;
2021-05-17 23:27:33 +02:00
$sql .= " s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client, " ;
$sql .= " country.code as country_code, " ;
2022-06-29 17:32:50 +02:00
$sql .= " cls.code as opp_status_code, " ;
$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender' ;
2019-10-16 03:34:32 +02:00
// Add fields from extrafields
2019-11-12 09:46:08 +01:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 18:49:22 +01:00
foreach ( $extrafields -> attributes [ $object -> table_element ][ 'label' ] as $key => $val ) {
2021-08-27 22:42:04 +02:00
$sql .= ( $extrafields -> attributes [ $object -> table_element ][ 'type' ][ $key ] != 'separate' ? " , ef. " . $key . " as options_ " . $key : '' );
2021-02-26 18:49:22 +01:00
}
2019-10-16 03:34:32 +02:00
}
2015-06-22 15:48:48 +02:00
// Add fields from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2020-12-17 22:52:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListSelect' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= preg_replace ( '/^,/' , '' , $hookmanager -> resPrint );
$sql = preg_replace ( '/,\s*$/' , '' , $sql );
2023-02-19 16:12:28 +01:00
$sqlfields = $sql ; // $sql fields to remove for count total
2020-12-17 22:52:42 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . $object -> table_element . " as p " ;
2021-08-25 12:54:09 +02:00
if ( ! empty ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && is_array ( $extrafields -> attributes [ $object -> table_element ][ 'label' ]) && count ( $extrafields -> attributes [ $object -> table_element ][ 'label' ])) {
2021-02-26 18:49:22 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object -> table_element . " _extrafields as ef on (p.rowid = ef.fk_object) " ;
}
2019-11-12 09:46:08 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe as s on p.fk_soc = s.rowid " ;
2021-05-17 23:27:33 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_country as country on (country.rowid = s.fk_pays) " ;
2019-11-12 09:46:08 +01:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " c_lead_status as cls on p.fk_opp_status = cls.rowid " ;
2022-06-29 17:32:50 +02:00
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'user AS u ON p.fk_user_creat = u.rowid' ;
2015-01-30 11:08:49 +01:00
// We'll need this table joined to the select in order to filter by sale
2018-06-20 21:24:57 +02:00
// No check is done on company permission because readability is managed by public status of project and assignement.
2017-01-12 15:23:30 +01: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";
2021-02-26 18:49:22 +01:00
if ( $search_sale > 0 ) {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " societe_commerciaux as sc ON sc.fk_soc = s.rowid " ;
}
if ( $search_project_user > 0 ) {
2019-11-12 09:46:08 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " element_contact as ecp " ;
2015-01-30 11:08:49 +01:00
}
2022-01-05 14:35:11 +01:00
if ( $search_project_contact > 0 ) {
$sql .= " , " . MAIN_DB_PREFIX . " element_contact as ecp_contact " ;
}
2022-12-08 16:33:04 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListFrom' , $parameters , $object ); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager -> resPrint ;
2019-11-12 09:46:08 +01:00
$sql .= " WHERE p.entity IN ( " . getEntity ( 'project' ) . ')' ;
2021-10-24 10:02:12 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.rowid IN ( " . $db -> sanitize ( $projectsListId ) . " ) " ; // public and assigned to, or restricted to company for external users
2021-02-26 18:49:22 +01:00
}
2017-07-31 04:52:27 +02:00
// No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
2021-02-26 18:49:22 +01:00
if ( $socid > 0 ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND (p.fk_soc = " . (( int ) $socid ) . " ) " ; // This filter if when we use a hard coded filter on company on url (not related to filter for external users)
2021-02-26 18:49:22 +01:00
}
if ( $search_ref ) {
$sql .= natural_search ( 'p.ref' , $search_ref );
}
if ( $search_label ) {
$sql .= natural_search ( 'p.title' , $search_label );
}
2022-12-08 10:34:48 +01:00
if ( empty ( $arrayfields [ 's.name_alias' ][ 'checked' ]) && $search_societe ) {
2022-12-07 10:11:57 +01:00
$sql .= natural_search ( array ( " s.nom " , " s.name_alias " ), $search_societe );
} else {
if ( $search_societe ) {
$sql .= natural_search ( 's.nom' , $search_societe );
}
if ( $search_societe_alias ) {
$sql .= natural_search ( 's.name_alias' , $search_societe_alias );
}
2022-06-21 17:57:00 +02:00
}
2021-02-26 18:49:22 +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 );
}
2019-09-28 13:22:05 +02:00
$sql .= dolSqlDateFilter ( 'p.dateo' , $search_sday , $search_smonth , $search_syear );
$sql .= dolSqlDateFilter ( 'p.datee' , $search_eday , $search_emonth , $search_eyear );
2021-08-25 12:46:56 +02:00
if ( $search_date_start_start ) {
$sql .= " AND p.dateo >= ' " . $db -> idate ( $search_date_start_start ) . " ' " ;
}
if ( $search_date_start_end ) {
$sql .= " AND p.dateo <= ' " . $db -> idate ( $search_date_start_end ) . " ' " ;
}
if ( $search_date_end_start ) {
$sql .= " AND p.datee >= ' " . $db -> idate ( $search_date_end_start ) . " ' " ;
}
if ( $search_date_end_end ) {
$sql .= " AND p.datee <= ' " . $db -> idate ( $search_date_end_end ) . " ' " ;
}
2021-02-26 18:49:22 +01:00
if ( $search_all ) {
$sql .= natural_search ( array_keys ( $fieldstosearchall ), $search_all );
}
if ( $search_status >= 0 ) {
if ( $search_status == 99 ) {
$sql .= " AND p.fk_statut <> 2 " ;
} else {
2021-06-09 15:36:47 +02:00
$sql .= " AND p.fk_statut = " . (( int ) $search_status );
2021-02-26 18:49:22 +01:00
}
}
if ( $search_opp_status ) {
if ( is_numeric ( $search_opp_status ) && $search_opp_status > 0 ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND p.fk_opp_status = " . (( int ) $search_opp_status );
2021-02-26 18:49:22 +01:00
}
if ( $search_opp_status == 'all' ) {
$sql .= " AND (p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1) " ;
}
if ( $search_opp_status == 'openedopp' ) {
$sql .= " AND p.fk_opp_status IS NOT NULL AND p.fk_opp_status <> -1 AND p.fk_opp_status NOT IN (SELECT rowid FROM " . MAIN_DB_PREFIX . " c_lead_status WHERE code IN ('WON','LOST')) " ;
}
if ( $search_opp_status == 'notopenedopp' ) {
2021-03-22 12:47:23 +01:00
$sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1 OR p.fk_opp_status IN (SELECT rowid FROM " . MAIN_DB_PREFIX . " c_lead_status WHERE code = 'WON')) " ;
2021-02-26 18:49:22 +01:00
}
if ( $search_opp_status == 'none' ) {
$sql .= " AND (p.fk_opp_status IS NULL OR p.fk_opp_status = -1) " ;
}
}
if ( $search_public != '' ) {
2021-06-09 15:36:47 +02:00
$sql .= " AND p.public = " . (( int ) $search_public );
2021-02-26 18:49:22 +01:00
}
2017-01-12 15:23:30 +01:00
// For external user, no check is done on company permission because readability is managed by public status of project and assignement.
2021-04-24 20:18:11 +02:00
//if ($socid > 0) $sql.= " AND s.rowid = ".((int) $socid);
2021-02-26 18:49:22 +01:00
if ( $search_sale > 0 ) {
2021-03-22 13:31:06 +01:00
$sql .= " AND sc.fk_user = " . (( int ) $search_sale );
2021-02-26 18:49:22 +01:00
}
2018-06-20 21:24:57 +02:00
// No check is done on company permission because readability is managed by public status of project and assignement.
2021-08-23 18:56:46 +02:00
//if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id).") OR (s.rowid IS NULL))";
2021-02-26 18:49:22 +01:00
if ( $search_project_user > 0 ) {
2023-02-19 16:12:28 +01:00
// TODO Replace this with a EXISTS and remove the link to table + DISTINCT
2021-08-23 18:56:46 +02:00
$sql .= " AND ecp.fk_c_type_contact IN ( " . $db -> sanitize ( join ( ',' , array_keys ( $listofprojectcontacttype ))) . " ) AND ecp.element_id = p.rowid AND ecp.fk_socpeople = " . (( int ) $search_project_user );
2021-02-26 18:49:22 +01:00
}
2022-01-05 14:35:11 +01:00
if ( $search_project_contact > 0 ) {
2023-02-19 16:12:28 +01:00
// TODO Replace this with a EXISTS and remove the link to table + DISTINCT
2022-01-05 14:35:11 +01:00
$sql .= " AND ecp_contact.fk_c_type_contact IN ( " . $db -> sanitize ( join ( ',' , array_keys ( $listofprojectcontacttypeexternal ))) . " ) AND ecp_contact.element_id = p.rowid AND ecp_contact.fk_socpeople = " . (( int ) $search_project_contact );
}
2021-02-26 18:49:22 +01: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 );
}
if ( $search_usage_opportunity != '' && $search_usage_opportunity >= 0 ) {
$sql .= natural_search ( 'p.usage_opportunity' , $search_usage_opportunity , 2 );
}
if ( $search_usage_task != '' && $search_usage_task >= 0 ) {
$sql .= natural_search ( 'p.usage_task' , $search_usage_task , 2 );
}
if ( $search_usage_bill_time != '' && $search_usage_bill_time >= 0 ) {
$sql .= natural_search ( 'p.usage_bill_time' , $search_usage_bill_time , 2 );
}
if ( $search_usage_event_organization != '' && $search_usage_event_organization >= 0 ) {
$sql .= natural_search ( 'p.usage_organize_event' , $search_usage_event_organization , 2 );
}
if ( $search_accept_conference_suggestions != '' && $search_accept_conference_suggestions >= 0 ) {
$sql .= natural_search ( 'p.accept_conference_suggestions' , $search_accept_conference_suggestions , 2 );
}
if ( $search_accept_booth_suggestions != '' && $search_accept_booth_suggestions >= 0 ) {
$sql .= natural_search ( 'p.accept_booth_suggestions' , $search_accept_booth_suggestions , 2 );
}
if ( $search_price_registration != '' ) {
$sql .= natural_search ( 'p.price_registration' , $search_price_registration , 1 );
}
if ( $search_price_booth != '' ) {
$sql .= natural_search ( 'p.price_booth' , $search_price_booth , 1 );
}
2022-06-29 17:32:50 +02:00
if ( $search_login ) {
$sql .= natural_search ( array ( 'u.login' , 'u.firstname' , 'u.lastname' ), $search_login );
}
2023-02-19 16:12:28 +01:00
if ( $search_import_key ) {
$sql .= natural_search ( array ( 'p.import_key' ), $search_import_key );
}
2022-10-11 02:26:12 +02:00
// Search for tag/category ($searchCategoryProjectList is an array of ID)
$searchCategoryProjectList = $search_category_array ;
$searchCategoryProjectOperator = 0 ;
if ( ! empty ( $searchCategoryProjectList )) {
$searchCategoryProjectSqlList = array ();
$listofcategoryid = '' ;
foreach ( $searchCategoryProjectList as $searchCategoryProject ) {
if ( intval ( $searchCategoryProject ) == - 2 ) {
$searchCategoryProjectSqlList [] = " NOT EXISTS (SELECT ck.fk_project FROM " . MAIN_DB_PREFIX . " categorie_project as ck WHERE p.rowid = ck.fk_project) " ;
} elseif ( intval ( $searchCategoryProject ) > 0 ) {
2022-10-31 08:13:11 +01:00
if ( $searchCategoryProjectOperator == 0 ) {
$searchCategoryProjectSqlList [] = " EXISTS (SELECT ck.fk_project FROM " . MAIN_DB_PREFIX . " categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie = " . (( int ) $searchCategoryProject ) . " ) " ;
} else {
$listofcategoryid .= ( $listofcategoryid ? ', ' : '' ) . (( int ) $searchCategoryProject );
}
2022-10-11 02:26:12 +02:00
}
}
if ( $listofcategoryid ) {
$searchCategoryProjectSqlList [] = " EXISTS (SELECT ck.fk_project FROM " . MAIN_DB_PREFIX . " categorie_project as ck WHERE p.rowid = ck.fk_project AND ck.fk_categorie IN ( " . $db -> sanitize ( $listofcategoryid ) . " )) " ;
}
if ( $searchCategoryProjectOperator == 1 ) {
if ( ! empty ( $searchCategoryProjectSqlList )) {
$sql .= " AND ( " . implode ( ' OR ' , $searchCategoryProjectSqlList ) . " ) " ;
}
} else {
if ( ! empty ( $searchCategoryProjectSqlList )) {
$sql .= " AND ( " . implode ( ' AND ' , $searchCategoryProjectSqlList ) . " ) " ;
}
}
}
2022-04-22 17:10:24 +02:00
$searchCategoryCustomerSqlList = array ();
if ( $searchCategoryCustomerOperator == 1 ) {
$existsCategoryCustomerList = array ();
foreach ( $searchCategoryCustomerList as $searchCategoryCustomer ) {
if ( intval ( $searchCategoryCustomer ) == - 2 ) {
$sqlCategoryCustomerNotExists = " NOT EXISTS ( " ;
$sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc " ;
$sqlCategoryCustomerNotExists .= " FROM " . $db -> prefix () . " categorie_societe AS cat_cus " ;
$sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc " ;
$sqlCategoryCustomerNotExists .= " ) " ;
$searchCategoryCustomerSqlList [] = $sqlCategoryCustomerNotExists ;
} elseif ( intval ( $searchCategoryCustomer ) > 0 ) {
$existsCategoryCustomerList [] = $db -> escape ( $searchCategoryCustomer );
}
}
if ( ! empty ( $existsCategoryCustomerList )) {
$sqlCategoryCustomerExists = " EXISTS ( " ;
$sqlCategoryCustomerExists .= " SELECT cat_cus.fk_soc " ;
$sqlCategoryCustomerExists .= " FROM " . $db -> prefix () . " categorie_societe AS cat_cus " ;
$sqlCategoryCustomerExists .= " WHERE cat_cus.fk_soc = p.fk_soc " ;
$sqlCategoryCustomerExists .= " AND cat_cus.fk_categorie IN ( " . $db -> sanitize ( implode ( ',' , $existsCategoryCustomerList )) . " ) " ;
$sqlCategoryCustomerExists .= " ) " ;
$searchCategoryCustomerSqlList [] = $sqlCategoryCustomerExists ;
}
if ( ! empty ( $searchCategoryCustomerSqlList )) {
$sql .= " AND ( " . implode ( ' OR ' , $searchCategoryCustomerSqlList ) . " ) " ;
}
} else {
foreach ( $searchCategoryCustomerList as $searchCategoryCustomer ) {
if ( intval ( $searchCategoryCustomer ) == - 2 ) {
$sqlCategoryCustomerNotExists = " NOT EXISTS ( " ;
$sqlCategoryCustomerNotExists .= " SELECT cat_cus.fk_soc " ;
$sqlCategoryCustomerNotExists .= " FROM " . $db -> prefix () . " categorie_societe AS cat_cus " ;
$sqlCategoryCustomerNotExists .= " WHERE cat_cus.fk_soc = p.fk_soc " ;
$sqlCategoryCustomerNotExists .= " ) " ;
$searchCategoryCustomerSqlList [] = $sqlCategoryCustomerNotExists ;
} elseif ( intval ( $searchCategoryCustomer ) > 0 ) {
$searchCategoryCustomerSqlList [] = " p.fk_soc IN (SELECT fk_soc FROM " . $db -> prefix () . " categorie_societe WHERE fk_categorie = " . (( int ) $searchCategoryCustomer ) . " ) " ;
}
}
if ( ! empty ( $searchCategoryCustomerSqlList )) {
$sql .= " AND ( " . implode ( ' AND ' , $searchCategoryCustomerSqlList ) . " ) " ;
}
}
2016-04-04 16:02:29 +02:00
// Add where from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php' ;
2015-06-22 15:48:48 +02:00
// Add where from hooks
2019-11-12 09:46:08 +01:00
$parameters = array ();
2020-12-17 22:52:42 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhere' , $parameters , $object ); // Note that $action and $object may have been modified by hook
2019-11-12 09:46:08 +01:00
$sql .= $hookmanager -> resPrint ;
2023-02-19 16:12:28 +01:00
//print $sql;
2016-01-21 14:59:09 +01:00
2020-12-17 22:52:42 +01:00
// Count total nb of records
2017-01-15 20:49:20 +01:00
$nbtotalofrecords = '' ;
2020-12-17 22:52:42 +01:00
if ( empty ( $conf -> global -> MAIN_DISABLE_FULL_SCANLIST )) {
2023-02-19 16:12:28 +01:00
/* The fast and low memory method to get and count full list converts the sql into a sql count */
$sqlforcount = preg_replace ( '/^' . preg_quote ( $sqlfields , '/' ) . '/' , 'SELECT COUNT(*) as nbtotalofrecords' , $sql );
$sqlforcount = preg_replace ( '/GROUP BY .*$/' , '' , $sqlforcount );
$resql = $db -> query ( $sqlforcount );
if ( $resql ) {
$objforcount = $db -> fetch_object ( $resql );
$nbtotalofrecords = $objforcount -> nbtotalofrecords ;
} else {
dol_print_error ( $db );
}
if (( $page * $limit ) > $nbtotalofrecords ) { // if total resultset is smaller then paging size (filtering), goto and load page 0
2018-04-24 11:37:57 +02:00
$page = 0 ;
$offset = 0 ;
}
2023-02-19 16:12:28 +01:00
$db -> free ( $resql );
2016-01-21 14:59:09 +01:00
}
2023-02-19 16:12:28 +01:00
// Complete request and execute it with limit
$sql .= $db -> order ( $sortfield , $sortorder );
if ( $limit ) {
$sql .= $db -> plimit ( $limit + 1 , $offset );
}
2018-11-22 11:36:30 +01:00
2023-02-19 16:12:28 +01:00
$resql = $db -> query ( $sql );
if ( ! $resql ) {
dol_print_error ( $db );
exit ;
2016-11-02 12:48:50 +01:00
}
2016-06-16 12:42:21 +02:00
2023-02-19 16:12:28 +01:00
$num = $db -> num_rows ( $resql );
2020-12-17 22:52:42 +01:00
// Direct jump if only one record found
2023-02-19 16:12:28 +01:00
if ( $num == 1 && ! empty ( $conf -> global -> MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE ) && $search_all && ! $page ) {
2017-10-07 13:09:31 +02:00
$obj = $db -> fetch_object ( $resql );
header ( " Location: " . DOL_URL_ROOT . '/projet/card.php?id=' . $obj -> id );
exit ;
2016-11-02 12:48:50 +01:00
}
2015-06-22 11:55:21 +02:00
2020-12-17 22:52:42 +01:00
// Output page
// --------------------------------------------------------------------
llxHeader ( '' , $title , $help_url );
$arrayofselected = is_array ( $toselect ) ? $toselect : array ();
2016-09-18 15:57:53 +02:00
2019-11-12 09:46:08 +01:00
$param = '' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $contextpage ) && $contextpage != $_SERVER [ " PHP_SELF " ]) {
$param .= '&contextpage=' . urlencode ( $contextpage );
}
if ( $limit > 0 && $limit != $conf -> liste_limit ) {
2023-04-06 13:29:24 +02:00
$param .= '&limit=' . (( int ) $limit );
2021-02-26 18:49:22 +01:00
}
if ( $search_all != '' ) {
$param .= '&search_all=' . urlencode ( $search_all );
}
if ( $search_sday ) {
$param .= '&search_sday=' . urlencode ( $search_sday );
}
if ( $search_smonth ) {
$param .= '&search_smonth=' . urlencode ( $search_smonth );
}
if ( $search_syear ) {
$param .= '&search_syear=' . urlencode ( $search_syear );
}
if ( $search_eday ) {
$param .= '&search_eday=' . urlencode ( $search_eday );
}
if ( $search_emonth ) {
$param .= '&search_emonth=' . urlencode ( $search_emonth );
}
if ( $search_eyear ) {
$param .= '&search_eyear=' . urlencode ( $search_eyear );
}
2021-08-25 12:46:56 +02:00
if ( $search_date_start_startmonth ) {
$param .= '&search_date_start_startmonth=' . urlencode ( $search_date_start_startmonth );
}
if ( $search_date_start_startyear ) {
$param .= '&search_date_start_startyear=' . urlencode ( $search_date_start_startyear );
}
if ( $search_date_start_startday ) {
$param .= '&search_date_start_startday=' . urlencode ( $search_date_start_startday );
}
if ( $search_date_start_start ) {
$param .= '&search_date_start_start=' . urlencode ( $search_date_start_start );
}
if ( $search_date_start_endmonth ) {
$param .= '&search_date_start_endmonth=' . urlencode ( $search_date_start_endmonth );
}
if ( $search_date_start_endyear ) {
$param .= '&search_date_start_endyear=' . urlencode ( $search_date_start_endyear );
}
if ( $search_date_start_endday ) {
$param .= '&search_date_start_endday=' . urlencode ( $search_date_start_endday );
}
if ( $search_date_start_end ) {
$param .= '&search_date_start_end=' . urlencode ( $search_date_start_end );
}
if ( $search_date_end_startmonth ) {
$param .= '&search_date_end_startmonth=' . urlencode ( $search_date_end_startmonth );
}
if ( $search_date_end_startyear ) {
$param .= '&search_date_end_startyear=' . urlencode ( $search_date_end_startyear );
}
if ( $search_date_end_startday ) {
$param .= '&search_date_end_startday=' . urlencode ( $search_date_end_startday );
}
if ( $search_date_end_start ) {
$param .= '&search_date_end_start=' . urlencode ( $search_date_end_start );
}
if ( $search_date_end_endmonth ) {
$param .= '&search_date_end_endmonth=' . urlencode ( $search_date_end_endmonth );
}
if ( $search_date_end_endyear ) {
$param .= '&search_date_end_endyear=' . urlencode ( $search_date_end_endyear );
}
if ( $search_date_end_endday ) {
$param .= '&search_date_end_endday=' . urlencode ( $search_date_end_endday );
}
if ( $search_date_end_end ) {
$param .= '&search_date_end_end=' . urlencode ( $search_date_end_end );
}
2021-02-26 18:49:22 +01:00
if ( $socid ) {
$param .= '&socid=' . urlencode ( $socid );
}
if ( $search_ref != '' ) {
$param .= '&search_ref=' . urlencode ( $search_ref );
}
if ( $search_label != '' ) {
$param .= '&search_label=' . urlencode ( $search_label );
}
if ( $search_societe != '' ) {
$param .= '&search_societe=' . urlencode ( $search_societe );
}
2022-06-21 17:57:00 +02:00
if ( $search_societe_alias != '' ) {
$param .= '&search_societe_alias=' . urlencode ( $search_societe_alias );
}
2021-02-26 18:49:22 +01:00
if ( $search_status >= 0 ) {
$param .= '&search_status=' . urlencode ( $search_status );
}
if (( is_numeric ( $search_opp_status ) && $search_opp_status >= 0 ) || in_array ( $search_opp_status , array ( 'all' , 'openedopp' , 'notopenedopp' , 'none' ))) {
$param .= '&search_opp_status=' . urlencode ( $search_opp_status );
}
if ( $search_opp_percent != '' ) {
$param .= '&search_opp_percent=' . urlencode ( $search_opp_percent );
}
if ( $search_public != '' ) {
$param .= '&search_public=' . urlencode ( $search_public );
}
2022-02-26 19:15:40 +01:00
if ( $search_project_user > 0 ) {
2021-02-26 18:49:22 +01:00
$param .= '&search_project_user=' . urlencode ( $search_project_user );
}
2022-01-05 14:35:11 +01:00
if ( $search_project_contact != '' ) {
2023-03-07 17:36:40 +01:00
$param .= '&search_project_contact=' . urlencode ( $search_project_contact );
2022-01-05 14:35:11 +01:00
}
2021-02-26 18:49:22 +01:00
if ( $search_sale > 0 ) {
$param .= '&search_sale=' . urlencode ( $search_sale );
}
if ( $search_opp_amount != '' ) {
$param .= '&search_opp_amount=' . urlencode ( $search_opp_amount );
}
if ( $search_budget_amount != '' ) {
$param .= '&search_budget_amount=' . urlencode ( $search_budget_amount );
}
if ( $search_usage_task != '' ) {
$param .= '&search_usage_task=' . urlencode ( $search_usage_task );
}
if ( $search_usage_bill_time != '' ) {
$param .= '&search_usage_opportunity=' . urlencode ( $search_usage_bill_time );
}
if ( $search_usage_event_organization != '' ) {
$param .= '&search_usage_event_organization=' . urlencode ( $search_usage_event_organization );
}
if ( $search_accept_conference_suggestions != '' ) {
$param .= '&search_accept_conference_suggestions=' . urlencode ( $search_accept_conference_suggestions );
}
if ( $search_accept_booth_suggestions != '' ) {
$param .= '&search_accept_booth_suggestions=' . urlencode ( $search_accept_booth_suggestions );
}
if ( $search_price_registration != '' ) {
$param .= '&search_price_registration=' . urlencode ( $search_price_registration );
}
if ( $search_price_booth != '' ) {
$param .= '&search_price_booth=' . urlencode ( $search_price_booth );
}
2022-06-29 17:32:50 +02:00
if ( $search_login ) {
$param .= '&search_login=' . urlencode ( $search_login );
}
2023-02-19 16:12:28 +01:00
if ( $search_import_key ) {
$param .= '&search_import_key=' . urlencode ( $search_import_key );
}
2021-02-26 18:49:22 +01:00
if ( $optioncss != '' ) {
$param .= '&optioncss=' . urlencode ( $optioncss );
}
2022-04-22 17:10:24 +02:00
foreach ( $searchCategoryCustomerList as $searchCategoryCustomer ) {
$param .= " &search_category_customer_list[]= " . urlencode ( $searchCategoryCustomer );
}
2016-11-02 12:48:50 +01:00
// Add $param from extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php' ;
2016-09-18 15:48:29 +02:00
2017-04-11 02:48:16 +02:00
// List of mass actions available
2019-11-12 09:46:08 +01:00
$arrayofmassactions = array (
2023-02-19 16:28:04 +01:00
'validate' => img_picto ( '' , 'check' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Validate " ),
2021-04-14 12:28:01 +02:00
'generate_doc' => img_picto ( '' , 'pdf' , 'class="pictofixedwidth"' ) . $langs -> trans ( " ReGeneratePDF " ),
2021-04-14 14:45:55 +02:00
//'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
//'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
2017-04-11 02:48:16 +02:00
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
2021-02-26 18:49:22 +01:00
if ( $user -> rights -> projet -> creer ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'close' ] = img_picto ( '' , 'close_title' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Close " );
2022-11-08 14:59:22 +01:00
$arrayofmassactions [ 'preaffectuser' ] = img_picto ( '' , 'user' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AffectUser " );
2021-02-26 18:49:22 +01:00
}
if ( $user -> rights -> projet -> supprimer ) {
2021-04-14 12:28:01 +02:00
$arrayofmassactions [ 'predelete' ] = img_picto ( '' , 'delete' , 'class="pictofixedwidth"' ) . $langs -> trans ( " Delete " );
2021-02-26 18:49:22 +01:00
}
2022-09-23 11:46:55 +02:00
if ( isModEnabled ( 'category' ) && $user -> rights -> projet -> creer ) {
2021-04-14 12:33:53 +02:00
$arrayofmassactions [ 'preaffecttag' ] = img_picto ( '' , 'category' , 'class="pictofixedwidth"' ) . $langs -> trans ( " AffectTag " );
2021-02-26 18:49:22 +01:00
}
2022-11-08 15:02:51 +01:00
if ( in_array ( $massaction , array ( 'presend' , 'predelete' , 'preaffecttag' , 'preaffectuser' ))) {
2021-02-26 18:49:22 +01:00
$arrayofmassactions = array ();
}
2018-03-16 15:24:49 +01:00
2019-11-12 09:46:08 +01:00
$massactionbutton = $form -> selectMassAction ( '' , $arrayofmassactions );
2017-04-11 02:48:16 +02:00
2020-09-18 10:46:23 +02:00
$url = DOL_URL_ROOT . '/projet/card.php?action=create' ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $socid )) {
$url .= '&socid=' . $socid ;
}
2021-11-27 01:09:16 +01:00
if ( $search_usage_event_organization == 1 ) {
$url .= '&usage_organize_event=1' ;
}
2020-09-18 10:52:17 +02:00
$newcardbutton = dolGetButtonTitle ( $langs -> trans ( 'NewProject' ), '' , 'fa fa-plus-circle' , $url , '' , $user -> rights -> projet -> creer );
2018-03-30 16:54:38 +02:00
2016-11-02 12:48:50 +01:00
print '<form method="POST" id="searchFormList" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2021-02-26 18:49:22 +01:00
if ( $optioncss != '' ) {
print '<input type="hidden" name="optioncss" value="' . $optioncss . '">' ;
}
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2016-11-02 12:48:50 +01:00
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="contextpage" value="' . $contextpage . '">' ;
// Show description of content
2019-11-12 09:46:08 +01:00
$texthelp = '' ;
2021-02-26 18:49:22 +01:00
if ( $search_project_user == $user -> id ) {
$texthelp .= $langs -> trans ( " MyProjectsDesc " );
} else {
if ( $user -> rights -> projet -> all -> lire && ! $socid ) {
$texthelp .= $langs -> trans ( " ProjectsDesc " );
} else {
$texthelp .= $langs -> trans ( " ProjectsPublicDesc " );
}
2016-11-02 12:48:50 +01:00
}
2019-04-09 19:36:56 +02:00
2020-04-12 18:13:43 +02:00
print_barre_liste ( $form -> textwithpicto ( $title , $texthelp ), $page , $_SERVER [ " PHP_SELF " ], $param , $sortfield , $sortorder , $massactionbutton , $num , $nbtotalofrecords , 'project' , 0 , $newcardbutton , '' , $limit , 0 , 0 , 1 );
2019-04-09 19:36:56 +02:00
2016-11-02 12:48:50 +01:00
2019-11-12 09:46:08 +01:00
$topicmail = " Information " ;
$modelmail = " project " ;
$objecttmp = new Project ( $db );
2020-11-08 14:39:20 +01:00
$trackid = 'proj' . $object -> id ;
2017-11-15 11:39:11 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php' ;
2021-02-26 18:49:22 +01:00
if ( $search_all ) {
foreach ( $fieldstosearchall as $key => $val ) {
$fieldstosearchall [ $key ] = $langs -> trans ( $val );
}
2019-11-12 09:46:08 +01:00
print '<div class="divsearchfieldfilter">' . $langs -> trans ( " FilterOnInto " , $search_all ) . join ( ', ' , $fieldstosearchall ) . '</div>' ;
2016-11-02 12:48:50 +01:00
}
2019-11-12 09:46:08 +01:00
$moreforfilter = '' ;
2016-11-02 12:48:50 +01:00
// If the user can view user other than himself
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-29 13:00:17 +02:00
$tmptitle = $langs -> trans ( 'ProjectsWithThisUserAsContact' );
2020-11-10 15:03:35 +01:00
//$includeonly = 'hierarchyme';
$includeonly = '' ;
2021-02-26 18:49:22 +01:00
if ( empty ( $user -> rights -> user -> user -> lire )) {
$includeonly = array ( $user -> id );
}
2022-02-25 21:45:29 +01:00
$moreforfilter .= img_picto ( $tmptitle , 'user' , 'class="pictofixedwidth"' ) . $form -> select_dolusers ( $search_project_user ? $search_project_user : '' , 'search_project_user' , $tmptitle , '' , 0 , $includeonly , '' , 0 , 0 , 0 , '' , 0 , '' , 'maxwidth250 widthcentpercentminusx' );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2016-11-02 12:48:50 +01:00
2022-01-05 14:35:11 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
$tmptitle = $langs -> trans ( 'ProjectsWithThisContact' );
2023-04-06 13:29:24 +02:00
$moreforfilter .= img_picto ( $tmptitle , 'contact' , 'class="pictofixedwidth"' ) . $form -> selectcontacts ( 0 , $search_project_contact ? $search_project_contact : '' , 'search_project_contact' , $tmptitle , '' , '' , 0 , 'maxwidth250 widthcentpercentminusx' );
2022-01-05 14:35:11 +01:00
$moreforfilter .= '</div>' ;
2016-11-02 12:48:50 +01:00
// If the user can view thirdparties other than his'
2022-05-03 17:05:14 +02:00
if ( $user -> rights -> user -> user -> lire ) {
2016-11-02 12:48:50 +01:00
$langs -> load ( " commercial " );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '<div class="divsearchfield">' ;
2021-03-29 13:00:17 +02:00
$tmptitle = $langs -> trans ( 'ThirdPartiesOfSaleRepresentative' );
2022-02-25 21:45:29 +01:00
$moreforfilter .= img_picto ( $tmptitle , 'user' , 'class="pictofixedwidth"' ) . $formother -> select_salesrepresentatives ( $search_sale , 'search_sale' , $user , 0 , $tmptitle , 'maxwidth250 widthcentpercentminusx' );
2019-11-12 09:46:08 +01:00
$moreforfilter .= '</div>' ;
2016-11-02 12:48:50 +01:00
}
2021-03-29 13:00:17 +02:00
// Filter on categories
2022-08-31 22:02:31 +02:00
if ( isModEnabled ( 'categorie' ) && $user -> rights -> categorie -> lire ) {
2021-03-29 13:00:17 +02:00
$formcategory = new FormCategory ( $db );
$moreforfilter .= $formcategory -> getFilterBox ( Categorie :: TYPE_PROJECT , $search_category_array );
}
2022-04-22 17:10:24 +02:00
// Filter on customer categories
2022-11-26 10:41:58 +01:00
if ( ! empty ( $conf -> global -> MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST ) && ! empty ( $conf -> categorie -> enabled ) && $user -> rights -> categorie -> lire ) {
2022-04-22 17:10:24 +02:00
$moreforfilter .= '<div class="divsearchfield">' ;
$tmptitle = $langs -> transnoentities ( 'CustomersProspectsCategoriesShort' );
$moreforfilter .= img_picto ( $tmptitle , 'category' , 'class="pictofixedwidth"' );
2022-05-23 12:25:25 +02:00
$categoriesArr = $form -> select_all_categories ( Categorie :: TYPE_CUSTOMER , '' , '' , 64 , 0 , 1 );
$categoriesArr [ - 2 ] = '- ' . $langs -> trans ( 'NotCategorized' ) . ' -' ;
$moreforfilter .= Form :: multiselectarray ( 'search_category_customer_list' , $categoriesArr , $searchCategoryCustomerList , 0 , 0 , 'minwidth300' , 0 , 0 , '' , 'category' , $tmptitle );
2022-05-20 15:34:40 +02:00
$moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"' . ( $searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '' ) . '/>' ;
$moreforfilter .= $form -> textwithpicto ( '' , $langs -> trans ( 'UseOrOperatorForCategories' ) . ' : ' . $tmptitle , 1 , 'help' , '' , 0 , 2 , 'tooltip_cat_cus' ); // Tooltip on click
2022-04-22 17:10:24 +02:00
$moreforfilter .= '</div>' ;
}
2021-03-29 13:00:17 +02:00
2021-02-26 18:49:22 +01:00
if ( ! empty ( $moreforfilter )) {
2016-11-02 12:48:50 +01:00
print '<div class="liste_titre liste_titre_bydiv centpercent">' ;
print $moreforfilter ;
2019-11-12 09:46:08 +01:00
$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>' ;
}
2019-11-12 09:46:08 +01:00
$varpage = empty ( $contextpage ) ? $_SERVER [ " PHP_SELF " ] : $contextpage ;
2022-06-25 18:51:19 +02:00
$selectedfields = $form -> multiSelectArrayWithCheckbox ( 'selectedfields' , $arrayfields , $varpage , getDolGlobalString ( 'MAIN_CHECKBOX_LEFT_COLUMN' , '' )); // This also change content of $arrayfields
2020-12-17 22:52:42 +01:00
$selectedfields .= ( count ( $arrayofmassactions ) ? $form -> showCheckAddButtons ( 'checkforselect' , 1 ) : '' );
2016-11-02 12:48:50 +01:00
2021-06-26 15:39:52 +02:00
2016-11-27 13:49:46 +01:00
print '<div class="div-table-responsive">' ;
2019-11-12 09:46:08 +01:00
print '<table class="tagtable nobottomiftotal liste' . ( $moreforfilter ? " listwithfilterbefore " : " " ) . '">' . " \n " ;
2016-11-02 12:48:50 +01:00
2020-12-17 22:52:42 +01:00
// Fields title search
// --------------------------------------------------------------------
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre_filter">' ;
2022-06-25 18:51:19 +02:00
// Action column
if ( ! empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ( 'left' );
print $searchpicto ;
print '</td>' ;
}
2018-10-01 18:56:47 +02:00
// Project ref
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="liste_titre">' ;
2017-07-31 04:52:27 +02:00
print '<input type="text" class="flat" name="search_ref" value="' . dol_escape_htmltag ( $search_ref ) . '" size="6">' ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
}
2018-10-01 18:56:47 +02:00
// Project label
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="liste_titre">' ;
2017-07-31 04:52:27 +02:00
print '<input type="text" class="flat" name="search_label" size="8" value="' . dol_escape_htmltag ( $search_label ) . '">' ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
}
2018-10-01 18:56:47 +02:00
// Third party
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="liste_titre">' ;
2021-02-09 22:00:54 +01:00
if ( $socid > 0 ) {
2019-11-12 09:46:08 +01:00
$tmpthirdparty = new Societe ( $db );
2017-07-31 04:52:27 +02:00
$tmpthirdparty -> fetch ( $socid );
2021-02-09 22:00:54 +01:00
$search_societe = $tmpthirdparty -> name ;
2017-07-31 04:52:27 +02:00
}
print '<input type="text" class="flat" name="search_societe" size="8" value="' . dol_escape_htmltag ( $search_societe ) . '">' ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
}
2022-06-21 17:57:00 +02:00
// Alias
if ( ! empty ( $arrayfields [ 's.name_alias' ][ 'checked' ])) {
print '<td class="liste_titre">' ;
if ( $socid > 0 ) {
$tmpthirdparty = new Societe ( $db );
$tmpthirdparty -> fetch ( $socid );
$search_societe_alias = $tmpthirdparty -> name_alias ;
}
print '<input type="text" class="flat" name="search_societe_alias" size="8" value="' . dol_escape_htmltag ( $search_societe_alias ) . '">' ;
print '</td>' ;
}
2016-11-02 12:48:50 +01:00
// Sale representative
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'commercial' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="liste_titre"> </td>' ;
}
// Start date
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.dateo' ][ 'checked' ])) {
2018-03-07 14:13:55 +01:00
print '<td class="liste_titre center nowraponall">' ;
2021-08-25 12:46:56 +02:00
/* if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) {
2021-02-26 18:49:22 +01:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_sday" value="' . dol_escape_htmltag ( $search_sday ) . '">' ;
}
2018-03-07 14:13:55 +01:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_smonth" value="' . dol_escape_htmltag ( $search_smonth ) . '">' ;
2022-05-18 11:38:56 +02:00
print $formother -> selectyear ( $search_syear ? $search_syear : - 1 , 'search_syear' , 1 , 20 , 5 , 0 , 0 , '' , 'widthauto valignmiddle' ); */
2021-08-25 12:46:56 +02:00
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_start_start ? $search_date_start_start : - 1 , 'search_date_start_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_start_end ? $search_date_start_end : - 1 , 'search_date_start_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
print '</div>' ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
}
// End date
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.datee' ][ 'checked' ])) {
2018-03-07 14:13:55 +01:00
print '<td class="liste_titre center nowraponall">' ;
2021-08-25 12:46:56 +02:00
/* if ( ! empty ( $conf -> global -> MAIN_LIST_FILTER_ON_DAY )) {
2021-02-26 18:49:22 +01:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_eday" value="' . dol_escape_htmltag ( $search_eday ) . '">' ;
}
2018-03-07 14:13:55 +01:00
print '<input class="flat valignmiddle" type="text" size="1" maxlength="2" name="search_emonth" value="' . dol_escape_htmltag ( $search_emonth ) . '">' ;
2022-05-18 11:38:56 +02:00
print $formother -> selectyear ( $search_eyear ? $search_eyear : - 1 , 'search_eyear' , 1 , 20 , 5 , 0 , 0 , '' , 'widthauto valignmiddle' ); */
2021-08-25 12:46:56 +02:00
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_end_start ? $search_date_end_start : - 1 , 'search_date_end_start' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'From' ));
print '</div>' ;
print '<div class="nowrap">' ;
print $form -> selectDate ( $search_date_end_end ? $search_date_end_end : - 1 , 'search_date_end_end' , 0 , 0 , 1 , '' , 1 , 0 , 0 , '' , '' , '' , '' , 1 , '' , $langs -> trans ( 'to' ));
print '</div>' ;
2016-11-02 12:48:50 +01:00
print '</td>' ;
}
2022-10-06 18:25:01 +02:00
// Visibility
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.public' ][ 'checked' ])) {
2022-05-16 18:00:59 +02:00
print '<td class="liste_titre center">' ;
2019-11-12 09:46:08 +01:00
$array = array ( '' => '' , 0 => $langs -> trans ( " PrivateProject " ), 1 => $langs -> trans ( " SharedProject " ));
2022-10-06 18:25:01 +02:00
print $form -> selectarray ( 'search_public' , $array , $search_public , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'maxwidth75' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2022-05-16 18:00:59 +02:00
if ( ! empty ( $arrayfields [ 'c.assigned' ][ 'checked' ])) {
print '<td class="liste_titre center">' ;
print '</td>' ;
}
2018-10-01 18:56:47 +02:00
// Opp status
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_opp_status' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="liste_titre nowrap center">' ;
2022-11-02 16:50:45 +01:00
print $formproject -> selectOpportunityStatus ( 'search_opp_status' , $search_opp_status , 1 , 1 , 1 , 0 , 'maxwidth125 nowrapoption' , 1 , 1 );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.opp_amount' ][ 'checked' ])) {
2017-06-08 12:21:41 +02:00
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>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.opp_percent' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
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>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'opp_weighted_amount' ][ 'checked' ])) {
2020-10-07 15:01:28 +02:00
print '<td class="liste_titre nowrap right">' ;
print '</td>' ;
2019-12-10 09:32:37 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.budget_amount' ][ 'checked' ])) {
2019-02-23 22:24:26 +01:00
print '<td class="liste_titre nowrap right">' ;
2016-11-02 12:48:50 +01:00
print '<input type="text" class="flat" name="search_budget_amount" size="4" value="' . $search_budget_amount . '">' ;
2017-10-07 13:09:31 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_opportunity' ][ 'checked' ])) {
2019-02-23 22:24:26 +01:00
print '<td class="liste_titre nowrap right">' ;
2019-09-09 14:08:10 +02:00
print $form -> selectyesno ( 'search_usage_opportunity' , $search_usage_opportunity , 1 , false , 1 );
2018-12-06 21:25:28 +01:00
print '' ;
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_task' ][ 'checked' ])) {
2019-09-09 14:08:10 +02:00
print '<td class="liste_titre nowrap right">' ;
print $form -> selectyesno ( 'search_usage_task' , $search_usage_task , 1 , false , 1 );
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_bill_time' ][ 'checked' ])) {
2019-09-09 14:08:10 +02:00
print '<td class="liste_titre nowrap right">' ;
print $form -> selectyesno ( 'search_usage_bill_time' , $search_usage_bill_time , 1 , false , 1 );
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_organize_event' ][ 'checked' ])) {
2021-02-15 12:18:08 +01:00
print '<td class="liste_titre nowrap right">' ;
print $form -> selectyesno ( 'search_usage_event_organization' , $search_usage_event_organization , 1 , false , 1 );
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.accept_conference_suggestions' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="liste_titre nowrap right">' ;
2021-02-22 21:00:54 +01:00
print $form -> selectyesno ( 'search_accept_conference_suggestions' , $search_accept_conference_suggestions , 1 , false , 1 );
2021-02-21 12:32:16 +01:00
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.accept_booth_suggestions' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="liste_titre nowrap right">' ;
2021-02-22 21:00:54 +01:00
print $form -> selectyesno ( 'search_accept_booth_suggestions' , $search_accept_booth_suggestions , 1 , false , 1 );
2021-02-21 12:32:16 +01:00
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.price_registration' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="liste_titre nowrap right">' ;
print '<input type="text" class="flat" name="search_price_registration" size="4" value="' . $search_price_registration . '">' ;
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.price_booth' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="liste_titre nowrap right">' ;
print '<input type="text" class="flat" name="search_price_booth" size="4" value="' . $search_price_booth . '">' ;
print '</td>' ;
}
2022-06-29 17:32:50 +02:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) {
// Author
print '<td class="liste_titre" align="center">' ;
print '<input class="flat" size="4" type="text" name="search_login" value="' . dol_escape_htmltag ( $search_login ) . '">' ;
print '</td>' ;
}
2016-11-02 12:48:50 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php' ;
2016-11-02 12:48:50 +01:00
// Fields from hook
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields );
$reshook = $hookmanager -> executeHooks ( 'printFieldListOption' , $parameters ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
2017-10-07 13:09:31 +02:00
// Date creation
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
2017-10-07 13:09:31 +02:00
// Date modification
print '<td class="liste_titre">' ;
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
2021-06-14 20:13:27 +02:00
if ( ! empty ( $arrayfields [ 'p.email_msgid' ][ 'checked' ])) {
2021-06-14 19:58:12 +02:00
// Email msg id
print '<td class="liste_titre">' ;
print '</td>' ;
}
2022-12-05 15:31:05 +01:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) {
// Import key
print '<td class="liste_titre">' ;
2023-02-19 16:12:28 +01:00
print '<input class="flat width75" type="text" name="search_import_key" value="' . dol_escape_htmltag ( $search_import_key ) . '">' ;
2022-12-05 15:31:05 +01:00
print '</td>' ;
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) {
2023-01-31 20:45:32 +01:00
print '<td class="liste_titre center parentonrightofpage">' ;
2017-10-07 13:09:31 +02:00
$arrayofstatus = array ();
2021-02-26 18:49:22 +01:00
foreach ( $object -> statuts_short as $key => $val ) {
$arrayofstatus [ $key ] = $langs -> trans ( $val );
}
2019-11-12 09:46:08 +01:00
$arrayofstatus [ '99' ] = $langs -> trans ( " NotClosed " ) . ' (' . $langs -> trans ( 'Draft' ) . ' + ' . $langs -> trans ( 'Opened' ) . ')' ;
2023-01-31 20:45:32 +01:00
print $form -> selectarray ( 'search_status' , $arrayofstatus , $search_status , 1 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'search_status width100 onrightofpage' , 1 );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2016-11-02 12:48:50 +01:00
}
// Action column
2022-06-25 18:51:19 +02:00
if ( empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print '<td class="liste_titre maxwidthsearch">' ;
$searchpicto = $form -> showFilterButtons ();
print $searchpicto ;
print '</td>' ;
}
2016-11-02 12:48:50 +01:00
print '</tr>' . " \n " ;
2017-03-28 18:42:23 +02:00
print '<tr class="liste_titre">' ;
2022-06-25 18:51:19 +02:00
if ( ! empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
}
2021-02-26 18:49:22 +01:00
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 );
}
2022-06-21 17:57:00 +02:00
if ( ! empty ( $arrayfields [ 's.name_alias' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 's.name_alias' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " s.name_alias " , " " , $param , " " , $sortfield , $sortorder );
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'commercial' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'commercial' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , " " , $param , " " , $sortfield , $sortorder , 'tdoverflowmax100imp ' );
}
if ( ! empty ( $arrayfields [ 'p.dateo' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.dateo' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.dateo " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'p.datee' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.datee' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datee " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'p.public' ][ 'checked' ])) {
2022-05-16 18:00:59 +02:00
print_liste_field_titre ( $arrayfields [ 'p.public' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.public " , " " , $param , " " , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'c.assigned' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'c.assigned' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " " , '' , $param , '' , $sortfield , $sortorder , 'center ' , '' );
2021-02-26 18:49:22 +01:00
}
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 , '' , $sortfield , $sortorder , 'center ' );
}
if ( ! empty ( $arrayfields [ 'p.opp_amount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.opp_amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.opp_amount' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.opp_percent' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.opp_percent' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'p.opp_percent' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'opp_weighted_amount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'opp_weighted_amount' ][ 'label' ], $_SERVER [ 'PHP_SELF' ], 'opp_weighted_amount' , '' , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.budget_amount' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.budget_amount' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.budget_amount' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.usage_opportunity' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.usage_opportunity' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.usage_opportunity' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.usage_task' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.usage_task' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.usage_task' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.usage_bill_time' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.usage_bill_time' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.usage_bill_time' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.usage_organize_event' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.usage_organize_event' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.usage_organize_event' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.accept_conference_suggestions' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accept_conference_suggestions' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.accept_conference_suggestions' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.accept_booth_suggestions' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.accept_booth_suggestions' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.accept_booth_suggestions' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.price_registration' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.price_registration' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.price_registration' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
if ( ! empty ( $arrayfields [ 'p.price_booth' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.price_booth' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'p.price_booth' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
}
2022-06-29 17:32:50 +02:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'u.login' ][ 'label' ], $_SERVER [ " PHP_SELF " ], 'u.login' , '' , $param , 'align="center"' , $sortfield , $sortorder );
}
2017-03-28 18:42:23 +02:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php' ;
2017-03-28 18:42:23 +02:00
// Hook fields
2019-11-12 09:46:08 +01:00
$parameters = array ( 'arrayfields' => $arrayfields , 'param' => $param , 'sortfield' => $sortfield , 'sortorder' => $sortorder );
$reshook = $hookmanager -> executeHooks ( 'printFieldListTitle' , $parameters ); // Note that $action and $object may have been modified by hook
2017-03-28 18:42:23 +02:00
print $hookmanager -> resPrint ;
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.datec' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.datec " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.tms' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.tms " , " " , $param , '' , $sortfield , $sortorder , 'center nowrap ' );
}
2021-06-14 20:13:27 +02:00
if ( ! empty ( $arrayfields [ 'p.email_msgid' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.email_msgid' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.email_msgid " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
}
2022-12-05 15:31:05 +01:00
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) {
print_liste_field_titre ( $arrayfields [ 'p.import_key' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.import_key " , " " , $param , '' , $sortfield , $sortorder , '' );
}
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) {
2023-01-31 20:45:32 +01:00
print_liste_field_titre ( $arrayfields [ 'p.fk_statut' ][ 'label' ], $_SERVER [ " PHP_SELF " ], " p.fk_statut " , " " , $param , '' , $sortfield , $sortorder , 'center ' );
2021-02-26 18:49:22 +01:00
}
2022-06-25 18:51:19 +02:00
if ( empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print_liste_field_titre ( $selectedfields , $_SERVER [ " PHP_SELF " ], " " , '' , '' , '' , $sortfield , $sortorder , 'center maxwidthsearch ' );
}
2017-03-28 18:42:23 +02:00
print " </tr> \n " ;
2022-06-29 17:32:50 +02:00
$userstatic = new User ( $db );
2019-11-12 09:46:08 +01:00
$i = 0 ;
2019-12-26 10:34:10 +01:00
$totalarray = array (
2020-10-07 15:01:28 +02:00
'nbfield' => 0 ,
'val' => array (),
2019-12-26 10:34:10 +01:00
);
2022-09-19 18:57:39 +02:00
$imaxinloop = ( $limit ? min ( $num , $limit ) : $num );
while ( $i < $imaxinloop ) {
2016-11-02 12:48:50 +01:00
$obj = $db -> fetch_object ( $resql );
2022-09-19 18:57:39 +02:00
if ( empty ( $obj )) {
break ; // Should not happen
}
2016-11-02 12:48:50 +01:00
2017-05-24 22:48:44 +02:00
$object -> id = $obj -> id ;
$object -> user_author_id = $obj -> fk_user_creat ;
$object -> public = $obj -> public ;
$object -> ref = $obj -> ref ;
$object -> datee = $db -> jdate ( $obj -> date_end );
2020-04-25 13:52:07 +02:00
$object -> statut = $obj -> status ; // deprecated
2020-04-20 02:14:43 +02:00
$object -> status = $obj -> status ;
$object -> public = $obj -> public ;
2017-05-24 22:48:44 +02:00
$object -> opp_status = $obj -> fk_opp_status ;
2017-10-25 12:03:22 +02:00
$object -> title = $obj -> title ;
2017-06-08 12:21:41 +02:00
2019-11-12 09:46:08 +01:00
$userAccess = $object -> restrictedProjectArea ( $user ); // why this ?
2021-02-26 18:49:22 +01:00
if ( $userAccess >= 0 ) {
2023-02-10 16:14:32 +01:00
// Thirdparty
2021-05-17 23:27:33 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$companystatic -> name_alias = $obj -> alias ;
$companystatic -> client = $obj -> client ;
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> email = $obj -> email ;
$companystatic -> phone = $obj -> phone ;
$companystatic -> address = $obj -> address ;
$companystatic -> zip = $obj -> zip ;
$companystatic -> town = $obj -> town ;
$companystatic -> country_code = $obj -> country_code ;
2019-04-29 17:17:25 +02:00
2023-02-10 16:14:32 +01:00
// Author
$userstatic -> id = $obj -> fk_user_creat ;
$userstatic -> login = $obj -> login ;
$userstatic -> lastname = $obj -> lastname ;
$userstatic -> firstname = $obj -> firstname ;
$userstatic -> email = $obj -> user_email ;
$userstatic -> statut = $obj -> user_statut ;
$userstatic -> entity = $obj -> entity ;
$userstatic -> photo = $obj -> photo ;
$userstatic -> office_phone = $obj -> office_phone ;
$userstatic -> office_fax = $obj -> office_fax ;
$userstatic -> user_mobile = $obj -> user_mobile ;
$userstatic -> job = $obj -> job ;
$userstatic -> gender = $obj -> gender ;
2017-03-29 11:03:13 +02:00
print '<tr class="oddeven">' ;
2009-01-15 00:36:51 +01:00
2022-06-25 18:51:19 +02:00
// Action column
if ( ! empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print '<td class="nowrap 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 -> id , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $obj -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
}
print '</td>' ;
2022-11-02 16:50:45 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2022-06-25 18:51:19 +02:00
}
2016-11-02 12:48:50 +01:00
// Project url
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.ref' ][ 'checked' ])) {
2023-04-08 14:37:27 +02:00
print '<td class="nowraponall tdoverflowmax200" title="' . dol_escape_htmltag ( $object -> ref ) . '">' ;
2021-03-15 20:20:53 +01:00
print $object -> getNomUrl ( 1 , ( ! empty ( GETPOST ( 'search_usage_event_organization' , 'int' )) ? 'eventorganization' : '' ));
2021-02-26 18:49:22 +01:00
if ( $object -> hasDelay ()) {
print img_warning ( $langs -> trans ( 'Late' ));
}
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2016-11-02 12:48:50 +01:00
// Title
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.title' ][ 'checked' ])) {
2022-05-16 10:45:42 +02:00
print '<td class="tdoverflowmax200" title="' . dol_escape_htmltag ( $obj -> title ) . '">' ;
print $obj -> title ;
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2016-11-02 12:48:50 +01:00
// Company
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 's.nom' ][ 'checked' ])) {
2017-10-07 13:09:31 +02:00
print '<td class="tdoverflowmax100">' ;
2021-01-20 21:02:01 +01:00
if ( $obj -> socid ) {
2022-06-21 17:57:00 +02:00
print $companystatic -> getNomUrl ( 1 , '' , 0 , 0 , - 1 , empty ( $arrayfields [ 's.name_alias' ][ 'checked' ]) ? 0 : 1 );
} else {
print ' ' ;
}
print '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
// Alias
if ( ! empty ( $arrayfields [ 's.name_alias' ][ 'checked' ])) {
print '<td class="tdoverflowmax100">' ;
if ( $obj -> socid ) {
print $companystatic -> name_alias ;
2020-05-21 15:05:19 +02:00
} else {
2017-10-07 13:09:31 +02:00
print ' ' ;
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2016-11-02 12:48:50 +01:00
// Sales Representatives
2021-01-20 21:02:01 +01:00
if ( ! empty ( $arrayfields [ 'commercial' ][ 'checked' ])) {
2022-11-12 12:41:44 +01:00
print '<td class="tdoverflowmax150">' ;
2021-01-20 21:02:01 +01:00
if ( $obj -> socid ) {
2021-05-17 23:27:33 +02:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$listsalesrepresentatives = $companystatic -> getSalesRepresentatives ( $user );
2019-11-12 09:46:08 +01:00
$nbofsalesrepresentative = count ( $listsalesrepresentatives );
2021-01-20 21:02:01 +01:00
if ( $nbofsalesrepresentative > 6 ) {
// We print only number
2017-10-07 13:09:31 +02:00
print $nbofsalesrepresentative ;
2021-01-20 18:45:44 +01:00
} elseif ( $nbofsalesrepresentative > 0 ) {
2019-11-12 09:46:08 +01:00
$userstatic = new User ( $db );
$j = 0 ;
2021-01-20 18:45:44 +01:00
foreach ( $listsalesrepresentatives as $val ) {
2019-11-12 09:46:08 +01:00
$userstatic -> id = $val [ 'id' ];
$userstatic -> lastname = $val [ 'lastname' ];
$userstatic -> firstname = $val [ 'firstname' ];
$userstatic -> email = $val [ 'email' ];
$userstatic -> statut = $val [ 'statut' ];
$userstatic -> entity = $val [ 'entity' ];
$userstatic -> photo = $val [ 'photo' ];
2021-01-20 18:45:44 +01:00
$userstatic -> login = $val [ 'login' ];
2021-05-17 18:04:21 +02:00
$userstatic -> office_phone = $val [ 'office_phone' ];
$userstatic -> office_fax = $val [ 'office_fax' ];
$userstatic -> user_mobile = $val [ 'user_mobile' ];
2021-01-20 18:45:44 +01:00
$userstatic -> job = $val [ 'job' ];
$userstatic -> gender = $val [ 'gender' ];
2021-02-09 21:35:50 +01:00
print ( $nbofsalesrepresentative < 2 ) ? $userstatic -> getNomUrl ( - 1 , '' , 0 , 0 , 12 ) : $userstatic -> getNomUrl ( - 2 );
2017-10-07 13:09:31 +02:00
$j ++ ;
2021-01-20 21:02:01 +01:00
if ( $j < $nbofsalesrepresentative ) {
print ' ' ;
}
2017-10-07 13:09:31 +02:00
}
}
//else print $langs->trans("NoSalesRepresentativeAffected");
2020-05-21 15:05:19 +02:00
} else {
2021-02-07 19:05:10 +01:00
print ' ' ;
2017-10-07 13:09:31 +02:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2022-10-21 13:19:21 +02:00
// Date start project
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.dateo' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="center">' ;
2019-01-27 11:55:16 +01:00
print dol_print_date ( $db -> jdate ( $obj -> date_start ), 'day' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2022-10-21 13:19:21 +02:00
// Date end project
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.datee' ][ 'checked' ])) {
2016-11-02 12:48:50 +01:00
print '<td class="center">' ;
2019-01-27 11:55:16 +01:00
print dol_print_date ( $db -> jdate ( $obj -> date_end ), 'day' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2022-10-21 13:19:21 +02:00
2016-11-02 12:48:50 +01:00
// Visibility
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.public' ][ 'checked' ])) {
2022-05-16 18:00:59 +02:00
print '<td class="center">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> public ) {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'SharedProject' ), 'world' , 'class="paddingrightonly"' );
//print $langs->trans('SharedProject');
2021-02-26 18:49:22 +01:00
} else {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'PrivateProject' ), 'private' , 'class="paddingrightonly"' );
//print $langs->trans('PrivateProject');
2021-02-26 18:49:22 +01:00
}
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2022-05-16 18:00:59 +02:00
// Contacts of project
if ( ! empty ( $arrayfields [ 'c.assigned' ][ 'checked' ])) {
2022-10-06 18:18:07 +02:00
print '<td class="center nowraponall tdoverflowmax200">' ;
2022-05-16 18:00:59 +02:00
$ifisrt = 1 ;
foreach ( array ( 'internal' , 'external' ) as $source ) {
2022-10-06 18:18:07 +02:00
$tab = $object -> liste_contact ( - 1 , $source , 0 , '' , 1 );
2022-05-16 18:00:59 +02:00
$numcontact = count ( $tab );
if ( ! empty ( $numcontact )) {
foreach ( $tab as $contactproject ) {
//var_dump($contacttask);
2023-02-10 16:14:32 +01:00
$cid = $contactproject [ 'id' ];
2022-05-16 18:00:59 +02:00
if ( $source == 'internal' ) {
2023-02-10 16:14:32 +01:00
if ( empty ( $conf -> cache [ 'user' ][ $cid ])) {
$c = new User ( $db );
$c -> fetch ( $cid );
$conf -> cache [ 'user' ][ $cid ] = $c ;
} else {
$c = $conf -> cache [ 'user' ][ $cid ];
}
2022-05-16 18:00:59 +02:00
} else {
2023-02-10 16:14:32 +01:00
if ( empty ( $conf -> cache [ 'contact' ][ $cid ])) {
$c = new Contact ( $db );
$c -> fetch ( $cid );
$conf -> cache [ 'contact' ][ $cid ] = $c ;
} else {
$c = $conf -> cache [ 'contact' ][ $cid ];
}
2022-05-16 18:00:59 +02:00
}
2023-02-10 16:14:32 +01:00
2022-05-16 18:00:59 +02:00
if ( ! empty ( $c -> photo )) {
if ( get_class ( $c ) == 'User' ) {
print $c -> getNomUrl ( - 2 , '' , 0 , 0 , 24 , 1 , '' , ( $ifisrt ? '' : 'notfirst' ));
} else {
print $c -> getNomUrl ( - 2 , '' , 0 , '' , - 1 , 0 , ( $ifisrt ? '' : 'notfirst' ));
}
} else {
if ( get_class ( $c ) == 'User' ) {
print $c -> getNomUrl ( 2 , '' , 0 , 0 , 24 , 1 , '' , ( $ifisrt ? '' : 'notfirst' ));
} else {
print $c -> getNomUrl ( 2 , '' , 0 , '' , - 1 , 0 , ( $ifisrt ? '' : 'notfirst' ));
}
}
$ifisrt = 0 ;
}
}
}
print '</td>' ;
2022-11-02 16:50:45 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2022-05-16 18:00:59 +02:00
}
2017-10-07 13:09:31 +02:00
// Opp Status
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_opp_status' ][ 'checked' ])) {
2017-10-07 13:09:31 +02:00
print '<td class="center">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> opp_status_code ) {
print $langs -> trans ( " OppStatus " . $obj -> opp_status_code );
}
2017-06-08 12:21:41 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
// Opp Amount
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.opp_amount' ][ 'checked' ])) {
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2017-06-08 12:21:41 +02:00
//if ($obj->opp_status_code)
2021-02-26 18:49:22 +01:00
if ( strcmp ( $obj -> opp_amount , '' )) {
2021-03-26 18:16:12 +01:00
print '<span class="amount">' . price ( $obj -> opp_amount , 1 , $langs , 1 , - 1 , - 1 , '' ) . '</span>' ;
2022-12-16 12:59:47 +01:00
if ( empty ( $totalarray [ 'val' ][ 'p.opp_amount' ])) {
$totalarray [ 'val' ][ 'p.opp_amount' ] = $obj -> opp_amount ;
} else {
$totalarray [ 'val' ][ 'p.opp_amount' ] += $obj -> opp_amount ;
}
2016-11-02 12:48:50 +01:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'p.opp_amount' ;
}
2017-10-07 13:09:31 +02:00
}
// Opp percent
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.opp_percent' ][ 'checked' ])) {
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> opp_percent ) {
print price ( $obj -> opp_percent , 1 , $langs , 1 , 0 ) . '%' ;
}
2016-11-02 12:48:50 +01:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2017-10-07 13:09:31 +02:00
}
2020-10-07 15:01:28 +02:00
// Opp weighted amount
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'opp_weighted_amount' ][ 'checked' ])) {
if ( ! isset ( $totalarray [ 'val' ][ 'opp_weighted_amount' ])) {
$totalarray [ 'val' ][ 'opp_weighted_amount' ] = 0 ;
}
2020-10-07 15:01:28 +02:00
print '<td align="right">' ;
if ( $obj -> opp_weighted_amount ) {
2021-03-26 18:16:12 +01:00
print '<span class="amount">' . price ( $obj -> opp_weighted_amount , 1 , $langs , 1 , - 1 , - 1 , '' ) . '</span>' ;
2022-12-16 12:59:47 +01:00
if ( empty ( $totalarray [ 'val' ][ 'opp_weighted_amount' ])) {
$totalarray [ 'val' ][ 'opp_weighted_amount' ] = $obj -> opp_weighted_amount ;
} else {
$totalarray [ 'val' ][ 'opp_weighted_amount' ] += $obj -> opp_weighted_amount ;
}
2020-10-07 15:01:28 +02:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'opp_weighted_amount' ;
}
2020-10-07 15:01:28 +02:00
}
2017-10-07 13:09:31 +02:00
// Budget
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.budget_amount' ][ 'checked' ])) {
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> budget_amount != '' ) {
2021-03-26 18:16:12 +01:00
print '<span class="amount">' . price ( $obj -> budget_amount , 1 , $langs , 1 , - 1 , - 1 ) . '</span>' ;
2022-12-16 12:59:47 +01:00
if ( empty ( $totalarray [ 'val' ][ 'p.budget_amount' ])) {
$totalarray [ 'val' ][ 'p.budget_amount' ] = $obj -> budget_amount ;
} else {
$totalarray [ 'val' ][ 'p.budget_amount' ] += $obj -> budget_amount ;
}
2016-11-02 12:48:50 +01:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'p.budget_amount' ;
}
2017-10-07 13:09:31 +02:00
}
2019-09-09 14:08:10 +02:00
// Usage opportunity
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_opportunity' ][ 'checked' ])) {
2019-09-09 14:08:10 +02:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> usage_opportunity ) {
2019-09-09 14:08:10 +02:00
print yn ( $obj -> usage_opportunity );
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-09-09 14:08:10 +02:00
}
// Usage task
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_task' ][ 'checked' ])) {
2019-09-09 14:08:10 +02:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> usage_task ) {
2019-09-09 14:08:10 +02:00
print yn ( $obj -> usage_task );
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2019-09-09 14:08:10 +02:00
}
2018-12-06 21:25:28 +01:00
// Bill time
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_bill_time' ][ 'checked' ])) {
2019-02-23 22:24:26 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> usage_bill_time ) {
2019-09-01 01:40:51 +02:00
print yn ( $obj -> usage_bill_time );
2018-12-06 21:25:28 +01:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-15 12:18:08 +01:00
}
// Event Organization
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.usage_organize_event' ][ 'checked' ])) {
2021-02-15 12:18:08 +01:00
print '<td class="right">' ;
2021-03-15 18:06:23 +01:00
if ( $obj -> usage_organize_event ) {
print yn ( $obj -> usage_organize_event );
2021-02-15 12:18:08 +01:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2018-12-06 21:25:28 +01:00
}
2021-02-21 12:32:16 +01:00
// Allow unknown people to suggest conferences
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.accept_conference_suggestions' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> accept_conference_suggestions ) {
2021-02-22 21:00:54 +01:00
print yn ( $obj -> accept_conference_suggestions );
2021-02-21 12:32:16 +01:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-21 12:32:16 +01:00
}
// Allow unknown people to suggest booth
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.accept_booth_suggestions' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> accept_booth_suggestions ) {
2021-02-22 21:00:54 +01:00
print yn ( $obj -> accept_booth_suggestions );
2021-02-21 12:32:16 +01:00
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-21 12:32:16 +01:00
}
// Price of registration
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.price_registration' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> price_registration != '' ) {
2021-03-26 18:16:12 +01:00
print '<span class="amount">' . price ( $obj -> price_registration , 1 , $langs , 1 , - 1 , - 1 ) . '</span>' ;
2021-02-21 12:32:16 +01:00
$totalarray [ 'val' ][ 'p.price_registration' ] += $obj -> price_registration ;
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'p.price_registration' ;
}
2021-02-21 12:32:16 +01:00
}
2021-03-29 13:00:17 +02:00
// Price of booth
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.price_booth' ][ 'checked' ])) {
2021-02-21 12:32:16 +01:00
print '<td class="right">' ;
2021-02-26 18:49:22 +01:00
if ( $obj -> price_booth != '' ) {
2021-03-26 18:16:12 +01:00
print '<span class="amount">' . price ( $obj -> price_booth , 1 , $langs , 1 , - 1 , - 1 ) . '</span>' ;
2021-02-21 12:32:16 +01:00
$totalarray [ 'val' ][ 'p.price_booth' ] += $obj -> price_booth ;
}
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
if ( ! $i ) {
$totalarray [ 'pos' ][ $totalarray [ 'nbfield' ]] = 'p.price_booth' ;
}
2021-02-21 12:32:16 +01:00
}
2022-06-29 17:32:50 +02:00
if ( ! empty ( $arrayfields [ 'u.login' ][ 'checked' ])) {
2022-11-02 16:50:45 +01:00
print '<td class="center tdoverflowmax150">' ;
2022-06-29 17:32:50 +02:00
if ( $userstatic -> id ) {
print $userstatic -> getNomUrl ( - 1 );
} else {
print ' ' ;
}
print " </td> \n " ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
2016-11-02 12:48:50 +01:00
// Extra fields
2017-11-27 15:24:29 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php' ;
2016-11-02 12:48:50 +01:00
// Fields from hook
2020-05-08 01:40:25 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'obj' => $obj , 'i' => $i , 'totalarray' =>& $totalarray );
2019-11-12 09:46:08 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListValue' , $parameters ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
// Date creation
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.datec' ][ 'checked' ])) {
2021-03-29 13:00:17 +02:00
print '<td class="center nowraponall">' ;
2017-10-12 17:09:17 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_creation ), 'dayhour' , 'tzuser' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
// Date modification
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.tms' ][ 'checked' ])) {
2021-03-29 13:00:17 +02:00
print '<td class="center nowraponall">' ;
2017-10-12 17:09:17 +02:00
print dol_print_date ( $db -> jdate ( $obj -> date_update ), 'dayhour' , 'tzuser' );
2017-10-07 13:09:31 +02:00
print '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2021-06-14 19:58:12 +02:00
// Email MsgID
2021-06-14 20:37:21 +02:00
if ( ! empty ( $arrayfields [ 'p.email_msgid' ][ 'checked' ])) {
2023-04-12 14:53:54 +02:00
print '<td class="tdoverflowmax125" title="' . dol_escape_htmltag ( $obj -> email_msgid ) . '">' ;
print dol_escape_htmltag ( $obj -> email_msgid );
2021-06-14 19:58:12 +02:00
print '</td>' ;
2023-04-12 14:53:54 +02:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-06-14 19:58:12 +02:00
}
2022-12-05 15:31:05 +01:00
// Import key
if ( ! empty ( $arrayfields [ 'p.import_key' ][ 'checked' ])) {
print '<td class="right">' . dol_escape_htmltag ( $obj -> import_key ) . '</td>' ;
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
}
2016-11-02 12:48:50 +01:00
// Status
2021-02-26 18:49:22 +01:00
if ( ! empty ( $arrayfields [ 'p.fk_statut' ][ 'checked' ])) {
2023-01-31 20:45:32 +01:00
print '<td class="center">' . $object -> getLibStatut ( 5 ) . '</td>' ;
2021-02-26 18:49:22 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2016-11-02 12:48:50 +01:00
}
2017-10-07 13:09:31 +02:00
// Action column
2022-06-25 18:51:19 +02:00
if ( empty ( $conf -> global -> MAIN_CHECKBOX_LEFT_COLUMN )) {
print '<td class="nowrap 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 -> id , $arrayofselected )) {
$selected = 1 ;
}
print '<input id="cb' . $obj -> id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $obj -> id . '"' . ( $selected ? ' checked="checked"' : '' ) . '>' ;
2021-02-26 18:49:22 +01:00
}
2022-06-25 18:51:19 +02:00
print '</td>' ;
2022-11-02 16:50:45 +01:00
if ( ! $i ) {
$totalarray [ 'nbfield' ] ++ ;
}
2021-02-26 18:49:22 +01:00
}
2017-06-08 12:21:41 +02:00
2016-11-02 12:48:50 +01:00
print " </tr> \n " ;
}
2015-06-16 19:36:44 +02:00
2016-11-02 12:48:50 +01:00
$i ++ ;
}
// Show total line
2019-11-05 12:47:38 +01:00
include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php' ;
2015-06-16 19:36:44 +02:00
2022-09-19 18:57:39 +02:00
// If no record found
if ( $num == 0 ) {
$colspan = 1 ;
foreach ( $arrayfields as $key => $val ) {
if ( ! empty ( $val [ 'checked' ])) {
$colspan ++ ;
}
}
print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs -> trans ( " NoRecordFound " ) . '</span></td></tr>' ;
}
2016-11-02 12:48:50 +01:00
$db -> free ( $resql );
2009-01-15 00:36:51 +01:00
2022-09-19 18:57:39 +02:00
$parameters = array ( 'arrayfields' => $arrayfields , 'sql' => $sql );
$reshook = $hookmanager -> executeHooks ( 'printFieldListFooter' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2016-11-02 12:48:50 +01:00
print $hookmanager -> resPrint ;
2006-03-09 12:35:25 +01:00
2016-11-02 12:48:50 +01:00
print " </table> \n " ;
2016-11-27 13:49:46 +01:00
print '</div>' ;
2022-09-19 18:57:39 +02:00
2016-11-02 12:48:50 +01:00
print " </form> \n " ;
2006-03-09 12:35:25 +01:00
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-04 18:34:52 +01:00
$db -> close ();