dolibarr 22.0.5
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-2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
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.'/core/lib/prelevement.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
34require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
35
44// Load translation files required by the page
45$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
46
47// Get supervariables
48$action = GETPOST('action', 'aZ09');
49
50$id = GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52$socid = GETPOSTINT('socid');
53$type = GETPOST('type', 'aZ09');
54$date_trans = dol_mktime(GETPOSTINT('date_transhour'), GETPOSTINT('date_transmin'), GETPOSTINT('date_transsec'), GETPOSTINT('date_transmonth'), GETPOSTINT('date_transday'), GETPOSTINT('date_transyear'));
55
56// Load variable for pagination
57$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
58$sortfield = GETPOST('sortfield', 'aZ09comma');
59$sortorder = GETPOST('sortorder', 'aZ09comma');
60$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
61if (empty($page) || $page == -1) {
62 $page = 0;
63} // If $page is not defined, or '' or -1
64$offset = $limit * $page;
65$pageprev = $page - 1;
66$pagenext = $page + 1;
67
68if (!$sortfield) {
69 $sortfield = 'pl.rowid';
70}
71if (!$sortorder) {
72 $sortorder = 'ASC';
73}
74
75$object = new BonPrelevement($db);
76
77// Load object
78include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
79
80$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
81
82$type = $object->type;
83
84// Check if salary or invoice
85$salaryBonPl = $object->checkIfSalaryBonPrelevement();
86
87// Security check
88if ($type == 'bank-transfer') {
89 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
90
91 $permissiontoadd = $user->hasRight('paymentbybanktransfer', 'create');
92 $permissiontosend = $user->hasRight('paymentbybanktransfer', 'send');
93 $permissiontocreditdebit = $user->hasRight('paymentbybanktransfer', 'debit');
94 $permissiontodelete = $user->hasRight('paymentbybanktransfer', 'read');
95} else {
96 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
97
98 $permissiontoadd = $user->hasRight('prelevement', 'bons', 'creer');
99 $permissiontosend = $user->hasRight('prelevement', 'bons', 'send');
100 $permissiontocreditdebit = $user->hasRight('prelevement', 'bons', 'credit');
101 $permissiontodelete = $user->hasRight('prelevement', 'bons', 'read');
102}
103
104
105/*
106 * Actions
107 */
108
109$parameters = array('socid' => $socid);
110$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
111if ($reshook < 0) {
112 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
113}
114
115if (empty($reshook)) {
116 if ($action == 'setbankaccount' && $permissiontoadd) {
117 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
118 $object->fk_bank_account = GETPOSTINT('fk_bank_account');
119
120 $object->update($user);
121 }
122
123 // date of upload
124 if ($action == 'setdate_trans' && $permissiontosend) {
125 $result = $object->setValueFrom('date_trans', $date_trans, '', null, 'date');
126 if ($result < 0) {
127 setEventMessages($object->error, $object->errors, 'errors');
128 }
129 }
130
131 if ($action == 'infotrans' && $permissiontosend) {
132 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
133
134 $dt = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
135
136 /*
137 if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
138 {
139 $dir = $conf->prelevement->dir_output.'/receipts';
140
141 if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
142 {
143 $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
144 }
145
146 header("Location: card.php?id=".$id);
147 exit;
148 }
149 else
150 {
151 dol_syslog("File invalid",LOG_WARNING);
152 $mesg='BadFile';
153 }*/
154
155 $error = $object->set_infotrans($user, $dt, GETPOSTINT('methode'));
156
157 if ($error) {
158 header("Location: card.php?id=".$id."&error=$error");
159 exit;
160 }
161 }
162
163 // Set direct debit order to credited, create payment and close invoices
164 if ($action == 'setinfocredit' && $permissiontocreditdebit) {
165 $dt = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
166
167 if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
168 $error = 1;
169 setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors');
170 } else {
171 $error = $object->set_infocredit($user, $dt, ($salaryBonPl ? 'salary' : ''));
172 }
173
174 if ($error) {
175 setEventMessages($object->error, $object->errors, 'errors');
176 }
177 }
178
179 if ($action == 'reopen' && $permissiontocreditdebit) {
180 $savtype = $object->type;
181 $res = $object->setStatut(BonPrelevement::STATUS_TRANSFERED);
182 if ($res <= 0) {
183 setEventMessages($object->error, $object->errors, 'errors');
184 }
185 }
186
187 if ($action == 'confirm_delete' && $permissiontodelete) {
188 $savtype = $object->type;
189 $res = $object->delete($user);
190 if ($res > 0) {
191 if ($savtype == 'bank-transfer') {
192 header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
193 } else {
194 header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
195 }
196 exit;
197 }
198 }
199}
200
201
202/*
203 * View
204 */
205
206$form = new Form($db);
207
208llxHeader('', $langs->trans("WithdrawalsReceipts"));
209
210if (($id > 0 || $ref) && $object->id <= 0) {
211 recordNotFound('', 0);
212}
213
214if ($id > 0 || $ref) {
216 print dol_get_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
217
218 if (GETPOST('error', 'alpha') != '') {
219 print '<div class="error">'.$object->getErrorString(GETPOST('error', 'alpha')).'</div>';
220 }
221
222 $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>';
223
224 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
225
226 print '<div class="fichecenter">';
227 print '<div class="underbanner clearboth"></div>';
228 print '<table class="border centpercent tableforfield">';
229
230 // Date for payment
231 print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
232
233 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
234
235 // Upload file
236 if (!empty($object->date_trans)) {
237 $muser = new User($db);
238 $muser->fetch($object->user_trans);
239
240 // Date upload
241 print '<tr><td>';
242 print '<table class="nobordernopadding centpercent"><tr><td>';
243 print $langs->trans('TransData');
244 print '</td>';
245 if ($action != 'editdate_trans' && $permissiontosend) {
246 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>';
247 }
248 print '</tr></table>';
249 print '</td><td>';
250 if ($action == 'editdate_trans' && $permissiontosend) {
251 print '<form name="setdate_trans" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
252 print '<input type="hidden" name="token" value="'.newToken().'">';
253 print '<input type="hidden" name="action" value="setdate_trans">';
254 print $form->selectDate($object->date_trans ? $object->date_trans : -1, 'date_trans', 0, 0, 0, "setdate_trans");
255 print '<input type="submit" class="button button-edit smallpaddingimp valign middle" value="'.$langs->trans('Modify').'">';
256 print '</form>';
257 } else {
258 print $object->date_trans ? dol_print_date($object->date_trans, 'day') : '';
259 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td>';
260 }
261 print '</td>';
262 print '</tr>';
263
264 // Method upload
265 print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
266 print $object->methodes_trans[$object->method_trans];
267 print '</td></tr>';
268 }
269
270 // Date real payment
271 if (!empty($object->date_credit)) {
272 print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
273 print dol_print_date($object->date_credit, 'day');
274 print '</td></tr>';
275 }
276
277 print '</table>';
278
279 print '<br>';
280
281 print '<div class="underbanner clearboth"></div>';
282 print '<table class="border centpercent tableforfield">';
283
284 // Get bank account for the payment
285 $acc = new Account($db);
286 $fk_bank_account = $object->fk_bank_account;
287 if (empty($fk_bank_account)) {
288 $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
289 }
290 if ($fk_bank_account > 0) {
291 $result = $acc->fetch($fk_bank_account);
292 }
293
294 // Bank account
295 $labelofbankfield = "BankToReceiveWithdraw";
296 if ($object->type == 'bank-transfer') {
297 $labelofbankfield = 'BankToPayCreditTransfer';
298 }
299 //print $langs->trans($labelofbankfield);
300 $caneditbank = $permissiontoadd;
301 if ($object->status != $object::STATUS_DRAFT) {
302 $caneditbank = 0;
303 }
304 /*
305 print '<tr><td class="titlefieldcreate">';
306 print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank);
307 print '</td>';
308 print '<td>';
309 print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl');
310 print '</td>';
311 print '</tr>';
312 */
313 print '<tr><td class="titlefieldcreate">';
314 print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
315 print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
316 print '<td>';
317 if (($action != 'editbankaccount') && $caneditbank) {
318 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>';
319 }
320 print '</tr></table>';
321 print '</td><td>';
322 if ($action == 'editfkbankaccount') {
323 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $fk_bank_account, 'fk_bank_account', 0);
324 } else {
325 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $fk_bank_account, 'none');
326 }
327 print "</td>";
328 print '</tr>';
329
330 // Download file
331 print '<tr><td class="titlefieldcreate">';
332 $labelfororderfield = 'WithdrawalFile';
333 if ($object->type == 'bank-transfer') {
334 $labelfororderfield = 'CreditTransferFile';
335 }
336 print $langs->trans($labelfororderfield).'</td><td>';
337
338 $modulepart = 'prelevement';
339 if ($object->type == 'bank-transfer') {
340 $modulepart = 'paymentbybanktransfer';
341 }
342
343 if (isModEnabled('multicompany')) {
344 $labelentity = $conf->entity;
345 $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
346
347 if ($type != 'bank-transfer') {
348 $dir = $conf->prelevement->dir_output;
349 } else {
350 $dir = $conf->paymentbybanktransfer->dir_output;
351 }
352 if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
353 $relativepath = 'receipts/'.$object->ref.'.xml';
354 }
355 } else {
356 $relativepath = 'receipts/'.$object->ref.'.xml';
357 }
358
359 print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
360 print img_picto('', 'download', 'class="paddingleft"');
361 print '</a>';
362 print '</td></tr>';
363
364 // Other attributes
365 $parameters = array();
366 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
367 print $hookmanager->resPrint;
368
369 print '</table>';
370
371 print '</div>';
372
373 print dol_get_fiche_end();
374
375
376 $formconfirm = '';
377
378 // Confirmation to delete
379 if ($action == 'delete') {
380 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
381 }
382
383 // Call Hook formConfirm
384 /*$parameters = array('formConfirm' => $formconfirm);
385 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
386 if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
387 elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/
388
389 // Print form confirm
390 print $formconfirm;
391
392
393 if (empty($object->date_trans) && (($user->hasRight('prelevement', 'bons', 'send') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'send') && $object->type == 'bank-transfer')) && $action == 'settransmitted') {
394 print '<form method="post" name="userfile" action="card.php?id='.$object->id.'" enctype="multipart/form-data">';
395 print '<input type="hidden" name="token" value="'.newToken().'">';
396 print '<input type="hidden" name="action" value="infotrans">';
397 print '<table class="noborder centpercent">';
398 print '<tr class="liste_titre">';
399 print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
400 print '<tr class="oddeven"><td>'.$langs->trans("TransData").'</td><td>';
401 print $form->selectDate('', '', 0, 0, 0, "userfile", 1, 1);
402 print '</td></tr>';
403 print '<tr class="oddeven"><td>'.$langs->trans("TransMetod").'</td><td>';
404 print $form->selectarray("methode", $object->methodes_trans);
405 print '</td></tr>';
406 print '</table>';
407 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("SetToStatusSent")).'"></div>';
408 print '</form>';
409 print '<br>';
410 }
411
412 if ($object->status == BonPrelevement::STATUS_TRANSFERED && (($user->hasRight('prelevement', 'bons', 'credit') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'debit') && $object->type == 'bank-transfer')) && $action == 'setcredited') {
413 $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited");
414 print '<form name="infocredit" method="post" action="card.php?id='.$object->id.'">';
415 print '<input type="hidden" name="token" value="'.newToken().'">';
416 print '<input type="hidden" name="action" value="setinfocredit">';
417 print '<table class="noborder centpercent">';
418 print '<tr class="liste_titre">';
419 print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
420 print '<tr class="oddeven"><td>'.$langs->trans('CreditDate').'</td><td>';
421 print $form->selectDate(-1, '', 0, 0, 0, "infocredit", 1, 1, 0, '', '', array(array('adddateof' => $object->date_trans, 'labeladddateof' => $langs->transnoentitiesnoconv('TransData'))));
422 print '</td></tr>';
423 print '</table>';
424 print '<br><div class="center"><span class="opacitymedium">'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice").'</span></div>';
425 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).'"></div>';
426 print '</form>';
427 print '<br>';
428 }
429
430 // Actions
431 if ($action != 'settransmitted' && $action != 'setcredited') {
432 print "\n".'<div class="tabsAction">'."\n";
433 $parameters = array();
434 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
435 if (empty($reshook)) {
436 if (empty($object->date_trans)) {
437 if ($object->type == 'bank-transfer') {
438 print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'send'));
439 } else {
440 print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'send'));
441 }
442 }
443
444 if ($object->status == BonPrelevement::STATUS_TRANSFERED) {
445 if ($object->type == 'bank-transfer') {
446 print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit'));
447 } else {
448 print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit'));
449 }
450 }
451
452 if (getDolGlobalString('BANK_CAN_REOPEN_DIRECT_DEBIT_OR_CREDIT_TRANSFER')) {
453 if ($object->status == BonPrelevement::STATUS_DEBITED || $object->status == BonPrelevement::STATUS_CREDITED) {
454 if ($object->type == 'bank-transfer') {
455 print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit'));
456 } else {
457 print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit'));
458 }
459 }
460 }
461
462 if ($object->type == 'bank-transfer') {
463 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'create'));
464 } else {
465 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'creer'));
466 }
467 }
468 print '</div>';
469 }
470
471
472 $ligne = new LignePrelevement($db);
473
474 // Lines into withdraw request
475 if ($salaryBonPl) {
476 $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user,";
477 $sql .= " u.rowid as socid, u.login as name";
478 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
479 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
480 $sql .= ", ".MAIN_DB_PREFIX."user as u";
481 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
482 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
483 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
484 $sql .= " AND pl.fk_user = u.rowid";
485 if ($socid) {
486 $sql .= " AND u.rowid = ".((int) $socid);
487 }
488 $sql .= $db->order($sortfield, $sortorder);
489 } else {
490 $sql = "SELECT pl.rowid, pl.statut, pl.amount,";
491 $sql .= " s.rowid as socid, s.nom as name";
492 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
493 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
494 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
495 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
496 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
497 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
498 $sql .= " AND pl.fk_soc = s.rowid";
499 if ($socid) {
500 $sql .= " AND s.rowid = ".((int) $socid);
501 }
502 $sql .= $db->order($sortfield, $sortorder);
503 }
504 // Count total nb of records
505 $nbtotalofrecords = '';
506 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
507 $result = $db->query($sql);
508 $nbtotalofrecords = $db->num_rows($result);
509 if (($page * $limit) > $nbtotalofrecords) {
510 // if total resultset is smaller then paging size (filtering), goto and load page 0
511 $page = 0;
512 $offset = 0;
513 }
514 }
515
516 $sql .= $db->plimit($limit + 1, $offset);
517
518 $result = $db->query($sql);
519
520 if ($result) {
521 $num = $db->num_rows($result);
522 $i = 0;
523
524 $urladd = "&id=".urlencode((string) ($id));
525 if ($limit > 0 && $limit != $conf->liste_limit) {
526 $urladd .= '&limit='.((int) $limit);
527 }
528
529 print '<form method="POST" action="'.$_SERVER ['PHP_SELF'].'" name="search_form">'."\n";
530 print '<input type="hidden" name="token" value="'.newToken().'"/>';
531 print '<input type="hidden" name="id" value="'.$id.'"/>';
532 print '<input type="hidden" name="socid" value="'.$socid.'"/>';
533 if (!empty($page)) {
534 print '<input type="hidden" name="page" value="'.$page.'"/>';
535 }
536 if (!empty($limit)) {
537 print '<input type="hidden" name="limit" value="'.$limit.'"/>';
538 }
539 if (!empty($sortfield)) {
540 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
541 }
542 if (!empty($sortorder)) {
543 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
544 }
545 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
546 print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
547
548 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
549 print '<table class="noborder liste centpercent">';
550 print '<tr class="liste_titre">';
551 print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder);
552 print_liste_field_titre((!$salaryBonPl ? "ThirdParty" : "Employee"), $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
553 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $urladd, 'class="right"', $sortfield, $sortorder);
555 print "</tr>\n";
556
557 $total = 0;
558
559 while ($i < min($num, $limit)) {
560 $obj = $db->fetch_object($result);
561
562 print '<tr class="oddeven">';
563
564 // Status of line
565 print "<td>";
566 print '<a class="valignmiddle" href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'&type='.$object->type.'&token='.newToken().'">';
567 print $ligne->LibStatut($obj->statut, 2);
568 print '<span class="paddingleft">'.$obj->rowid.'</span>';
569 print '</a></td>';
570 if (!$salaryBonPl) {
571 $thirdparty = new Societe($db);
572 $thirdparty->fetch($obj->socid);
573 $name = $thirdparty->getNomUrl(1);
574 } else {
575 $userSalary = new User($db);
576 $userSalary->fetch($obj->fk_user);
577 $name = $userSalary->getNomUrl(-1);
578 }
579 print '<td class="tdoverflowmax150">';
580 print($name);
581 print "</td>\n";
582
583 print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
584
585 print '<td class="right">';
586
587 if ($obj->statut == 3) {
588 print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
589 } else {
590 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
591 if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
592 if ($user->hasRight('prelevement', 'bons', 'credit')) {
593 //print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
594 print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'&token='.newToken().'">'.$langs->trans("StandingOrderReject").'</a>';
595 } else {
596 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
597 }
598 }
599 } else {
600 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine").'">'.$langs->trans("StandingOrderReject").'</a>';
601 }
602 }
603
604 print '</td></tr>';
605
606 $total += $obj->amount;
607
608 $i++;
609 }
610
611 if ($num > 0) {
612 $total = price2num($total, 'MT');
613
614 print '<tr class="liste_total">';
615 print '<td>'.$langs->trans("Total").'</td>';
616 print '<td>&nbsp;</td>';
617 print '<td class="right">';
618 if (empty($offset) && $num <= $limit) {
619 // If we have all record on same page, then the following test/warning can be done
620 if ($total != $object->amount) {
621 print img_warning($langs->trans("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
622 }
623 }
624 print price($total);
625 print "</td>\n";
626 print '<td>&nbsp;</td>';
627 print "</tr>\n";
628 }
629
630 print "</table>";
631 print '</div>';
632 print '</form>';
633
634 $db->free($result);
635 } else {
636 dol_print_error($db);
637 }
638}
639
640// End of page
641llxFooter();
642$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
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.
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.