dolibarr 24.0.0-beta
paymentbybanktransfer.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2019 Markus Welters <markus@welters.de>
7 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
36
45// Load translation files required by the page
46$langs->loadLangs(array("admin", "withdrawals"));
47
48// Security check
49if (!$user->admin) {
51}
52
53$action = GETPOST('action', 'aZ09');
54$type = 'paymentorder';
55
56
57/*
58 * Actions
59 */
60$error = 0;
61
62if ($action == "set") {
63 $db->begin();
64
65 $id = GETPOSTINT('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT');
66 $account = new Account($db);
67 if ($account->fetch($id) > 0) {
68 $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT", $id, 'chaine', 0, '', $conf->entity);
69 if (!($res > 0)) {
70 $error++;
71 }
72 /*
73 $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
74 if (! $res > 0) $error++;
75 $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
76 if (! $res > 0) $error++;
77 $res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity);
78 if (! $res > 0) $error++;
79 $res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity);
80 if (! $res > 0) $error++;
81 $res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity);
82 if (! $res > 0) $error++;
83 $res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity);
84 if (! $res > 0) $error++;
85 $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->owner_address,'chaine',0,'',$conf->entity);
86 if (! $res > 0) $error++;
87 */
88 } else {
89 $error++;
90 }
91 /* Moved to account
92 $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ICS", GETPOST("PAYMENTBYBANKTRANSFER_ICS"), 'chaine', 0, '', $conf->entity);
93 if (!($res > 0)) $error++;
94 */
95
96 if (GETPOST("PAYMENTBYBANKTRANSFER_USER") > 0) {
97 $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USER", GETPOST("PAYMENTBYBANKTRANSFER_USER"), 'chaine', 0, '', $conf->entity);
98 if (!($res > 0)) {
99 $error++;
100 }
101 }
102 /*
103 if (GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END") || GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END") == "")
104 {
105 $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_END_TO_END", GETPOST("PAYMENTBYBANKTRANSFER_END_TO_END"), 'chaine', 0, '', $conf->entity);
106 if (!($res > 0)) $error++;
107 }
108 if (GETPOST("PAYMENTBYBANKTRANSFER_USTRD") || GETPOST("PAYMENTBYBANKTRANSFER_USTRD") == "")
109 {
110 $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_USTRD", GETPOST("PAYMENTBYBANKTRANSFER_USTRD"), 'chaine', 0, '', $conf->entity);
111 if (!($res > 0)) $error++;
112 }
113 */
114 if (GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS") !== null && GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS") !== '') {
115 $res = dolibarr_set_const($db, "PAYMENTBYBANKTRANSFER_ADDDAYS", GETPOST("PAYMENTBYBANKTRANSFER_ADDDAYS"), 'chaine', 0, '', $conf->entity);
116 if (!($res > 0)) {
117 $error++;
118 }
119 }
120
121 if (!$error) {
122 $db->commit();
123 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
124 } else {
125 $db->rollback();
126 setEventMessages($langs->trans("Error"), null, 'errors');
127 }
128}
129
130if ($action == "addnotif") {
131 $bon = new BonPrelevement($db);
132 $bon->addNotification($db, GETPOSTINT('user'), $action);
133
134 header("Location: ".$_SERVER["PHP_SELF"]);
135 exit;
136}
137
138if ($action == "deletenotif") {
139 $bon = new BonPrelevement($db);
140 $bon->deleteNotificationById(GETPOSTINT('notif'));
141
142 header("Location: ".$_SERVER["PHP_SELF"]);
143 exit;
144}
145
146
147/*
148 * View
149 */
150
151$form = new Form($db);
152
153$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
154
155llxHeader('', $langs->trans("CreditTransferSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-paymentbybanktransfer');
156
157$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
158
159print load_fiche_titre($langs->trans("CreditTransferSetup"), $linkback, 'title_setup');
160print '<br>';
161
162print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'">';
163print '<input type="hidden" name="token" value="'.newToken().'">';
164
165print '<table class="noborder centpercent">';
166
167print '<tr class="liste_titre">';
168print '<td>'.$langs->trans("Parameter").'</td>';
169print '<td></td>';
170print "</tr>";
171
172// Bank account (from Banks module)
173print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("BankToPayCreditTransfer").'</td>';
174print '<td>';
175print img_picto('', 'bank_account', 'class="pictofixedwidth"');
176print $form->select_comptes(getDolGlobalString('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT'), 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "(courant:=:1)", 1, '', 0, 'minwidth200', 1);
177print '</td></tr>';
178
179/* Moved to bank account data
180// ICS
181print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ICS").'</td>';
182print '<td>';
183print '<input type="text" name="PAYMENTBYBANKTRANSFER_ICS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ICS.'" size="15" ></td>';
184print '</td></tr>';
185*/
186
187//User
188print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';
189print '<td>';
190print img_picto('', 'user', 'class="pictofixedwidth"');
191print $form->select_dolusers(getDolGlobalString('PAYMENTBYBANKTRANSFER_USER'), 'PAYMENTBYBANKTRANSFER_USER', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'minwidth200 maxwidth500');
192print '</td>';
193print '</tr>';
194
195/*
196//EntToEnd
197print '<tr class="oddeven"><td>'.$langs->trans("END_TO_END").'</td>';
198print '<td>';
199print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->PRELEVEMENT_END_TO_END.'" class="width100"></td>';
200print '</td></tr>';
201
202//USTRD
203print '<tr class="oddeven"><td>'.$langs->trans("USTRD").'</td>';
204print '<td>';
205print '<input type="text" name="CREDITTRANSFER_USTRD" value="'.$conf->global->CREDITTRANSFER_USTRD.'" class="width100"></td>';
206print '</td></tr>';
207*/
208
209//ADDDAYS
210$addDaysValue = getDolGlobalInt('PAYMENTBYBANKTRANSFER_ADDDAYS', 0);
211
212print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>';
213print '<td class="left">';
214print '<input type="number" name="PAYMENTBYBANKTRANSFER_ADDDAYS" value="' . $addDaysValue .'" class="width50" min="0"></td>';
215print '</td></tr>';
216print '</table>';
217
218print $form->buttonsSaveCancel("Save", '');
219
220print '</form>';
221
222
223print '<br>';
224
225
226/*
227 * Document templates generators
228 */
229/*
230print load_fiche_titre($langs->trans("OrdersModelModule"),'','');
231
232// Load array def with activated templates
233$def = array();
234$sql = "SELECT nom";
235$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
236$sql.= " WHERE type = '".$db->escape($type)."'";
237$sql.= " AND entity = ".((int) $conf->entity);
238$resql=$db->query($sql);
239if ($resql)
240{
241 $i = 0;
242 $num_rows=$db->num_rows($resql);
243 while ($i < $num_rows)
244 {
245 $array = $db->fetch_array($resql);
246 array_push($def, $array[0]);
247 $i++;
248 }
249}
250else
251{
252 dol_print_error($db);
253}
254
255
256print "<table class=\"noborder\" width=\"100%\">\n";
257print "<tr class=\"liste_titre\">\n";
258print '<td>'.$langs->trans("Name").'</td>';
259print '<td>'.$langs->trans("Description").'</td>';
260print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
261print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
262print '<td align="center" width="38">'.$langs->trans("ShortInfo").'</td>';
263print '<td align="center" width="38">'.$langs->trans("Preview").'</td>';
264print "</tr>\n";
265
266clearstatcache();
267
268foreach ($dirmodels as $reldir)
269{
270 foreach (array('','/doc') as $valdir)
271 {
272 $dir = dol_buildpath($reldir."core/modules/paymentorders".$valdir);
273
274 if (is_dir($dir))
275 {
276 $handle=opendir($dir);
277 if (is_resource($handle))
278 {
279 while (($file = readdir($handle))!==false)
280 {
281 $filelist[]=$file;
282 }
283 closedir($handle);
284 arsort($filelist);
285
286 foreach($filelist as $file)
287 {
288 if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
289 {
290
291 if (file_exists($dir.'/'.$file))
292 {
293 $name = substr($file, 4, dol_strlen($file) -16);
294 $classname = substr($file, 0, dol_strlen($file) -12);
295
296 require_once $dir.'/'.$file;
297 $module = new $classname($db);
298
299 $modulequalified=1;
300 if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
301 if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
302
303 if ($modulequalified) {
304 print '<tr class="oddeven"><td width="100">';
305 print (empty($module->name)?$name:$module->name);
306 print "</td><td>\n";
307 if (method_exists($module,'info')) print $module->info($langs);
308 else print $module->description;
309 print '</td>';
310
311 // Active
312 if (in_array($name, $def))
313 {
314 print '<td class="center">'."\n";
315 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'">';
316 print img_picto($langs->trans("Enabled"),'switch_on');
317 print '</a>';
318 print '</td>';
319 }
320 else
321 {
322 print '<td class="center">'."\n";
323 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&token='.newToken().'&value='.urlencode($name).'&scan_dir='.urlencode($module->scandir).'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
324 print "</td>";
325 }
326
327 // Default
328 print '<td class="center">';
329 if (getDolGlobalString('PAYMENTORDER_ADDON_PDF') == $name)
330 {
331 print img_picto($langs->trans("Default"),'on');
332 }
333 else
334 {
335 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
336 }
337 print '</td>';
338
339 // Info
340 $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
341 $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
342 if ($module->type == 'pdf')
343 {
344 $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
345 }
346 $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
347 $htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
348 $htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
349 $htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
350 $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
351 //$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
352 //$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
353 $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
354
355
356 print '<td class="center">';
357 print $form->textwithpicto('',$htmltooltip,1,0);
358 print '</td>';
359
360 // Preview
361 print '<td class="center">';
362 if ($module->type == 'pdf')
363 {
364 print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
365 }
366 else
367 {
368 print img_object($langs->transnoentitiesnoconv("PreviewNotAvailable"),'generic');
369 }
370 print '</td>';
371
372 print "</tr>\n";
373 }
374 }
375 }
376 }
377 }
378 }
379 }
380}
381
382*/
383
384
385print dol_get_fiche_end();
386
387print '<br>';
388
389
390/*
391 * Notifications
392 */
393
394/* Disable this, there is no trigger with elementtype 'withdraw'
395if (isModEnabled('notification'))
396{
397 $langs->load("mails");
398 print load_fiche_titre($langs->trans("Notifications"));
399
400 $sql = "SELECT u.rowid, u.lastname, u.firstname, u.fk_soc, u.email";
401 $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
402 $sql.= " WHERE entity IN (".getEntity('invoice').")";
403
404 $resql=$db->query($sql);
405 if ($resql)
406 {
407 $num = $db->num_rows($resql);
408 $i = 0;
409 while ($i < $num)
410 {
411 $obj = $db->fetch_object($resql);
412
413 if (!$obj->fk_soc)
414 {
415 $username=dolGetFirstLastname($obj->firstname,$obj->lastname);
416 $internalusers[$obj->rowid] = $username;
417 }
418
419 $i++;
420 }
421 $db->free($resql);
422 }
423
424 // Get list of triggers for module withdraw
425 $sql = "SELECT rowid, code, label";
426 $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
427 $sql.= " WHERE elementtype = 'withdraw'";
428 $sql.= " ORDER BY rang ASC";
429
430 $resql = $db->query($sql);
431 if ($resql)
432 {
433 $num = $db->num_rows($resql);
434 $i = 0;
435 while ($i < $num)
436 {
437 $obj = $db->fetch_object($resql);
438 $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
439 $actions[$obj->rowid]=$label;
440 $i++;
441 }
442 $db->free($resql);
443 }
444
445
446 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=addnotif&token='.newToken().'">';
447 print '<input type="hidden" name="token" value="'.newToken().'">';
448 print '<table class="noborder centpercent">';
449 print '<tr class="liste_titre">';
450 print '<td>'.$langs->trans("User").'</td>';
451 print '<td></td>';
452 print '<td class="right">'.$langs->trans("Action").'</td>';
453 print "</tr>\n";
454
455 print '<tr class="impair"><td class="left">';
456 print $form->selectarray('user',$internalusers);// select_dolusers(0,'user',0);
457 print '</td>';
458
459 print '<td>';
460 print $form->selectarray('action',$actions);// select_dolusers(0,'user',0);
461 print '</td>';
462
463 print '<td class="right"><input type="submit" class="button button-add" value="'.$langs->trans("Add").'"></td></tr>';
464
465 // List of current notifications for objet_type='withdraw'
466 $sql = "SELECT u.lastname, u.firstname,";
467 $sql.= " nd.rowid, ad.code, ad.label";
468 $sql.= " FROM ".MAIN_DB_PREFIX."user as u,";
469 $sql.= " ".MAIN_DB_PREFIX."notify_def as nd,";
470 $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as ad";
471 $sql.= " WHERE u.rowid = nd.fk_user";
472 $sql.= " AND nd.fk_action = ad.rowid";
473 $sql.= " AND u.entity IN (0,".$conf->entity.")";
474
475 $resql = $db->query($sql);
476 if ($resql)
477 {
478 $num = $db->num_rows($resql);
479 $i = 0;
480 while ($i < $num)
481 {
482 $obj = $db->fetch_object($resql);
483
484
485 print '<tr class="oddeven">';
486 print '<td>'.dolGetFirstLastname($obj->firstname,$obj->lastname).'</td>';
487 $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
488 print '<td>'.$label.'</td>';
489 print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=deletenotif&token='.newToken().'&notif='.$obj->rowid.'">'.img_delete().'</a></td>';
490 print '</tr>';
491 $i++;
492 }
493 $db->free($resql);
494 }
495
496 print '</table>';
497 print '</form>';
498}
499*/
500
501// End of page
502llxFooter();
503$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage bank accounts.
Class to manage withdrawal receipts.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.