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