From c2590433fe3cbddcdb1dca125ab34c8c9b933cba Mon Sep 17 00:00:00 2001 From: "Sekan, Tobias" Date: Thu, 27 Aug 2020 10:11:18 +0200 Subject: [PATCH 1/3] Show ref in contract form on interventions --- htdocs/core/class/html.formcontract.class.php | 19 ++++++++++++++++--- htdocs/fichinter/card.php | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 6dce90d372b..860bcc2ca67 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -58,9 +58,10 @@ class FormContract * @param string $htmlname Nom de la zone html * @param int $maxlength Maximum length of label * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) { // phpcs:enable global $db, $user, $conf, $langs; @@ -70,6 +71,10 @@ class FormContract // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; + if($showRef) + { + $sql .= ', c.ref_customer, c.ref_supplier'; + } $sql .= ' FROM '.MAIN_DB_PREFIX.'contrat as c'; $sql .= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; @@ -105,6 +110,13 @@ class FormContract // Do nothing } else { $labeltoshow = dol_trunc($obj->ref, 18); + + if($showRef) + { + if($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer; + if($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier; + } + //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; if (!empty($selected) && $selected == $obj->rowid && $obj->statut > 0) @@ -166,9 +178,10 @@ class FormContract * @param string $htmlname Nom de la zone html * @param int $maxlength Maximum length of label * @param int $showempty Show empty line + * @param int $showRef Show customer and supplier reference on each contract (when found) * @return int Nbr of project if OK, <0 if KO */ - public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1, $showRef = 0) { global $langs; @@ -176,7 +189,7 @@ class FormContract print '
'; print ''; print ''; - $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty); + $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty, $showRef); print ''; print '
'; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index a4fa1fff132..5925bb079a2 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -906,7 +906,7 @@ if ($action == 'create') { $langs->load("contracts"); print ''.$langs->trans("Contract").''; - $numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1); + $numcontrat = $formcontract->select_contract($soc->id, GETPOST('contratid', 'int'), 'contratid', 0, 1, 1); if ($numcontrat == 0) { print '   '; @@ -1238,7 +1238,7 @@ if ($action == 'create') if ($action == 'contrat') { $formcontract = new Formcontract($db); - $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1); + $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1); } else { if ($object->fk_contrat) { From 8ff24282d9f3e02884a06c59db05b1bfb4e3e63a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 27 Aug 2020 08:16:32 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/core/class/html.formcontract.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 860bcc2ca67..c0ea71ee6f8 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -71,7 +71,7 @@ class FormContract // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; - if($showRef) + if ($showRef) { $sql .= ', c.ref_customer, c.ref_supplier'; } @@ -111,10 +111,10 @@ class FormContract } else { $labeltoshow = dol_trunc($obj->ref, 18); - if($showRef) + if ($showRef) { - if($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer; - if($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier; + if ($obj->ref_customer) $labeltoshow = $labeltoshow." - ".$obj->ref_customer; + if ($obj->ref_supplier) $labeltoshow = $labeltoshow." - ".$obj->ref_supplier; } //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; From 6715eaee095f713a48910a9ef9c6ce3776a987e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 27 Aug 2020 19:44:17 +0200 Subject: [PATCH 3/3] Update html.formcontract.class.php --- htdocs/core/class/html.formcontract.class.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index c0ea71ee6f8..d4ce1cbb0fe 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -70,11 +70,8 @@ class FormContract if (!empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; // Search all contacts - $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; - if ($showRef) - { - $sql .= ', c.ref_customer, c.ref_supplier'; - } + $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut,'; + $sql .= ' c.ref_customer, c.ref_supplier'; $sql .= ' FROM '.MAIN_DB_PREFIX.'contrat as c'; $sql .= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")";