Skip to content

Commit

Permalink
Normalize code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 24, 2012
1 parent 354e815 commit ad1ec03
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
2 changes: 1 addition & 1 deletion htdocs/admin/company.php
Expand Up @@ -871,7 +871,7 @@
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>';
$monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1;
print monthArrayOrSelected($monthstart) . '</td></tr>';
print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . '</td></tr>';

print "</table>";

Expand Down
6 changes: 4 additions & 2 deletions htdocs/core/class/html.formother.class.php
Expand Up @@ -542,16 +542,18 @@ function select_dayofweek($selected='',$htmlname='weekid',$useempty=0)
*/
function select_month($selected='',$htmlname='monthid',$useempty=0)
{
global $langs;

require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");

$month = monthArrayOrSelected(-1); // Get array
$montharray = monthArray($langs); // Get array

$select_month = '<select class="flat" name="'.$htmlname.'">';
if ($useempty)
{
$select_month .= '<option value="0">&nbsp;</option>';
}
foreach ($month as $key => $val)
foreach ($montharray as $key => $val)
{
if ($selected == $key)
{
Expand Down
52 changes: 17 additions & 35 deletions htdocs/core/lib/date.lib.php
Expand Up @@ -697,45 +697,27 @@ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0)
/**
* Return array of translated months or selected month
*
* @param int $selected -1 to return array of all months or motnh to select
* @return mixed Month string or array if selected < 0
* @param Translate $outputlangs Object langs
* @return array Month string or array if selected < 0
*/
function monthArrayOrSelected($selected=0)
function monthArray($outputlangs)
{
global $langs;

$month = array (
1 => $langs->trans("January"),
2 => $langs->trans("February"),
3 => $langs->trans("March"),
4 => $langs->trans("April"),
5 => $langs->trans("May"),
6 => $langs->trans("June"),
7 => $langs->trans("July"),
8 => $langs->trans("August"),
9 => $langs->trans("September"),
10 => $langs->trans("October"),
11 => $langs->trans("November"),
12 => $langs->trans("December")
$montharray = array (
1 => $outputlangs->trans("January"),
2 => $outputlangs->trans("February"),
3 => $outputlangs->trans("March"),
4 => $outputlangs->trans("April"),
5 => $outputlangs->trans("May"),
6 => $outputlangs->trans("June"),
7 => $outputlangs->trans("July"),
8 => $outputlangs->trans("August"),
9 => $outputlangs->trans("September"),
10 => $outputlangs->trans("October"),
11 => $outputlangs->trans("November"),
12 => $outputlangs->trans("December")
);

if ($selected >=0)
{
$return='';
foreach ($month as $key => $val)
{
if ($selected == $key)
{
$return = $val;
break;
}
}
return $return;
}
else
{
return $month;
}
return $montharray;
}

?>

0 comments on commit ad1ec03

Please sign in to comment.