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