From ad1ec032f3b9015e477ee57ba261847a4c2031b8 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Tue, 24 Jan 2012 09:19:28 +0100
Subject: [PATCH] Normalize code

---
 htdocs/admin/company.php                   |  2 +-
 htdocs/core/class/html.formother.class.php |  6 ++-
 htdocs/core/lib/date.lib.php               | 52 +++++++---------------
 3 files changed, 22 insertions(+), 38 deletions(-)

diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 8c5fe0c7dbf..9c075a36cd7 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -871,7 +871,7 @@ else
     $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>";
 
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 65d6f098aa3..16682a7b7a2 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -542,16 +542,18 @@ class FormOther
      */
     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)
             {
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 29cf6b72bd8..fa3b3d4f113 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -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;
 }
 
 ?>
\ No newline at end of file
-- 
GitLab