dolibarr 18.0.6
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2010-2016 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.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('banks', 'categories', 'bills', 'companies', 'withdrawals'));
37
38// Get supervariables
39$action = GETPOST('action', 'aZ09');
40
41$id = GETPOST('id', 'int');
42$ref = GETPOST('ref', 'alpha');
43$socid = GETPOST('socid', 'int');
44$type = GETPOST('type', 'aZ09');
45$date_trans = dol_mktime(GETPOST('date_transhour', 'int'), GETPOST('date_transmin', 'int'), GETPOST('date_transsec', 'int'), GETPOST('date_transmonth', 'int'), GETPOST('date_transday', 'int'), GETPOST('date_transyear', 'int'));
46
47// Load variable for pagination
48$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
49$sortfield = GETPOST('sortfield', 'aZ09comma');
50$sortorder = GETPOST('sortorder', 'aZ09comma');
51$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
52if (empty($page) || $page == -1) {
53 $page = 0;
54} // If $page is not defined, or '' or -1
55$offset = $limit * $page;
56$pageprev = $page - 1;
57$pagenext = $page + 1;
58
59if (!$sortfield) {
60 $sortfield = 'pl.rowid';
61}
62if (!$sortorder) {
63 $sortorder = 'ASC';
64}
65
66$object = new BonPrelevement($db);
67
68// Load object
69include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
70
71$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
72
73$type = $object->type;
74
75if ($type == 'bank-transfer') {
76 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
77
78 $permissiontoadd = $user->hasRight('paymentbybanktransfer', 'read');
79 $permissiontosend = $user->hasRight('paymentbybanktransfer', 'send');
80 $permissiontocreditdebit = $user->hasRight('paymentbybanktransfer', 'debit');
81 $permissiontodelete = $user->hasRight('paymentbybanktransfer', 'read');
82} else {
83 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
84
85 $permissiontoadd = $user->hasRight('prelevement', 'bons', 'read');
86 $permissiontosend = $user->hasRight('prelevement', 'bons', 'send');
87 $permissiontocreditdebit = $user->hasRight('prelevement', 'bons', 'credit');
88 $permissiontodelete = $user->hasRight('prelevement', 'bons', 'read');
89}
90
91
92
93/*
94 * Actions
95 */
96
97$parameters = array('socid' => $socid);
98$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
99if ($reshook < 0) {
100 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
101}
102
103if (empty($reshook)) {
104 if ($action == 'setbankaccount' && $permissiontoadd) {
105 $object->oldcopy = dol_clone($object);
106 $object->fk_bank_account = GETPOST('fk_bank_account', 'int');
107 $object->update($user);
108 }
109
110 // date of upload
111 if ($action == 'setdate_trans' && $permissiontoadd) {
112 $result = $object->setValueFrom('date_trans', $date_trans, '', null, 'date');
113 if ($result < 0) {
114 setEventMessages($object->error, $object->errors, 'errors');
115 }
116 }
117
118 if ($action == 'infotrans' && $permissiontosend) {
119 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
120
121 $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
122
123 /*
124 if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
125 {
126 $dir = $conf->prelevement->dir_output.'/receipts';
127
128 if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
129 {
130 $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
131 }
132
133 header("Location: card.php?id=".$id);
134 exit;
135 }
136 else
137 {
138 dol_syslog("Fichier invalide",LOG_WARNING);
139 $mesg='BadFile';
140 }*/
141
142 $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
143
144 if ($error) {
145 header("Location: card.php?id=".$id."&error=$error");
146 exit;
147 }
148 }
149
150 // Set direct debit order to credited, create payment and close invoices
151 if ($action == 'infocredit' && $permissiontocreditdebit) {
152 $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
153
154 if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
155 $error = 1;
156 setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors');
157 } else {
158 $error = $object->set_infocredit($user, $dt);
159 }
160
161 if ($error) {
162 setEventMessages($object->error, $object->errors, 'errors');
163 }
164 }
165
166 if ($action == 'confirm_delete' && $permissiontodelete) {
167 $savtype = $object->type;
168 $res = $object->delete($user);
169 if ($res > 0) {
170 if ($savtype == 'bank-transfer') {
171 header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
172 } else {
173 header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
174 }
175 exit;
176 }
177 }
178}
179
180
181
182/*
183 * View
184 */
185
186$form = new Form($db);
187
188llxHeader('', $langs->trans("WithdrawalsReceipts"));
189
190if ($id > 0 || $ref) {
191 $head = prelevement_prepare_head($object);
192 print dol_get_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
193
194 if (GETPOST('error', 'alpha') != '') {
195 print '<div class="error">'.$object->getErrorString(GETPOST('error', 'alpha')).'</div>';
196 }
197
198 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/orders_list.php?restore_lastsearch_values=1'.($object->type != 'bank-transfer' ? '' : '&type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
199
200 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
201
202 print '<div class="fichecenter">';
203 print '<div class="underbanner clearboth"></div>';
204 print '<table class="border centpercent tableforfield">';
205
206 // Date for payment
207 print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
208
209 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
210
211 // Upload file
212 if (!empty($object->date_trans)) {
213 $muser = new User($db);
214 $muser->fetch($object->user_trans);
215
216 // Date upload
217 print '<tr><td>';
218 print '<table class="nobordernopadding centpercent"><tr><td>';
219 print $langs->trans('TransData');
220 print '</td>';
221 if ($action != 'editdate_trans') {
222 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_trans&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetTransDate'), 1).'</a></td>';
223 }
224 print '</tr></table>';
225 print '</td><td>';
226 if ($action == 'editdate_trans') {
227 print '<form name="setdate_trans" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
228 print '<input type="hidden" name="token" value="'.newToken().'">';
229 print '<input type="hidden" name="action" value="setdate_trans">';
230 print $form->selectDate($object->date_trans ? $object->date_trans : -1, 'date_trans', 0, '', "setdate_trans");
231 print '<input type="submit" class="button button-edit smallpaddingimp valign middle" value="'.$langs->trans('Modify').'">';
232 print '</form>';
233 } else {
234 print $object->date_trans ? dol_print_date($object->date_trans, 'day') : '';
235 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td>';
236 }
237 print '</td>';
238 print '</tr>';
239
240 // Method upload
241 print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
242 print $object->methodes_trans[$object->method_trans];
243 print '</td></tr>';
244 }
245
246 // Date real payment
247 if (!empty($object->date_credit)) {
248 print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
249 print dol_print_date($object->date_credit, 'day');
250 print '</td></tr>';
251 }
252
253 print '</table>';
254
255 print '<br>';
256
257 print '<div class="underbanner clearboth"></div>';
258 print '<table class="border centpercent tableforfield">';
259
260 // Get bank account for the payment
261 $acc = new Account($db);
262 $fk_bank_account = $object->fk_bank_account;
263 if (empty($fk_bank_account)) {
264 $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
265 }
266 if ($fk_bank_account > 0) {
267 $result = $acc->fetch($fk_bank_account);
268 }
269
270 // Bank account
271 $labelofbankfield = "BankToReceiveWithdraw";
272 if ($object->type == 'bank-transfer') {
273 $labelofbankfield = 'BankToPayCreditTransfer';
274 }
275 //print $langs->trans($labelofbankfield);
276 $caneditbank = $permissiontoadd;
277 if ($object->status != $object::STATUS_DRAFT) {
278 $caneditbank = 0;
279 }
280 /*
281 print '<tr><td class="titlefieldcreate">';
282 print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank);
283 print '</td>';
284 print '<td>';
285 print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl');
286 print '</td>';
287 print '</tr>';
288 */
289 print '<tr><td class="titlefieldcreate">';
290 print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
291 print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
292 print '<td>';
293 if (($action != 'editbankaccount') && $caneditbank) {
294 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editfkbankaccount&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
295 }
296 print '</tr></table>';
297 print '</td><td>';
298 if ($action == 'editfkbankaccount') {
299 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'fk_bank_account', 0);
300 } else {
301 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'none');
302 }
303 print "</td>";
304 print '</tr>';
305
306 // Donwload file
307 print '<tr><td class="titlefieldcreate">';
308 $labelfororderfield = 'WithdrawalFile';
309 if ($object->type == 'bank-transfer') {
310 $labelfororderfield = 'CreditTransferFile';
311 }
312 print $langs->trans($labelfororderfield).'</td><td>';
313
314 $modulepart = 'prelevement';
315 if ($object->type == 'bank-transfer') {
316 $modulepart = 'paymentbybanktransfer';
317 }
318
319 if (isModEnabled('multicompany')) {
320 $labelentity = $conf->entity;
321 $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
322
323 if ($type != 'bank-transfer') {
324 $dir = $conf->prelevement->dir_output;
325 } else {
326 $dir = $conf->paymentbybanktransfer->dir_output;
327 }
328 if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
329 $relativepath = 'receipts/'.$object->ref.'.xml';
330 }
331 } else {
332 $relativepath = 'receipts/'.$object->ref.'.xml';
333 }
334
335 print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
336 print img_picto('', 'download', 'class="paddingleft"');
337 print '</a>';
338 print '</td></tr>';
339
340 // Other attributes
341 $parameters = array();
342 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
343 print $hookmanager->resPrint;
344
345 print '</table>';
346
347 print '</div>';
348
349 print dol_get_fiche_end();
350
351
352 $formconfirm = '';
353
354 // Confirmation to delete
355 if ($action == 'delete') {
356 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
357 }
358
359 // Call Hook formConfirm
360 /*$parameters = array('formConfirm' => $formconfirm);
361 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
362 if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
363 elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/
364
365 // Print form confirm
366 print $formconfirm;
367
368
369 if (empty($object->date_trans) && (($user->rights->prelevement->bons->send && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type == 'bank-transfer')) && $action == 'settransmitted') {
370 print '<form method="post" name="userfile" action="card.php?id='.$object->id.'" enctype="multipart/form-data">';
371 print '<input type="hidden" name="token" value="'.newToken().'">';
372 print '<input type="hidden" name="action" value="infotrans">';
373 print '<table class="noborder centpercent">';
374 print '<tr class="liste_titre">';
375 print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
376 print '<tr class="oddeven"><td>'.$langs->trans("TransData").'</td><td>';
377 print $form->selectDate('', '', '', '', '', "userfile", 1, 1);
378 print '</td></tr>';
379 print '<tr class="oddeven"><td>'.$langs->trans("TransMetod").'</td><td>';
380 print $form->selectarray("methode", $object->methodes_trans);
381 print '</td></tr>';
382 print '</table>';
383 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("SetToStatusSent")).'"></div>';
384 print '</form>';
385 print '<br>';
386 }
387
388 if (!empty($object->date_trans) && empty($object->date_credit) && (($user->rights->prelevement->bons->credit && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->debit && $object->type == 'bank-transfer')) && $action == 'setcredited') {
389 $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited");
390 print '<form name="infocredit" method="post" action="card.php?id='.$object->id.'">';
391 print '<input type="hidden" name="token" value="'.newToken().'">';
392 print '<input type="hidden" name="action" value="infocredit">';
393 print '<table class="noborder centpercent">';
394 print '<tr class="liste_titre">';
395 print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
396 print '<tr class="oddeven"><td>'.$langs->trans('CreditDate').'</td><td>';
397 print $form->selectDate(-1, '', '', '', '', "infocredit", 1, 1);
398 print '</td></tr>';
399 print '</table>';
400 print '<br><div class="center"><span class="opacitymedium">'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice").'</span></div>';
401 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).'"></div>';
402 print '</form>';
403 print '<br>';
404 }
405
406 // Actions
407 if ($action != 'settransmitted' && $action != 'setcredited') {
408 print "\n".'<div class="tabsAction">'."\n";
409 $parameters = array();
410 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
411 if (empty($reshook)) {
412 if (empty($object->date_trans)) {
413 if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->send);
414 else print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->send);
415 }
416 if (!empty($object->date_trans) && empty($object->date_credit)) {
417 if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->debit);
418 else print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->credit);
419 }
420
421 if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->create);
422 else print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->creer);
423 }
424 print '</div>';
425 }
426
427
428 $ligne = new LignePrelevement($db);
429
430 /*
431 * Lines into withdraw request
432 */
433 $sql = "SELECT pl.rowid, pl.statut, pl.amount,";
434 $sql .= " s.rowid as socid, s.nom as name";
435 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
436 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
437 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
438 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
439 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
440 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
441 $sql .= " AND pl.fk_soc = s.rowid";
442 if ($socid) {
443 $sql .= " AND s.rowid = ".((int) $socid);
444 }
445 $sql .= $db->order($sortfield, $sortorder);
446
447 // Count total nb of records
448 $nbtotalofrecords = '';
449 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
450 $result = $db->query($sql);
451 $nbtotalofrecords = $db->num_rows($result);
452 if (($page * $limit) > $nbtotalofrecords) {
453 // if total resultset is smaller then paging size (filtering), goto and load page 0
454 $page = 0;
455 $offset = 0;
456 }
457 }
458
459 $sql .= $db->plimit($limit + 1, $offset);
460
461 $result = $db->query($sql);
462
463 if ($result) {
464 $num = $db->num_rows($result);
465 $i = 0;
466
467 $urladd = "&id=".urlencode($id);
468 if ($limit > 0 && $limit != $conf->liste_limit) {
469 $urladd .= '&limit='.((int) $limit);
470 }
471
472 print '<form method="POST" action="'.$_SERVER ['PHP_SELF'].'" name="search_form">'."\n";
473 print '<input type="hidden" name="token" value="'.newToken().'"/>';
474 print '<input type="hidden" name="id" value="'.$id.'"/>';
475 print '<input type="hidden" name="socid" value="'.$socid.'"/>';
476 if (!empty($page)) {
477 print '<input type="hidden" name="page" value="'.$page.'"/>';
478 }
479 if (!empty($limit)) {
480 print '<input type="hidden" name="limit" value="'.$limit.'"/>';
481 }
482 if (!empty($sortfield)) {
483 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
484 }
485 if (!empty($sortorder)) {
486 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
487 }
488 print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
489
490 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
491 print '<table class="noborder liste centpercent">';
492 print '<tr class="liste_titre">';
493 print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder);
494 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
495 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $urladd, 'class="right"', $sortfield, $sortorder);
497 print "</tr>\n";
498
499 $total = 0;
500
501 while ($i < min($num, $limit)) {
502 $obj = $db->fetch_object($result);
503
504 print '<tr class="oddeven">';
505
506 // Status of line
507 print "<td>";
508 print '<a class="valignmiddle" href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'&type='.$object->type.'&token='.newToken().'">';
509 print $ligne->LibStatut($obj->statut, 2);
510 print '<span class="paddingleft">'.$obj->rowid.'</span>';
511 print '</a></td>';
512
513 $thirdparty = new Societe($db);
514 $thirdparty->fetch($obj->socid);
515 print '<td>';
516 print $thirdparty->getNomUrl(1);
517 print "</td>\n";
518
519 print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
520
521 print '<td class="right">';
522
523 if ($obj->statut == 3) {
524 print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
525 } else {
526 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
527 if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
528 if ($user->hasRight('prelevement', 'bons', 'credit')) {
529 //print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
530 print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'&token='.newToken().'">'.$langs->trans("StandingOrderReject").'</a>';
531 } else {
532 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
533 }
534 }
535 } else {
536 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine").'">'.$langs->trans("StandingOrderReject").'</a>';
537 }
538 }
539
540 print '</td></tr>';
541
542 $total += $obj->amount;
543
544 $i++;
545 }
546
547 if ($num > 0) {
548 $total = price2num($total, 'MT');
549
550 print '<tr class="liste_total">';
551 print '<td>'.$langs->trans("Total").'</td>';
552 print '<td>&nbsp;</td>';
553 print '<td class="right">';
554 if (empty($offset) && $num <= $limit) {
555 // If we have all record on same page, then the following test/warning can be done
556 if ($total != $object->amount) {
557 print img_warning($langs->trans("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
558 }
559 }
560 print price($total);
561 print "</td>\n";
562 print '<td>&nbsp;</td>';
563 print "</tr>\n";
564 }
565
566 print "</table>";
567 print '</div>';
568 print '</form>';
569
570 $db->free($result);
571 } else {
572 dol_print_error($db);
573 }
574}
575
576// End of page
577llxFooter();
578$db->close();
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.
Class to manage withdrawals.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
dol_is_file($pathoffile)
Return if path is a file.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.