From 975300b90bb8e40eb52895d29f0c244c20dafe07 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Sat, 10 Mar 2018 11:23:35 +0100 Subject: [PATCH] Add execution date on prelevement --- .../class/bonprelevement.class.php | 14 ++++++--- htdocs/compta/prelevement/create.php | 31 ++++++++++--------- htdocs/langs/en_US/withdrawals.lang | 4 +++ 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index e2517bdfada..f720d088b6d 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014-2016 Ferran Marcet + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -760,9 +761,10 @@ class BonPrelevement extends CommonObject * @param int $agence dolibarr mysoc bank office (guichet) * @param string $mode real=do action, simu=test only * @param string $format FRST, RCUR or ALL + * @param string $executiondate * @return int <0 if KO, nbre of invoice withdrawed if OK */ - function Create($banque=0, $agence=0, $mode='real', $format='ALL') + function Create($banque=0, $agence=0, $mode='real', $format='ALL',$executiondate='') { global $conf,$langs; @@ -776,6 +778,8 @@ class BonPrelevement extends CommonObject $error = 0; $datetimeprev = time(); + //Choice the date of the execution direct debit + if(!empty($executiondate)) $datetimeprev = $executiondate; $month = strftime("%m", $datetimeprev); $year = strftime("%Y", $datetimeprev); @@ -1077,7 +1081,7 @@ class BonPrelevement extends CommonObject $this->factures = $factures_prev_id; // Generation of SEPA file $this->filename - $this->generate($format); + $this->generate($format,$executiondate); } dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG); } @@ -1276,7 +1280,7 @@ class BonPrelevement extends CommonObject * @param string $format FRST, RCUR or ALL * @return int 0 if OK, <0 if KO */ - function generate($format='ALL') + function generate($format='ALL',$executiondate='') { global $conf,$langs,$mysoc; @@ -1306,9 +1310,11 @@ class BonPrelevement extends CommonObject // SEPA Initialisation $CrLf = "\n"; $date_actu = dol_now(); + $dateTime_ECMA = dol_print_date($date_actu, '%Y-%m-%dT%H:%M:%S'); + + if(!empty($executiondate)) $date_actu=$executiondate; $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); - $dateTime_ECMA = dol_print_date($date_actu, '%Y-%m-%dT%H:%M:%S'); $fileDebiteurSection = ''; $fileEmetteurSection = ''; $i = 0; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index cd3aebf62f4..c94a786917f 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -3,6 +3,7 @@ * Copyright (C) 2010-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -65,7 +66,9 @@ if ($action == 'create') { // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty $bprev = new BonPrelevement($db); - $result=$bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format); + $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format,$executiondate); if ($result < 0) { setEventMessages($bprev->error, $bprev->errors, 'errors'); @@ -90,6 +93,7 @@ if ($action == 'create') /* * View */ +$form = new Form($db); $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); @@ -144,23 +148,22 @@ print ''; if ($mesg) print $mesg; print "
\n"; +print '
'; +print ''; +if ($nb) { + if ($pricetowithdraw) { + print $langs->trans('ExecutionDate').' '; + print $form->select_date(); + if ($mysoc->isInEEC()) { + print ''; + print ''; + } else { + print '' . $langs->trans("CreateAll") . "\n"; + } -if ($nb) -{ - if ($pricetowithdraw) - { - if ($mysoc->isInEEC()) - { - print ''.$langs->trans("CreateForSepaFRST")."\n"; - print ''.$langs->trans("CreateForSepaRCUR")."\n"; } else { - print ''.$langs->trans("CreateAll")."\n"; - } - } - else - { if ($mysoc->isInEEC()) { print ''.$langs->trans("CreateForSepaFRST")."\n"; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 7b33ad15947..8dd4e573e37 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -98,6 +98,10 @@ ModeFRST=One-off payment PleaseCheckOne=Please check one only DirectDebitOrderCreated=Direct debit order %s created AmountRequested=Amount requested +SEPARCUR=SEPA CUR +SEPAFRST=SEPA FRST +ExecutionDate=Execution date +CreateForSepa=Create direct debit file ### Notifications InfoCreditSubject=Payment of direct debit payment order %s by the bank