diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php
index 40d2f5c8ffc..8cb5b878dc0 100644
--- a/htdocs/compta/bank/bankentries.php
+++ b/htdocs/compta/bank/bankentries.php
@@ -104,9 +104,9 @@ if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid';
$mode_balance_ok=false;
//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
-if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid'))
+if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid'))
{
- $sortfield = 'b.datev, b.dateo, b.rowid';
+ $sortfield = 'b.datev,b.dateo,b.rowid';
if ($id > 0 || ! empty($ref) || $account > 0) $mode_balance_ok = true;
}
if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
@@ -887,7 +887,7 @@ if ($resql)
if (! empty($arrayfields['b.rowid']['checked'])) print_liste_field_titre($arrayfields['b.rowid']['label'],$_SERVER['PHP_SELF'],'b.rowid','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['description']['checked'])) print_liste_field_titre($arrayfields['description']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.dateo']['checked'])) print_liste_field_titre($arrayfields['b.dateo']['label'],$_SERVER['PHP_SELF'],'b.dateo','',$param,'align="center"',$sortfield,$sortorder);
- if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev, b.dateo, b.rowid','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['b.datev']['checked'])) print_liste_field_titre($arrayfields['b.datev']['label'],$_SERVER['PHP_SELF'],'b.datev,b.dateo,b.rowid','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['b.num_chq']['checked'])) print_liste_field_titre($arrayfields['b.num_chq']['label'],$_SERVER['PHP_SELF'],'b.num_chq','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['bu.label']['checked'])) print_liste_field_titre($arrayfields['bu.label']['label'],$_SERVER['PHP_SELF'],'bu.label','',$param,'',$sortfield,$sortorder);
@@ -1065,7 +1065,7 @@ if ($resql)
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
print ' ('.$langs->trans("TransferFrom").' ';
- print $bankstatic->getNomUrl(1,'transactions');
+ print $bankstatic->getNomUrl(1);
print ' '.$langs->trans("toward").' ';
$bankstatic->id=$objp->bankid;
$bankstatic->label=$objp->bankref;
@@ -1082,7 +1082,7 @@ if ($resql)
$banklinestatic->fetch($links[$key]['url_id']);
$bankstatic->id=$banklinestatic->fk_account;
$bankstatic->label=$banklinestatic->bank_account_ref;
- print $bankstatic->getNomUrl(1,'transactions');
+ print $bankstatic->getNomUrl(1);
print ')';
}
//var_dump($links);
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index b575180feed..cb59862e005 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -925,7 +925,8 @@ class Account extends CommonObject
}
else
{
- dol_print_error($this->db);
+ $this->error=$this->db->lasterror;
+ $this->errors[]=$this->error;
return -1;
}
}
diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php
index 5a0ab062b29..4485680a4e9 100644
--- a/htdocs/compta/bank/index.php
+++ b/htdocs/compta/bank/index.php
@@ -92,7 +92,8 @@ $arrayfields=array(
'b.account_number'=>array('label'=>$langs->trans("AccountAccounting"), 'checked'=>$conf->accountancy->enabled),
'b.fk_accountancy_journal'=>array('label'=>$langs->trans("AccountancyJournal"), 'checked'=>$conf->accountancy->enabled),
'toreconcile'=>array('label'=>$langs->trans("TransactionsToConciliate"), 'checked'=>1),
- 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
+ 'b.currency_code'=>array('label'=>$langs->trans("Currency"), 'checked'=>0),
+ 'b.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'b.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'b.clos'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
@@ -121,7 +122,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
-if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
+if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers
{
$search_ref='';
$search_label='';
@@ -142,7 +143,7 @@ $title=$langs->trans('BankAccounts');
// Load array of financial accounts (opened by default)
$accounts = array();
-$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, datec as date_creation, tms as date_update";
+$sql = "SELECT rowid, label, courant, rappro, account_number, fk_accountancy_journal, currency_code, datec as date_creation, tms as date_update";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@@ -337,6 +338,12 @@ if (! empty($arrayfields['toreconcile']['checked']))
print '
';
print ' | ';
}
+// Currency
+if (! empty($arrayfields['b.currency_code']['checked']))
+{
+ print '';
+ print ' | ';
+}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
{
@@ -407,6 +414,7 @@ if (! empty($arrayfields['accountype']['checked'])) print_liste_field_titr
if (! empty($arrayfields['b.number']['checked'])) print_liste_field_titre($arrayfields['b.number']['label'],$_SERVER["PHP_SELF"],'b.number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.account_number']['checked'])) print_liste_field_titre($arrayfields['b.account_number']['label'],$_SERVER["PHP_SELF"],'b.account_number','',$param,'',$sortfield,$sortorder);
if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) print_liste_field_titre($arrayfields['b.fk_accountancy_journal']['label'],$_SERVER["PHP_SELF"],'b.fk_accountancy_journal','',$param,'',$sortfield,$sortorder);
+if (! empty($arrayfields['b.currency_code']['checked'])) print_liste_field_titre($arrayfields['b.currency_code']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['toreconcile']['checked'])) print_liste_field_titre($arrayfields['toreconcile']['label'],$_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@@ -442,19 +450,19 @@ foreach ($accounts as $key=>$type)
$found++;
- $acc = new Account($db);
- $acc->fetch($key);
+ $obj = new Account($db);
+ $obj->fetch($key);
$var = !$var;
- $solde = $acc->solde(1);
+ $solde = $obj->solde(1);
- if (! empty($lastcurrencycode) && $lastcurrencycode != $acc->currency_code)
+ if (! empty($lastcurrencycode) && $lastcurrencycode != $obj->currency_code)
{
$lastcurrencycode='various'; // We found several different currencies
}
if ($lastcurrencycode != 'various')
{
- $lastcurrencycode=$acc->currency_code;
+ $lastcurrencycode=$obj->currency_code;
}
print '';
@@ -462,14 +470,14 @@ foreach ($accounts as $key=>$type)
// Ref
if (! empty($arrayfields['b.ref']['checked']))
{
- print '| '.$acc->getNomUrl(1).' | ';
+ print ''.$obj->getNomUrl(1).' | ';
if (! $i) $totalarray['nbfield']++;
}
// Label
if (! empty($arrayfields['b.label']['checked']))
{
- print ''.$acc->label.' | ';
+ print ''.$obj->label.' | ';
if (! $i) $totalarray['nbfield']++;
}
@@ -477,7 +485,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['accountype']['checked']))
{
print '';
- print $acc->type_lib[$acc->type];
+ print $obj->type_lib[$obj->type];
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
@@ -485,7 +493,7 @@ foreach ($accounts as $key=>$type)
// Number
if (! empty($arrayfields['b.number']['checked']))
{
- print ''.$acc->number.' | ';
+ print ''.$obj->number.' | ';
if (! $i) $totalarray['nbfield']++;
}
@@ -496,12 +504,12 @@ foreach ($accounts as $key=>$type)
if (! empty($conf->accounting->enabled))
{
$accountingaccount = new AccountingAccount($db);
- $accountingaccount->fetch('',$acc->account_number);
+ $accountingaccount->fetch('',$obj->account_number);
print $accountingaccount->getNomUrl(0,1,1,'',1);
}
else
{
- print $acc->account_number;
+ print $obj->account_number;
}
print '';
if (! $i) $totalarray['nbfield']++;
@@ -514,7 +522,7 @@ foreach ($accounts as $key=>$type)
if (! empty($conf->accounting->enabled))
{
$accountingjournal = new AccountingJournal($db);
- $accountingjournal->fetch($acc->fk_accountancy_journal);
+ $accountingjournal->fetch($obj->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0,1,1,'',1);
}
else
@@ -525,15 +533,24 @@ foreach ($accounts as $key=>$type)
if (! $i) $totalarray['nbfield']++;
}
+ // Currency
+ if (! empty($arrayfields['b.currency_code']['checked']))
+ {
+ print '';
+ print $obj->currency_code;
+ print ' | ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
// Transactions to reconcile
if (! empty($arrayfields['toreconcile']['checked']))
{
print '';
- if ($acc->rappro)
+ if ($obj->rappro)
{
- $result=$acc->load_board($user,$acc->id);
+ $result=$obj->load_board($user,$obj->id);
if ($result<0) {
- setEventMessages($acc->error, $acc->errors, 'errors');
+ setEventMessages($obj->error, $obj->errors, 'errors');
} else {
print $result->nbtodo;
if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')';
@@ -570,7 +587,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['b.datec']['checked']))
{
print ' | ';
- print dol_print_date($acc->date_creation, 'dayhour');
+ print dol_print_date($obj->date_creation, 'dayhour');
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
@@ -578,7 +595,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['b.tms']['checked']))
{
print '';
- print dol_print_date($acc->date_update, 'dayhour');
+ print dol_print_date($obj->date_update, 'dayhour');
print ' | ';
if (! $i) $totalarray['nbfield']++;
}
@@ -586,7 +603,7 @@ foreach ($accounts as $key=>$type)
// Status
if (! empty($arrayfields['b.clos']['checked']))
{
- print ''.$acc->getLibStatut(5).' | ';
+ print ''.$obj->getLibStatut(5).' | ';
if (! $i) $totalarray['nbfield']++;
}
@@ -594,7 +611,7 @@ foreach ($accounts as $key=>$type)
if (! empty($arrayfields['balance']['checked']))
{
print '';
- print ''.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).'';
+ print ''.price($solde, 0, $langs, 0, 0, -1, $obj->currency_code).'';
print ' | ';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
@@ -614,7 +631,7 @@ foreach ($accounts as $key=>$type)
print '
';
- $total[$acc->currency_code] += $solde;
+ $total[$obj->currency_code] += $solde;
$i++;
}
diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php
index 1f3ca1cde8e..7696427b059 100644
--- a/htdocs/compta/bank/transfer.php
+++ b/htdocs/compta/bank/transfer.php
@@ -30,8 +30,7 @@ require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-$langs->load("banks");
-$langs->load("categories");
+$langs->loadLangs(array("banks", "categories", "multicurrency"));
if (! $user->rights->banque->transfer)
accessforbidden();
@@ -44,14 +43,14 @@ $error = 0;
* Actions
*/
-if ($action == 'add_confirm')
+if ($action == 'add')
{
$langs->load("errors");
$dateo = dol_mktime(12,0,0,GETPOST('remonth','int'),GETPOST('reday','int'),GETPOST('reyear','int'));
$label = GETPOST('label','alpha');
$amount= GETPOST('amount');
- $amount_to= GETPOST('amount_to');
+ $amountto= GETPOST('amountto');
if (! $label)
{
@@ -83,7 +82,17 @@ if ($action == 'add_confirm')
$accountto=new Account($db);
$accountto->fetch(GETPOST('account_to','int'));
- if ($accountto->id != $accountfrom->id)
+ if ($accountto->currency_code == $accountfrom->currency_code) {
+ $amountto=$amount;
+ } else {
+ if (! $amountto)
+ {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AmountTo")), null, 'errors');
+ }
+ }
+
+ if (($accountto->id != $accountfrom->id) && empty($error))
{
$db->begin();
@@ -103,8 +112,7 @@ if ($action == 'add_confirm')
if (! $error) $bank_line_id_from = $accountfrom->addline($dateo, $typefrom, $label, -1*price2num($amount), '', '', $user);
if (! ($bank_line_id_from > 0)) $error++;
- if ((! $error) && ($accountto->currency_code == $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount), '', '', $user);
- if ((! $error) && ($accountto->currency_code != $accountfrom->currency_code)) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amount_to), '', '', $user);
+ if (! $error) $bank_line_id_to = $accountto->addline($dateo, $typeto, $label, price2num($amountto), '', '', $user);
if (! ($bank_line_id_to > 0)) $error++;
if (! $error) $result=$accountfrom->add_url_line($bank_line_id_from, $bank_line_id_to, DOL_URL_ROOT.'/compta/bank/ligne.php?rowid=', '(banktransfert)', 'banktransfert');
@@ -114,7 +122,7 @@ if ($action == 'add_confirm')
if (! $error)
{
- $mesgs = $langs->trans("TransferFromToDone","id."\">".$accountfrom->label."","id."\">".$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency));
+ $mesgs = $langs->trans("TransferFromToDone",''.$accountfrom->label."",''.$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency));
setEventMessages($mesgs, null, 'mesgs');
$db->commit();
}
@@ -139,6 +147,58 @@ if ($action == 'add_confirm')
*/
llxHeader();
+print ' ';
$form=new Form($db);
@@ -146,9 +206,8 @@ $account_from='';
$account_to='';
$label='';
$amount='';
-$amount_to='';
-if ($error)
+if($error)
{
$account_from = GETPOST('account_from','int');
$account_to = GETPOST('account_to','int');
@@ -164,21 +223,21 @@ print "
";
print '';
diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php
index d3e6964aea6..04b987192e1 100644
--- a/htdocs/variants/class/ProductCombination.class.php
+++ b/htdocs/variants/class/ProductCombination.class.php
@@ -476,7 +476,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
*/
public function createProductCombination(Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false)
{
- global $db, $user;
+ global $db, $user, $conf;
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
@@ -542,7 +542,11 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
$price_impact += (float) price2num($variations[$currcombattr][$currcombval]['price']);
}
- $newproduct->ref .= '_'.$prodattrval->ref;
+ if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) {
+ $newproduct->ref .= $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR . $prodattrval->ref;
+ } else {
+ $newproduct->ref .= '_'.$prodattrval->ref;
+ }
//The first one should not contain a linebreak
if ($newproduct->description) {
@@ -660,4 +664,4 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
return 1;
}
-}
\ No newline at end of file
+}