';
diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php
index 34e533974fc..bdda4583d54 100644
--- a/htdocs/accountancy/journal/bankjournal.php
+++ b/htdocs/accountancy/journal/bankjournal.php
@@ -177,7 +177,7 @@ $accountingjournalstatic->fetch($id_journal);
$journal = $accountingjournalstatic->code;
$journal_label = $accountingjournalstatic->label;
-
+//print $sql;
dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
@@ -252,6 +252,7 @@ if ($result) {
);
// Set accountancy code for user
+ // $obj->accountancy_code is the accountancy_code of table u=user but it is defined only if a link with type 'user' exists)
$compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : '');
$tabuser[$obj->rowid] = array(
@@ -277,7 +278,7 @@ if ($result) {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
}
- // Load of url links to the line into llx_bank
+ // Load of url links to the line into llx_bank (so load llx_bank_url)
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
// By default
@@ -287,7 +288,7 @@ if ($result) {
// get_url may return -1 which is not traversable
if (is_array($links) && count($links) > 0) {
- // Now loop on each link of record in bank.
+ // Now loop on each link of record in bank (code similar to bankentries_list.php)
foreach ($links as $key => $val) {
if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) {
// So we excluded 'company' and 'user' here. We want only payment lines
@@ -302,6 +303,7 @@ if ($result) {
}
}
+ // Special case to ask later to add more request to get information for old links without company link.
if ($links[$key]['type'] == 'withdraw') {
$tabmoreinfo[$obj->rowid]['withdraw'] = 1;
}
@@ -401,6 +403,44 @@ if ($result) {
$paymentsalstatic->label = $links[$key]['label'];
$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2);
$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
+
+ // This part of code is no more required. it is here to solve case where a link were missing (ith v14.0.0) and keep writing in accountancy complete.
+ // Note: A better way to fix this is to delete payement of salary and recreate it, or to fix the bookkeeping table manually after.
+ if (!empty($conf->global->ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT)) {
+ $tmpsalary = new Salary($db);
+ $tmpsalary->fetch($paymentsalstatic->id);
+ $tmpsalary->fetch_user($tmpsalary->fk_user);
+
+ $userstatic->id = $tmpsalary->user->id;
+ $userstatic->name = $tmpsalary->user->name;
+ $userstatic->email = $tmpsalary->user->email;
+ $userstatic->firstname = $tmpsalary->user->firstname;
+ $userstatic->lastname = $tmpsalary->user->lastname;
+ $userstatic->statut = $tmpsalary->user->statut;
+ $userstatic->accountancy_code = $tmpsalary->user->accountancy_code;
+
+ if ($userstatic->id > 0) {
+ $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
+ } else {
+ $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen
+ }
+
+ if (empty($obj->typeop_user)) { // Add test to avoid to add amount twice if a link already exists also on user.
+ $compta_user = $userstatic->accountancy_code;
+ if ($compta_user) {
+ $tabtp[$obj->rowid][$compta_user] += $obj->amount;
+ $tabuser[$obj->rowid] = array(
+ 'id' => $userstatic->id,
+ 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname),
+ 'lastname' => $userstatic->lastname,
+ 'firstname' => $userstatic->firstname,
+ 'email' => $userstatic->email,
+ 'accountancy_code' => $compta_user,
+ 'status' => $userstatic->statut
+ );
+ }
+ }
+ }
} elseif ($links[$key]['type'] == 'payment_expensereport') {
$paymentexpensereportstatic->id = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2);
@@ -468,7 +508,7 @@ if ($result) {
}
}
- // If no links were found to know the amount on thirdparty, we init it to account 'NotDefined'.
+ // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'.
if (empty($tabtp[$obj->rowid])) {
$tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
}
@@ -1162,9 +1202,9 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'unknown') {
// We will accept writing, but into a waiting account
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1') {
- print ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'';
+ print ''.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'';
} else {
- print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account
+ print ''.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).''; // We will use a waiting account
}
} else {
// We will refuse writing
@@ -1187,7 +1227,7 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'member') {
$errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
}
- print ''.$langs->trans($errorstring).'';
+ print ''.$langs->trans($errorstring).'';
}
} else {
print $accounttoshow;
@@ -1196,7 +1236,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "
";
- if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payment with subledger
+ if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger
$accounttoshowsubledger = length_accounta($k);
if ($accounttoshow != $accounttoshowsubledger) {
if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') {
@@ -1205,14 +1245,14 @@ if (empty($action) || $action == 'view') {
var_dump($tabbq[$key]);*/
//print ''.$langs->trans("ThirdpartyAccountNotDefined").'';
if (!empty($tabcompany[$key]['code_compta'])) {
- if (in_array($tabtype[$key], array('payment_various'))) {
+ if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) {
// For such case, if subledger is not defined, we won't use subledger accounts.
- print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'';
+ print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'';
} else {
- print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'';
+ print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'';
}
} else {
- print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'';
+ print ''.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'';
}
} else {
print $accounttoshowsubledger;
@@ -1220,10 +1260,15 @@ if (empty($action) || $action == 'view') {
}
}
print "
';
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index 937750648bb..be18099b6a8 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -67,6 +67,7 @@ $hookmanager->initHooks(array('directdebitcreatecard', 'globalcard'));
/*
* Actions
*/
+
if (GETPOST('cancel', 'alpha')) {
$massaction = '';
}
@@ -165,7 +166,11 @@ llxHeader('', $langs->trans("NewStandingOrder"));
if (prelevement_check_config($type) < 0) {
$langs->load("errors");
- setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
+ $modulenametoshow = "Withdraw";
+ if ($type == 'bank-transfer') {
+ $modulenametoshow = "PaymentByBankTransfer";
+ }
+ setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv($modulenametoshow)), null, 'errors');
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 55f53a6e057..9bcbf08f71a 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1953,15 +1953,12 @@ class Form
}
dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG);
+
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
if ($num) {
- // Enhance with select2
- include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
- $out .= ajax_combobox($htmlname);
-
// do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined
$out .= '';
+
+ if ($num) {
+ // Enhance with select2
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+ $out .= ajax_combobox($htmlname);
+ }
} else {
dol_print_error($this->db);
}
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index a7b732643c4..89f4c37f459 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1345,15 +1345,15 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Accounting
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
- // Balance
- $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
-
// General Ledger
$newmenu->add("/accountancy/bookkeeping/listbyaccount.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("Bookkeeping"), 1, $user->rights->accounting->mouvements->lire);
// Journals
$newmenu->add("/accountancy/bookkeeping/list.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("Journals"), 1, $user->rights->accounting->mouvements->lire);
+ // Account Balance
+ $newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
+
// Files
if (empty($conf->global->ACCOUNTANCY_HIDE_EXPORT_FILES_MENU)) {
$newmenu->add("/compta/accounting-files.php?mainmenu=accountancy&leftmenu=accountancy_files", $langs->trans("AccountantFiles"), 1, $user->rights->accounting->mouvements->lire);
diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang
index ec74c9361f5..771f0a83e7b 100644
--- a/htdocs/langs/en_US/accountancy.lang
+++ b/htdocs/langs/en_US/accountancy.lang
@@ -246,9 +246,9 @@ DescThirdPartyReport=Consult here the list of third-party customers and vendors
ListAccounts=List of the accounting accounts
UnknownAccountForThirdparty=Unknown third-party account. We will use %s
UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error
-ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. We will use %s
+ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Subledger account not defined or third party or user unknown. We will use %s
ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored=Third-party unknown and subledger not defined on the payment. We will keep the subledger account value empty.
-ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Third-party account not defined or third party unknown. Blocking error.
+ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Subledger account not defined or third party or user unknown. Blocking error.
UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error
PaymentsNotLinkedToProduct=Payment not linked to any product / service
OpeningBalance=Opening balance
diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php
index f10adee334e..4408afd9ff1 100644
--- a/htdocs/product/class/productbatch.class.php
+++ b/htdocs/product/class/productbatch.class.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2007-2021 Laurent Destailleur
* Copyright (C) 2013-2014 Cedric GROSS
*
* This program is free software; you can redistribute it and/or modify
@@ -44,8 +44,8 @@ class Productbatch extends CommonObject
public $tms = '';
public $fk_product_stock;
- public $sellby = '';
- public $eatby = '';
+ public $sellby = ''; // dlc
+ public $eatby = ''; // dmd/dluo
public $batch = '';
public $qty;
public $warehouseid;
diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php
index e2b199780f0..76236bb88aa 100644
--- a/htdocs/salaries/class/paymentsalary.class.php
+++ b/htdocs/salaries/class/paymentsalary.class.php
@@ -477,7 +477,7 @@ class PaymentSalary extends CommonObject
* All payment properties must have been set first like after a call to create().
*
* @param User $user Object of user making payment
- * @param string $mode 'payment_sc'
+ * @param string $mode 'payment_salary'
* @param string $label Label to use in bank record
* @param int $accountid Id of bank account to do link with
* @param string $emetteur_nom Name of transmitter
@@ -516,8 +516,8 @@ class PaymentSalary extends CommonObject
$this->datev
);
- // Mise a jour fk_bank dans llx_paiement.
- // On connait ainsi le paiement qui a genere l'ecriture bancaire
+ // Update fk_bank into llx_paiement_salary.
+ // so we know the payment that was used to generated the bank entry.
if ($bank_line_id > 0) {
$result = $this->update_fk_bank($bank_line_id);
if ($result <= 0) {
@@ -525,9 +525,12 @@ class PaymentSalary extends CommonObject
dol_print_error($this->db);
}
- // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
+ // Add link 'payment_salary' in bank_url between payment and bank transaction
$url = '';
- if ($mode == 'payment_salary') $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
+ if ($mode == 'payment_salary') {
+ $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
+ }
+
if ($url) {
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
if ($result <= 0) {
@@ -536,14 +539,31 @@ class PaymentSalary extends CommonObject
}
}
- // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
- $linkaddedforthirdparty = array();
+ // Add link 'user' in bank_url between user and bank transaction
foreach ($this->amounts as $key => $value) {
- if ($mode == 'payment_salary') {
- $salary = new Salary($this->db);
- $salary->fetch($key);
- $result = $acc->add_url_line($bank_line_id, $salary->id, DOL_URL_ROOT.'/salaries/card.php?id=', '('.$salary->label.')', 'salary');
- if ($result <= 0) dol_print_error($this->db);
+ if (!$error) {
+ if ($mode == 'payment_salary') {
+ $salary = new Salary($this->db);
+ $salary->fetch($key);
+ $salary->fetch_user($salary->fk_user);
+
+ $fuser = $salary->user;
+
+ if ($fuser->id > 0) {
+ $result = $acc->add_url_line(
+ $bank_line_id,
+ $fuser->id,
+ DOL_URL_ROOT.'/user/card.php?id=',
+ $fuser->getFullName($langs),
+ 'user'
+ );
+ }
+ if ($result <= 0) {
+ $this->error = $this->db->lasterror();
+ dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error);
+ $error++;
+ }
+ }
}
}
} else {
diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php
index 35ceb8a1931..cc50c57ec84 100644
--- a/htdocs/salaries/class/salary.class.php
+++ b/htdocs/salaries/class/salary.class.php
@@ -88,6 +88,12 @@ class Salary extends CommonObject
*/
public $fk_user_modif;
+ /**
+ * @var user User
+ */
+ public $user;
+
+
const STATUS_UNPAID = 0;
const STATUS_PAID = 1;
diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php
index 0d9de5d857f..c29fc519258 100644
--- a/htdocs/variants/combinations.php
+++ b/htdocs/variants/combinations.php
@@ -30,10 +30,13 @@ $langs->loadLangs(array("products", "other"));
$id = GETPOST('id', 'int');
$valueid = GETPOST('valueid', 'int');
$ref = GETPOST('ref', 'alpha');
-$weight_impact = GETPOST('weight_impact', 'alpha');
-$price_impact = GETPOST('price_impact', 'alpha');
+$weight_impact = price2num(GETPOST('weight_impact', 'alpha'), 2);
$price_impact_percent = (bool) GETPOST('price_impact_percent');
-
+if ($price_impact_percent) {
+ $price_impact = price2num(GETPOST('price_impact', 'alpha'), 2);
+} else {
+ $price_impact = price2num(GETPOST('price_impact', 'alpha'), 'MU');
+}
$level_price_impact = GETPOST('level_price_impact', 'array');
$level_price_impact_percent = GETPOST('level_price_impact_percent', 'array');
diff --git a/htdocs/variants/list.php b/htdocs/variants/list.php
index dcf4fdcdb43..ecb42ba25e2 100644
--- a/htdocs/variants/list.php
+++ b/htdocs/variants/list.php
@@ -16,8 +16,8 @@
*/
require '../main.inc.php';
-require DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-require DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
$action = GETPOST('action', 'aZ09');
$object = new ProductAttribute($db);