diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index fddd0ee2493..9f000786b7f 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -1067,12 +1067,12 @@ if ($action == 'create') {
if ($conf->prelevement->enabled) {
print '
| '.$langs->trans("BankAccountDomiciliation").' | ';
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index 42bf73eaae6..3f00a4f0660 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -45,9 +45,12 @@ $type = GETPOST('type', 'aZ09');
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
+
$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
$format = GETPOST('format', 'aZ09');
$id_bankaccount = GETPOST('id_bankaccount', 'int');
+$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
@@ -67,6 +70,8 @@ if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
}
+$error = 0;
+
/*
* Actions
@@ -92,8 +97,10 @@ if (empty($reshook)) {
if ($action == 'create') {
$default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
- if ($id_bankaccount != $conf->global->{$default_account}) {
- $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); //Set as default
+ //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit;
+
+ if ($id_bankaccount != $conf->global->$default_account) {
+ $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default
}
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -104,44 +111,39 @@ if (empty($reshook)) {
) {
$errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}'));
setEventMessages($errormessage, null, 'errors');
- header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php');
- exit;
+ $action = '';
+ $error++;
}
- $delayindays = 0;
- if ($type != 'bank-transfer') {
- $delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
- } else {
- $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
- }
$bprev = new BonPrelevement($db);
- $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
- // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
- $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
- if ($result < 0) {
- setEventMessages($bprev->error, $bprev->errors, 'errors');
- } elseif ($result == 0) {
- $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
- setEventMessages($mesg, null, 'errors');
- $mesg .= ' '."\n";
- foreach ($bprev->invoice_in_error as $key => $val) {
- $mesg .= ''.$val." \n";
- }
- } else {
- if ($type != 'bank-transfer') {
- $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}');
- $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
- setEventMessages($texttoshow, null);
+ if (!$error) {
+ // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
+ $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
+ if ($result < 0) {
+ setEventMessages($bprev->error, $bprev->errors, 'errors');
+ } elseif ($result == 0) {
+ $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
+ setEventMessages($mesg, null, 'errors');
+ $mesg .= ' '."\n";
+ foreach ($bprev->invoice_in_error as $key => $val) {
+ $mesg .= ''.$val." \n";
+ }
} else {
- $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}');
- $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
- setEventMessages($texttoshow, null);
- }
+ if ($type != 'bank-transfer') {
+ $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}');
+ $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
+ setEventMessages($texttoshow, null);
+ } else {
+ $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}');
+ $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
+ setEventMessages($texttoshow, null);
+ }
- header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id);
- exit;
+ header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type));
+ exit;
+ }
}
}
$objectclass = "BonPrelevement";
@@ -250,11 +252,25 @@ if ($nb) {
}
print $title;
print img_picto('', 'bank_account');
- print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1);
+
+ $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
+
+ print $form->select_comptes($conf->global->$default_account, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1);
print ' - ';
+ if (empty($executiondate)) {
+ $delayindays = 0;
+ if ($type != 'bank-transfer') {
+ $delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
+ } else {
+ $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
+ }
+
+ $executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd');
+ }
+
print $langs->trans('ExecutionDate').' ';
- $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+ $datere = $executiondate;
print $form->selectDate($datere, 're');
@@ -276,7 +292,8 @@ if ($nb) {
if ($type == 'bank-transfer') {
$title = $langs->trans("CreateFileForPaymentByBankTransfer");
}
- print ''.$title."\n";
+ print ''."\n";
+ print ''."\n";
}
} else {
if ($mysoc->isInEEC()) {
diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang
index a3773a427a1..7b18c1a0d70 100644
--- a/htdocs/langs/en_US/withdrawals.lang
+++ b/htdocs/langs/en_US/withdrawals.lang
@@ -80,7 +80,7 @@ StatusMotif7=Judicial Decision
StatusMotif8=Other reason
CreateForSepaFRST=Create direct debit file (SEPA FRST)
CreateForSepaRCUR=Create direct debit file (SEPA RCUR)
-CreateAll=Create direct debit file (all)
+CreateAll=Create direct debit file
CreateFileForPaymentByBankTransfer=Create file for credit transfer
CreateSepaFileForPaymentByBankTransfer=Create credit transfer file (SEPA)
CreateGuichet=Only office
|