From b4cdb3f609359cfb90cac058244cc4e2c8098d08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 27 Apr 2026 23:40:35 +0200 Subject: [PATCH] FIX Some critical pb with the select_contract() component. --- htdocs/core/class/html.formcontract.class.php | 9 +++++---- htdocs/core/class/html.formticket.class.php | 18 +++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 70424b2c931..76349b7c898 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -53,6 +53,7 @@ class FormContract // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party + * TODO This is a bugged function. It downloads all contracts into the select hanging the browser on large database. * * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) * @param int $selected Id contract preselected @@ -88,7 +89,7 @@ class FormContract if (!getDolGlobalString('CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) { $sql .= " AND (c.fk_soc=".((int) $socid)." OR c.fk_soc IS NULL)"; } elseif (getDolGlobalString('CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') != 'all') { - $sql .= " AND (c.fk_soc IN (".$this->db->sanitize(((int) $socid).",".((int) $conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)).")"; + $sql .= " AND (c.fk_soc IN (".$this->db->sanitize(((int) $socid).",".getDolGlobalInt('CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')).")"; $sql .= " OR c.fk_soc IS NULL)"; } } @@ -133,11 +134,11 @@ class FormContract $disabled = 0; if ($obj->status == 0) { $disabled = 1; - $labeltoshow .= ' ('.$langs->trans("Draft").')'; + $labeltoshow .= ' ('.$langs->transnoentitiesnoconv("Draft").')'; } if (!getDolGlobalString('CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') && $socid > 0 && (!empty($obj->fk_soc) && $obj->fk_soc != $socid)) { $disabled = 1; - $labeltoshow .= ' - '.$langs->trans("LinkedToAnotherCompany"); + $labeltoshow .= ' - '.$langs->transnoentitiesnoconv("LinkedToAnotherCompany"); } if ($hideunselectables && $disabled) { @@ -149,7 +150,7 @@ class FormContract } //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; - $resultat .= '>'.$labeltoshow; + $resultat .= '>'.dolPrintHTML($labeltoshow); $resultat .= ''."\n"; } $ret .= $resultat; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 4639f2ce999..41da6a1e398 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -772,13 +772,17 @@ class FormTicket if ($subelement != 'contract' && $subelement != 'contrat') { if (isModEnabled('contract') && !$this->ispublic) { - $langs->load('contracts'); - $formcontract = new FormContract($this->db); - print ''; - print img_picto('', 'contract', 'class="pictofixedwidth"'); - // socid is for internal users null and not 0 or -1 - print $formcontract->select_contract($user->socid ?? -1, GETPOSTINT('contractid'), 'contractid', 0, 1, 1, 1); - print ''; + // This feature hang the application on large list of contracts, because the select component is not complete: it does not work like select of thirdparty or product to support large lists + // So we add a hidden option to avoid to have it used and the application locked, until the select_contract is fixed. + if (getDolGlobalString("TICKET_CAN_SELECT_CONTRACT_WITH_BUGGED_SELECT_LIST")) { + $langs->load('contracts'); + $formcontract = new FormContract($this->db); + print ''; + print img_picto('', 'contract', 'class="pictofixedwidth"'); + // socid is for internal users null and not 0 or -1 + print $formcontract->select_contract($user->socid ?? -1, GETPOSTINT('contractid'), 'contractid', 0, 1, 1, 1); + print ''; + } } }