Fix the extracss parameter was overwritten other css into

textwithtooltip function.
Add tooltip on THM and TJM parameter of user.
This commit is contained in:
Laurent Destailleur
2015-06-04 10:42:12 +02:00
parent dd8a0b849a
commit 8010cb7f33
4 changed files with 31 additions and 20 deletions

View File

@@ -376,7 +376,7 @@ class Form
* @return string Code html du tooltip (texte+picto)
* @see Use function textwithpicto if you can.
*/
function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 0, $incbefore = '', $noencodehtmltext = 0)
function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0)
{
global $conf;
@@ -391,14 +391,19 @@ class Form
$htmltext=str_replace("\r","",$htmltext);
$htmltext=str_replace("\n","",$htmltext);
$extrastyle='';
if ($direction < 0) { $extracss=($extracss?$extracss.' ':'').'inline-block'; $extrastyle='padding: 0px; padding-left: 3px !important;'; }
if ($direction > 0) { $extracss=($extracss?$extracss.' ':'').'inline-block'; $extrastyle='padding: 0px; padding-right: 3px !important;'; }
$htmltext=str_replace('"',"&quot;",$htmltext);
if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip
else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag
if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip
else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag
if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip
else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag
if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip inline-block'.($extracss?' '.$extracss:'').'" style="padding: 0px;'.($extrastyle?' '.$extrastyle:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip
else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':'').($extrastyle?' style="'.$extrastyle.'"':''); // Attribut to put on td text tag
$s="";
if (empty($notabs)) $s.='<table class="nobordernopadding" summary=""><tr style="height: auto;">';
elseif ($notabs == 2) $s.='<div class="inline-block nowrap">';
// Define value if value is before
if ($direction < 0) {
$s.='<'.$tag.$paramfortooltipimg;
if ($tag == 'td') {
@@ -407,16 +412,12 @@ class Form
$s.= '>'.$img.'</'.$tag.'>';
}
// Use another method to help avoid having a space in value in order to use this value with jquery
// TODO add this in css
//if ($text != '') $s.='<'.$tag.$paramfortooltiptd.'>'.(($direction < 0)?'&nbsp;':'').$text.(($direction > 0)?'&nbsp;':'').'</'.$tag.'>';
$paramfortooltiptd.= (($direction < 0)?' class="inline-block" style="padding: 0px; padding-left: 3px !important;"':'');
$paramfortooltiptd.= (($direction > 0)?' class="inline-block" style="padding: 0px; padding-right: 3px !important;"':'');
// Define label
if ((string) $text != '') $s.='<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>';
// Define value if value is after
if ($direction > 0) {
$s.='<'.$tag.$paramfortooltipimg;
if ($tag == 'td') {
$s .= ' valign="middle" width="14"';
}
if ($tag == 'td') $s .= ' valign="middle" width="14"';
$s.= '>'.$img.'</'.$tag.'>';
}
if (empty($notabs)) $s.='</tr></table>';
@@ -437,7 +438,7 @@ class Form
* @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span
* @return string HTML code of text, picto, tooltip
*/
function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 0)
function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2)
{
global $conf;

View File

@@ -2186,7 +2186,7 @@ function img_help($usehelpcursor = 1, $usealttitle = 1)
else $usealttitle = $langs->trans('Info');
}
return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="cursor: help"' : ''));
return img_picto($usealttitle, 'info.png', ($usehelpcursor ? 'style="vertical-align: middle; cursor: help"' : 'style="vertical-align: middle;"'));
}
/**
@@ -2201,7 +2201,7 @@ function img_info($titlealt = 'default')
if ($titlealt == 'default') $titlealt = $langs->trans('Informations');
return img_picto($titlealt, 'info.png');
return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"');
}
/**

View File

@@ -11,3 +11,5 @@ ShowSalaryPayment=Show salary payment
THM=Average hourly price
TJM=Average daily price
CurrentSalary=Current salary
THMDescription=This value may be used to calculate cost of time consumed on a project entered by users if module project is used
TJMDescription=This value is currently as information only and is not used for any calculation

View File

@@ -1272,10 +1272,12 @@ else
print '</td></tr>'."\n";
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td colspan="2">';
print '<tr><td>';
$text=$langs->trans("Type");
print $form->textwithpicto($text, $langs->trans("InternalExternalDesc"));
print '</td><td colspan="2">';
$type=$langs->trans("Internal");
if ($object->societe_id) $type=$langs->trans("External");
print $form->textwithpicto($type, $langs->trans("InternalExternalDesc"), 1, 'help', '', 0, 2);
if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')';
print '</td></tr>'."\n";
@@ -1337,14 +1339,20 @@ else
$langs->load("salaries");
// THM
print '<tr><td>'.$langs->trans("THM").'</td>';
print '<tr><td>';
$text=$langs->trans("THM");
print $form->textwithpicto($text, $langs->trans("THMDescription"), 1, 'help', 'classthm');
print '</td>';
print '<td colspan="2">';
print ($object->thm!=''?price($object->thm,'',$langs,1,-1,-1,$conf->currency):'');
print '</td>';
print "</tr>\n";
// TJM
print '<tr><td>'.$langs->trans("TJM").'</td>';
print '<tr><td>';
$text=$langs->trans("TJM");
print $form->textwithpicto($text, $langs->trans("TJMDescription"), 1, 'help', 'classtjm');
print '</td>';
print '<td colspan="2">';
print ($object->tjm!=''?price($object->tjm,'',$langs,1,-1,-1,$conf->currency):'');
print '</td>';