From f203eace15f24ff0741600ce41a3ff6c394b84ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 23 Oct 2025 13:26:25 +0200 Subject: [PATCH] make jobposition ajaxtooltip (#35899) * make jobposition ajaxtooltip * make jobposition ajaxtooltip * fix * fix --------- Co-authored-by: Laurent Destailleur --- htdocs/langs/en_US/recruitment.lang | 1 + .../class/recruitmentjobposition.class.php | 72 ++++++++++++++----- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index 3d249271e2b..7312889d4c2 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -68,3 +68,4 @@ ApplyJobCandidature=Apply for this job ErrorRecruitmmentCandidatureAlreadyExists= Recruitment candidature already exists with email %s RecruitmentCandidatureSaved=Recruitement candidature successfully saved NoOpenJobOffer=No open job offers at the moment +ShowPositionToBeFilled=Show Position to be filled diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index e74023e626b..d9da5ad847e 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -353,8 +353,7 @@ class RecruitmentJobPosition extends CommonObject $result = $object->createCommon($user); if ($result < 0) { $error++; - $this->error = $object->error; - $this->errors = $object->errors; + $this->setErrorsFromObject($object); } if (!$error) { @@ -809,6 +808,38 @@ class RecruitmentJobPosition extends CommonObject return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'RECRUITMENTJOBPOSITION_REOPEN'); } + /** + * getTooltipContentArray + * + * @param array $params Params to construct tooltip data + * + * @return array{optimize?:string,picto?:string,ref?:string} + */ + public function getTooltipContentArray($params) + { + global $langs; + + $langs->load('recruitment'); + + $datas = []; + + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { + return ['optimize' => $langs->trans("ShowPositionToBeFilled")]; + } + $datas['picto'] = img_picto('', $this->picto) . ' ' . $langs->trans("PositionToBeFilled") . ''; + if (isset($this->status)) { + $datas['picto'] .= ' ' . $this->getLibStatut(5); + } + if (!empty($this->ref)) { + $datas['ref'] = '
' . $langs->trans('Ref') . ': ' . $this->ref; + } + if (!empty($this->label)) { + $datas['ref'] = '
' . $langs->trans('Label') . ': ' . $this->label; + } + + return $datas; + } + /** * Return a link to the object card (with optionally the picto) * @@ -828,36 +859,43 @@ class RecruitmentJobPosition extends CommonObject } $result = ''; - - $label = img_picto('', $this->picto).' '.$langs->trans("PositionToBeFilled").''; - if (isset($this->status)) { - $label .= ' '.$this->getLibStatut(5); + $params = [ + 'id' => (string) $this->id, + 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''), + 'option' => $option, + ]; + $classfortooltip = 'classfortooltip'; + $dataparams = ''; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $classfortooltip = 'classforajaxtooltip'; + $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"'; + $label = ''; + } else { + $label = implode($this->getTooltipContentArray($params)); } - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; - $label .= '
'.$langs->trans('Label').': '.$this->label; - $url = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.$this->id; - - if ($option != 'nolink') { + $baseurl = DOL_URL_ROOT . '/recruitment/recruitmentjobposition_card.php'; + $query = ['id' => $this->id]; + if ($option !== 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url .= '&save_lastsearch_values=1'; + $query = array_merge($query, ['save_lastsearch_values' => 1]); } } + $url = dolBuildUrl($baseurl, $query); $linkclose = ''; if (empty($notooltip)) { - if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { - $label = $langs->trans("ShowRecruitmentJobPosition"); + if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { + $label = $langs->trans("ShowPositionToBeFilled"); $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"'; } - $linkclose .= ' title="'.dolPrintHTMLForAttribute($label).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + $linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"'); + $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"'; } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); }