Enhancement of holiday module

This commit is contained in:
Laurent Destailleur 2012-09-06 23:58:09 +02:00
parent 6e90e60268
commit 28e7b73d21
4 changed files with 21 additions and 24 deletions

View File

@ -2679,7 +2679,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT; if ($rounding == 'MU') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_UNIT;
elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT; elseif ($rounding == 'MT') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_TOT;
elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN; elseif ($rounding == 'MS') $nbofdectoround=$conf->global->MAIN_MAX_DECIMALS_SHOWN;
elseif ($rounding == '2') $nbofdectoround=2; // For admin info page elseif (is_numeric($rounding)) $nbofdectoround=$rounding; // For admin info page
//print "RR".$amount.' - '.$nbofdectoround.'<br>'; //print "RR".$amount.' - '.$nbofdectoround.'<br>';
if (dol_strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0. if (dol_strlen($nbofdectoround)) $amount = round($amount,$nbofdectoround); // $nbofdectoround can be 0.
else return 'ErrorBadParameterProvidedToFunction'; else return 'ErrorBadParameterProvidedToFunction';

View File

@ -72,7 +72,7 @@ if ($action == "add")
} }
// Option du nombre de jours à ajouter chaque mois // Option du nombre de jours à ajouter chaque mois
$nbHolidayEveryMonth = price2num($_POST['nbHolidayEveryMonth'],2); $nbHolidayEveryMonth = price2num($_POST['nbHolidayEveryMonth'],5);
if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth)) if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth))
{ {
@ -80,28 +80,28 @@ if ($action == "add")
} }
// Option du nombre de jours pour un mariage // Option du nombre de jours pour un mariage
$OptMariageCP = price2num($_POST['OptMariage'],2); $OptMariageCP = price2num($_POST['OptMariage'],5);
if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) { if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) {
$error = true; $error = true;
} }
// Option du nombre de jours pour un décés d'un proche // Option du nombre de jours pour un décés d'un proche
$OptDecesProcheCP = price2num($_POST['OptDecesProche'],2); $OptDecesProcheCP = price2num($_POST['OptDecesProche'],5);
if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) { if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) {
$error = true; $error = true;
} }
// Option du nombre de jours pour un mariage d'un enfant // Option du nombre de jours pour un mariage d'un enfant
$OptMariageProcheCP = price2num($_POST['OptMariageProche'],2); $OptMariageProcheCP = price2num($_POST['OptMariageProche'],5);
if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) { if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) {
$error = true; $error = true;
} }
// Option du nombre de jours pour un décés d'un parent // Option du nombre de jours pour un décés d'un parent
$OptDecesParentsCP = price2num($_POST['OptDecesParents'],2); $OptDecesParentsCP = price2num($_POST['OptDecesParents'],5);
if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) { if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) {
$error = true; $error = true;
@ -307,7 +307,7 @@ print '</tr>'."\n";
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'."\n"; print '<tr '.$bc[$var].'>'."\n";
print '<td style="padding:5px;">'.$langs->trans('nbHolidayEveryMonthCP').'</td>'."\n"; print '<td style="padding:5px;">'.$langs->trans('nbHolidayEveryMonthCP').'</td>'."\n";
print '<td style="padding:5px;"><input type="text" name="nbHolidayEveryMonth" value="'.$cp->getConfCP('nbHolidayEveryMonth').'" size="2"/> '.$langs->trans('Jours').'</td>'."\n"; print '<td style="padding:5px;"><input type="text" name="nbHolidayEveryMonth" value="'.$cp->getConfCP('nbHolidayEveryMonth').'" size="5"/> '.$langs->trans('Jours').'</td>'."\n";
print '</tr>'."\n"; print '</tr>'."\n";
$var=!$var; $var=!$var;

View File

@ -1399,42 +1399,39 @@ class Holiday extends CommonObject
} }
/** /**
* select event * Select event
* *
* @return string|boolean * @return string|boolean Select Html to select type of holiday
*/ */
function selectEventCP() function selectEventCP()
{ {
$sql = "SELECT *"; $sql = "SELECT rowid, name, value";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result)
if($result) { {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0; $i = 0;
$out = '<select name="list_event" class="flat" >'; $out = '<select name="list_event" class="flat" >';
$out.= '<option value="-1">&nbsp;</option>'; $out.= '<option value="-1">&nbsp;</option>';
while ($i < $num)
while($i < $num) { {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$out.= '<option value="'.$obj->rowid.'">'.$obj->name.'</option>'; $out.= '<option value="'.$obj->rowid.'">'.$obj->name.' ('.$obj->value.')</option>';
$i++; $i++;
} }
$out.= '</select>'; $out.= '</select>';
return $out; return $out;
} else {
return false;
} }
else
{
return false;
}
} }
/** /**

View File

@ -124,7 +124,7 @@ if($cp_events == 1)
print $langs->trans('MotifCP').' : '; print $langs->trans('MotifCP').' : ';
print $holiday->selectEventCP(); print $holiday->selectEventCP();
print ' '.$langs->trans('UserCP').' : '; print ' &nbsp; '.$langs->trans('UserCP').' : ';
print $form->select_users('',"userCP",1,"",0,''); print $form->select_users('',"userCP",1,"",0,'');
print ' <input type="submit" value="'.$langs->trans("addEventToUserCP").'" name="bouton" class="button"/>'; print ' <input type="submit" value="'.$langs->trans("addEventToUserCP").'" name="bouton" class="button"/>';