From 2fe0736b87e215ab823e9dbf172fe95b25b30016 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 12:32:50 +0200 Subject: [PATCH 01/21] Update qty dispatched on qty change Store qty dispatched and qty ordered only once per orderline --- htdocs/fourn/js/lib_dispatch.js | 55 +++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 84f74c30c54..50b6809a979 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -1,5 +1,5 @@ // Copyright (C) 2014 Cedric GROSS -// Copyright (C) 2015 Francis Appels +// Copyright (C) 2017 Francis Appels // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ * addDispatchLine * Adds new table row for dispatching to multiple stock locations * - * @param index int index of produt line. 0 = first product line + * @param index int index of product line. 0 = first product line * @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch) * @param mode string 'qtymissing' will create new line with qty missing, 'lessone' will keep 1 in old line and the rest in new one */ @@ -35,17 +35,17 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; if (mode === 'lessone') { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + 1; } else { - qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + qty; + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()) + qty; } if (qtyDispatched < qtyOrdered) @@ -63,10 +63,10 @@ function addDispatchLine(index, type, mode) //insert new row before last row $("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row); //remove cloned select2 with duplicate id. - $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); + $("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); /* Suffix of lines are: _ trs.length _ index */ $("#qty_"+nbrTrs+"_"+index).focus(); - $("#qty_dispatched_"+(nbrTrs)+"_"+index).val(qtyDispatched); + $("#qty_dispatched_0_"+index).val(qtyDispatched); //hide all buttons then show only the last one $("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide(); @@ -79,10 +79,47 @@ function addDispatchLine(index, type, mode) } else { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // Store arbitrary data for dispatch qty input field change event + $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); + $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); + $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); } - //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } +} + +/** + * onChangeDispatchLineQty + * + * event handler for dispatch qty input field + * + * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) + */ + +function onChangeDispatchLineQty() { + var index = $(this).data('index'), + type = $(this).data('type'), + qty = parseFloat($(this).data('qty')), + changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched; + + if (index >= 0 && type && qty >= 0) { + nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; + qtyChanged = parseFloat($(this).val()) - qty; // qty changed + qtyDispatching = parseFloat($("#qty_"+(nbrTrs-1)+"_"+index).val()); // qty currently being dispatched + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered + qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched + + // console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + + if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { + $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); + } else { + $(this).val($(this).data('qty')); + } + $(this).data('qty', $(this).val()); + } } \ No newline at end of file From d4488cb040beebd84ff0a1e2843c7e9ebea331a1 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 26 Sep 2017 15:44:40 +0200 Subject: [PATCH 02/21] Fix for 'lessone' mode --- htdocs/fourn/js/lib_dispatch.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/htdocs/fourn/js/lib_dispatch.js b/htdocs/fourn/js/lib_dispatch.js index 50b6809a979..2b39c18cbb2 100644 --- a/htdocs/fourn/js/lib_dispatch.js +++ b/htdocs/fourn/js/lib_dispatch.js @@ -35,7 +35,7 @@ function addDispatchLine(index, type, mode) console.log("Split line type="+type+" index="+index+" mode="+mode); var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch - qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), + qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qtyDispatched; @@ -74,19 +74,16 @@ function addDispatchLine(index, type, mode) if (mode === 'lessone') { - $("#qty_"+(nbrTrs)+"_"+index).val(qty-1); - $("#qty_"+(nbrTrs-1)+"_"+index).val(1); - } - else - { - $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); - // Store arbitrary data for dispatch qty input field change event - $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); - $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); - $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); - // Update dispatched qty when value dispatch qty input field changed - $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); + qty = 1; // keep 1 in old line + $("#qty_"+(nbrTrs-1)+"_"+index).val(qty); } + $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); + // Store arbitrary data for dispatch qty input field change event + $("#qty_"+(nbrTrs-1)+"_"+index).data('qty', qty); + $("#qty_"+(nbrTrs-1)+"_"+index).data('type', type); + $("#qty_"+(nbrTrs-1)+"_"+index).data('index', index); + // Update dispatched qty when value dispatch qty input field changed + $("#qty_"+(nbrTrs-1)+"_"+index).change(this.onChangeDispatchLineQty); //set focus on lot of new line (if it exists) $("#lot_number_"+(nbrTrs)+"_"+index).focus(); } @@ -95,7 +92,9 @@ function addDispatchLine(index, type, mode) /** * onChangeDispatchLineQty * - * event handler for dispatch qty input field + * Change event handler for dispatch qty input field, + * recalculate qty dispatched when qty input has changed. + * If qty is more then qty ordered reset input qty to max qty to dispatch. * * element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line) */ @@ -113,7 +112,7 @@ function onChangeDispatchLineQty() { qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // qty ordered qtyDispatched = parseFloat($("#qty_dispatched_0_"+index).val()); // qty already dispatched - // console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); + console.log("onChangeDispatchLineQty qtyChanged: " + qtyChanged + " qtyDispatching: " + qtyDispatching + " qtyOrdered: " + qtyOrdered + " qtyDispatched: "+ qtyDispatched); if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) { $("#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged); From 2a76cc6f5434a6839c84d0835dbec57ef43fa9c3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 10 Oct 2017 06:34:16 +0200 Subject: [PATCH 03/21] Fix : missing class AccountingJournal in subscription member page when accountancy not activated --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8002b33b1f6..9bb4565d6c9 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("companies"); $langs->load("bills"); From 913a5d1df2104a18e2c9d45fe034c49a49687cfe Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 07:37:39 +0200 Subject: [PATCH 04/21] Fix: if module is not activated, functionality of module is deactivated! --- htdocs/adherents/subscription.php | 43 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 8002b33b1f6..7c0a0cfe407 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -31,10 +31,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // TODO a lot of dependency on the bank module, but no test if this module is not activated! +if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +} +if (! empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +} $langs->load("companies"); $langs->load("bills"); @@ -859,10 +863,13 @@ if ($rowid > 0) $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->fk_accountancy_journal); + if (! empty($conf->accounting->enabled)) + { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + } $accountstatic->ref=$objp->ref; print $accountstatic->getNomUrl(1); @@ -1093,12 +1100,12 @@ if ($rowid > 0) print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - $prodtmp=new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product - } + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + $prodtmp=new Product($db); + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product + } print '
'; } // Add invoice with payments @@ -1118,12 +1125,12 @@ if ($rowid > 0) print ')'; } if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0); - if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) - { - $prodtmp=new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); - print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product - } + if (! empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + { + $prodtmp=new Product($db); + $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product + } print '
'; } print ''; From 6d5c2bf7b2fe29383d76107d0d19f3c32f7df818 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 07:56:10 +0200 Subject: [PATCH 05/21] Fix: check if module bank activated Conflicts: htdocs/adherents/subscription.php --- htdocs/adherents/class/subscription.class.php | 9 ++--- htdocs/adherents/subscription.php | 30 +++++++------- htdocs/adherents/subscription/card.php | 33 ++++++++-------- htdocs/adherents/subscription/list.php | 39 ++++++++++--------- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 733524e53c0..bdb43dd41d3 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -33,7 +33,7 @@ class Subscription extends CommonObject public $element='subscription'; public $table_element='subscription'; public $picto='payment'; - + var $datec; // Date creation var $datem; // Date modification var $dateh; // Subscription start date (date subscription) @@ -193,12 +193,11 @@ class Subscription extends CommonObject */ function delete($user) { - $accountline=new AccountLine($this->db); - // It subscription is linked to a bank transaction, we get it if ($this->fk_bank > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline=new AccountLine($this->db); $result=$accountline->fetch($this->fk_bank); } @@ -288,7 +287,7 @@ class Subscription extends CommonObject { return ''; } - + /** * Renvoi le libelle d'un statut donne * @@ -301,7 +300,7 @@ class Subscription extends CommonObject $langs->load("members"); return ''; } - + /** * Load information of the subscription object * diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 7c0a0cfe407..2bdbe821105 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2012-2017 Regis Houssin * Copyright (C) 2015-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -32,7 +32,10 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // TODO a lot of dependency on the bank module, but no test if this module is not activated! +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } @@ -823,7 +826,6 @@ if ($rowid > 0) if ($result) { $subscriptionstatic=new Subscription($db); - $accountstatic=new Account($db); $num = $db->num_rows($result); $i = 0; @@ -853,15 +855,17 @@ if ($rowid > 0) print ''.dol_print_date($db->jdate($objp->dateh),'day')."\n"; print ''.dol_print_date($db->jdate($objp->datef),'day')."\n"; print ''.price($objp->subscription).''; - if (! empty($conf->banque->enabled)) - { - print ''; - if ($objp->bid) - { - $accountstatic->label=$objp->label; - $accountstatic->id=$objp->baid; - $accountstatic->number=$objp->number; - $accountstatic->account_number=$objp->account_number; + if (! empty($conf->banque->enabled)) + { + print ''; + if ($objp->bid) + { + $accountstatic=new Account($db); + + $accountstatic->label=$objp->label; + $accountstatic->id=$objp->baid; + $accountstatic->number=$objp->number; + $accountstatic->account_number=$objp->account_number; if (! empty($conf->accounting->enabled)) { diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 3faa45d7d84..3c368c05c9a 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -25,7 +25,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} $langs->load("companies"); $langs->load("bills"); @@ -231,20 +233,20 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') if (! empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''.$langs->trans("BankTransactionLine").''; + { + print ''.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); + $bankline=new AccountLine($db); + $result=$bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1,0,'showall'); } else { print $langs->trans("NoneF"); } - print ''; - } + print ''; + } } print ''; @@ -326,27 +328,26 @@ if ($rowid && $action != 'edit') // Amount print ''.$langs->trans("Label").''.$object->note.''; - // Bank line + // Bank line if (! empty($conf->banque->enabled)) { if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) - { - print ''.$langs->trans("BankTransactionLine").''; + { + print ''.$langs->trans("BankTransactionLine").''; if ($object->fk_bank) { - $bankline=new AccountLine($db); - $result=$bankline->fetch($object->fk_bank); - print $bankline->getNomUrl(1,0,'showall'); + $bankline=new AccountLine($db); + $result=$bankline->fetch($object->fk_bank); + print $bankline->getNomUrl(1,0,'showall'); } else { print $langs->trans("NoneF"); } - print ''; - } + print ''; + } } - print "\n"; print ''; diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 1fee5ac545c..adbc0ea98b6 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -26,7 +26,9 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->banque->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +} $langs->load("members"); @@ -267,7 +269,6 @@ if ($result) // Static objects $subscription=new Subscription($db); $adherent=new Adherent($db); - $accountstatic=new Account($db); $total=0; while ($i < min($num, $limit)) @@ -304,22 +305,24 @@ if ($result) print dol_trunc($obj->note,32); print ''; - // Banque - if (! empty($conf->banque->enabled)) - { - if ($obj->fk_account) - { - $accountstatic->id=$obj->fk_account; - $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print ''.$accountstatic->getNomUrl(1).''; - } - else - { - print ""; - print "\n"; - } - } + // Banque + if (! empty($conf->banque->enabled)) + { + $accountstatic=new Account($db); + + if ($obj->fk_account) + { + $accountstatic->id=$obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print ''.$accountstatic->getNomUrl(1).''; + } + else + { + print ""; + print "\n"; + } + } // Date start print ''.dol_print_date($db->jdate($obj->dateadh),'day')."\n"; From f2ad2055382105d653fa5ecdb0baecc50d8dd716 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Oct 2017 08:07:09 +0200 Subject: [PATCH 06/21] Fix: wrong copy/paste ! --- htdocs/adherents/subscription.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 2bdbe821105..23876545a60 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -35,7 +35,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (! empty($conf->banque->enabled)) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; } -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } From f8771c22149e95e0762128f9364a9d805ac77b8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:39:56 +0200 Subject: [PATCH 07/21] Update list.php --- htdocs/adherents/subscription/list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index adbc0ea98b6..2a839106f05 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -269,6 +269,7 @@ if ($result) // Static objects $subscription=new Subscription($db); $adherent=new Adherent($db); + $accountstatic=new Account($db); $total=0; while ($i < min($num, $limit)) @@ -308,9 +309,7 @@ if ($result) // Banque if (! empty($conf->banque->enabled)) { - $accountstatic=new Account($db); - - if ($obj->fk_account) + if ($obj->fk_account > 0) { $accountstatic->id=$obj->fk_account; $accountstatic->fetch($obj->fk_account); From 7e999603fc2b48e504b478a93867282a4fb56bd7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:40:19 +0200 Subject: [PATCH 08/21] Update list.php --- htdocs/adherents/subscription/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 2a839106f05..e831a4449ab 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -26,9 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; -if (! empty($conf->banque->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("members"); From d59d7887bb9db0c7d05190342bd94ef2c70e8c65 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 11:42:39 +0200 Subject: [PATCH 09/21] Update subscription.php --- htdocs/adherents/subscription.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index e6caae34d6a..36f8968587a 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -32,13 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->banque->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -} -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -} -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("companies"); $langs->load("bills"); @@ -841,6 +837,8 @@ if ($rowid > 0) } print "\n"; + $accountstatic=new Account($db); + while ($i < $num) { $objp = $db->fetch_object($result); @@ -857,8 +855,6 @@ if ($rowid > 0) print ''; if ($objp->bid) { - $accountstatic=new Account($db); - $accountstatic->label=$objp->label; $accountstatic->id=$objp->baid; $accountstatic->number=$objp->number; From 220b37133bb74a37a6d46befc7b994a7f463022a Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Tue, 10 Oct 2017 09:43:03 +0200 Subject: [PATCH 10/21] Wrong test https://github.com/Dolibarr/dolibarr/issues/7604#issuecomment-335387587 --- htdocs/admin/modulehelp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 143ebc627f8..f60f5922160 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -365,7 +365,7 @@ if ($mode == 'desc') if ($mode == 'feature') { $text.='
'.$langs->trans("DependsOn").': '; - if (count($objMod->requiredby)) $text.=join(',', $objMod->depends); + if (count($objMod->depends)) $text.=join(',', $objMod->depends); else $text.=$langs->trans("None"); $text.='
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) $text.=join(',', $objMod->requiredby); From 68ec8ef313580c71fcd0e29b0545f7b8c42367f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 12:05:48 +0200 Subject: [PATCH 11/21] Fix lang missing --- htdocs/fourn/commande/card.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 43ce10ba2f6..03a39f2a5e3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -54,16 +54,7 @@ if (!empty($conf->variants->enabled)) { require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; } -$langs->load('admin'); -$langs->load('orders'); -$langs->load('sendings'); -$langs->load('companies'); -$langs->load('bills'); -$langs->load('propal'); -$langs->load('supplier_proposal'); -$langs->load('deliveries'); -$langs->load('products'); -$langs->load('stocks'); +$langs->loadLangs(array('admin','orders','sendings','companies','bills','propal','supplier_proposal','deliveries','products','stocks','productbatch')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $id = GETPOST('id','int'); From cd814d420b956a4d7c1f9ba06fb992054cf39383 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Oct 2017 16:54:17 +0200 Subject: [PATCH 12/21] Fix repair utf8 mix collation --- htdocs/install/mysql/migration/repair.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 46f75ff0d7f..68671ecd4d7 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -31,6 +31,10 @@ -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_bookkeeping MODIFY numero_compte VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_accounting_journal MODIFY code VARCHAR(20) COLLATE utf8_unicode_ci; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) CHARACTER SET utf8; +-- VMYSQLUTF8UNICODECI ALTER TABLE llx_bank_account MODIFY accountancy_journal VARCHAR(20) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) CHARACTER SET utf8; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_stock_mouvement MODIFY batch VARCHAR(30) COLLATE utf8_unicode_ci; -- VMYSQLUTF8UNICODECI ALTER TABLE llx_product_lot MODIFY batch VARCHAR(30) CHARACTER SET utf8; From 8d3df7ea5751136bc01cdbca4608d16255766475 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 12 Oct 2017 09:59:25 +0200 Subject: [PATCH 13/21] Fix can not distinct which credit note are in select list --- htdocs/core/class/html.form.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 25cdfa2d887..5330ce24048 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1188,12 +1188,17 @@ class Form // On recherche les remises $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source"; + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= ", f.facnumber"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re"; + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture f ON (f.rowid = re.fk_facture_source)"; $sql.= " WHERE re.fk_soc = ".(int) $socid; $sql.= " AND re.entity = " . $conf->entity; if ($filter) $sql.= " AND ".$filter; $sql.= " ORDER BY re.description ASC"; + // Prevent sql error on the ambiguous column + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql = preg_replace('/(.*)(?!re\.)fk_facture_source(.*)/m', '\1 re.fk_facture_source \2', $sql); + dol_syslog(get_class($this)."::select_remises", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1225,6 +1230,8 @@ class Form $disabled=' disabled'; } + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->facnumber)) $desc=$desc.' - '.$obj->facnumber; + print ''; $i++; } From 2fd0ffbfec8958ac66dce877ed9028e18e616598 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 Oct 2017 14:50:25 +0200 Subject: [PATCH 14/21] Fix tz for date creation/update --- htdocs/projet/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 5d0af329952..6eaf231a5cb 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -846,7 +846,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.datec']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; if (! $i) $totalarray['nbfield']++; } @@ -854,7 +854,7 @@ while ($i < min($num,$limit)) if (! empty($arrayfields['p.tms']['checked'])) { print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); print ''; if (! $i) $totalarray['nbfield']++; } From 558f261b604a196bad04f7a6cc7d1b3c9b09ce33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 01:03:33 +0200 Subject: [PATCH 15/21] FIX #7593 --- htdocs/comm/remx.php | 2 +- htdocs/compta/facture/card.php | 12 ++++++------ htdocs/core/class/discount.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 17 ++++++++++++++--- htdocs/langs/en_US/companies.lang | 1 + 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 94142b6ec54..17e2feb4a84 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -389,7 +389,7 @@ if ($socid > 0) $facturestatic->id=$obj->fk_facture_source; $facturestatic->ref=$obj->ref; $facturestatic->type=$obj->type; - print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("Invoice"),$obj->description).' '.$facturestatic->getNomURl(1); + print preg_replace('/\(EXCESS RECEIVED\)/',$langs->trans("ExcessReceived"),$obj->description).' '.$facturestatic->getNomURl(1); print ''; } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1d621d153f5..9c0aff43abf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2843,12 +2843,12 @@ else if ($id > 0 || ! empty($ref)) $resteapayer = 0; $resteapayeraffiche = $resteapayer; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice } else { - $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%'))"; - $filtercreditnote = "fk_facture_source IS NOT NULL AND description NOT LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'"; + $filterabsolutediscount = "fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'))"; + $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); @@ -2871,9 +2871,9 @@ else if ($id > 0 || ! empty($ref)) // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { - if($object->type == 0) $type_fac = 'ExcessReceived'; - elseif($object->type == 2) $type_fac = 'CreditNote'; - elseif($object->type == 3) $type_fac = 'Deposit'; + if($object->type == Facture::TYPE_STANDARD) $type_fac = 'ExcessReceived'; + elseif($object->type == Facture::TYPE_CREDIT_NOTE) $type_fac = 'CreditNote'; + elseif($object->type == Facture::TYPE_DEPOSIT) $type_fac = 'Deposit'; $text = $langs->trans('ConfirmConvertToReduc', strtolower($langs->transnoentities($type_fac))); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('ConvertToReduc'), $text, 'confirm_converttoreduc', '', "yes", 2); } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 89bb230d34f..bef86a320ab 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -445,14 +445,14 @@ class DiscountAbsolute $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql.= ' AND f.type = 2'; + $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received } else if ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql.= ' AND f.type = 2'; + $sql.= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received } else { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 25cdfa2d887..05b976ad4d2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4153,15 +4153,26 @@ class Form print ''; print ''; print '
'; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) // Never use this option. { if (! $filter || $filter=="fk_facture_source IS NULL") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); // If we want deposit to be substracted to payments only and not to total of final invoice else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); } else { - if (! $filter || $filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%'))") print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); - else print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); + if (! $filter) + { + print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); + } + elseif ($filter=="fk_facture_source IS NULL OR (fk_facture_source IS NOT NULL AND (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%'))") + { + // Replace trans key with CompanyHasDownPaymentOrCommercialDiscount + print $langs->trans("CompanyHasAbsoluteDiscount",price($amount,0,$langs,0,0,-1,$conf->currency)); + } + else + { + print $langs->trans("CompanyHasCreditNote",price($amount,0,$langs,0,0,-1,$conf->currency)); + } } if (empty($hidelist)) print ': '; print '
'; diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index bd7d7983191..2be010b8803 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -265,6 +265,7 @@ CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% CompanyHasNoRelativeDiscount=This customer has no relative discount by default CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for %s %s +CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for %s %s CompanyHasCreditNote=This customer still has credit notes for %s %s CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users) From c3ada198927600fad1a7009551155a48f23d5ac1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 01:27:49 +0200 Subject: [PATCH 16/21] Fix demo backup --- dev/initdemo/savedemo.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/initdemo/savedemo.sh b/dev/initdemo/savedemo.sh index fd3f8caafd5..20aebb29b28 100755 --- a/dev/initdemo/savedemo.sh +++ b/dev/initdemo/savedemo.sh @@ -187,6 +187,7 @@ export list=" --ignore-table=$base.llx_bt_webseedfiles --ignore-table=$base.llx_c_civilite --ignore-table=$base.llx_c_dolicloud_plans + --ignore-table=$base.llx_c_pays --ignore-table=$base.llx_c_source --ignore-table=$base.llx_cabinetmed_c_banques --ignore-table=$base.llx_cabinetmed_c_ccam From 857b59409c832ca1b3e6b49a6b8a0f50a3093d09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 01:50:00 +0200 Subject: [PATCH 17/21] FIX sql syntax error because of old field accountancy_journal --- htdocs/compta/charges/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index e048de2deb7..c9a58670897 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -135,7 +135,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql.= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; $sql.= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; $sql.= " ".MAIN_DB_PREFIX."chargesociales as cs"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid"; @@ -256,7 +256,7 @@ if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.fk_bank,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as pv"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON pv.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; @@ -470,7 +470,7 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, s.fk_bank, u.salary as current_salary,"; $sql.= " pct.code as payment_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.accountancy_journal, ba.label as blabel"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; From 647c4036cf105436048febbefd391702193fd845 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 13 Oct 2017 09:21:37 +0200 Subject: [PATCH 18/21] Fix simplification of code --- htdocs/core/class/html.form.class.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5330ce24048..8de5ba47ceb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1188,17 +1188,12 @@ class Form // On recherche les remises $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source"; - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= ", f.facnumber"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re"; - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture f ON (f.rowid = re.fk_facture_source)"; $sql.= " WHERE re.fk_soc = ".(int) $socid; $sql.= " AND re.entity = " . $conf->entity; if ($filter) $sql.= " AND ".$filter; $sql.= " ORDER BY re.description ASC"; - // Prevent sql error on the ambiguous column - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST)) $sql = preg_replace('/(.*)(?!re\.)fk_facture_source(.*)/m', '\1 re.fk_facture_source \2', $sql); - dol_syslog(get_class($this)."::select_remises", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1230,7 +1225,11 @@ class Form $disabled=' disabled'; } - if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->facnumber)) $desc=$desc.' - '.$obj->facnumber; + if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) + { + $tmpfac = new Facture($this->db); + if ($tmpfac->fetch($obj->fk_facture_source) > 0) $desc=$desc.' - '.$tmpfac->ref; + } print ''; $i++; From 5f021990b4769739fe61c90a1084a0394e8e655f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 17:44:31 +0200 Subject: [PATCH 19/21] Code comment --- htdocs/user/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index eeb1e898736..4902e0b6de0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1412,9 +1412,13 @@ else print ''; print "\n"; + //$childids = $user->getAllChildIds(1); + if ((! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->hrm->enabled) && ! empty($user->rights->hrm->employee->read))) { + // Even a superior can't see this info of its subordinates wihtout $user->rights->salaries->read and $user->rights->hrm->employee->read (setting/viewing is reserverd to HR people). + // However, he can see the valuation of timesheet of its subordinates even without these permissions. $langs->load("salaries"); // THM From 807724e0f0f18a04c789e9bb1d85633c9b89cfc5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 19:51:36 +0200 Subject: [PATCH 20/21] Add link other invoices of third party on supplier card to --- htdocs/fourn/facture/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ca9689292b4..c0e8ce23c4b 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2028,6 +2028,7 @@ else $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->facture->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherBills").')'; // Project if (! empty($conf->projet->enabled)) { From 5a4480bd1d57940b09166b44ce5d0016d5af4c06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Oct 2017 21:25:27 +0200 Subject: [PATCH 21/21] Fix navigation on bank receipts --- htdocs/compta/bank/releve.php | 120 ++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ec61c39ee84..efa7c03f89b 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -47,10 +47,11 @@ $langs->load("companies"); $langs->load("bills"); $action=GETPOST('action', 'alpha'); -$id=GETPOST('account'); -$ref=GETPOST('ref'); -$dvid=GETPOST('dvid'); -$numref=GETPOST('num'); +$id=GETPOST('account','int'); +$ref=GETPOST('ref','alpha'); +$dvid=GETPOST('dvid','alpha'); +$numref=GETPOST('num','alpha'); +$ve=GETPOST("ve",'alpha'); // Security check $fieldid = (! empty($ref)?$ref:$id); @@ -95,6 +96,62 @@ if ($id > 0 || ! empty($ref)) // Initialize technical object to manage context to save list fields $contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); + +// Define number of receipt to show (current, previous or next one ?) +$found=false; +if ($_GET["rel"] == 'prev') +{ + // Recherche valeur pour num = numero releve precedent + $sql = "SELECT DISTINCT(b.num_releve) as num"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; + $sql.= " AND b.fk_account = ".$object->id; + $sql.= " ORDER BY b.num_releve DESC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found=true; + } + } +} +elseif ($_GET["rel"] == 'next') +{ + // Recherche valeur pour num = numero releve precedent + $sql = "SELECT DISTINCT(b.num_releve) as num"; + $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; + $sql.= " AND b.fk_account = ".$object->id; + $sql.= " ORDER BY b.num_releve ASC"; + + dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $numrows = $db->num_rows($resql); + if ($numrows > 0) + { + $obj = $db->fetch_object($resql); + $numref = $obj->num; + $found=true; + } + } +} +else { + // On veut le releve num + $found=true; +} + + + + + $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,"; $sql.= " b.fk_bordereau,"; @@ -104,7 +161,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql.= ", ".MAIN_DB_PREFIX."bank as b"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; $sql.= " WHERE b.num_releve='".$db->escape($numref)."'"; -if (!isset($numref)) $sql.= " OR b.num_releve is null"; +if (empty($numref)) $sql.= " OR b.num_releve is null"; $sql.= " AND b.fk_account = ".$object->id; $sql.= " AND b.fk_account = ba.rowid"; $sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day @@ -420,58 +477,6 @@ else /** * Show list of bank statements */ - $ve=$_GET["ve"]; - - // Define number of receipt to show (current, previous or next one ?) - $found=false; - if ($_GET["rel"] == 'prev') - { - // Recherche valeur pour num = numero releve precedent - $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve < '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve DESC"; - - dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - if ($numrows > 0) - { - $obj = $db->fetch_object($resql); - $numref = $obj->num; - $found=true; - } - } - } - elseif ($_GET["rel"] == 'next') - { - // Recherche valeur pour num = numero releve precedent - $sql = "SELECT DISTINCT(b.num_releve) as num"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= " WHERE b.num_releve > '".$db->escape($numref)."'"; - $sql.= " AND b.fk_account = ".$object->id; - $sql.= " ORDER BY b.num_releve ASC"; - - dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) - { - $numrows = $db->num_rows($resql); - if ($numrows > 0) - { - $obj = $db->fetch_object($resql); - $numref = $obj->num; - $found=true; - } - } - } - else { - // On veut le releve num - $found=true; - } $mesprevnext=''; $mesprevnext.='