2013-06-14 22:33:01 +02:00
< ? php
/* Copyright ( c ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2015-06-15 10:04:36 +02:00
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2018-05-13 15:34:26 +02:00
* Copyright ( C ) 2018 Charlene Benke < charlie @ patas - monkey . com >
2013-06-14 22:33:01 +02:00
*
2015-06-15 10:04:36 +02:00
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2015-06-15 10:04:36 +02:00
*/
2013-06-14 22:33:01 +02:00
/**
* \file htdocs / core / class / html . formprojet . class . php
* \ingroup core
* \brief Class file for html component project
*/
/**
* Class to manage building of HTML components
*/
class FormProjets
{
2018-08-22 11:06:34 +02:00
/**
2020-04-16 00:42:57 +02:00
* @ var DoliDB Database handler .
*/
public $db ;
2018-09-02 22:05:19 +02:00
2018-08-22 10:37:16 +02:00
/**
* @ var string Error code ( or message )
*/
2020-04-10 10:59:32 +02:00
public $error = '' ;
2013-06-14 22:33:01 +02:00
/**
* Constructor
*
* @ param DoliDB $db Database handler
*/
2019-02-27 20:45:07 +01:00
public function __construct ( $db )
2013-06-14 22:33:01 +02:00
{
$this -> db = $db ;
}
2020-04-16 00:42:57 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2013-06-14 22:33:01 +02:00
/**
2016-10-17 17:52:58 +02:00
* Output a combo list with projects qualified for a third party / user
2013-06-14 22:33:01 +02:00
*
2013-07-07 13:14:32 +02:00
* @ param int $socid Id third party ( - 1 = all , 0 = only projects not linked to a third party , id = projects not linked or linked to third party id )
2018-01-29 18:22:26 +01:00
* @ param string $selected Id project preselected ( '' or id of project )
2016-09-18 21:13:23 +02:00
* @ param string $htmlname Name of HTML field
2013-07-07 13:14:32 +02:00
* @ param int $maxlength Maximum length of label
2014-11-20 15:32:10 +01:00
* @ param int $option_only Return only html options lines without the select tag
2013-07-07 13:14:32 +02:00
* @ param int $show_empty Add an empty line
2019-07-23 14:41:29 +02:00
* @ param int $discard_closed Discard closed projects ( 0 = Keep , 1 = hide completely , 2 = Disable ) . Use a negative value to not show the " discarded " tooltip .
2015-06-15 10:04:36 +02:00
* @ param int $forcefocus Force focus on field ( works with javascript only )
* @ param int $disabled Disabled
2016-01-28 11:59:18 +01:00
* @ param int $mode 0 for HTML mode and 1 for JSON mode
* @ param string $filterkey Key to filter
2016-09-18 21:13:23 +02:00
* @ param int $nooutput No print output . Return it only .
2016-10-17 17:52:58 +02:00
* @ param int $forceaddid Force to add project id in list , event if not qualified
2016-11-12 15:18:38 +01:00
* @ param string $morecss More css
2017-01-31 12:20:45 +01:00
* @ param int $htmlid Html id to use instead of htmlname
2016-09-18 21:13:23 +02:00
* @ return string Return html content
2015-06-15 10:04:36 +02:00
*/
2020-04-16 00:42:57 +02:00
public function select_projects ( $socid = - 1 , $selected = '' , $htmlname = 'projectid' , $maxlength = 16 , $option_only = 0 , $show_empty = 1 , $discard_closed = 0 , $forcefocus = 0 , $disabled = 0 , $mode = 0 , $filterkey = '' , $nooutput = 0 , $forceaddid = 0 , $morecss = '' , $htmlid = '' )
{
// phpcs:enable
2020-04-10 10:59:32 +02:00
global $langs , $conf , $form ;
2015-06-15 10:04:36 +02:00
2020-04-10 10:59:32 +02:00
$out = '' ;
2017-12-12 10:37:51 +01:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && ! empty ( $conf -> global -> PROJECT_USE_SEARCH_TO_SELECT )) {
2020-04-10 10:59:32 +02:00
$placeholder = '' ;
2015-06-15 10:04:36 +02:00
2021-02-23 22:03:23 +01:00
if ( $selected && empty ( $selected_input_value )) {
2015-06-15 10:04:36 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$project = new Project ( $this -> db );
$project -> fetch ( $selected );
2020-04-10 10:59:32 +02:00
$selected_input_value = $project -> ref ;
2015-06-15 10:04:36 +02:00
}
2020-04-10 10:59:32 +02:00
$urloption = 'socid=' . $socid . '&htmlname=' . $htmlname . '&discardclosed=' . $discard_closed ;
2020-04-16 00:42:57 +02:00
$out .= ajax_autocompleter ( $selected , $htmlname , DOL_URL_ROOT . '/projet/ajax/projects.php' , $urloption , $conf -> global -> PROJECT_USE_SEARCH_TO_SELECT , 0 , array (
// 'update' => array(
// 'projectid' => 'id'
// )
));
2015-06-15 10:04:36 +02:00
2020-04-16 00:42:57 +02:00
$out .= '<input type="text" class="minwidth200' . ( $morecss ? ' ' . $morecss : '' ) . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' />' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$out .= $this -> select_projects_list ( $socid , $selected , $htmlname , $maxlength , $option_only , $show_empty , abs ( $discard_closed ), $forcefocus , $disabled , 0 , $filterkey , 1 , $forceaddid , $htmlid , $morecss );
2017-12-12 10:37:51 +01:00
}
2021-02-23 22:03:23 +01:00
if ( $discard_closed > 0 ) {
if ( class_exists ( 'Form' )) {
if ( ! is_object ( $form )) {
$form = new Form ( $this -> db );
}
2020-04-10 10:59:32 +02:00
$out .= $form -> textwithpicto ( '' , $langs -> trans ( " ClosedProjectsAreHidden " ));
2016-01-28 11:59:18 +01:00
}
2015-06-15 10:04:36 +02:00
}
2017-06-02 12:27:46 +02:00
2021-02-23 22:03:23 +01:00
if ( empty ( $nooutput )) {
2020-04-16 00:42:57 +02:00
print $out ;
return '' ;
2021-02-23 22:03:23 +01:00
} else {
return $out ;
}
2015-06-15 10:04:36 +02:00
}
2020-04-16 00:42:57 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2015-06-15 10:04:36 +02:00
/**
2015-10-04 16:02:50 +02:00
* Returns an array with projects qualified for a third party
2015-06-15 10:04:36 +02:00
*
2015-10-04 16:02:50 +02:00
* @ param int $socid Id third party ( - 1 = all , 0 = only projects not linked to a third party , id = projects not linked or linked to third party id )
* @ param int $selected Id project preselected
* @ param string $htmlname Nom de la zone html
* @ param int $maxlength Maximum length of label
* @ param int $option_only Return only html options lines without the select tag
* @ param int $show_empty Add an empty line
* @ param int $discard_closed Discard closed projects ( 0 = Keep , 1 = hide completely , 2 = Disable )
2020-04-16 00:42:57 +02:00
* @ param int $forcefocus Force focus on field ( works with javascript only )
* @ param int $disabled Disabled
2015-10-04 16:02:50 +02:00
* @ param int $mode 0 for HTML mode and 1 for array return ( to be used by json_encode for example )
* @ param string $filterkey Key to filter
2016-09-18 21:13:23 +02:00
* @ param int $nooutput No print output . Return it only .
2016-10-17 17:52:58 +02:00
* @ param int $forceaddid Force to add project id in list , event if not qualified
2017-01-31 12:20:45 +01:00
* @ param int $htmlid Html id to use instead of htmlname
2017-12-20 21:14:22 +01:00
* @ param string $morecss More CSS
2015-10-04 16:02:50 +02:00
* @ return int Nb of project if OK , < 0 if KO
2013-06-14 22:33:01 +02:00
*/
2020-04-16 00:42:57 +02:00
public function select_projects_list ( $socid = - 1 , $selected = '' , $htmlname = 'projectid' , $maxlength = 24 , $option_only = 0 , $show_empty = 1 , $discard_closed = 0 , $forcefocus = 0 , $disabled = 0 , $mode = 0 , $filterkey = '' , $nooutput = 0 , $forceaddid = 0 , $htmlid = '' , $morecss = 'maxwidth500' )
{
// phpcs:enable
2020-04-10 10:59:32 +02:00
global $user , $conf , $langs ;
2013-07-07 13:14:32 +02:00
2013-06-14 22:33:01 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2021-02-23 22:03:23 +01:00
if ( empty ( $htmlid )) {
$htmlid = $htmlname ;
}
2017-06-02 12:27:46 +02:00
2020-04-10 10:59:32 +02:00
$out = '' ;
$outarray = array ();
2017-06-02 12:27:46 +02:00
2013-06-14 22:33:01 +02:00
$hideunselectables = false ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PROJECT_HIDE_UNSELECTABLES )) {
$hideunselectables = true ;
}
2013-06-14 22:33:01 +02:00
$projectsListId = false ;
2021-02-23 22:03:23 +01:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2020-04-10 10:59:32 +02:00
$projectstatic = new Project ( $this -> db );
2019-01-27 11:55:16 +01:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 );
2013-06-14 22:33:01 +02:00
}
// Search all projects
2017-04-05 11:51:55 +02:00
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, s.nom as name, s.name_alias' ;
2020-04-10 10:59:32 +02:00
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'projet as p LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc' ;
$sql .= " WHERE p.entity IN ( " . getEntity ( 'project' ) . " ) " ;
2021-02-23 22:03:23 +01:00
if ( $projectsListId !== false ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.rowid IN ( " . $this -> db -> sanitize ( $projectsListId ) . " ) " ;
2021-02-23 22:03:23 +01:00
}
if ( $socid == 0 ) {
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL) " ;
}
if ( $socid > 0 ) {
if ( empty ( $conf -> global -> PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY )) {
2021-03-22 11:30:18 +01:00
$sql .= " AND (p.fk_soc= " . (( int ) $socid ) . " OR p.fk_soc IS NULL) " ;
2021-02-23 22:03:23 +01:00
} elseif ( $conf -> global -> PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all' ) { // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma.
2021-03-22 12:47:23 +01:00
$sql .= " AND (p.fk_soc IN ( " . $this -> db -> sanitize ((( int ) $socid ) . " , " . $conf -> global -> PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY ) . " ) OR p.fk_soc IS NULL) " ;
2020-04-16 00:42:57 +02:00
}
2017-03-15 12:33:06 +01:00
}
2021-02-23 22:03:23 +01:00
if ( ! empty ( $filterkey )) {
$sql .= natural_search ( array ( 'p.title' , 'p.ref' ), $filterkey );
}
2020-04-10 10:59:32 +02:00
$sql .= " ORDER BY p.ref ASC " ;
2013-06-14 22:33:01 +02:00
2020-04-10 10:59:32 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2015-01-30 19:57:38 +01:00
// Use select2 selector
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> use_javascript_ajax )) {
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php' ;
2021-02-23 22:03:23 +01:00
$comboenhancement = ajax_combobox ( $htmlid , array (), 0 , $forcefocus );
2020-04-16 00:42:57 +02:00
$out .= $comboenhancement ;
$morecss .= ' minwidth100' ;
2015-01-30 19:57:38 +01:00
}
2013-06-14 22:33:01 +02:00
if ( empty ( $option_only )) {
2020-04-10 10:59:32 +02:00
$out .= '<select class="flat' . ( $morecss ? ' ' . $morecss : '' ) . '"' . ( $disabled ? ' disabled="disabled"' : '' ) . ' id="' . $htmlid . '" name="' . $htmlname . '">' ;
2013-06-14 22:33:01 +02:00
}
if ( ! empty ( $show_empty )) {
2020-04-10 10:59:32 +02:00
$out .= '<option value="0"> </option>' ;
2013-06-14 22:33:01 +02:00
}
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 22:03:23 +01:00
if ( $num ) {
while ( $i < $num ) {
2013-06-14 22:33:01 +02:00
$obj = $this -> db -> fetch_object ( $resql );
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
2021-02-23 22:03:23 +01:00
if ( $socid > 0 && ( empty ( $obj -> fk_soc ) || $obj -> fk_soc == $socid ) && ! $user -> rights -> societe -> lire ) {
2013-06-14 22:33:01 +02:00
// Do nothing
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 22:03:23 +01:00
if ( $discard_closed == 1 && $obj -> fk_statut == 2 && $obj -> rowid != $selected ) { // We discard closed except if selected
2014-11-20 15:32:10 +01:00
$i ++ ;
continue ;
}
2020-04-10 10:59:32 +02:00
$labeltoshow = dol_trunc ( $obj -> ref , 18 );
2013-06-14 22:33:01 +02:00
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
2020-04-10 10:59:32 +02:00
$labeltoshow .= ', ' . dol_trunc ( $obj -> title , $maxlength );
2021-02-23 22:03:23 +01:00
if ( $obj -> name ) {
2020-04-16 00:42:57 +02:00
$labeltoshow .= ' - ' . $obj -> name ;
2021-02-23 22:03:23 +01:00
if ( $obj -> name_alias ) {
$labeltoshow .= ' (' . $obj -> name_alias . ')' ;
}
2017-04-05 11:51:55 +02:00
}
2017-06-02 12:27:46 +02:00
2020-04-10 10:59:32 +02:00
$disabled = 0 ;
2021-02-23 22:03:23 +01:00
if ( $obj -> fk_statut == 0 ) {
2020-04-10 10:59:32 +02:00
$disabled = 1 ;
$labeltoshow .= ' - ' . $langs -> trans ( " Draft " );
2021-02-23 22:03:23 +01:00
} elseif ( $obj -> fk_statut == 2 ) {
if ( $discard_closed == 2 ) {
$disabled = 1 ;
}
2020-04-10 10:59:32 +02:00
$labeltoshow .= ' - ' . $langs -> trans ( " Closed " );
2021-02-23 22:03:23 +01:00
} elseif ( empty ( $conf -> global -> PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY ) && $socid > 0 && ( ! empty ( $obj -> fk_soc ) && $obj -> fk_soc != $socid )) {
2020-04-10 10:59:32 +02:00
$disabled = 1 ;
$labeltoshow .= ' - ' . $langs -> trans ( " LinkedToAnotherCompany " );
2015-01-28 19:27:56 +01:00
}
2015-01-30 16:33:39 +01:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $selected ) && $selected == $obj -> rowid ) {
2020-04-10 10:59:32 +02:00
$out .= '<option value="' . $obj -> rowid . '" selected' ;
2015-06-03 21:01:50 +02:00
//if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
2020-04-10 10:59:32 +02:00
$out .= '>' . $labeltoshow . '</option>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 22:03:23 +01:00
if ( $hideunselectables && $disabled && ( $selected != $obj -> rowid )) {
2020-04-10 10:59:32 +02:00
$resultat = '' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$resultat = '<option value="' . $obj -> rowid . '"' ;
2021-02-23 22:03:23 +01:00
if ( $disabled ) {
$resultat .= ' disabled' ;
}
2013-06-14 22:33:01 +02:00
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
2020-04-10 10:59:32 +02:00
$resultat .= '>' ;
$resultat .= $labeltoshow ;
$resultat .= '</option>' ;
2013-06-14 22:33:01 +02:00
}
2020-04-10 10:59:32 +02:00
$out .= $resultat ;
2015-06-15 10:04:36 +02:00
$outarray [] = array (
2015-06-16 07:19:31 +02:00
'key' => ( int ) $obj -> rowid ,
2015-06-15 10:04:36 +02:00
'value' => $obj -> ref ,
'ref' => $obj -> ref ,
2020-10-16 20:17:54 +02:00
'labelx' => $labeltoshow ,
'label' => (( bool ) $disabled ) ? '<span class="opacitymedium">' . $labeltoshow . '</span>' : $labeltoshow ,
2015-06-16 07:19:31 +02:00
'disabled' => ( bool ) $disabled
2015-06-15 10:04:36 +02:00
);
2013-06-14 22:33:01 +02:00
}
}
$i ++ ;
}
}
2015-01-30 16:33:39 +01:00
2013-06-14 22:33:01 +02:00
$this -> db -> free ( $resql );
2015-06-15 10:04:36 +02:00
if ( ! $mode ) {
2021-02-23 22:03:23 +01:00
if ( empty ( $option_only )) {
$out .= '</select>' ;
}
if ( empty ( $nooutput )) {
2020-04-16 00:42:57 +02:00
print $out ;
return '' ;
2021-02-23 22:03:23 +01:00
} else {
return $out ;
}
2015-06-15 10:04:36 +02:00
} else {
return $outarray ;
}
2020-05-21 15:05:19 +02:00
} else {
2013-06-14 22:33:01 +02:00
dol_print_error ( $this -> db );
return - 1 ;
}
}
2013-07-07 13:14:32 +02:00
2015-06-11 18:27:59 +02:00
/**
2019-02-27 20:45:07 +01:00
* Output a combo list with tasks qualified for a third party
2015-06-11 18:27:59 +02:00
*
2019-02-27 20:45:07 +01:00
* @ param int $socid Id third party ( - 1 = all , 0 = only projects not linked to a third party , id = projects not linked or linked to third party id )
* @ param int $selected Id task preselected
* @ param string $htmlname Name of HTML select
2015-06-11 18:27:59 +02:00
* @ param int $maxlength Maximum length of label
* @ param int $option_only Return only html options lines without the select tag
2017-06-02 12:27:46 +02:00
* @ param string $show_empty Add an empty line ( '1' or string to show for empty line )
2020-10-16 20:17:54 +02:00
* @ param int $discard_closed Discard closed projects ( 0 = Keep , 1 = hide completely , 2 = Disable )
2020-04-16 00:42:57 +02:00
* @ param int $forcefocus Force focus on field ( works with javascript only )
* @ param int $disabled Disabled
2017-06-02 12:27:46 +02:00
* @ param string $morecss More css added to the select component
2018-02-26 11:57:29 +01:00
* @ param string $projectsListId '' = Automatic filter on project allowed . List of id = Filter on project ids .
* @ param string $showproject 'all' = Show project info , '' = Hide project info
2018-11-05 10:39:22 +01:00
* @ param User $usertofilter User object to use for filtering
2020-04-15 14:54:54 +02:00
* @ return int Nbr of tasks if OK , < 0 if KO
2015-06-11 18:27:59 +02:00
*/
2020-04-16 00:42:57 +02:00
public function selectTasks ( $socid = - 1 , $selected = '' , $htmlname = 'taskid' , $maxlength = 24 , $option_only = 0 , $show_empty = '1' , $discard_closed = 0 , $forcefocus = 0 , $disabled = 0 , $morecss = 'maxwidth500' , $projectsListId = '' , $showproject = 'all' , $usertofilter = null )
2015-06-11 18:27:59 +02:00
{
2020-04-10 10:59:32 +02:00
global $user , $conf , $langs ;
2015-06-11 18:27:59 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
2021-02-23 22:03:23 +01:00
if ( is_null ( $usertofilter )) {
2018-10-30 12:28:04 +01:00
$usertofilter = $user ;
}
2020-04-10 10:59:32 +02:00
$out = '' ;
2015-06-11 18:27:59 +02:00
$hideunselectables = false ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $conf -> global -> PROJECT_HIDE_UNSELECTABLES )) {
$hideunselectables = true ;
}
2015-06-11 18:27:59 +02:00
2021-02-23 22:03:23 +01:00
if ( empty ( $projectsListId )) {
if ( empty ( $usertofilter -> rights -> projet -> all -> lire )) {
2020-04-10 10:59:32 +02:00
$projectstatic = new Project ( $this -> db );
2019-01-27 11:55:16 +01:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $usertofilter , 0 , 1 );
2018-02-26 11:57:29 +01:00
}
2015-06-11 18:27:59 +02:00
}
// Search all projects
2018-12-10 12:49:20 +01:00
$sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,' ;
2020-04-10 10:59:32 +02:00
$sql .= ' s.nom as name' ;
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'projet as p' ;
$sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc,' ;
$sql .= ' ' . MAIN_DB_PREFIX . 'projet_task as t' ;
$sql .= " WHERE p.entity IN ( " . getEntity ( 'project' ) . " ) " ;
$sql .= " AND t.fk_projet = p.rowid " ;
2021-02-23 22:03:23 +01:00
if ( $projectsListId ) {
2021-03-22 11:30:18 +01:00
$sql .= " AND p.rowid IN ( " . $this -> db -> sanitize ( $projectsListId ) . " ) " ;
2021-02-23 22:03:23 +01:00
}
if ( $socid == 0 ) {
$sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL) " ;
}
if ( $socid > 0 ) {
$sql .= " AND (p.fk_soc= " . $socid . " OR p.fk_soc IS NULL) " ;
}
2020-04-10 10:59:32 +02:00
$sql .= " ORDER BY p.ref, t.ref ASC " ;
$resql = $this -> db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2015-06-11 18:27:59 +02:00
// Use select2 selector
2021-02-23 22:03:23 +01:00
if ( empty ( $option_only ) && ! empty ( $conf -> use_javascript_ajax )) {
2020-04-10 10:59:32 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php' ;
2021-01-18 12:07:40 +01:00
$comboenhancement = ajax_combobox ( $htmlname , '' , 0 , $forcefocus );
2020-04-16 00:42:57 +02:00
$out .= $comboenhancement ;
2020-10-13 10:05:47 +02:00
$morecss = 'minwidth200 maxwidth500' ;
2015-06-11 18:27:59 +02:00
}
if ( empty ( $option_only )) {
2020-04-10 10:59:32 +02:00
$out .= '<select class="valignmiddle flat' . ( $morecss ? ' ' . $morecss : '' ) . '"' . ( $disabled ? ' disabled="disabled"' : '' ) . ' id="' . $htmlname . '" name="' . $htmlname . '">' ;
2015-06-11 18:27:59 +02:00
}
2020-04-10 10:59:32 +02:00
if ( ! empty ( $show_empty )) {
$out .= '<option value="0" class="optiongrey">' ;
if ( ! is_numeric ( $show_empty )) {
2020-03-28 15:20:26 +01:00
//if (! empty($conf->use_javascript_ajax)) $out .= '<span class="opacitymedium">aaa';
2020-04-10 10:59:32 +02:00
$out .= $show_empty ;
2020-03-28 15:20:26 +01:00
//if (! empty($conf->use_javascript_ajax)) $out .= '</span>';
2021-02-23 22:03:23 +01:00
} else {
$out .= ' ' ;
}
2020-04-10 10:59:32 +02:00
$out .= '</option>' ;
2015-06-11 18:27:59 +02:00
}
2020-10-08 17:49:26 +02:00
2015-06-11 18:27:59 +02:00
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 22:03:23 +01:00
if ( $num ) {
while ( $i < $num ) {
2015-06-11 18:27:59 +02:00
$obj = $this -> db -> fetch_object ( $resql );
// If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project.
2021-02-23 22:03:23 +01:00
if ( $socid > 0 && ( empty ( $obj -> fk_soc ) || $obj -> fk_soc == $socid ) && empty ( $usertofilter -> rights -> societe -> lire )) {
2015-06-11 18:27:59 +02:00
// Do nothing
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 22:03:23 +01:00
if ( $discard_closed == 1 && $obj -> fk_statut == Project :: STATUS_CLOSED ) {
2015-06-11 18:27:59 +02:00
$i ++ ;
continue ;
}
2021-03-01 20:37:16 +01:00
$labeltoshow = '' ;
$titletoshow = '' ;
2015-07-04 02:08:06 +02:00
2020-10-08 17:49:26 +02:00
$disabled = 0 ;
2021-02-23 22:03:23 +01:00
if ( $obj -> fk_statut == Project :: STATUS_DRAFT ) {
2020-10-08 17:49:26 +02:00
$disabled = 1 ;
2021-02-23 22:03:23 +01:00
} elseif ( $obj -> fk_statut == Project :: STATUS_CLOSED ) {
if ( $discard_closed == 2 ) {
$disabled = 1 ;
}
} elseif ( $socid > 0 && ( ! empty ( $obj -> fk_soc ) && $obj -> fk_soc != $socid )) {
2020-10-08 17:49:26 +02:00
$disabled = 1 ;
}
2021-02-23 22:03:23 +01:00
if ( $showproject == 'all' ) {
2020-04-10 10:59:32 +02:00
$labeltoshow .= dol_trunc ( $obj -> ref , 18 ); // Project ref
2018-02-26 11:57:29 +01:00
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
2020-04-10 10:59:32 +02:00
$labeltoshow .= ' ' . dol_trunc ( $obj -> title , $maxlength );
2021-01-18 12:07:40 +01:00
$titletoshow = $labeltoshow ;
2018-02-26 11:57:29 +01:00
2021-01-18 12:07:40 +01:00
if ( $obj -> name ) {
$labeltoshow .= ' (' . $obj -> name . ')' ;
$titletoshow .= ' <span class="opacitymedium">(' . $obj -> name . ')</span>' ;
}
2018-02-26 11:57:29 +01:00
2020-04-10 10:59:32 +02:00
$disabled = 0 ;
2021-01-18 12:07:40 +01:00
if ( $obj -> fk_statut == Project :: STATUS_DRAFT ) {
2020-04-10 10:59:32 +02:00
$disabled = 1 ;
$labeltoshow .= ' - ' . $langs -> trans ( " Draft " );
2021-01-18 12:07:40 +01:00
$titletoshow .= ' - <span class="opacitymedium">' . $langs -> trans ( " Draft " ) . '</span>' ;
} elseif ( $obj -> fk_statut == Project :: STATUS_CLOSED ) {
2021-02-23 22:03:23 +01:00
if ( $discard_closed == 2 ) {
$disabled = 1 ;
}
2020-04-10 10:59:32 +02:00
$labeltoshow .= ' - ' . $langs -> trans ( " Closed " );
2021-01-18 12:07:40 +01:00
$titletoshow .= ' - <span class="opacitymedium">' . $langs -> trans ( " Closed " ) . '</span>' ;
} elseif ( $socid > 0 && ( ! empty ( $obj -> fk_soc ) && $obj -> fk_soc != $socid )) {
2020-04-10 10:59:32 +02:00
$disabled = 1 ;
$labeltoshow .= ' - ' . $langs -> trans ( " LinkedToAnotherCompany " );
2021-01-18 12:07:40 +01:00
$titletoshow .= ' - <span class="opacitymedium">' . $langs -> trans ( " LinkedToAnotherCompany " ) . '</span>' ;
2018-02-26 11:57:29 +01:00
}
2020-04-10 10:59:32 +02:00
$labeltoshow .= ' - ' ;
2021-01-18 12:07:40 +01:00
$titletoshow .= ' - ' ;
2015-06-11 18:27:59 +02:00
}
2018-02-26 11:57:29 +01:00
2015-06-11 18:27:59 +02:00
// Label for task
2020-04-10 10:59:32 +02:00
$labeltoshow .= $obj -> tref . ' ' . dol_trunc ( $obj -> tlabel , $maxlength );
2021-01-18 12:07:40 +01:00
$titletoshow .= $obj -> tref . ' ' . dol_trunc ( $obj -> tlabel , $maxlength );
2015-06-29 16:57:32 +02:00
2021-02-23 22:03:23 +01:00
if ( ! empty ( $selected ) && $selected == $obj -> rowid ) {
2020-04-10 10:59:32 +02:00
$out .= '<option value="' . $obj -> rowid . '" selected' ;
2021-01-18 12:07:40 +01:00
$out .= ' data-html="' . dol_escape_htmltag ( $titletoshow ) . '"' ;
2015-06-11 18:27:59 +02:00
//if ($disabled) $out.=' disabled'; // with select2, field can't be preselected if disabled
2020-04-10 10:59:32 +02:00
$out .= '>' . $labeltoshow . '</option>' ;
2020-05-21 15:05:19 +02:00
} else {
2021-02-23 22:03:23 +01:00
if ( $hideunselectables && $disabled && ( $selected != $obj -> rowid )) {
2020-04-10 10:59:32 +02:00
$resultat = '' ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$resultat = '<option value="' . $obj -> rowid . '"' ;
2021-02-23 22:03:23 +01:00
if ( $disabled ) {
$resultat .= ' disabled' ;
}
2015-06-11 18:27:59 +02:00
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')';
2021-01-18 12:07:40 +01:00
$resultat .= ' data-html="' . dol_escape_htmltag ( $titletoshow ) . '"' ;
2020-04-10 10:59:32 +02:00
$resultat .= '>' ;
$resultat .= $labeltoshow ;
$resultat .= '</option>' ;
2015-06-11 18:27:59 +02:00
}
2020-04-10 10:59:32 +02:00
$out .= $resultat ;
2015-06-11 18:27:59 +02:00
}
}
$i ++ ;
}
}
if ( empty ( $option_only )) {
2020-04-10 10:59:32 +02:00
$out .= '</select>' ;
2015-06-11 18:27:59 +02:00
}
print $out ;
$this -> db -> free ( $resql );
return $num ;
2020-05-21 15:05:19 +02:00
} else {
2015-06-11 18:27:59 +02:00
dol_print_error ( $this -> db );
return - 1 ;
}
}
2015-06-29 16:57:32 +02:00
2020-04-16 00:42:57 +02:00
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
2013-06-17 14:25:33 +02:00
/**
2014-10-29 20:21:24 +01:00
* Build a HTML select list of element of same thirdparty to suggest to link them to project
2013-06-17 14:25:33 +02:00
*
2014-10-29 20:21:24 +01:00
* @ param string $table_element Table of the element to update
2016-12-22 16:52:03 +01:00
* @ param string $socid If of thirdparty to use as filter or 'id1,id2,...'
2015-06-30 01:34:17 +02:00
* @ param string $morecss More CSS
2015-11-26 00:47:17 +01:00
* @ param int $limitonstatus Add filters to limit length of list to opened status ( for example to avoid ERR_RESPONSE_HEADERS_TOO_BIG on project / element . php page ) . TODO To implement
2018-07-31 10:02:36 +02:00
* @ param string $projectkey Equivalent key to fk_projet for actual table_element
2015-06-03 21:01:50 +02:00
* @ return int | string The HTML select list of element or '' if nothing or - 1 if KO
2013-06-17 14:25:33 +02:00
*/
2019-02-27 20:45:07 +01:00
public function select_element ( $table_element , $socid = 0 , $morecss = '' , $limitonstatus = - 2 , $projectkey = " fk_projet " )
2013-06-17 14:25:33 +02:00
{
2020-04-16 00:42:57 +02:00
// phpcs:enable
2014-10-29 20:21:24 +01:00
global $conf , $langs ;
2013-07-07 13:14:32 +02:00
2021-02-23 22:03:23 +01:00
if ( $table_element == 'projet_task' ) {
return '' ; // Special cas of element we never link to a project (already always done)
}
2015-06-03 21:01:50 +02:00
2020-04-10 10:59:32 +02:00
$linkedtothirdparty = false ;
2021-04-15 09:59:08 +02:00
if ( ! in_array ( $table_element , array ( 'don' , 'expensereport_det' , 'expensereport' , 'loan' , 'stock_mouvement' , 'payment_salary' , 'payment_various' , 'chargesociales' , 'entrepot' ))) {
2021-02-23 22:03:23 +01:00
$linkedtothirdparty = true ;
}
2015-06-30 01:34:17 +02:00
2020-04-10 10:59:32 +02:00
$sqlfilter = '' ;
2018-08-13 17:26:32 +02:00
2015-11-26 00:47:17 +01:00
//print $table_element;
2021-02-23 22:03:23 +01:00
switch ( $table_element ) {
2017-01-07 17:54:47 +01:00
case " loan " :
$sql = " SELECT t.rowid, t.label as ref " ;
break ;
2013-06-17 14:25:33 +02:00
case " facture " :
2018-12-02 14:31:45 +01:00
$sql = " SELECT t.rowid, t.ref as ref " ;
2013-06-17 14:25:33 +02:00
break ;
case " facture_fourn " :
2015-06-30 01:34:17 +02:00
$sql = " SELECT t.rowid, t.ref, t.ref_supplier " ;
2014-10-29 20:21:24 +01:00
break ;
case " commande_fourn " :
2015-11-26 00:47:17 +01:00
case " commande_fournisseur " :
2020-04-16 00:42:57 +02:00
$sql = " SELECT t.rowid, t.ref, t.ref_supplier " ;
2013-06-17 14:25:33 +02:00
break ;
case " facture_rec " :
2015-06-30 01:34:17 +02:00
$sql = " SELECT t.rowid, t.titre as ref " ;
2013-06-17 14:25:33 +02:00
break ;
case " actioncomm " :
2015-06-30 01:34:17 +02:00
$sql = " SELECT t.id as rowid, t.label as ref " ;
2020-04-10 10:59:32 +02:00
$projectkey = " fk_project " ;
2013-06-17 14:25:33 +02:00
break ;
2016-07-01 17:49:13 +02:00
case " expensereport " :
2015-02-21 15:18:05 +01:00
return '' ;
2016-07-01 17:49:13 +02:00
case " expensereport_det " :
2015-02-21 15:18:05 +01:00
/* $sql = " SELECT rowid, '' as ref " ; // table is llx_expensereport_det
$projectkey = " fk_projet " ;
break ; */
2016-07-01 17:49:13 +02:00
return '' ;
case " commande " :
2020-04-16 00:42:57 +02:00
case " contrat " :
2015-11-26 00:47:17 +01:00
case " fichinter " :
2020-04-16 00:42:57 +02:00
$sql = " SELECT t.rowid, t.ref " ;
break ;
2017-01-29 13:36:33 +01:00
case 'stock_mouvement' :
$sql = 'SELECT t.rowid, t.label as ref' ;
2020-04-10 10:59:32 +02:00
$projectkey = 'fk_origin' ;
2017-01-29 13:36:33 +01:00
break ;
2018-10-26 19:00:24 +02:00
case " payment_salary " :
2020-04-10 10:59:32 +02:00
$sql = " SELECT t.rowid, t.num_payment as ref " ; // TODO In a future fill and use real ref field
2018-10-26 19:00:24 +02:00
break ;
2017-09-11 14:29:27 +02:00
case " payment_various " :
$sql = " SELECT t.rowid, t.num_payment as ref " ;
break ;
2017-03-12 14:32:49 +01:00
case " chargesociales " :
2013-06-17 14:25:33 +02:00
default :
2015-06-30 01:34:17 +02:00
$sql = " SELECT t.rowid, t.ref " ;
2013-06-17 14:25:33 +02:00
break ;
}
2021-02-23 22:03:23 +01:00
if ( $linkedtothirdparty ) {
$sql .= " , s.nom as name " ;
}
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . $table_element . " as t " ;
2021-02-23 22:03:23 +01:00
if ( $linkedtothirdparty ) {
$sql .= " , " . MAIN_DB_PREFIX . " societe as s " ;
}
2020-04-10 10:59:32 +02:00
$sql .= " WHERE " . $projectkey . " is null " ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $socid ) && $linkedtothirdparty ) {
if ( is_numeric ( $socid )) {
2021-03-22 11:30:18 +01:00
$sql .= " AND t.fk_soc = " . (( int ) $socid );
2021-02-23 22:03:23 +01:00
} else {
2021-03-22 11:30:18 +01:00
$sql .= " AND t.fk_soc IN ( " . $this -> db -> sanitize ( $socid ) . " ) " ;
2021-02-23 22:03:23 +01:00
}
}
if ( ! in_array ( $table_element , array ( 'expensereport_det' , 'stock_mouvement' ))) {
$sql .= ' AND t.entity IN (' . getEntity ( 'project' ) . ')' ;
}
if ( $linkedtothirdparty ) {
$sql .= " AND s.rowid = t.fk_soc " ;
}
if ( $sqlfilter ) {
$sql .= " AND " . $sqlfilter ;
2016-12-22 16:52:03 +01:00
}
2020-04-10 10:59:32 +02:00
$sql .= " ORDER BY ref DESC " ;
2013-07-07 13:14:32 +02:00
2014-06-13 01:34:39 +02:00
dol_syslog ( get_class ( $this ) . '::select_element' , LOG_DEBUG );
2020-04-10 10:59:32 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2013-06-17 14:25:33 +02:00
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 22:03:23 +01:00
if ( $num > 0 ) {
2020-04-10 10:59:32 +02:00
$sellist = '<select class="flat elementselect css' . $table_element . ( $morecss ? ' ' . $morecss : '' ) . '" name="elementselect">' ;
$sellist .= '<option value="-1"></option>' ;
2021-02-23 22:03:23 +01:00
while ( $i < $num ) {
2013-06-17 14:25:33 +02:00
$obj = $this -> db -> fetch_object ( $resql );
2020-04-10 10:59:32 +02:00
$ref = $obj -> ref ? $obj -> ref : $obj -> rowid ;
2021-02-23 22:03:23 +01:00
if ( ! empty ( $obj -> ref_supplier )) {
$ref .= ' (' . $obj -> ref_supplier . ')' ;
}
if ( ! empty ( $obj -> name )) {
$ref .= ' - ' . $obj -> name ;
}
2020-04-10 10:59:32 +02:00
$sellist .= '<option value="' . $obj -> rowid . '">' . $ref . '</option>' ;
2013-06-17 14:25:33 +02:00
$i ++ ;
}
2020-04-10 10:59:32 +02:00
$sellist .= '</select>' ;
2013-06-17 14:25:33 +02:00
}
2014-10-29 20:21:24 +01:00
/* else
{
$sellist = '<select class="flat" name="elementselect">' ;
2015-05-07 11:57:23 +02:00
$sellist .= '<option value="0" disabled>' . $langs -> trans ( " None " ) . '</option>' ;
2014-10-29 20:21:24 +01:00
$sellist .= '</select>' ;
} */
2013-06-17 14:25:33 +02:00
$this -> db -> free ( $resql );
2014-10-29 20:21:24 +01:00
2015-02-21 15:18:05 +01:00
return $sellist ;
2020-05-21 15:05:19 +02:00
} else {
2015-06-30 01:34:17 +02:00
dol_print_error ( $this -> db );
2020-04-10 10:59:32 +02:00
$this -> error = $this -> db -> lasterror ();
$this -> errors [] = $this -> db -> lasterror ();
dol_syslog ( get_class ( $this ) . " ::select_element " . $this -> error , LOG_ERR );
2014-06-13 15:54:37 +02:00
return - 1 ;
2013-06-17 14:25:33 +02:00
}
}
2013-07-07 13:14:32 +02:00
2013-06-14 22:33:01 +02:00
2015-06-29 16:57:32 +02:00
/**
* Build a HTML select list of element of same thirdparty to suggest to link them to project
*
2015-08-31 17:22:36 +02:00
* @ param string $htmlname HTML name
2016-02-06 15:06:37 +01:00
* @ param string $preselected Preselected ( int or 'all' or 'none' )
2015-08-31 17:22:36 +02:00
* @ param int $showempty Add an empty line
* @ param int $useshortlabel Use short label
* @ param int $showallnone Add choice " All " and " None "
2016-01-28 20:04:02 +01:00
* @ param int $showpercent Show default probability for status
2017-02-01 13:25:16 +01:00
* @ param string $morecss Add more css
2020-05-15 15:50:50 +02:00
* @ param int $noadmininfo 0 = Add admin info , 1 = Disable admin info
2020-12-11 01:20:40 +01:00
* @ param int $addcombojs 1 = Add a js combo
2015-08-31 17:22:36 +02:00
* @ return int | string The HTML select list of element or '' if nothing or - 1 if KO
2015-06-29 16:57:32 +02:00
*/
2020-12-11 01:20:40 +01:00
public function selectOpportunityStatus ( $htmlname , $preselected = '-1' , $showempty = 1 , $useshortlabel = 0 , $showallnone = 0 , $showpercent = 0 , $morecss = '' , $noadmininfo = 0 , $addcombojs = 0 )
2015-06-29 16:57:32 +02:00
{
2020-05-15 15:50:50 +02:00
global $conf , $langs , $user ;
2015-06-29 16:57:32 +02:00
2015-06-30 01:34:17 +02:00
$sql = " SELECT rowid, code, label, percent " ;
2020-04-10 10:59:32 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . 'c_lead_status' ;
$sql .= " WHERE active = 1 " ;
$sql .= " ORDER BY position " ;
2015-06-29 16:57:32 +02:00
2020-04-10 10:59:32 +02:00
$resql = $this -> db -> query ( $sql );
2021-02-23 22:03:23 +01:00
if ( $resql ) {
2015-06-29 16:57:32 +02:00
$num = $this -> db -> num_rows ( $resql );
$i = 0 ;
2021-02-23 22:03:23 +01:00
if ( $num > 0 ) {
2020-04-10 10:59:32 +02:00
$sellist = '<select class="flat oppstatus' . ( $morecss ? ' ' . $morecss : '' ) . '" id="' . $htmlname . '" name="' . $htmlname . '">' ;
2018-10-01 21:03:33 +02:00
if ( $showempty ) {
2020-04-16 00:42:57 +02:00
// Without  , strange move of screen when switching value
$sellist .= '<option value="-1"> </option>' ;
}
2018-10-01 21:03:33 +02:00
if ( $showallnone ) {
2020-04-16 00:42:57 +02:00
$sellist .= '<option value="all"' . ( $preselected == 'all' ? ' selected="selected"' : '' ) . '>-- ' . $langs -> trans ( " OnlyOpportunitiesShort " ) . ' --</option>' ;
$sellist .= '<option value="openedopp"' . ( $preselected == 'openedopp' ? ' selected="selected"' : '' ) . '>-- ' . $langs -> trans ( " OpenedOpportunitiesShort " ) . ' --</option>' ;
$sellist .= '<option value="notopenedopp"' . ( $preselected == 'notopenedopp' ? ' selected="selected"' : '' ) . '>-- ' . $langs -> trans ( " NotOpenedOpportunitiesShort " ) . ' --</option>' ;
$sellist .= '<option value="none"' . ( $preselected == 'none' ? ' selected="selected"' : '' ) . '>-- ' . $langs -> trans ( " NotAnOpportunityShort " ) . ' --</option>' ;
}
2021-02-23 22:03:23 +01:00
while ( $i < $num ) {
2015-06-29 16:57:32 +02:00
$obj = $this -> db -> fetch_object ( $resql );
2020-04-10 10:59:32 +02:00
$sellist .= '<option value="' . $obj -> rowid . '" defaultpercent="' . $obj -> percent . '" elemcode="' . $obj -> code . '"' ;
2021-02-23 22:03:23 +01:00
if ( $obj -> rowid == $preselected ) {
$sellist .= ' selected="selected"' ;
}
2015-06-30 01:34:17 +02:00
$sellist .= '>' ;
2021-02-23 22:03:23 +01:00
if ( $useshortlabel ) {
2018-11-08 20:05:01 +01:00
$finallabel = ( $langs -> transnoentitiesnoconv ( " OppStatus " . $obj -> code ) != " OppStatus " . $obj -> code ? $langs -> transnoentitiesnoconv ( " OppStatus " . $obj -> code ) : $obj -> label );
2020-05-21 15:05:19 +02:00
} else {
2015-06-30 01:34:17 +02:00
$finallabel = ( $langs -> transnoentitiesnoconv ( " OppStatus " . $obj -> code ) != " OppStatus " . $obj -> code ? $langs -> transnoentitiesnoconv ( " OppStatus " . $obj -> code ) : $obj -> label );
2021-02-23 22:03:23 +01:00
if ( $showpercent ) {
$finallabel .= ' (' . $obj -> percent . '%)' ;
}
2015-06-30 01:34:17 +02:00
}
$sellist .= $finallabel ;
2020-04-10 10:59:32 +02:00
$sellist .= '</option>' ;
2015-06-29 16:57:32 +02:00
$i ++ ;
}
2020-04-10 10:59:32 +02:00
$sellist .= '</select>' ;
2020-12-11 01:20:40 +01:00
2021-02-23 22:03:23 +01:00
if ( $user -> admin && ! $noadmininfo ) {
$sellist .= info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2020-12-11 01:20:40 +01:00
2021-02-23 22:03:23 +01:00
if ( $addcombojs ) {
$sellist .= ajax_combobox ( $htmlname );
}
2015-06-29 16:57:32 +02:00
}
/* else
{
$sellist = '<select class="flat" name="elementselect">' ;
$sellist .= '<option value="0" disabled>' . $langs -> trans ( " None " ) . '</option>' ;
$sellist .= '</select>' ;
} */
$this -> db -> free ( $resql );
return $sellist ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +02:00
$this -> error = $this -> db -> lasterror ();
$this -> errors [] = $this -> db -> lasterror ();
dol_syslog ( get_class ( $this ) . " ::selectOpportunityStatus " . $this -> error , LOG_ERR );
2015-06-29 16:57:32 +02:00
return - 1 ;
}
}
2014-07-14 23:36:10 +02:00
}