diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index bc3762b41ea..2b181e52078 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -29,11 +29,14 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
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';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
+require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
if (!$user->rights->facture->lire) accessforbidden();
@@ -44,14 +47,18 @@ $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); //
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'alpha');
-
$type = GETPOST('type', 'aZ09');
+$mode = GETPOST('mode', 'aZ09');
$fieldid = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);
-$object = new Facture($db);
+if ($mode == 'bank-transfer') {
+ $object = new FactureFournisseur($db);
+} else {
+ $object = new Facture($db);
+}
// Load object
if ($id > 0 || !empty($ref))
@@ -124,13 +131,20 @@ if (empty($reshook))
* View
*/
+$form = new Form($db);
+
$now = dol_now();
-$title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('StandingOrders');
-$helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
+if ($mode == 'bank-transfer') {
+ $title = $langs->trans('InvoiceSupplier')." - ".$langs->trans('CreditTransfer');
+ $helpurl = "";
+} else {
+ $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('StandingOrders');
+ $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
+}
+
llxHeader('', $title, $helpurl);
-$form = new Form($db);
/* *************************************************************************** */
/* */
@@ -156,18 +170,33 @@ if ($object->id > 0)
if ($object->paye) $resteapayer = 0;
$resteapayeraffiche = $resteapayer;
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $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 (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)%')";
- }
+ if ($mode == 'bank-transfer') {
+ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this
+ $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
+ } else {
+ $filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
+ $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
+ }
- $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount);
- $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote);
- $absolute_discount = price2num($absolute_discount, 'MT');
- $absolute_creditnote = price2num($absolute_creditnote, 'MT');
+ $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
+ $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote, 0, 1);
+ $absolute_discount = price2num($absolute_discount, 'MT');
+ $absolute_creditnote = price2num($absolute_creditnote, 'MT');
+ } else {
+ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
+ $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 (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 = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount);
+ $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote);
+ $absolute_discount = price2num($absolute_discount, 'MT');
+ $absolute_creditnote = price2num($absolute_creditnote, 'MT');
+ }
$author = new User($db);
if ($object->user_author)
@@ -175,20 +204,37 @@ if ($object->id > 0)
$author->fetch($object->user_author);
}
- $head = facture_prepare_head($object);
+ if ($mode == 'bank-transfer') {
+ $head = facturefourn_prepare_head($object);
+ } else {
+ $head = facture_prepare_head($object);
+ }
- dol_fiche_head($head, 'standingorders', $langs->trans('InvoiceCustomer'), -1, 'bill');
+ dol_fiche_head($head, 'standingorders', $title, -1, 'bill');
// Invoice content
-
- $linkback = ''.$langs->trans("BackToList").'';
+ if ($mode == 'bank-transfer') {
+ $linkback = ''.$langs->trans("BackToList").'';
+ } else {
+ $linkback = ''.$langs->trans("BackToList").'';
+ }
$morehtmlref = '
';
// Ref customer
- $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
- $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ if ($mode == 'bank-transfer') {
+ $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
+ } else {
+ $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
+ $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
+ }
// Thirdparty
$morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+ if ($mode == 'bank-transfer') {
+ if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (
'.$langs->trans("OtherBills").')';
+ } else {
+ if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (
'.$langs->trans("OtherBills").')';
+ }
// Project
if (!empty($conf->projet->enabled))
{
@@ -239,15 +285,26 @@ if ($object->id > 0)
// Type
print '
| '.$langs->trans('Type').' | ';
print $object->getLibType();
- if ($object->type == Facture::TYPE_REPLACEMENT)
+ if ($object->module_source) {
+ print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')';
+ }
+ if ($object->type == $object::TYPE_REPLACEMENT)
{
- $facreplaced = new Facture($db);
+ if ($mode == 'bank-transfer') {
+ $facreplaced = new FactureFournisseur($db);
+ } else {
+ $facreplaced = new Facture($db);
+ }
$facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')';
}
- if ($object->type == Facture::TYPE_CREDIT_NOTE)
+ if ($object->type == $object::TYPE_CREDIT_NOTE)
{
- $facusing = new Facture($db);
+ if ($mode == 'bank-transfer') {
+ $facusing = new FactureFournisseur($db);
+ } else {
+ $facusing = new Facture($db);
+ }
$facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')';
}
@@ -261,7 +318,11 @@ if ($object->id > 0)
{
if ($i == 0) print ' ';
else print ',';
- $facavoir = new Facture($db);
+ if ($mode == 'bank-transfer') {
+ $facavoir = new FactureFournisseur($db);
+ } else {
+ $facavoir = new Facture($db);
+ }
$facavoir->fetch($id);
print $facavoir->getNomUrl(1);
}
@@ -280,24 +341,39 @@ if ($object->id > 0)
// Discounts
print ' |
| '.$langs->trans('Discounts').' | ';
- $thirdparty = $object->thirdparty;
- $discount_type = 0;
+ if ($mode == 'bank-transfer') {
+ //$societe = new Fournisseur($db);
+ //$result = $societe->fetch($object->socid);
+ $thirdparty = $object->thirdparty;
+ $discount_type = 1;
+ } else {
+ $thirdparty = $object->thirdparty;
+ $discount_type = 0;
+ }
$backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id);
$cannotApplyDiscount = 1;
include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
print ' |
';
+ // Label
+ if ($mode == 'bank-transfer') {
+ print '
';
+ print '| '.$form->editfieldkey("Label", 'label', $object->label, $object, 0).' | ';
+ print ''.$form->editfieldval("Label", 'label', $object->label, $object, 0).' | ';
+ print '
';
+ }
+
// Date invoice
print '
| ';
print '';
print ' | ';
- if ($object->type != Facture::TYPE_CREDIT_NOTE)
+ if ($object->type != $object::TYPE_CREDIT_NOTE)
{
if ($action == 'editinvoicedate')
{
@@ -305,12 +381,12 @@ if ($object->id > 0)
}
else
{
- print dol_print_date($object->date, 'daytext');
+ print dol_print_date($object->date, 'day');
}
}
else
{
- print dol_print_date($object->date, 'daytext');
+ print dol_print_date($object->date, 'day');
}
print ' | ';
print '
';
@@ -320,10 +396,10 @@ if ($object->id > 0)
print '
';
print '
';
- if ($object->type != Facture::TYPE_CREDIT_NOTE)
+ if ($object->type != $object::TYPE_CREDIT_NOTE)
{
if ($action == 'editconditions')
{
@@ -345,18 +421,23 @@ if ($object->id > 0)
print '';
print ' | ';
- if ($object->type != Facture::TYPE_CREDIT_NOTE)
+ if ($object->type != $object::TYPE_CREDIT_NOTE)
{
+ $duedate = $object->date_lim_reglement;
+ if ($mode == 'bank-transfer') {
+ $duedate = $object->date_echeance;
+ }
+
if ($action == 'editpaymentterm')
{
- $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date_lim_reglement, 'paymentterm');
+ $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm');
}
else
{
- print dol_print_date($object->date_lim_reglement, 'daytext');
+ print dol_print_date($duedate, 'day');
if ($object->hasDelay()) {
print img_warning($langs->trans('Late'));
}
@@ -559,8 +640,13 @@ if ($object->id > 0)
print "\n \n";
- print ''.$langs->trans("DoStandingOrdersBeforePayments").' ';
-
+ if ($mode == 'bank-transfer') {
+ print ''.$langs->trans("DoCreditTransferBeforePayments").' ';
+ } else {
+ print ''.$langs->trans("DoStandingOrdersBeforePayments").' ';
+ }
/*
* Withdrawals
@@ -614,7 +703,11 @@ if ($object->id > 0)
print ' | '.$langs->trans("DateRequest").' | ';
print '
'.$langs->trans("User").' | ';
print '
'.$langs->trans("Amount").' | ';
- print '
'.$langs->trans("WithdrawalReceipt").' | ';
+ if ($mode == 'bank-transfer') {
+ print '
'.$langs->trans("BankTransferReceipt").' | ';
+ } else {
+ print '
'.$langs->trans("WithdrawalReceipt").' | ';
+ }
print '
| ';
print '
'.$langs->trans("DateProcess").' | ';
print '
| ';
diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php
index 3b41f2620b4..8d0e767c943 100644
--- a/htdocs/core/lib/fourn.lib.php
+++ b/htdocs/core/lib/fourn.lib.php
@@ -53,6 +53,28 @@ function facturefourn_prepare_head($object)
$h++;
}
+ //if ($fac->mode_reglement_code == 'PRE')
+ if (!empty($conf->paymentbybanktransfer->enabled))
+ {
+ $nbStandingOrders = 0;
+ $sql = "SELECT COUNT(pfd.rowid) as nb";
+ $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
+ $sql .= " WHERE pfd.fk_facture_fourn = ".$object->id;
+ $sql .= " AND pfd.ext_payment_id IS NULL";
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj) $nbStandingOrders = $obj->nb;
+ }
+ else dol_print_error($db);
+ $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$object->id.'&mode=bank-transfer';
+ $head[$h][1] = $langs->trans('BankTransfer');
+ if ($nbStandingOrders > 0) $head[$h][1] .= '
'.$nbStandingOrders.'';
+ $head[$h][2] = 'standingorders';
+ $h++;
+ }
+
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index f081fc94120..077176c6ff9 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -55,7 +55,6 @@ function facture_prepare_head($object)
$h++;
}
- //if ($fac->mode_reglement_code == 'PRE')
if (!empty($conf->prelevement->enabled))
{
$nbStandingOrders = 0;
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index a5f15e997de..2113d7ebb12 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -2559,14 +2559,6 @@ else
// Date
print '
| '.$form->editfieldkey("DateInvoice", 'datef', $object->datep, $object, $form_permission, 'datepicker').' | ';
print $form->editfieldval("Date", 'datef', $object->datep, $object, $form_permission, 'datepicker');
- print ' | ';
-
- // Due date
- print '
| '.$form->editfieldkey("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission, 'datepicker').' | ';
- print $form->editfieldval("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission, 'datepicker');
- if ($action != 'editdate_lim_reglement' && $object->hasDelay()) {
- print img_warning($langs->trans('Late'));
- }
print ' | ';
// Default terms of the settlement
@@ -2591,6 +2583,14 @@ else
print "";
print '
';
+ // Due date
+ print '
| '.$form->editfieldkey("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission, 'datepicker').' | ';
+ print $form->editfieldval("DateMaxPayment", 'date_lim_reglement', $object->date_echeance, $object, $form_permission, 'datepicker');
+ if ($action != 'editdate_lim_reglement' && $object->hasDelay()) {
+ print img_warning($langs->trans('Late'));
+ }
+ print ' | ';
+
// Mode of payment
$langs->load('bills');
print '
';
diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php
index ebe3573bd99..eca47acaef5 100644
--- a/htdocs/fourn/facture/contact.php
+++ b/htdocs/fourn/facture/contact.php
@@ -193,7 +193,7 @@ if ($id > 0 || !empty($ref))
print '';
print ' ';
- print ' ';
+ print '';
// Type
print '| '.$langs->trans('Type').' | ';
diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql
index 8c50964eb59..f335a93cfeb 100644
--- a/htdocs/install/mysql/tables/llx_actioncomm.sql
+++ b/htdocs/install/mysql/tables/llx_actioncomm.sql
@@ -17,7 +17,8 @@
-- along with this program. If not, see .
--
--
--- Actions commerciales
+-- Table of events and actions (past and to do).
+-- This is also the table to track events on other Dolibarr objects.
-- ========================================================================
create table llx_actioncomm
@@ -40,7 +41,7 @@ create table llx_actioncomm
fk_soc integer,
fk_contact integer,
fk_parent integer NOT NULL default 0,
- fk_user_action integer, -- user id of owner of action (note that users assigned to event are stored into another table)
+ fk_user_action integer, -- user id of owner of action (note that users assigned to event are stored into table 'actioncomm_resources')
fk_user_done integer, -- user id of user that has made action (deprecated)
transparency integer, -- transparency (ical standard). used to say if user assigned to event are busy or not by event. This field may be deprecated if we want to store transparency for each assigned user, moved into table llx_actioncomm_resources.
diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang
index 17ebc2ff7ed..7a36346733f 100644
--- a/htdocs/langs/en_US/banks.lang
+++ b/htdocs/langs/en_US/banks.lang
@@ -105,8 +105,8 @@ SupplierInvoicePayment=Vendor payment
SubscriptionPayment=Subscription payment
WithdrawalPayment=Debit payment order
SocialContributionPayment=Social/fiscal tax payment
-BankTransfer=Bank transfer
-BankTransfers=Bank transfers
+BankTransfer=Credit transfer
+BankTransfers=Credit transfers
MenuBankInternalTransfer=Internal transfer
TransferDesc=Transfer from one account to another, Dolibarr will write two records (a debit in source account and a credit in target account). The same amount (except sign), label and date will be used for this transaction)
TransferFrom=From
diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang
index c80db907a84..bea89f1d5d0 100644
--- a/htdocs/langs/en_US/withdrawals.lang
+++ b/htdocs/langs/en_US/withdrawals.lang
@@ -40,6 +40,7 @@ CreditTransferStatistics=Credit transfer statistics
Rejects=Rejects
LastWithdrawalReceipt=Latest %s direct debit receipts
MakeWithdrawRequest=Make a direct debit payment request
+MakeBankTransferOrder=Make a credit transfer request
WithdrawRequestsDone=%s direct debit payment requests recorded
ThirdPartyBankCode=Third-party bank code
NoInvoiceCouldBeWithdrawed=No invoice debited successfully. Check that invoices are on companies with a valid IBAN and that IBAN has a UMR (Unique Mandate Reference) with mode %s.
@@ -93,6 +94,7 @@ WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your cou
ShowWithdraw=Show Direct Debit Order
IfInvoiceNeedOnWithdrawPaymentWontBeClosed=However, if invoice has at least one direct debit payment order not yet processed, it won't be set as paid to allow prior withdrawal management.
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.
+DoCreditTransferBeforePayments=This tab allows you to request a credit transfer order. Once done, go into menu Bank->Credit transfer orders to manage the credit transfer 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 on invoices and will classify them as "Paid" if remain to pay is null
@@ -103,6 +105,7 @@ RUMLong=Unique Mandate Reference
RUMWillBeGenerated=If empty, a UMR (Unique Mandate Reference) will be generated once the bank account information is saved.
WithdrawMode=Direct debit mode (FRST or RECUR)
WithdrawRequestAmount=Amount of Direct debit request:
+BankTransferAmount=Amount of Credit Transfer request:
WithdrawRequestErrorNilAmount=Unable to create direct debit request for empty amount.
SepaMandate=SEPA Direct Debit Mandate
SepaMandateShort=SEPA Mandate
| |