make jobposition ajaxtooltip (#35899)

* make jobposition ajaxtooltip

* make jobposition ajaxtooltip

* fix

* fix

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Frédéric FRANCE 2025-10-23 13:26:25 +02:00 committed by GitHub
parent c42f2e4c88
commit f203eace15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 56 additions and 17 deletions

View file

@ -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

View file

@ -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<string,string> $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) . ' <u class="paddingrightonly">' . $langs->trans("PositionToBeFilled") . '</u>';
if (isset($this->status)) {
$datas['picto'] .= ' ' . $this->getLibStatut(5);
}
if (!empty($this->ref)) {
$datas['ref'] = '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
}
if (!empty($this->label)) {
$datas['ref'] = '<br>' . $langs->trans('Label') . ':</b> ' . $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).' <u class="paddingrightonly">'.$langs->trans("PositionToBeFilled").'</u>';
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 .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
$label .= '<br><b>'.$langs->trans('Label').':</b> '.$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.'"' : '');
}