From c386f4b2e3762a721cd70773f9cfb1a82805c04f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 11:43:20 +0200 Subject: [PATCH 1/7] Maxi debug of direct debit order --- htdocs/compta/bank/class/account.class.php | 1 - htdocs/compta/facture/prelevement.php | 44 +++++-- htdocs/compta/prelevement/bons.php | 45 +++---- htdocs/compta/prelevement/card.php | 23 +++- .../class/bonprelevement.class.php | 5 +- .../class/ligneprelevement.class.php | 12 +- htdocs/compta/prelevement/create.php | 44 +++++-- htdocs/compta/prelevement/demandes.php | 8 +- htdocs/compta/prelevement/factures.php | 10 +- htdocs/compta/prelevement/line.php | 63 ++++++---- htdocs/compta/prelevement/list.php | 110 +++++++++++------- htdocs/compta/prelevement/rejets.php | 54 ++++++--- htdocs/compta/prelevement/stats.php | 34 +++++- htdocs/langs/en_US/main.lang | 2 + htdocs/langs/en_US/withdrawals.lang | 26 +++-- htdocs/societe/paymentmodes.php | 11 +- 16 files changed, 334 insertions(+), 158 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 80e52110d8c..ca6a2e8d589 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -333,7 +333,6 @@ class Account extends CommonObject public function __toString() { $string = ''; - foreach ($this->getFieldsToShow() as $val) { if ($val == 'BankCode') { $string .= $this->code_banque.' '; diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 74de1c640d4..984c29d75ed 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; if (!$user->rights->facture->lire) accessforbidden(); @@ -44,6 +45,8 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); +$type = GETPOST('type', 'aZ09'); + $fieldid = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); @@ -397,7 +400,13 @@ if ($object->id > 0) print ''; print ''.$langs->trans("RIB").''; - print $object->thirdparty->display_rib(); + + $bac = new CompanyBankAccount($db); + $bac->fetch(0, $object->thirdparty->id); + + print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic; + if ($bac->verif() <= 0) print img_warning('Error on default bank number for IBAN : '.$bac->error_message); + print ''; print ''; @@ -493,7 +502,11 @@ if ($object->id > 0) $sql .= " , pfd.date_traite as date_traite"; $sql .= " , pfd.amount"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " WHERE fk_facture = ".$object->id; + if ($type == 'bank-transfer') { + $sql .= " WHERE fk_facture_fourn = ".$object->id; + } else { + $sql .= " WHERE fk_facture = ".$object->id; + } $sql .= " AND pfd.traite = 0"; $sql .= " ORDER BY pfd.date_demande DESC"; @@ -508,11 +521,15 @@ if ($object->id > 0) dol_print_error($db); } - // For wich amount ? + // For which amount ? $sql = "SELECT SUM(pfd.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql .= " WHERE fk_facture = ".$object->id; + if ($type == 'bank-transfer') { + $sql .= " WHERE fk_facture_fourn = ".$object->id; + } else { + $sql .= " WHERE fk_facture = ".$object->id; + } $sql .= " AND pfd.traite = 0"; $result_sql = $db->query($sql); @@ -543,10 +560,11 @@ if ($object->id > 0) $remaintopaylesspendingdebit = $resteapayer - $pending; print '
'; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'; } @@ -593,13 +611,17 @@ if ($object->id > 0) print ' '; print ''; - $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande"; - $sql .= " , pfd.date_traite as date_traite, pfd.amount,"; + $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,"; + $sql .= " pfd.date_traite as date_traite, pfd.amount,"; $sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; - $sql .= " WHERE fk_facture = ".$object->id; + if ($type == 'bank-transfer') { + $sql .= " WHERE fk_facture_fourn = ".$object->id; + } else { + $sql .= " WHERE fk_facture = ".$object->id; + } $sql .= " AND pfd.traite = 0"; $sql .= " ORDER BY pfd.date_demande DESC"; @@ -649,7 +671,11 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons"; - $sql .= " WHERE fk_facture = ".$object->id; + if ($type == 'bank-transfer') { + $sql .= " WHERE fk_facture_fourn = ".$object->id; + } else { + $sql .= " WHERE fk_facture = ".$object->id; + } $sql .= " AND pfd.traite = 1"; $sql .= " ORDER BY pfd.date_demande DESC"; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index ea768638552..5a1ce4e7024 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -174,35 +174,40 @@ if ($result) $directdebitorder = new BonPrelevement($db); - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($result); + if ($num) { + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($result); - $directdebitorder->id = $obj->rowid; - $directdebitorder->ref = $obj->ref; - $directdebitorder->datec = $obj->datec; - $directdebitorder->amount = $obj->amount; - $directdebitorder->statut = $obj->statut; + $directdebitorder->id = $obj->rowid; + $directdebitorder->ref = $obj->ref; + $directdebitorder->datec = $obj->datec; + $directdebitorder->amount = $obj->amount; + $directdebitorder->statut = $obj->statut; - print ''; + print ''; - print ''; - print $directdebitorder->getNomUrl(1); - print "\n"; + print ''; + print $directdebitorder->getNomUrl(1); + print "\n"; - print ''.dol_print_date($db->jdate($obj->datec), 'day')."\n"; + print ''.dol_print_date($db->jdate($obj->datec), 'day')."\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; - print ''; - print $bon->LibStatut($obj->statut, 3); - print ''; + print ''; + print $bon->LibStatut($obj->statut, 3); + print ''; - print ''."\n"; + print ''."\n"; - print "\n"; - $i++; + print "\n"; + $i++; + } + } else { + print ''.$langs->trans("None").''; } + print ""; print ''; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index d630f65edd7..3ad145e2f56 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -292,7 +292,7 @@ if ($id > 0 || $ref) print $form->selectDate('', '', '', '', '', "infocredit", 1, 1); print ''; print ''; - print '
'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice"); + print '
'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice").'
'; print '
'; print ''; print '
'; @@ -405,7 +405,7 @@ if ($id > 0 || $ref) print ''.price($obj->amount)."\n"; - print ''; + print ''; if ($obj->statut == 3) { @@ -413,7 +413,24 @@ if ($id > 0 || $ref) } else { - print " "; + if ($object->statut == BonPrelevement::STATUS_CREDITED) + { + if ($obj->statut == 2) { + if ($user->rights->prelevement->bons->credit) + { + //print ''.$langs->trans("StandingOrderReject").''; + print ''.$langs->trans("StandingOrderReject").''; + } + else + { + //print ''.$langs->trans("StandingOrderReject").''; + } + } + } + else + { + //print ''.$langs->trans("StandingOrderReject").''; + } } print ''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a923f66c699..0997fb593cb 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -288,7 +288,7 @@ class BonPrelevement extends CommonObject $sql .= ", p.method_trans, p.fk_user_trans"; $sql .= ", p.date_credit as date_credit"; $sql .= ", p.fk_user_credit"; - $sql .= ", p.statut"; + $sql .= ", p.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " WHERE p.entity IN (".getEntity('invoice').")"; if ($rowid > 0) $sql .= " AND p.rowid = ".$rowid; @@ -315,7 +315,8 @@ class BonPrelevement extends CommonObject $this->date_credit = $this->db->jdate($obj->date_credit); $this->user_credit = $obj->fk_user_credit; - $this->statut = $obj->statut; + $this->status = $obj->status; + $this->statut = $obj->status; // For backward compatibility $this->fetched = 1; diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 88b612554df..d2dd9f3470f 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -66,14 +66,14 @@ class LignePrelevement /** * Recupere l'objet prelevement * - * @param int $rowid id de la facture a recuperer - * @return integer + * @param int $rowid Id de la facture a recuperer + * @return integer <0 if KO, >=0 if OK */ public function fetch($rowid) { global $conf; - $result = 0; + $error = 0; $sql = "SELECT pl.rowid, pl.amount, p.ref, p.rowid as bon_rowid"; $sql .= ", pl.statut, pl.fk_soc"; @@ -99,7 +99,7 @@ class LignePrelevement } else { - $result++; + $error++; dol_syslog("LignePrelevement::Fetch rowid=$rowid numrows=0"); } @@ -107,12 +107,12 @@ class LignePrelevement } else { - $result++; + $error++; dol_syslog("LignePrelevement::Fetch rowid=$rowid"); dol_syslog($this->db->error()); } - return $result; + return $error; } /** diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index d94864e8358..6da71e7bf43 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -99,6 +99,9 @@ if (empty($reshook)) else { setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null); + + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id); + exit; } } } @@ -141,8 +144,8 @@ print load_fiche_titre($title); dol_fiche_head(); -$nb = $bprev->NbFactureAPrelever(); -$pricetowithdraw = $bprev->SommeAPrelever(); +$nb = $bprev->nbOfInvoiceToPay($type); +$pricetowithdraw = $bprev->SommeAPrelever($type); if ($nb < 0) { dol_print_error($bprev->error); @@ -178,19 +181,34 @@ if ($nb) { if ($pricetowithdraw) { print $langs->trans('ExecutionDate').' '; print $form->selectDate(); + if ($mysoc->isInEEC()) { + $title = $langs->trans("CreateForSepa"); + print ''; - print ''; + print ''; } else { - print ''.$langs->trans("CreateAll")."\n"; + $title = $langs->trans("CreateAll"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreateFileForPaymentByBankTransfer"); + } + print ''.$title."\n"; } } else { if ($mysoc->isInEEC()) { - print ''.$langs->trans("CreateForSepaFRST")."\n"; - print ''.$langs->trans("CreateForSepaRCUR")."\n"; + $title = $langs->trans("CreateForSepaFRST"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); + } + print ''.$title."\n"; + + if ($type != 'bank-transfer') { + $title = $langs->trans("CreateForSepaRCUR"); + print ''.$title."\n"; + } } else { @@ -236,9 +254,9 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) $sql .= " AND f.total_ttc > 0"; $sql .= " AND pfd.traite = 0"; if ($type == 'bank-transfer') { - $sql .= " AND pfd.fk_facture = f.rowid"; -} else { $sql .= " AND pfd.fk_facture_fourn = f.rowid"; +} else { + $sql .= " AND pfd.fk_facture = f.rowid"; } if ($socid > 0) $sql .= " AND f.fk_soc = ".$socid; @@ -299,23 +317,29 @@ if ($resql) { $obj = $db->fetch_object($resql); + $bac->fetch(0, $obj->socid); + print ''; + + // Ref invoice print ''; $invoicestatic->id = $obj->rowid; $invoicestatic->ref = $obj->ref; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; + // Thirdparty print ''; $thirdpartystatic->fetch($obj->socid); print $thirdpartystatic->getNomUrl(1, 'ban'); print ''; + // RIB print ''; - print $thirdpartystatic->display_rib(); - $bac->fetch(0, $obj->socid); + print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic; if ($bac->verif() <= 0) print img_warning('Error on default bank number for IBAN : '.$bac->error_message); print ''; + // RUM print ''; print $thirdpartystatic->display_rib('rum'); diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 720aac24be5..b92df4e446c 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -199,14 +199,14 @@ print ''; print ''; print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]); print_liste_field_titre("Company", $_SERVER["PHP_SELF"]); -print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'class="right"'); -print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'class="center"'); +print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right '); +print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center '); print_liste_field_titre(''); print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; print ''; // Action column diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 06c20a2b04f..556f40de9be 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('banks', 'categories', 'companies', 'withdrawals', 'bill if ($user->socid > 0) accessforbidden(); // Get supervariables -$prev_id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -68,9 +68,9 @@ $thirdpartytmp = new Societe($db); llxHeader('', $langs->trans("WithdrawalsReceipts")); -if ($prev_id > 0 || $ref) +if ($id > 0 || $ref) { - if ($object->fetch($prev_id, $ref) >= 0) + if ($object->fetch($id, $ref) >= 0) { $head = prelevement_prepare_head($object); dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment'); @@ -183,7 +183,7 @@ if ($result) $num = $db->num_rows($result); $i = 0; - $param = "&id=".$prev_id; + $param = "&id=".$id; // Lines of title fields print ''; @@ -195,7 +195,7 @@ if ($result) print ''; print ''; print ''; - print ''; + print ''; $massactionbutton = ''; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index c225b9d47f3..d6124113321 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -124,11 +124,18 @@ if ($action == 'confirm_rejet') $invoicestatic = new Facture($db); -llxHeader('', $langs->trans("StandingOrder")); +$title = $langs->trans("WithdrawalsLine"); +if ($type == 'bank-transfer') { + $title = $langs->trans("CreditTransferLine"); +} + +llxHeader('', $title); + +$head = array(); $h = 0; $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id; -$head[$h][1] = $langs->trans("StandingOrder"); +$head[$h][1] = $title; $hselected = $h; $h++; @@ -136,20 +143,24 @@ if ($id) { $lipre = new LignePrelevement($db); - if ($lipre->fetch($id) == 0) + if ($lipre->fetch($id) >= 0) { $bon = new BonPrelevement($db); $bon->fetch($lipre->bon_rowid); - dol_fiche_head($head, $hselected, $langs->trans("StandingOrder")); + dol_fiche_head($head, $hselected, $title); - print '
'; + print '
'; - print ''; + + print ''; - print ''; - print ''; - print ''; + + print ''; + print ''; + print ''; if ($lipre->statut == 3) { @@ -157,8 +168,8 @@ if ($id) $resf = $rej->fetch($lipre->id); if ($resf == 0) { - print ''; - print ''; + print ''; - print ''; + print ''; } else { - print ''; + print ''; } } @@ -197,7 +208,7 @@ if ($id) print ''; print ''; print ''; - print '
'.$langs->trans("WithdrawalsReceipts").''; + print '
'.$langs->trans("Ref").''; + print $id.'
'.$langs->trans("WithdrawalsReceipts").''; print $bon->getNomUrl(1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec, 'day').'
'.$langs->trans("Amount").''.price($lipre->amount).'
'.$langs->trans("Status").''.$lipre->LibStatut($lipre->statut, 1).'
'.$langs->trans("Date").''.dol_print_date($bon->datec, 'day').'
'.$langs->trans("Amount").''.price($lipre->amount).'
'.$langs->trans("Status").''.$lipre->LibStatut($lipre->statut, 1).'
'.$langs->trans("RefusedReason").''.$rej->motif.'
'.$langs->trans("RefusedData").''; + print '
'.$langs->trans("RefusedReason").''.$rej->motif.'
'.$langs->trans("RefusedData").''; if ($rej->date_rejet == 0) { /* Historique pour certaines install */ @@ -169,11 +180,11 @@ if ($id) print dol_print_date($rej->date_rejet, 'day'); } print '
'.$langs->trans("RefusedInvoicing").''.$rej->invoicing.'
'.$langs->trans("RefusedInvoicing").''.$rej->invoicing.'
'.$resf.'
'.$resf.'
'; + print '
'; print ''; print ''; @@ -217,13 +228,13 @@ if ($id) //Reason print ''; print ''; //Facturer print ''; print ''; print '
'.$langs->trans("WithdrawalRefused").'
'.$langs->trans("RefusedReason").''; - print $form->selectarray("motif", $rej->motifs); + print $form->selectarray("motif", $rej->motifs, GETPOSTISSET('motif') ? GETPOST('motif', 'int') : ''); print '
'.$langs->trans("RefusedInvoicing").''; - print $form->selectarray("facturer", $rej->facturer); + print $form->selectarray("facturer", $rej->facturer, GETPOSTISSET('facturer') ? GETPOST('facturer', 'int') : ''); print '

