diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index fe1b2e60702..bc61dad4aed 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -674,7 +674,7 @@ else
$var=!$var;
print '
| '.$langs->trans("CompanyCurrency").' | ';
print currency_name($conf->currency,1);
- print ' ('.getCurrencySymbol($conf->currency).')';
+ print ' ('.$langs->getCurrencySymbol($conf->currency).')';
print ' |
';
$var=!$var;
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 432dd7c7571..25bde7a7b85 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -138,7 +138,7 @@ $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.
$tabsql[6] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
$tabsql[7] = "SELECT a.id as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, p.code as pays_code, p.libelle as pays, a.fk_pays as pays_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
$tabsql[8] = "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
-$tabsql[9] = "SELECT code_iso as code, label as libelle, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
+$tabsql[9] = "SELECT code_iso as code, label, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, llx_c_pays as p WHERE t.fk_pays=p.rowid";
$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
$tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
@@ -165,7 +165,7 @@ $tabsqlsort[5] ="libelle ASC";
$tabsqlsort[6] ="a.type ASC, a.module ASC, a.position ASC, a.code ASC";
$tabsqlsort[7] ="pays ASC, code ASC, a.libelle ASC";
$tabsqlsort[8] ="libelle ASC";
-$tabsqlsort[9] ="libelle ASC";
+$tabsqlsort[9] ="label ASC";
$tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
$tabsqlsort[11]="element ASC, source ASC, code ASC";
$tabsqlsort[12]="sortorder ASC, code ASC";
@@ -192,7 +192,7 @@ $tabfield[5] = "code,libelle";
$tabfield[6] = "code,libelle,type,position";
$tabfield[7] = "code,libelle,pays_id,pays,accountancy_code,deductible";
$tabfield[8] = "code,libelle";
-$tabfield[9] = "code,libelle,unicode";
+$tabfield[9] = "code,label,unicode";
$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
$tabfield[11]= "element,source,code,libelle";
$tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
@@ -219,7 +219,7 @@ $tabfieldvalue[5] = "code,libelle";
$tabfieldvalue[6] = "code,libelle,type,position";
$tabfieldvalue[7] = "code,libelle,pays,accountancy_code,deductible";
$tabfieldvalue[8] = "code,libelle";
-$tabfieldvalue[9] = "code,libelle,unicode";
+$tabfieldvalue[9] = "code,label,unicode";
$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1_type,localtax1,localtax2_type,localtax2,accountancy_code_sell,accountancy_code_buy,note";
$tabfieldvalue[11]= "element,source,code,libelle";
$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
@@ -961,7 +961,7 @@ if ($id)
$key=$langs->trans("Action".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
- else if (! empty($obj->code_iso) && $fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') {
+ else if (! empty($obj->code_iso) && $fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') {
$key=$langs->trans("Currency".strtoupper($obj->code_iso));
$valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]);
}
@@ -1020,7 +1020,7 @@ if ($id)
$showfield=0;
}
else if ($fieldlist[$field]=='unicode') {
- $valuetoshow = getCurrencySymbol($obj->code);
+ $valuetoshow = $langs->getCurrencySymbol($obj->code,1);
}
else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 15824176bbb..8d0a608f6c2 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -764,7 +764,7 @@ else if ($action == "addline" && $user->rights->propal->creer)
if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency));
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency));
setEventMessage($mesg, 'errors');
}
else
@@ -875,7 +875,7 @@ else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('sa
if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).getCurrencySymbol($conf->currency), 'errors');
+ setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors');
$error++;
}
}
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index aa8434bbc62..61f52eadc62 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -681,7 +681,7 @@ else if ($action == 'addline' && $user->rights->commande->creer)
if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency));
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency));
setEventMessage($mesg, 'errors');
}
else
@@ -799,7 +799,7 @@ else if ($action == 'updateligne' && $user->rights->commande->creer && GETPOST('
if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).getCurrencySymbol($conf->currency), 'errors');
+ setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors');
$error++;
}
}
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 770cf80a256..f685a5c7609 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -738,7 +738,7 @@ else if ($action == 'add' && $user->rights->facture->creer)
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors');
}
-
+
$datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($datefacture))
{
@@ -1136,7 +1136,7 @@ else if (($action == 'addline' || $action == 'addline_predef') && $user->rights-
if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').getCurrencySymbol($conf->currency));
+ $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency));
setEventMessage($mesg, 'errors');
}
else
@@ -1259,7 +1259,7 @@ else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['sa
if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min)))
{
- setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).getCurrencySymbol($conf->currency), 'errors');
+ setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors');
$error++;
}
}
@@ -1934,7 +1934,7 @@ if ($action == 'create')
print $desc;
print ''."\n";
}
-
+
if ($socid>0)
{
// Replacement
@@ -1960,7 +1960,7 @@ if ($action == 'create')
$desc=$form->textwithpicto($text,$langs->transnoentities("InvoiceReplacementDesc"),1);
print $desc;
print ''."\n";
-
+
// Credit note
print '| ';
print '';
print ' |
';
-
+
if($socid>0)
{
// Discounts for third party
@@ -2004,7 +2004,7 @@ if ($action == 'create')
print '.';
print '';
}
-
+
// Date invoice
print '| '.$langs->trans('Date').' | ';
$form->select_date($dateinvoice,'','','','',"add",1,1);
diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php
index bddbab34c6e..5918a036807 100644
--- a/htdocs/compta/facture/impayees.php
+++ b/htdocs/compta/facture/impayees.php
@@ -366,11 +366,11 @@ if ($resql)
print ' | '.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($objp->nom,28).' | ';
- print ''.price($objp->total_ht).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($objp->total_tva).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($objp->total_ttc).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.(! empty($objp->am)?price($objp->am).' '.getCurrencySymbol($conf->currency):' ').' | ';
- print ''.(! empty($objp->am)?price($objp->total_ttc-$objp->am).' '.getCurrencySymbol($conf->currency):' ').' | ';
+ print ''.price($objp->total_ht).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($objp->total_tva).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($objp->total_ttc).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.(! empty($objp->am)?price($objp->am).' '.$langs->getCurrencySymbol($conf->currency):' ').' | ';
+ print ''.(! empty($objp->am)?price($objp->total_ttc-$objp->am).' '.$langs->getCurrencySymbol($conf->currency):' ').' | ';
// Affiche statut de la facture
print '';
@@ -396,10 +396,10 @@ if ($resql)
print ' |
';
print '| '.$langs->trans("Total").' | ';
- print ''.price($total_ht).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($total_tva).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($total_ttc).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($total_paid).' '.getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_ht).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_tva).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_ttc).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_paid).' '.$langs->getCurrencySymbol($conf->currency).' | ';
print ' | ';
print ' | ';
print ' | ';
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index a27041c82a5..12d653e5b26 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -369,13 +369,13 @@ if ($resql)
print $thirdparty->getNomUrl(1,'customer');
print '';
- print ''.price($objp->total_ht).' '.getCurrencySymbol($conf->currency).' | ';
+ print ''.price($objp->total_ht).' '.$langs->getCurrencySymbol($conf->currency).' | ';
- print ''.price($objp->total_tva).' '.getCurrencySymbol($conf->currency).' | ';
+ print ''.price($objp->total_tva).' '.$langs->getCurrencySymbol($conf->currency).' | ';
- print ''.price($objp->total_ttc).' '.getCurrencySymbol($conf->currency).' | ';
+ print ''.price($objp->total_ttc).' '.$langs->getCurrencySymbol($conf->currency).' | ';
- print ''.(! empty($paiement)?price($paiement).' '.getCurrencySymbol($conf->currency):' ').' | ';
+ print ''.(! empty($paiement)?price($paiement).' '.$langs->getCurrencySymbol($conf->currency):' ').' | ';
// Affiche statut de la facture
print '';
@@ -395,10 +395,10 @@ if ($resql)
// Print total
print ' |
';
print '| '.$langs->trans('Total').' | ';
- print ''.price($total_ht).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($total_tva).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($total_ttc).' '.getCurrencySymbol($conf->currency).' | ';
- print ''.price($totalrecu).' '.getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_ht).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_tva).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($total_ttc).' '.$langs->getCurrencySymbol($conf->currency).' | ';
+ print ''.price($totalrecu).' '.$langs->getCurrencySymbol($conf->currency).' | ';
print ' | ';
print '
';
}
diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php
index 318d9b6ba6e..3a9a5a484ec 100644
--- a/htdocs/core/boxes/box_activity.php
+++ b/htdocs/core/boxes/box_activity.php
@@ -113,8 +113,9 @@ class box_activity extends ModeleBoxes
);
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
- 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".getCurrencySymbol($conf->currency)
+ 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".$langs->getCurrencySymbol($conf->currency)
);
+
// We add only for the current year
if ($objp->annee == date("Y"))
{
@@ -157,7 +158,7 @@ class box_activity extends ModeleBoxes
);
$totalnb += $objp->nb;
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
- 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".getCurrencySymbol($conf->currency)
+ 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".$langs->getCurrencySymbol($conf->currency)
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"',
@@ -211,7 +212,7 @@ class box_activity extends ModeleBoxes
$totalnb += $objp->nb;
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
- 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".getCurrencySymbol($conf->currency)
+ 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".$langs->getCurrencySymbol($conf->currency)
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut,0,3));
@@ -262,7 +263,7 @@ class box_activity extends ModeleBoxes
$totalnb += $objp->nb;
$this->info_box_contents[$i][3] = array('td' => 'align="right"',
- 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".getCurrencySymbol($conf->currency)
+ 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '),40)." ".$langs->getCurrencySymbol($conf->currency)
);
$totalMnt += $objp->Mnttot;
$this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut,3));
@@ -276,7 +277,7 @@ class box_activity extends ModeleBoxes
// Add the sum in the bottom of the boxes
$this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total")." ".$textHead);
$this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' '));
- $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => number_format($totalMnt, 0, ',', ' ')." ".getCurrencySymbol($conf->currency));
+ $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => number_format($totalMnt, 0, ',', ' ')." ".$langs->getCurrencySymbol($conf->currency));
$this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => "");
$this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => "");
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index dab536ccf2d..9a44de0dbf0 100755
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -523,8 +523,8 @@ class ExtraFields
*/
function showInputField($key,$value,$moreparam='')
{
- global $conf;
-
+ global $conf,$langs;
+
$label=$this->attribute_label[$key];
$type =$this->attribute_type[$key];
$size =$this->attribute_size[$key];
@@ -591,7 +591,7 @@ class ExtraFields
}
elseif ($type == 'price')
{
- $out=' '.getCurrencySymbol($conf->currency);
+ $out=' '.$langs->getCurrencySymbol($conf->currency);
}
// Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
@@ -610,7 +610,7 @@ class ExtraFields
function showOutputField($key,$value,$moreparam='')
{
global $conf;
-
+
$label=$this->attribute_label[$key];
$type=$this->attribute_type[$key];
$size=$this->attribute_size[$key];
@@ -636,7 +636,7 @@ class ExtraFields
$checked=' checked="checked" ';
}
$value='';
- }
+ }
elseif ($type == 'mail')
{
$value=dol_print_email($value);
@@ -647,7 +647,7 @@ class ExtraFields
}
elseif ($type == 'price')
{
- $value=price($value).' '.getCurrencySymbol($conf->currency);
+ $value=price($value).' '.$langs->getCurrencySymbol($conf->currency);
}
else
{
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index bd6f11d0e40..d050c7e0510 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -51,7 +51,6 @@ class Form
var $cache_availability=array();
var $cache_demand_reason=array();
var $cache_types_fees=array();
- var $cache_currencies=array();
var $cache_vatrates=array();
var $tva_taux_value;
@@ -2996,52 +2995,6 @@ class Form
print $this->selectcurrency($selected,$htmlname);
}
- /**
- * Load into the cache all currencies
- *
- * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
- */
- function load_cache_currencies()
- {
- global $langs;
-
- $langs->load("dict");
-
- if (count($this->cache_currencies)) return 0; // Cache deja charge
-
- $sql = "SELECT code_iso, label, unicode";
- $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
- $sql.= " WHERE active = 1";
- $sql.= " ORDER BY code_iso ASC";
-
- dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
-
- // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
- $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $langs->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$langs->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
- $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
- $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
- $i++;
- }
-
- array_multisort($label, SORT_ASC, $this->cache_currencies);
-
- return $num;
- }
- else
- {
- dol_print_error($this->db);
- return -1;
- }
- }
-
/**
* Retourne la liste des devises, dans la langue de l'utilisateur
*
@@ -3053,9 +3006,7 @@ class Form
{
global $conf,$langs,$user;
- $langs->load("dict");
-
- $this->load_cache_currencies();
+ $langs->load_cache_currencies();
$out='';
@@ -3073,7 +3024,7 @@ class Form
$out.= '';
}
$out.= '';
diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php
index 2feec9eb821..d07360a3503 100644
--- a/htdocs/core/class/html.formother.class.php
+++ b/htdocs/core/class/html.formother.class.php
@@ -809,19 +809,19 @@ class FormOther
include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$confuserzone='MAIN_BOXES_'.$areacode;
-
- $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of user (or everybody if user has no specific setup)
-
+
+ $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of common+user (or common only if user has no specific setup)
$boxidactivatedforuser=array();
- foreach($boxactivated as $box)
+ foreach($boxactivated as $box)
{
if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user
}
-
+
$selectboxlist='';
$arrayboxtoactivatelabel=array();
if (! empty($user->conf->$confuserzone))
{
+ $langs->load("boxes"); // Load label of boxes
foreach($boxactivated as $box)
{
if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user
diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php
index d5831f09018..1a4cd9d4244 100644
--- a/htdocs/core/class/infobox.class.php
+++ b/htdocs/core/class/infobox.class.php
@@ -33,7 +33,7 @@ class InfoBox
* @param DoliDB $db Database handler
* @param string $mode 'available' or 'activated'
* @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...)
- * @param User $user Objet user to filter
+ * @param User $user Object user to filter
* @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude
* @return array Array of boxes
*/
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index d4258e3bae1..a15fb092b55 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -29,17 +29,18 @@
*/
class Translate
{
- var $dir; // Directories that contains /langs subdirectory
+ var $dir; // Directories that contains /langs subdirectory
- var $defaultlang; // Current language for current user
- var $direction = 'ltr'; // Left to right or Right to left
+ var $defaultlang; // Current language for current user
+ var $direction = 'ltr'; // Left to right or Right to left
var $charset_inputfile=array(); // To store charset encoding used for language
- var $charset_output='UTF-8'; // Codage used by "trans" method outputs
+ var $charset_output='UTF-8'; // Codage used by "trans" method outputs
var $tab_translate=array(); // Array of all translations key=>value
- private $_tab_loaded=array(); // Array to store result after loading each language file
+ private $_tab_loaded=array(); // Array to store result after loading each language file
- var $cache_labels=array(); // Cache for labels return by getLabelFromKey method
+ var $cache_labels=array(); // Cache for labels return by getLabelFromKey method
+ var $cache_currencies=array(); // Cache to store currency symbols
@@ -143,7 +144,7 @@ class Translate
* If data for file already loaded, do nothing.
* All data in translation array are stored in UTF-8 format.
* tab_loaded is completed with $domain key.
- * Warning: MAIN_USE_CUSTOM_TRANSLATION is an old deprecated feature. Do not use it. It will revert
+ * Warning: MAIN_USE_CUSTOM_TRANSLATION is an old deprecated feature. Do not use it. It will revert
* rule "we keep first entry found with we keep last entry found" so it is probably not what you want to do.
*
* Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache
@@ -689,6 +690,96 @@ class Translate
}
}
+
+ /**
+ * Return a currency code into its symbol
+ *
+ * @param string $amount If not '', show currency + amount according to langs ($10, 10€).
+ * @return string Amount + Currency symbol encoded into UTF8
+ */
+ function getCurrencyAmount($currency_code, $amount)
+ {
+ $symbol=$this->getCurrencSymbol($currency_code);
+
+ if (in_array($currency_code, array('USD'))) return $symbol.$amount;
+ else return $amount.$symbol;
+ }
+
+ /**
+ * Return a currency code into its symbol
+ *
+ * @param string $currency_code Currency code
+ * @param string $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency.
+ * @return string Currency symbol encoded into UTF8
+ */
+ function getCurrencySymbol($currency_code, $forceloadall=0)
+ {
+ $currency_sign = ''; // By default return iso code
+
+ if (function_exists("mb_convert_encoding"))
+ {
+ $this->load_cache_currencies($forceloadall?'':$currency_code);
+
+ if (isset($this->cache_currencies[$currency_code]) && ! empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
+ {
+ foreach($this->cache_currencies[$currency_code]['unicode'] as $unicode)
+ {
+ $currency_sign .= mb_convert_encoding("{$unicode};", "UTF-8", 'HTML-ENTITIES');
+ }
+ }
+ }
+
+ return ($currency_sign?$currency_sign:$currency_code);
+ }
+
+ /**
+ * Load into the cache, all currencies
+ *
+ * @param string $currency_code Get only currency. Get all if ''.
+ * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
+ */
+ function load_cache_currencies($currency_code)
+ {
+ global $db;
+
+ if (! empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Value already into cache
+
+ $sql = "SELECT code_iso, label, unicode";
+ $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
+ $sql.= " WHERE active = 1";
+ if (! empty($currency_code)) $sql.=" AND code_iso = '".$currency_code."'";
+ //$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later
+
+ dol_syslog(get_class($this).'::load_cache_currencies sql='.$sql, LOG_DEBUG);
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $this->load("dict");
+ $label=array();
+
+ $num = $db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $db->fetch_object($resql);
+
+ // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
+ $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$this->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
+ $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
+ $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
+ $i++;
+ }
+
+ array_multisort($label, SORT_ASC, $this->cache_currencies);
+
+ return $num;
+ }
+ else
+ {
+ dol_print_error($db);
+ return -1;
+ }
+ }
}
?>
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 4e76905b9c4..f3a31bfb1e8 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -707,6 +707,23 @@ function dol_format_address($object)
}
+
+/**
+ * Format a string.
+ *
+ * @param string $fmt Format of strftime function (http://php.net/manual/fr/function.strftime.php)
+ * @param int $ts Timesamp (If is_gmt is true, timestamp is already includes timezone and daylight saving offset, if is_gmt is false, timestamp is a GMT timestamp and we must compensate with server PHP TZ)
+ * @param int $is_gmt See comment of timestamp parameter
+ * @return string A formatted string
+ */
+function dol_strftime($fmt, $ts=false, $is_gmt=false)
+{
+ if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
+ return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts);
+ }
+ else return 'Error date into a not supported range';
+}
+
/**
* Output date in a string format according to outputlangs (or langs if not defined).
* Return charset is always UTF-8, except if encodetoouput is defined. In this case charset is output charset
@@ -717,7 +734,7 @@ function dol_format_address($object)
* "%d/%m/%Y %H:%M",
* "%d/%m/%Y %H:%M:%S",
* "day", "daytext", "dayhour", "dayhourldap", "dayhourtext", "dayrfc", "dayhourrfc"
- * @param string $tzoutput true=output or 'gmt' => string is for Greenwich location
+ * @param string $tzoutput true or 'gmt' => string is for Greenwich location
* false or 'tzserver' => output string is for local PHP server TZ usage
* 'tzuser' => output string is for local browser TZ usage
* @param Tranlsate $outputlangs Object lang that contains language for text translation.
@@ -4204,37 +4221,6 @@ function colorArrayToHex($arraycolor,$colorifnotfound='888888')
return dechex($arraycolor[0]).dechex($arraycolor[1]).dechex($arraycolor[2]);
}
-/**
- * Convert a currency code into its symbol
- *
- * @param string $currency_code Currency code
- * @return string Currency symbol encoded into UTF8
- */
-function getCurrencySymbol($currency_code)
-{
- global $db, $form;
-
- $currency_sign = '';
-
- if (! is_object($form)) $form = new Form($db);
-
- $form->load_cache_currencies();
-
- if (function_exists("mb_convert_encoding") && isset($form->cache_currencies[$currency_code]) && is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
- {
- foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
- {
- $currency_sign .= mb_convert_encoding("{$unicode};", "UTF-8", 'HTML-ENTITIES');
- }
- }
- else
- {
- $currency_sign = $currency_code;
- }
-
- return $currency_sign;
-}
-
if (! function_exists('getmypid'))
{
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index ad1fa61a54d..481e1751ef0 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1410,38 +1410,6 @@ function pdf_getTotalQty($object,$type,$outputlangs,$hookmanager=false)
return $total;
}
-/**
- * Convert a currency code into its symbol
- *
- * @param PDF &$pdf PDF object
- * @param string $currency_code Currency code
- * @return string Currency symbol encoded into UTF8
- */
-function pdf_getCurrencySymbol(&$pdf, $currency_code)
-{
- global $db, $form;
-
- $currency_sign = '';
-
- if (! is_object($form)) $form = new Form($db);
-
- $form->load_cache_currencies();
-
- if (is_array($form->cache_currencies[$currency_code]['unicode']) && ! empty($form->cache_currencies[$currency_code]['unicode']))
- {
- foreach($form->cache_currencies[$currency_code]['unicode'] as $unicode)
- {
- $currency_sign.= $pdf->unichr($unicode);
- }
- }
- else
- {
- $currency_sign = $currency_code;
- }
-
- return $currency_sign;
-}
-
/**
* Return linked objects
*
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index ff928a5f43d..313d50a8d80 100755
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -167,20 +167,16 @@ foreach($paths as $tmppath)
}
//else print "Not found yet for concatpath=".$concatpath."
\n";
}
-
-if (! $found) // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT.
-{
- $tmp=$dolibarr_main_url_root;
-}
+if (! $found) $tmp=$dolibarr_main_url_root; // If autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT.
else $tmp='http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]!=443))?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80||$_SERVER["SERVER_PORT"]==443)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:'');
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp;
-
if (! empty($dolibarr_main_force_https)) $tmp=preg_replace('/^http:/i','https:',$tmp);
define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
$uri=preg_replace('/^http(s?):\/\//i','',constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
+
// Define DOL_MAIN_URL_ROOT_ALT and DOL_URL_ROOT_ALT
if (! empty($dolibarr_main_url_root_alt))
{
@@ -194,9 +190,11 @@ if (! empty($dolibarr_main_url_root_alt))
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT_ALT', $suburi); // URL relative root ('', '/dolibarr/custom', ...)
}
-// Define prefix
+
+//print DOL_URL_ROOT.'-'.DOL_URL_ROOT_ALT;
+
+// Define prefix MAIN_DB_PREFIX
define('MAIN_DB_PREFIX',$dolibarr_main_db_prefix);
-//print DOL_URL_ROOT.'-'.DOL_URL_ROOT_ALT;
/*
@@ -220,10 +218,6 @@ if (! defined('JS_JQUERY_FLOT')) { define('JS_JQUERY_FLOT', (!isset(
// Other required path
if (! defined('DOL_DEFAULT_TTF')) { define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF))?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf':(empty($dolibarr_font_DOL_DEFAULT_TTF)?'':$dolibarr_font_DOL_DEFAULT_TTF)); }
if (! defined('DOL_DEFAULT_TTF_BOLD')) { define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf':(empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD)?'':$dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
-// Old path to root deprecated (no more used).
-//if (! defined('ARTICHOW_FONT')) { define('ARTICHOW_FONT', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?DOL_DOCUMENT_ROOT.'/includes/fonts':dirname($dolibarr_font_DOL_DEFAULT_TTF_BOLD)); }
-//if (! defined('ARTICHOW_FONT_NAMES')) { define('ARTICHOW_FONT_NAMES', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD))?'Aerial,AerialBd,AerialBdIt,AerialIt':'DejaVuSans,DejaVuSans-Bold,DejaVuSans-BoldOblique,DejaVuSans-Oblique'); }
-//if (! defined('ARTICHOW_PATH')) { define('ARTICHOW_PATH', (!isset($dolibarr_lib_ARTICHOW))?DOL_DOCUMENT_ROOT.'/includes/artichow/':(empty($dolibarr_lib_ARTICHOW)?'':$dolibarr_lib_ARTICHOW.'/')); }
/*
diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php
index 09e18b18355..938b3af2279 100644
--- a/htdocs/fourn/ajax/getSupplierPrices.php
+++ b/htdocs/fourn/ajax/getSupplierPrices.php
@@ -77,7 +77,7 @@ if (! empty($idprod))
if ($objp->quantity == 1)
{
$title.= price($objp->fprice);
- $title.= getCurrencySymbol($conf->currency)."/";
+ $title.= $langs->getCurrencySymbol($conf->currency)."/";
$price = $objp->fprice;
}
@@ -95,18 +95,18 @@ if (! empty($idprod))
if ($objp->quantity > 1)
{
$title.=" - ";
- $title.= price($objp->unitprice).getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
+ $title.= price($objp->unitprice).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
$price = $objp->unitprice;
}
if ($objp->unitcharges > 0 && ($conf->global->MARGIN_TYPE == "2")) {
$title.=" + ";
- $title.= price($objp->unitcharges).getCurrencySymbol($conf->currency);
+ $title.= price($objp->unitcharges).$langs->getCurrencySymbol($conf->currency);
$price += $objp->unitcharges;
}
if ($objp->duration) $label .= " - ".$objp->duration;
- $label = price($price).getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
+ $label = price($price).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
$prices[] = array("id" => $objp->idprodfournprice, "price" => price($price,0,'',0), "label" => $label, "title" => $title);
$i++;
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index 514dea9a075..5bd17604b9e 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -138,17 +138,6 @@ else
print '
'.$langs->trans("PHPSupportUTF8")."
\n";
}
-// Check if mb_convert_encoding supported (used by getCurrencySymbol)
-/*if (! function_exists("mb_convert_encoding"))
-{
- $langs->load("errors");
- print '
'.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n";
- // $checksok=0; // If image ko, just warning. So check must still be 1 (otherwise no way to install)
-}
-else
-{
- print '
'.$langs->trans("PHPSupportUTF8")."
\n";
-}*/
// Check memory