Date: Tue, 3 Aug 2021 15:02:09 +0200
Subject: [PATCH 4/9] FIx #18217 - Salary - link 'salary' of bank_url not
managed
---
.../accountancy/bookkeeping/listbyaccount.php | 37 ++++------
.../bookkeeping/listbysubaccount.php | 37 ++++------
htdocs/accountancy/journal/bankjournal.php | 69 +++++++++++++++----
htdocs/compta/bank/bankentries_list.php | 17 +++--
htdocs/compta/bank/class/account.class.php | 12 ++--
htdocs/core/menus/standard/eldy.lib.php | 6 +-
htdocs/langs/en_US/accountancy.lang | 4 +-
htdocs/salaries/class/paymentsalary.class.php | 44 ++++++++----
htdocs/salaries/class/salary.class.php | 6 ++
9 files changed, 148 insertions(+), 84 deletions(-)
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index 522576350e7..27f23d36a74 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -509,10 +509,9 @@ $moreforfilter = '';
$moreforfilter .= '';
$moreforfilter .= $langs->trans('AccountAccounting').': ';
$moreforfilter .= '
';
-$moreforfilter .= $langs->trans('From').' ';
-$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
-$moreforfilter .= ' '.$langs->trans('to').' ';
-$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
+$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200');
+$moreforfilter .= ' ';
+$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200');
$moreforfilter .= '
';
$moreforfilter .= '
';
@@ -671,23 +670,19 @@ while ($i < min($num, $limit)) {
$accountg = length_accountg($line->numero_compte);
//if (empty($accountg)) $accountg = '-';
+ $colspan = 0; // colspan before field 'label of operation'
+ $colspanend = 3; // colspan after debit/credit
+ if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
+ if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
+ if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
+
// Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
- $colnumber = 5;
- $colnumberend = 8;
-
- if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
- $colnumber--;
- }
- if (empty($arrayfields['t.date_export']['checked'])) {
- $colnumber--;
- }
- if (empty($arrayfields['t.date_validated']['checked'])) {
- $colnumber--;
- }
-
- $colspan = $totalarray['nbfield'] - $colnumber;
- $colspanend = $totalarray['nbfield'] - $colnumberend;
// Show a subtotal by accounting account
if (isset($displayed_account_number)) {
print '';
@@ -926,9 +921,7 @@ while ($i < min($num, $limit)) {
$i++;
}
-if ($num > 0) {
- $colspan = $totalarray['nbfield'] - $colnumber;
- $colspanend = $totalarray['nbfield'] - $colnumberend;
+if ($num > 0 && $colspan > 0) {
print ' ';
print ''.$langs->trans("TotalForAccount").' '.$accountg.': ';
print ''.price($sous_total_debit).' ';
diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php
index efc93f1b96c..5e83c729fb1 100644
--- a/htdocs/accountancy/bookkeeping/listbysubaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php
@@ -511,10 +511,9 @@ $moreforfilter = '';
$moreforfilter .= '';
$moreforfilter .= $langs->trans('AccountAccounting').': ';
$moreforfilter .= '
';
-$moreforfilter .= $langs->trans('From').' ';
-$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', 1, 'maxwidth200');
-$moreforfilter .= ' '.$langs->trans('to').' ';
-$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', 1, 'maxwidth200');
+$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200');
+$moreforfilter .= ' ';
+$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200');
$moreforfilter .= '
';
$moreforfilter .= '
';
@@ -673,23 +672,19 @@ while ($i < min($num, $limit)) {
$accountg = length_accounta($line->subledger_account);
//if (empty($accountg)) $accountg = '-';
+ $colspan = 0; // colspan before field 'label of operation'
+ $colspanend = 3; // colspan after debit/credit
+ if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; }
+ if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
+ if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
+ if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
+
// Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
- $colnumber = 5;
- $colnumberend = 8;
-
- if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
- $colnumber--;
- }
- if (empty($arrayfields['t.date_export']['checked'])) {
- $colnumber--;
- }
- if (empty($arrayfields['t.date_validated']['checked'])) {
- $colnumber--;
- }
-
- $colspan = $totalarray['nbfield'] - $colnumber;
- $colspanend = $totalarray['nbfield'] - $colnumberend;
// Show a subtotal by accounting account
if (isset($displayed_account_number)) {
print ' ';
@@ -937,9 +932,7 @@ while ($i < min($num, $limit)) {
$i++;
}
-if ($num > 0) {
- $colspan = $totalarray['nbfield'] - $colnumber;
- $colspanend = $totalarray['nbfield'] - $colnumberend;
+if ($num > 0 && $colspan > 0) {
print ' ';
print ''.$langs->trans("TotalForAccount").' '.$accountg.': ';
print ''.price($sous_total_debit).' ';
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 " ";
+
print "".$reflabel." ";
+
print ''.$val["type_payment"]." ";
+
print ''.($mt < 0 ? price(-$mt) : '')." ";
+
print ''.($mt >= 0 ? price($mt) : '')." ";
+
print " ";
}
}
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 666621cbdd6..14aeee29d69 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -1346,7 +1346,7 @@ if ($resql) {
print '';
print $labeltoshow; // Already escaped
- // Add links after description
+ // Add info about links after description
$cachebankaccount = array();
foreach ($links as $key => $val) {
print '';
@@ -1424,6 +1424,7 @@ if ($resql) {
} elseif ($links[$key]['type'] == 'sc') {
} elseif ($links[$key]['type'] == 'vat') {
} elseif ($links[$key]['type'] == 'salary') {
+ // Information is already shown using the payment_salary link. No need of this link.
} else {
// Show link with label $links[$key]['label']
if (!empty($objp->label) && !empty($links[$key]['label'])) {
@@ -1530,15 +1531,21 @@ if ($resql) {
}
if ($companylinked_id) {
- // TODO Add a cache of loaded companies here
+ // TODO Add a cache of loaded companies here ?
$companystatic->fetch($companylinked_id);
print $companystatic->getNomUrl(1);
} elseif ($userlinked_id &&
(($type_link == 'payment_salary' && !empty($user->rights->salaries->read))
|| ($type_link == 'payment_sc' && !empty($user->rights->tax->charges->lire)))) {
- // TODO Add a cache of loaded users here
- $userstatic->fetch($userlinked_id);
- print $userstatic->getNomUrl(1);
+ // Get object user from cache or load it
+ if (!empty($conf->cache['user'][$userlinked_id])) {
+ $tmpuser = $conf->cache['user'][$userlinked_id];
+ } else {
+ $tmpuser = new User($db);
+ $tmpuser->fetch($userlinked_id);
+ $conf->cache['user'][$userlinked_id] = $tmpuser;
+ }
+ print $tmpuser->getNomUrl(1);
} else {
print ' ';
}
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 8619ff25dae..ed61da3592e 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -399,9 +399,9 @@ class Account extends CommonObject
/**
* Add a link between bank line record and its source
*
- * @param int $line_id Id ecriture bancaire
- * @param int $url_id Id parametre url
- * @param string $url Url
+ * @param int $line_id Id of bank entry
+ * @param int $url_id Id of object related to link
+ * @param string $url Url (deprecated, we use now 'url_id' and 'type' instead)
* @param string $label Link label
* @param string $type Type of link ('payment', 'company', 'member', ...)
* @return int <0 if KO, id line if OK
@@ -412,13 +412,13 @@ class Account extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
$sql .= "fk_bank";
$sql .= ", url_id";
- $sql .= ", url";
+ $sql .= ", url"; // deprecated
$sql .= ", label";
$sql .= ", type";
$sql .= ") VALUES (";
$sql .= " ".((int) $line_id);
- $sql .= ", '".$this->db->escape($url_id)."'";
- $sql .= ", '".$this->db->escape($url)."'";
+ $sql .= ", ".((int) $url_id);
+ $sql .= ", '".$this->db->escape($url)."'"; // dperecated
$sql .= ", '".$this->db->escape($label)."'";
$sql .= ", '".$this->db->escape($type)."'";
$sql .= ")";
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 2f36290c8d4..1fbd91cb623 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1344,15 +1344,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/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;
From ce5acda635e62378a8495b4bd212e8d702017da8 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 3 Aug 2021 15:03:41 +0200
Subject: [PATCH 5/9] Fix phpcs
---
htdocs/accountancy/class/accountancyexport.class.php | 4 ++--
htdocs/projet/tasks/time.php | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 5ac3ebcb37d..a96c672608a 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -488,8 +488,8 @@ class AccountancyExport
foreach ($TData as $data) {
$code_compta = length_accountg($data->numero_compte);
if (!empty($data->subledger_account)) {
- $code_compta = length_accounta($data->subledger_account);
- }
+ $code_compta = length_accounta($data->subledger_account);
+ }
$date_document = dol_print_date($data->doc_date, '%Y%m%d');
$date_echeance = dol_print_date($data->date_lim_reglement, '%Y%m%d');
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 1923bde17b2..0daf5439dc0 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -1423,9 +1423,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) {
$totalarray['nbfield']++;
}
}
- } elseif ($action !== 'createtime') {
- print ' ';
- }
+ } elseif ($action !== 'createtime') {
+ print ' ';
+ }
// Task label
if (!empty($arrayfields['t.task_label']['checked'])) {
From 8b746b64a0601c4c15a6a18ff0d23326e079f98a Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 3 Aug 2021 15:04:29 +0200
Subject: [PATCH 6/9] Prepare 14.0.1
---
htdocs/filefunc.inc.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index 8aa64da85f1..e55ca5b6e04 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) {
define('DOL_APPLICATION_TITLE', 'Dolibarr');
}
if (!defined('DOL_VERSION')) {
- define('DOL_VERSION', '14.0.0'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
+ define('DOL_VERSION', '14.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
}
if (!defined('EURO')) {
From 19f17ed1145685a625d2c7ab9c0bb742fb138f5e Mon Sep 17 00:00:00 2001
From: Florian HENRY
Date: Wed, 21 Jul 2021 14:52:37 +0200
Subject: [PATCH 7/9] fix: bad setEventMessages input
---
htdocs/product/stock/massstockmove.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php
index f2432ea25af..9f3390d34af 100644
--- a/htdocs/product/stock/massstockmove.php
+++ b/htdocs/product/stock/massstockmove.php
@@ -209,7 +209,7 @@ if ($action == 'createmovements' && !empty($user->rights->stock->mouvement->cree
);
if ($result1 < 0) {
$error++;
- setEventMessages($product->errors, $product->errorss, 'errors');
+ setEventMessages($product->error, $product->errors, 'errors');
}
// Add stock
@@ -224,7 +224,7 @@ if ($action == 'createmovements' && !empty($user->rights->stock->mouvement->cree
);
if ($result2 < 0) {
$error++;
- setEventMessages($product->errors, $product->errorss, 'errors');
+ setEventMessages($product->error, $product->errors, 'errors');
}
} else {
$arraybatchinfo = $product->loadBatchInfo($batch);
@@ -253,7 +253,7 @@ if ($action == 'createmovements' && !empty($user->rights->stock->mouvement->cree
);
if ($result1 < 0) {
$error++;
- setEventMessages($product->errors, $product->errorss, 'errors');
+ setEventMessages($product->error, $product->errors, 'errors');
}
// Add stock
@@ -271,7 +271,7 @@ if ($action == 'createmovements' && !empty($user->rights->stock->mouvement->cree
);
if ($result2 < 0) {
$error++;
- setEventMessages($product->errors, $product->errorss, 'errors');
+ setEventMessages($product->error, $product->errors, 'errors');
}
}
} else {
From 9ceab9b86b9adedd37ef6204b483fe969d82c484 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 3 Aug 2021 15:47:00 +0200
Subject: [PATCH 8/9] Doc
---
htdocs/product/class/productbatch.class.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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;
From 1c981ccb9d137aa7324001bc9eee463464f722fe Mon Sep 17 00:00:00 2001
From: Laurent Destailleur
Date: Tue, 3 Aug 2021 17:03:34 +0200
Subject: [PATCH 9/9] Fix look and feel v14
---
htdocs/admin/paymentbybanktransfer.php | 22 ++++++++++++----------
htdocs/admin/prelevement.php | 20 +++++++++++---------
htdocs/compta/bank/line.php | 8 ++++----
htdocs/compta/prelevement/create.php | 7 ++++++-
htdocs/core/class/html.form.class.php | 11 +++++++----
5 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php
index be5dc4e76e6..43ad8c15929 100644
--- a/htdocs/admin/paymentbybanktransfer.php
+++ b/htdocs/admin/paymentbybanktransfer.php
@@ -156,36 +156,38 @@ print "";
// Bank account (from Banks module)
print ''.$langs->trans("BankToPayCreditTransfer").' ';
-print '';
-$form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1);
+print ' ';
+print img_picto('', 'bank_account', 'class="pictofixedwidth"');
+print $form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1, '', 0, 'minwidth200', 1);
print ' ';
/* Moved to bank account data
// ICS
print ''.$langs->trans("ICS").' ';
-print '';
+print ' ';
print ' ';
print ' ';
*/
//User
print ''.$langs->trans("ResponsibleUser").' ';
-print '';
-print $form->select_dolusers($conf->global->PAYMENTBYBANKTRANSFER_USER, 'PAYMENTBYBANKTRANSFER_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+print ' ';
+print img_picto('', 'user', 'class="pictofixedwidth"');
+print $form->select_dolusers($conf->global->PAYMENTBYBANKTRANSFER_USER, 'PAYMENTBYBANKTRANSFER_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth200 maxwidth500');
print ' ';
print ' ';
/*
//EntToEnd
print ''.$langs->trans("END_TO_END").' ';
-print '';
-print ' ';
+print '';
+print ' ';
print ' ';
//USTRD
print ''.$langs->trans("USTRD").' ';
-print '';
-print ' ';
+print '';
+print ' ';
print ' ';
*/
@@ -195,7 +197,7 @@ print '';
if (!$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS) {
$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS = 0;
}
-print ' ';
+print ' ';
print '';
print '';
print ' ';
diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index c7de6d59896..01e3b6d4913 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -160,8 +160,9 @@ print "";
// Bank account (from Banks module)
print ''.$langs->trans("BankToReceiveWithdraw").' ';
-print '';
-$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1);
+print ' ';
+print img_picto('', 'bank_account', 'class="pictofixedwidth"');
+print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1, '', 0, 'minwidth200', 1);
print ' ';
/* Moved to bank account data
@@ -179,8 +180,9 @@ print '';
//User
print ''.$langs->trans("ResponsibleUser").' ';
-print '';
-print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+print ' ';
+print img_picto('', 'user', 'class="pictofixedwidth"');
+print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth200 maxwidth500');
print ' ';
print ' ';
@@ -189,8 +191,8 @@ print '';
$htmltext = $langs->trans("KeepThisEmptyInMostCases");
print $form->textwithpicto($langs->trans("END_TO_END"), $htmltext);
print ' ';
-print '';
-print ' ';
+print '';
+print ' ';
print ' ';
//USTRD
@@ -199,16 +201,16 @@ $htmltext = $langs->trans("KeepThisEmptyInMostCases");
print $form->textwithpicto($langs->trans("USTRD"), $htmltext);
print '';
print '';
-print ' ';
+print ' ';
print '';
//ADDDAYS
print ''.$langs->trans("ADDDAYS").' ';
-print '';
+print ' ';
if (empty($conf->global->PRELEVEMENT_ADDDAYS)) {
$conf->global->PRELEVEMENT_ADDDAYS = 0;
}
-print ' ';
+print ' ';
print ' ';
print '';
diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php
index 2c33085aa6d..05aed6a215e 100644
--- a/htdocs/compta/bank/line.php
+++ b/htdocs/compta/bank/line.php
@@ -624,21 +624,21 @@ if ($result) {
print '';
- print ''.$langs->trans("Conciliation")." ";
+ print ''.$form->textwithpicto($langs->trans("AccountStatement"), $langs->trans("InputReceiptNumber"))." ";
if ($user->rights->banque->consolidate) {
print '';
if ($objp->rappro) {
- print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>';
+ print ' rappro ? ' disabled' : '').'>';
print ' ';
} else {
- print $langs->trans("AccountStatement").' rappro ? ' disabled' : '').'>';
+ print ' rappro ? ' disabled' : '').'>';
}
if ($objp->num_releve) {
print ' ('.$langs->trans("AccountStatement").' '.$objp->num_releve.') ';
}
print ' ';
} else {
- print ''.$objp->num_releve.' ';
+ print ''.$objp->num_releve.' ';
}
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 9e46d55d6a8..4e9da790f28 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1952,15 +1952,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 ($show_empty && !$multiple) {
@@ -2068,6 +2065,12 @@ class Form
$out .= ''.$langs->trans("None").' ';
}
$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);
}