2
0
forked from Wavyzz/dolibarr

New: Function yn can show a visual checkbox

This commit is contained in:
Laurent Destailleur
2014-12-07 01:57:23 +01:00
parent 1ad4ae5c78
commit c731321024
3 changed files with 28 additions and 8 deletions

View File

@@ -1029,7 +1029,7 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
function dol_getdate($timestamp,$fast=false)
{
global $conf;
$usealternatemethod=false;
if ($timestamp <= 0) $usealternatemethod=true; // <= 1970
if ($timestamp >= 2145913200) $usealternatemethod=true; // >= 2038
@@ -1041,7 +1041,7 @@ function dol_getdate($timestamp,$fast=false)
else
{
$arrayinfo=getdate($timestamp);
$startday=isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:1;
if($startday==1)
{
@@ -1116,11 +1116,11 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1)
$default_timezone=@date_default_timezone_get();
}
}
if (empty($localtz)) {
$localtz = new DateTimeZone('UTC');
}
$dt = new DateTime(null,$localtz);
$dt->setDate($year,$month,$day);
$dt->setTime((int) $hour, (int) $minute, (int) $second);
@@ -3595,7 +3595,7 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id
* Return yes or no in current language
*
* @param string $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false')
* @param string $case 1=Yes/No, 0=yes/no
* @param string $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No
* @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color.
* @return string HTML string
*/
@@ -3605,12 +3605,20 @@ function yn($yesno, $case=1, $color=0)
$result='unknown';
if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') // A mettre avant test sur no a cause du == 0
{
$result=($case?$langs->trans("Yes"):$langs->trans("yes"));
$result=$langs->trans('yes');
if ($case == 1 || $case == 3) $result=$langs->trans("Yes");
if ($case == 2) $result='<input type="checkbox" value="1" checked="checked" disabled="disabled">';
if ($case == 3) $result='<input type="checkbox" value="1" checked="checked" disabled="disabled"> '.$result;
$classname='ok';
}
elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false')
{
$result=($case?$langs->trans("No"):$langs->trans("no"));
$result=$langs->trans("no");
if ($case == 1 || $case == 3) $result=$langs->trans("No");
if ($case == 2) $result='<input type="checkbox" value="0" disabled="disabled">';
if ($case == 3) $result='<input type="checkbox" value="0" disabled="disabled"> '.$result;
if ($color == 2) $classname='ok';
else $classname='error';
}