'; @@ -242,20 +253,22 @@ if ($id) if ($action == '') { - if ($bon->statut == 2 && $lipre->statut == 2) + if ($bon->statut == BonPrelevement::STATUS_CREDITED) { - if ($user->rights->prelevement->bons->credit) - { - print "id\">".$langs->trans("StandingOrderReject").""; - } - else - { - print "trans("NotAllowed")."\">".$langs->trans("StandingOrderReject").""; + if ($lipre->statut == 2) { + if ($user->rights->prelevement->bons->credit) + { + print ''.$langs->trans("StandingOrderReject").''; + } + else + { + print ''.$langs->trans("StandingOrderReject").''; + } } } else { - print "trans("NotPossibleForThisStatusOfWithdrawReceiptORLine")."\">".$langs->trans("StandingOrderReject").""; + print ''.$langs->trans("StandingOrderReject").''; } } diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index e97a492de9b..72960c9c15b 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -21,7 +21,7 @@ /** * \file htdocs/compta/prelevement/list.php * \ingroup prelevement - * \brief Page liste des prelevements + * \brief Page list of direct debit orders or credit transfers orders */ require '../../main.inc.php'; @@ -96,23 +96,35 @@ $form = new Form($db); llxHeader('', $langs->trans("WithdrawalsLines")); $sql = "SELECT p.rowid, p.ref, p.statut as status, p.datec"; -$sql .= " ,f.rowid as facid, f.ref as invoiceref, f.total_ttc"; +$sql .= " , f.rowid as facid, f.ref as invoiceref, f.total_ttc"; $sql .= " , s.rowid as socid, s.nom as name, s.code_client, s.email"; $sql .= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_facture as pf"; -$sql .= " , ".MAIN_DB_PREFIX."facture as f"; +if ($type == 'bank-transfer') { + $sql .= " , ".MAIN_DB_PREFIX."facture_fourn as f"; +} else { + $sql .= " , ".MAIN_DB_PREFIX."facture as f"; +} $sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE pl.fk_prelevement_bons = p.rowid"; $sql .= " AND pf.fk_prelevement_lignes = pl.rowid"; -$sql .= " AND pf.fk_facture = f.rowid"; +if ($type == 'bank-transfer') { + $sql .= " AND pf.fk_facture_fourn = f.rowid"; +} else { + $sql .= " AND pf.fk_facture = f.rowid"; +} $sql .= " AND f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) $sql .= " AND s.rowid = ".$socid; if ($search_line) $sql .= " AND pl.rowid = '".$db->escape($search_line)."'"; if ($search_bon) $sql .= natural_search("p.ref", $search_bon); -if ($search_code) $sql .= natural_search("s.code_client", $search_code); +if ($type == 'bank-transfer') { + if ($search_code) $sql .= natural_search("s.code_fourn", $search_code); +} else { + if ($search_code) $sql .= natural_search("s.code_client", $search_code); +} if ($search_company) $sql .= natural_search("s.nom", $search_company); $sql .= $db->order($sortfield, $sortorder); @@ -152,7 +164,11 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("WithdrawalsLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1); + $title = $langs->trans("WithdrawalsLines"); + if ($type == 'bank-transfer') { + $title = $langs->trans("CreditTransferLines"); + } + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1); $moreforfilter = ''; @@ -173,9 +189,14 @@ if ($result) print ''; print ''; + $columntitle= "WithdrawalsReceipts"; + if ($type == 'bank-transfer') { + $columntitle= "BankTransferReceipts"; + } + print ''; + print_liste_field_titre($columntitle, $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Line", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("WithdrawalsReceipts", $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Bill", $_SERVER["PHP_SELF"], "f.ref", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", '', $param, '', $sortfield, $sortorder, 'center '); @@ -184,53 +205,58 @@ if ($result) print_liste_field_titre(''); print "\n"; - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($result); + if ($num) { + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($result); - $bon->ref = $obj->ref; - $bon->statut = $obj->status; + $bon->id = $obj->rowid; + $bon->ref = $obj->ref; + $bon->statut = $obj->status; - $company->id = $obj->socid; - $company->name = $obj->name; - $company->email = $obj->email; - $company->code_client = $obj->code_client; + $company->id = $obj->socid; + $company->name = $obj->name; + $company->email = $obj->email; + $company->code_client = $obj->code_client; - print ''; + print ''; - print ''; - print $line->LibStatut($obj->statut_ligne, 2); - print " "; - print ''; - print substr('000000'.$obj->rowid_ligne, -6); - print ''; + print ''; + print $bon->getNomUrl(1); + print "\n"; - print ''; - print $bon->getNomUrl(1); - print "\n"; + print ''; + print $line->LibStatut($obj->statut_ligne, 2); + print " "; + print ''; + print substr('000000'.$obj->rowid_ligne, -6); + print ''; - print ''; - print ''; - print img_object($langs->trans("ShowBill"), "bill"); - print ' '.$obj->invoiceref."\n"; - print ''; - print ''; + print ''; + print ''; + print img_object($langs->trans("ShowBill"), "bill"); + print ' '.$obj->invoiceref."\n"; + print ''; + print ''; - print ''; - print $company->getNomUrl(1); - print "\n"; + print ''; + print $company->getNomUrl(1); + print "\n"; - print ''.$obj->code_client."\n"; + print ''.$obj->code_client."\n"; - print ''.dol_print_date($db->jdate($obj->datec), 'day')."\n"; + print ''.dol_print_date($db->jdate($obj->datec), 'day')."\n"; - print ''.price($obj->amount)."\n"; + print ''.price($obj->amount)."\n"; - print ' '; + print ' '; - print "\n"; - $i++; - } + print "\n"; + $i++; + } + } else { + print ''.$langs->trans("None").''; + } print ""; print ''; diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 7dfd5e558d9..81f17dc784b 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -55,7 +55,12 @@ $pagenext = $page + 1; * View */ -llxHeader('', $langs->trans("WithdrawsRefused")); +$title = $langs->trans("WithdrawsRefused"); +if ($type == 'bank-transfer') { + $title = $langs->trans("CreditTransfersRefused"); +} + +llxHeader('', $title); if ($sortorder == "") $sortorder = "DESC"; if ($sortfield == "") $sortfield = "p.datec"; @@ -80,9 +85,14 @@ $sql .= " WHERE pr.fk_prelevement_lignes = pl.rowid"; $sql .= " AND pl.fk_prelevement_bons = p.rowid"; $sql .= " AND pl.fk_soc = s.rowid"; $sql .= " AND p.entity = ".$conf->entity; +if ($type == 'bank-transfer') { + $sql .= " AND p.type = 'bank-transfer'"; +} else { + $sql .= " AND p.type = 'debit-order'"; +} if ($socid) $sql .= " AND s.rowid = ".$socid; -$sql .= " ".$db->order($sortfield, $sortorder); -$sql .= " ".$db->plimit($conf->liste_limit + 1, $offset); +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -90,33 +100,39 @@ if ($result) $num = $db->num_rows($result); $i = 0; - print_barre_liste($langs->trans("WithdrawsRefused"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); + $param = ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num); print"\n\n"; print ''; print ''; - print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $urladd); - print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd); - print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $urladd); + print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $param); + print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param); + print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", "", $param); print "\n"; - $total = 0; + if ($num) { + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($result); - while ($i < min($num, $conf->liste_limit)) - { - $obj = $db->fetch_object($result); + print ''; - print '"; - print substr('000000'.$obj->rowid, -6).""; + print '\n"; - print '\n"; + print ''; - print ''; - print "\n"; + print "\n"; - $i++; + $i++; + } + } else { + print ''; } print "
'; - print $line->LibStatut($obj->statut, 2).' '; - print ''; + print ''; + print $line->LibStatut($obj->statut, 2).' '; + print ''; + print substr('000000'.$obj->rowid, -6)."'.$obj->nom."'.stripslashes($obj->nom)."'.$rej->motifs[$obj->motif].''.$rej->motifs[$obj->motif].'
'.$langs->trans("None").'
"; diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 416bb68128b..87fd3917a56 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -43,15 +43,25 @@ $type = GETPOST('type', 'aZ09'); * View */ -llxHeader('', $langs->trans("WithdrawStatistics")); +$title = $langs->trans("WithdrawStatistics"); +if ($type == 'bank-transfer') { + $title = $langs->trans("CreditTransferStatistics"); +} -print load_fiche_titre($langs->trans("Statistics")); +llxHeader('', $title); + +print load_fiche_titre($title); // Define total and nbtotal $sql = "SELECT sum(pl.amount), count(pl.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; $sql .= " WHERE pl.fk_prelevement_bons = pb.rowid"; +if ($type == 'bank-transfer') { + $sql .= " AND pb.type = 'bank-transfer'"; +} else { + $sql .= " AND pb.type = 'debit-order'"; +} $sql .= " AND pb.entity = ".$conf->entity; $resql = $db->query($sql); if ($resql) @@ -73,7 +83,7 @@ if ($resql) */ print '
'; -print load_fiche_titre($langs->trans("WithdrawStatistics"), '', ''); +print load_fiche_titre($langs->trans("ByStatus"), '', ''); $ligne = new LignePrelevement($db); @@ -82,6 +92,11 @@ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; $sql .= " WHERE pl.fk_prelevement_bons = pb.rowid"; $sql .= " AND pb.entity = ".$conf->entity; +if ($type == 'bank-transfer') { + $sql .= " AND pb.type = 'bank-transfer'"; +} else { + $sql .= " AND pb.type = 'debit-order'"; +} $sql .= " GROUP BY pl.statut"; $resql = $db->query($sql); @@ -139,7 +154,7 @@ else */ print '
'; -print load_fiche_titre($langs->trans("WithdrawRejectStatistics"), '', ''); +print load_fiche_titre($langs->trans("Rejects"), '', ''); // Define total and nbtotal @@ -149,6 +164,11 @@ $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; $sql .= " WHERE pl.fk_prelevement_bons = pb.rowid"; $sql .= " AND pb.entity = ".$conf->entity; $sql .= " AND pl.statut = 3"; +if ($type == 'bank-transfer') { + $sql .= " AND pb.type = 'bank-transfer'"; +} else { + $sql .= " AND pb.type = 'debit-order'"; +} $resql = $db->query($sql); if ($resql) { @@ -166,6 +186,7 @@ if ($resql) /* * Stats sur les rejets */ + $sql = "SELECT sum(pl.amount), count(pl.amount) as cc, pr.motif"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb"; @@ -174,6 +195,11 @@ $sql .= " WHERE pl.fk_prelevement_bons = pb.rowid"; $sql .= " AND pb.entity = ".$conf->entity; $sql .= " AND pl.statut = 3"; $sql .= " AND pr.fk_prelevement_lignes = pl.rowid"; +if ($type == 'bank-transfer') { + $sql .= " AND pb.type = 'bank-transfer'"; +} else { + $sql .= " AND pb.type = 'debit-order'"; +} $sql .= " GROUP BY pr.motif"; $sql .= " ORDER BY cc DESC"; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 105d5c83bec..dd250316bc7 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1035,3 +1035,5 @@ DeleteFileText=Do you really want delete this file? ShowOtherLanguages=Show other languages SwitchInEditModeToAddTranslation=Switch in edit mode to add translations for this language NotUsedForThisCustomer=Not used for this customer +AmountMustBePositive=Amount must be positive +ByStatus=By status \ No newline at end of file diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index a7a55c69c53..87afa3246b4 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -1,6 +1,6 @@ # Dolibarr language file - Source file is en_US - withdrawals -CustomersStandingOrdersArea=Direct debit payment orders area -SuppliersStandingOrdersArea=Direct credit payment orders area +CustomersStandingOrdersArea=Payments by Direct debit orders +SuppliersStandingOrdersArea=Payments by Credit transfer StandingOrdersPayment=Direct debit payment orders StandingOrderPayment=Direct debit payment order NewStandingOrder=New direct debit order @@ -10,26 +10,34 @@ PaymentByBankTransferReceipts=Credit transfer orders PaymentByBankTransferLines=Credit transfer order lines WithdrawalsReceipts=Direct debit orders WithdrawalReceipt=Direct debit order +BankTransferReceipts=Credit transfer receipts +BankTransferReceipt=Credit transfer receipt LatestBankTransferReceipts=Latest %s credit transfer orders LastWithdrawalReceipts=Latest %s direct debit files +WithdrawalsLine=Direct debit order line +CreditTransferLine=Credit transfer line WithdrawalsLines=Direct debit order lines -RequestStandingOrderToTreat=Request for direct debit payment order to process -RequestStandingOrderTreated=Request for direct debit payment order processed +CreditTransferLines=Credit transfer lines +RequestStandingOrderToTreat=Requests for direct debit payment order to process +RequestStandingOrderTreated=Requests for direct debit payment order processed +RequestPaymentsByBankTransferToTreat=Requests for credit transfer to process +RequestPaymentsByBankTransferTreated=Requests for credit transfer processed NotPossibleForThisStatusOfWithdrawReceiptORLine=Not yet possible. Withdraw status must be set to 'credited' before declaring reject on specific lines. NbOfInvoiceToWithdraw=No. of qualified customer invoices with waiting direct debit order NbOfInvoiceToWithdrawWithInfo=No. of customer invoice with direct debit payment orders having defined bank account information NbOfInvoiceToPayByBankTransfer=No. of qualified supplier invoices waiting for a payment by credit transfer SupplierInvoiceWaitingWithdraw=Vendor invoice waiting for payment by credit transfer InvoiceWaitingWithdraw=Invoice waiting for direct debit +InvoiceWaitingPaymentByBankTransfer=Invoice waiting for credit transfer AmountToWithdraw=Amount to withdraw -WithdrawsRefused=Direct debit refused NoInvoiceToWithdraw=No customer invoice with open 'Direct debit requests' is waiting. Go on tab '%s' on invoice card to make a request. NoSupplierInvoiceToWithdraw=No supplier invoice with open 'Direct credit requests' is waiting. Go on tab '%s' on invoice card to make a request. ResponsibleUser=User Responsible WithdrawalsSetup=Direct debit payment setup CreditTransferSetup=Crebit transfer setup WithdrawStatistics=Direct debit payment statistics -WithdrawRejectStatistics=Direct debit payment reject statistics +CreditTransferStatistics=Credit transfer statistics +Rejects=Rejects LastWithdrawalReceipt=Latest %s direct debit receipts MakeWithdrawRequest=Make a direct debit payment request WithdrawRequestsDone=%s direct debit payment requests recorded @@ -42,7 +50,9 @@ TransMetod=Transmission method Send=Send Lines=Lines StandingOrderReject=Issue a rejection +WithdrawsRefused=Direct debit refused WithdrawalRefused=Withdrawal refused +CreditTransfersRefused=Credit transfers refused WithdrawalRefusedConfirm=Are you sure you want to enter a withdrawal rejection for society RefusedData=Date of rejection RefusedReason=Reason for rejection @@ -66,6 +76,8 @@ StatusMotif8=Other reason CreateForSepaFRST=Create direct debit file (SEPA FRST) CreateForSepaRCUR=Create direct debit file (SEPA RCUR) CreateAll=Create direct debit file (all) +CreateFileForPaymentByBankTransfer=Create credit transfer (all) +CreateSepaFileForPaymentByBankTransfer=Create credit transfer file (SEPA) CreateGuichet=Only office CreateBanque=Only bank OrderWaiting=Waiting for treatment @@ -83,7 +95,7 @@ IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one DoStandingOrdersBeforePayments=This tab allows you to request a direct debit payment order. Once done, go into menu Bank->Direct Debit orders to manage the direct debit payment order. When payment order is closed, payment on invoice will be automatically recorded, and invoice closed if remainder to pay is null. WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" -ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and will classify them as "Paid" if remain to pay is null +ThisWillAlsoAddPaymentOnInvoice=This will also record payments on invoices and will classify them as "Paid" if remain to pay is null StatisticsByLineStatus=Statistics by status of lines RUM=UMR DateRUM=Mandate signature date diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index e0636932cc2..a57fda0403c 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1660,6 +1660,7 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) // Show fields of bank account foreach ($companybankaccount->getFieldsToShow(1) as $val) { $require = false; + $tooltip = ''; if ($val == 'BankCode') { $name = 'code_banque'; $size = 8; @@ -1681,14 +1682,22 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer) $size = 30; $content = $companybankaccount->iban; if ($companybankaccount->needIBAN()) $require = true; + $tooltip = $langs->trans("Example").':
LT12 1000 0111 0100 1000
FR14 2004 1010 0505 0001 3M02 606
LU28 0019 4006 4475 0000
DE89 3704 0044 0532 0130 00'; } elseif ($val == 'BIC') { $name = 'bic'; $size = 12; $content = $companybankaccount->bic; if ($companybankaccount->needIBAN()) $require = true; + $tooltip = $langs->trans("Example").': LIABLT2XXXX'; } - print ''.$langs->trans($val).''; + print ''; + if ($tooltip) { + print $form->textwithpicto($langs->trans($val), $tooltip, 4, 'help', '', 0, 3, $name); + } else { + print $langs->trans($val); + } + print ''; print ''; print ''; } From 70bdd595488163faa004031ed606057b86c1a3c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 11:52:43 +0200 Subject: [PATCH 2/7] Fix trans --- htdocs/compta/prelevement/create.php | 8 +++++++- htdocs/langs/en_US/withdrawals.lang | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 6da71e7bf43..db9ad26f31d 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -222,7 +222,13 @@ if ($nb) { } else { - print 'transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."\n"; + $titlefortab = $langs->transnoentitiesnoconv("StandingOrders"); + $title = $langs->trans("CreateAll"); + if ($type == 'bank-transfer') { + $titlefortab = $langs->transnoentitiesnoconv("PaymentByBankTransfers"); + $title = $langs->trans("CreateFileForPaymentByBankTransfer"); + } + print ''.$title."\n"; } print "\n"; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 87afa3246b4..5217d54d39a 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -30,7 +30,7 @@ SupplierInvoiceWaitingWithdraw=Vendor invoice waiting for payment by credit tran InvoiceWaitingWithdraw=Invoice waiting for direct debit InvoiceWaitingPaymentByBankTransfer=Invoice waiting for credit transfer AmountToWithdraw=Amount to withdraw -NoInvoiceToWithdraw=No customer invoice with open 'Direct debit requests' is waiting. Go on tab '%s' on invoice card to make a request. +NoInvoiceToWithdraw=No invoice open for '%s' is waiting. Go on tab '%s' on invoice card to make a request. NoSupplierInvoiceToWithdraw=No supplier invoice with open 'Direct credit requests' is waiting. Go on tab '%s' on invoice card to make a request. ResponsibleUser=User Responsible WithdrawalsSetup=Direct debit payment setup From 2e06ce306a0448376c5c6d55468403db3a7f7c5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 15:03:10 +0200 Subject: [PATCH 3/7] Tooltip --- htdocs/langs/en_US/website.lang | 1 + htdocs/website/index.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 6109f3ca879..04338f38e6e 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -16,6 +16,7 @@ WEBSITE_ROBOT=Robot file (robots.txt) WEBSITE_HTACCESS=Website .htaccess file WEBSITE_MANIFEST_JSON=Website manifest.json file WEBSITE_README=README.md file +WEBSITE_KEYWORDSDesc=Use a comma to separate values EnterHereLicenseInformation=Enter here meta data or license information to fille a README.md file. if you distribute your website as a template, the file will be included into the temptate package. HtmlHeaderPage=HTML header (specific to this page only) PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 3b541a40588..d67a04deb06 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3297,7 +3297,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') if (GETPOST('WEBSITE_IMAGE', 'alpha')) $pageimage = GETPOST('WEBSITE_IMAGE', 'alpha'); if (GETPOST('WEBSITE_KEYWORDS', 'alpha')) $pagekeywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); - if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); + if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); // Type of container print ''; @@ -3342,8 +3342,10 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print ''; + // Keywords print ''; - print $langs->trans('WEBSITE_KEYWORDS'); + $htmlhelp = $langs->trans("WEBSITE_KEYWORDSDesc"); + print $form->textwithpicto($langs->trans('WEBSITE_KEYWORDS'), $htmlhelp, 1, 'help', '', 0, 2, 'keywordtooltip'); print ''; print ''; print ''; From fd8f8ff4e191178b1849387a866e12941a2f7fd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 15:12:07 +0200 Subject: [PATCH 4/7] Error message --- htdocs/core/class/commonobject.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9dba821c012..29e0de2ba23 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3049,7 +3049,11 @@ abstract class CommonObject //print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."
\n"; if ($diff) { - if (abs($diff) > 0.1) { dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); exit; } + if (abs($diff) > 0.1) { + dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); + dol_print_error('', 'A rounding difference was detected into TOTAL but is too high to be corrected'); + exit; + } $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix); $resqlfix = $this->db->query($sqlfix); From 366f458b39edec2949ccb68c71bc8e75e98f607d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 15:20:01 +0200 Subject: [PATCH 5/7] Show more info to help fix corrupted data --- htdocs/core/class/commonobject.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 29e0de2ba23..0f055d457ed 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3050,8 +3050,9 @@ abstract class CommonObject if ($diff) { if (abs($diff) > 0.1) { - dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); - dol_print_error('', 'A rounding difference was detected into TOTAL but is too high to be corrected'); + $errmsg = 'A rounding difference was detected into TOTAL but is too high to be corrected. Some data in your line may be corrupted. Try to edit each line manually.'; + dol_syslog($errmsg, LOG_WARNING); + dol_print_error('', $errmsg); exit; } $sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid; From cf976a2b98ab13405df470ec3cb0b1ffc0e563eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 17:00:58 +0200 Subject: [PATCH 6/7] Fix translation --- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/element.php | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index e145647baa4..1a35eda4b9c 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -265,3 +265,4 @@ NewInvoice=New invoice OneLinePerTask=One line per task OneLinePerPeriod=One line per period RefTaskParent=Ref. Parent Task +ProfitIsCalculatedWith=Profit is calculated using \ No newline at end of file diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 23fa6551656..0b46d14a7fa 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -526,7 +526,7 @@ $listofreferent = array( */ ); -// Change rules for benefit calculation +// Change rules for profit/benefit calculation if (! empty($conf->global->PROJECT_ELEMENTS_FOR_PLUS_MARGIN)) { foreach($listofreferent as $key => $element) { if ($listofreferent[$key]['margin'] == 'add') { @@ -624,7 +624,28 @@ print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy'); print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -640,7 +661,7 @@ foreach ($listofreferent as $key => $value) $qualified = $value['test']; $margin = $value['margin']; $project_field = $value['project_field']; - if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'plus') + if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add') { $element = new $classname($db); From 233c7e53f109f8142ea22c732bbcbab377c46dc3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Jun 2020 20:31:09 +0200 Subject: [PATCH 7/7] Debug v12 --- htdocs/langs/en_US/stocks.lang | 1 + htdocs/product/stock/product.php | 2 ++ htdocs/product/stock/replenish.php | 7 +++++-- htdocs/theme/eldy/dropdown.inc.php | 4 +--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 9856649b834..f62bf5d9cc5 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -123,6 +123,7 @@ WarehouseForStockDecrease=The warehouse %s will be used for stock decreas WarehouseForStockIncrease=The warehouse %s will be used for stock increase ForThisWarehouse=For this warehouse ReplenishmentStatusDesc=This is a list of all products with a stock lower than desired stock (or lower than alert value if checkbox "alert only" is checked). Using the checkbox, you can create purchase orders to fill the difference. +ReplenishmentStatusDescPerWarehouse=If you want a replenishment based on desired quantity defined per warehouse, you must add a filter on the warehouse. ReplenishmentOrdersDesc=This is a list of all open purchase orders including predefined products. Only open orders with predefined products, so orders that may affect stocks, are visible here. Replenishments=Replenishments NbOfProductBeforePeriod=Quantity of product %s in stock before selected period (< %s) diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index fcd08f8b662..89e99df4b1e 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -909,6 +909,7 @@ if (!$variants) { print "\n".''; print '
'.$langs->trans("Element").''; +$tooltiponprofit = $langs->trans("ProfitIsCalculatedWith")."
\n"; +$tooltiponprofitplus = $tooltiponprofitminus = ''; +foreach($listofreferent as $key => $value) +{ + $name = $langs->trans($value['name']); + $qualified = $value['test']; + $margin = $value['margin']; + if ($qualified && isset($margin)) // If this element must be included into profit calculation ($margin is 'minus' or 'add') + { + if ($margin == 'add') { + $tooltiponprofitplus.=' + '.$name."
\n"; + } + if ($margin == 'minus') { + $tooltiponprofitminus.=' - '.$name."
\n"; + } + } +} +$tooltiponprofit .= $tooltiponprofitplus; +$tooltiponprofit .= $tooltiponprofitminus; +print $form->textwithpicto($langs->trans("Element"), $tooltiponprofit); +print '
'.$langs->trans("Number").''.$langs->trans("AmountHT").''.$langs->trans("AmountTTC").'
'; print '
'; + print ''; print ''; print ''; print '
'; @@ -976,6 +977,7 @@ if (!$variants) { if (!empty($user->rights->produit->creer)) { print ''; + print ''; print ''; print ''; } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 5f3ac1fd187..56b9dd4781f 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -99,6 +99,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + /* * Actions */ @@ -107,7 +108,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' { $sref = ''; $snom = ''; - $sal = ''; + $sall = ''; $salert = ''; $draftorder = ''; } @@ -304,7 +305,6 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entre $sqlalertstock = 'p.seuil_stock_alerte'; } - $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,'; $sql .= ' p.price_ttc, p.price_base_type,p.fk_product_type,'; $sql .= ' p.tms as datem, p.duration, p.tobuy,'; @@ -495,6 +495,9 @@ print load_fiche_titre($langs->trans('Replenishment'), '', 'stock'); dol_fiche_head($head, 'replenish', '', -1, ''); print ''.$langs->trans("ReplenishmentStatusDesc").'
'."\n"; +if (empty($fk_warhouse) && !empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) { + print ''.$langs->trans("ReplenishmentStatusDescPerWarehouse").''."
\n"; +} if ($usevirtualstock == 1) { print $langs->trans("CurentSelectionMode").': '; diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index b22441f2445..2944dbe6c61 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -186,11 +186,9 @@ a.top-menu-dropdown-link { } .dropdown-menu > .user-header{ - background: rgb(); + background: var(--colorbackhmenu1); } - - .dropdown-menu .dropdown-header{ padding: 8px 8px 8px 8px; }