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