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