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