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) {
212 print dol_get_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
213
214 if (GETPOST('error', 'alpha') != '') {
215 print '<div class="error">'.$object->getErrorString(GETPOST('error', 'alpha')).'</div>';
216 }
217
218 $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>';
219
220 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
221
222 print '<div class="fichecenter">';
223 print '<div class="underbanner clearboth"></div>';
224 print '<table class="border centpercent tableforfield">';
225
226 // Date for payment
227 print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
228
229 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
230
231 // Upload file
232 if (!empty($object->date_trans)) {
233 $muser = new User($db);
234 $muser->fetch($object->user_trans);
235
236 // Date upload
237 print '<tr><td>';
238 print '<table class="nobordernopadding centpercent"><tr><td>';
239 print $langs->trans('TransData');
240 print '</td>';
241 if ($action != 'editdate_trans' && $permissiontosend) {
242 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>';
243 }
244 print '</tr></table>';
245 print '</td><td>';
246 if ($action == 'editdate_trans' && $permissiontosend) {
247 print '<form name="setdate_trans" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
248 print '<input type="hidden" name="token" value="'.newToken().'">';
249 print '<input type="hidden" name="action" value="setdate_trans">';
250 print $form->selectDate($object->date_trans ? $object->date_trans : -1, 'date_trans', 0, 0, 0, "setdate_trans");
251 print '<input type="submit" class="button button-edit smallpaddingimp valign middle" value="'.$langs->trans('Modify').'">';
252 print '</form>';
253 } else {
254 print $object->date_trans ? dol_print_date($object->date_trans, 'day') : '';
255 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td>';
256 }
257 print '</td>';
258 print '</tr>';
259
260 // Method upload
261 print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
262 print $object->methodes_trans[$object->method_trans];
263 print '</td></tr>';
264 }
265
266 // Date real payment
267 if (!empty($object->date_credit)) {
268 print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
269 print dol_print_date($object->date_credit, 'day');
270 print '</td></tr>';
271 }
272
273 print '</table>';
274
275 print '<br>';
276
277 print '<div class="underbanner clearboth"></div>';
278 print '<table class="border centpercent tableforfield">';
279
280 // Get bank account for the payment
281 $acc = new Account($db);
282 $fk_bank_account = $object->fk_bank_account;
283 if (empty($fk_bank_account)) {
284 $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
285 }
286 if ($fk_bank_account > 0) {
287 $result = $acc->fetch($fk_bank_account);
288 }
289
290 // Bank account
291 $labelofbankfield = "BankToReceiveWithdraw";
292 if ($object->type == 'bank-transfer') {
293 $labelofbankfield = 'BankToPayCreditTransfer';
294 }
295 //print $langs->trans($labelofbankfield);
296 $caneditbank = $permissiontoadd;
297 if ($object->status != $object::STATUS_DRAFT) {
298 $caneditbank = 0;
299 }
300 /*
301 print '<tr><td class="titlefieldcreate">';
302 print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank);
303 print '</td>';
304 print '<td>';
305 print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl');
306 print '</td>';
307 print '</tr>';
308 */
309 print '<tr><td class="titlefieldcreate">';
310 print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
311 print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
312 print '<td>';
313 if (($action != 'editbankaccount') && $caneditbank) {
314 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>';
315 }
316 print '</tr></table>';
317 print '</td><td>';
318 if ($action == 'editfkbankaccount') {
319 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $fk_bank_account, 'fk_bank_account', 0);
320 } else {
321 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $fk_bank_account, 'none');
322 }
323 print "</td>";
324 print '</tr>';
325
326 // Download file
327 print '<tr><td class="titlefieldcreate">';
328 $labelfororderfield = 'WithdrawalFile';
329 if ($object->type == 'bank-transfer') {
330 $labelfororderfield = 'CreditTransferFile';
331 }
332 print $langs->trans($labelfororderfield).'</td><td>';
333
334 $modulepart = 'prelevement';
335 if ($object->type == 'bank-transfer') {
336 $modulepart = 'paymentbybanktransfer';
337 }
338
339 if (isModEnabled('multicompany')) {
340 $labelentity = $conf->entity;
341 $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
342
343 if ($type != 'bank-transfer') {
344 $dir = $conf->prelevement->dir_output;
345 } else {
346 $dir = $conf->paymentbybanktransfer->dir_output;
347 }
348 if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
349 $relativepath = 'receipts/'.$object->ref.'.xml';
350 }
351 } else {
352 $relativepath = 'receipts/'.$object->ref.'.xml';
353 }
354
355 print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
356 print img_picto('', 'download', 'class="paddingleft"');
357 print '</a>';
358 print '</td></tr>';
359
360 // Other attributes
361 $parameters = array();
362 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
363 print $hookmanager->resPrint;
364
365 print '</table>';
366
367 print '</div>';
368
369 print dol_get_fiche_end();
370
371
372 $formconfirm = '';
373
374 // Confirmation to delete
375 if ($action == 'delete') {
376 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
377 }
378
379 // Call Hook formConfirm
380 /*$parameters = array('formConfirm' => $formconfirm);
381 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
382 if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
383 elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/
384
385 // Print form confirm
386 print $formconfirm;
387
388
389 if (empty($object->date_trans) && (($user->hasRight('prelevement', 'bons', 'send') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'send') && $object->type == 'bank-transfer')) && $action == 'settransmitted') {
390 print '<form method="post" name="userfile" action="card.php?id='.$object->id.'" enctype="multipart/form-data">';
391 print '<input type="hidden" name="token" value="'.newToken().'">';
392 print '<input type="hidden" name="action" value="infotrans">';
393 print '<table class="noborder centpercent">';
394 print '<tr class="liste_titre">';
395 print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
396 print '<tr class="oddeven"><td>'.$langs->trans("TransData").'</td><td>';
397 print $form->selectDate('', '', 0, 0, 0, "userfile", 1, 1);
398 print '</td></tr>';
399 print '<tr class="oddeven"><td>'.$langs->trans("TransMetod").'</td><td>';
400 print $form->selectarray("methode", $object->methodes_trans);
401 print '</td></tr>';
402 print '</table>';
403 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("SetToStatusSent")).'"></div>';
404 print '</form>';
405 print '<br>';
406 }
407
408 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') {
409 $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited");
410 print '<form name="infocredit" method="post" action="card.php?id='.$object->id.'">';
411 print '<input type="hidden" name="token" value="'.newToken().'">';
412 print '<input type="hidden" name="action" value="setinfocredit">';
413 print '<table class="noborder centpercent">';
414 print '<tr class="liste_titre">';
415 print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
416 print '<tr class="oddeven"><td>'.$langs->trans('CreditDate').'</td><td>';
417 print $form->selectDate(-1, '', 0, 0, 0, "infocredit", 1, 1, 0, '', '', array(array('adddateof' => $object->date_trans, 'labeladddateof' => $langs->transnoentitiesnoconv('TransData'))));
418 print '</td></tr>';
419 print '</table>';
420 print '<br><div class="center"><span class="opacitymedium">'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice").'</span></div>';
421 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).'"></div>';
422 print '</form>';
423 print '<br>';
424 }
425
426 // Actions
427 if ($action != 'settransmitted' && $action != 'setcredited') {
428 print "\n".'<div class="tabsAction">'."\n";
429 $parameters = array();
430 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
431 if (empty($reshook)) {
432 if (empty($object->date_trans)) {
433 if ($object->type == 'bank-transfer') {
434 print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'send'));
435 } else {
436 print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'send'));
437 }
438 }
439
440 if ($object->status == BonPrelevement::STATUS_TRANSFERED) {
441 if ($object->type == 'bank-transfer') {
442 print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit'));
443 } else {
444 print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit'));
445 }
446 }
447
448 if (getDolGlobalString('BANK_CAN_REOPEN_DIRECT_DEBIT_OR_CREDIT_TRANSFER')) {
449 if ($object->status == BonPrelevement::STATUS_DEBITED || $object->status == BonPrelevement::STATUS_CREDITED) {
450 if ($object->type == 'bank-transfer') {
451 print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit'));
452 } else {
453 print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit'));
454 }
455 }
456 }
457
458 if ($object->type == 'bank-transfer') {
459 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'create'));
460 } else {
461 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'creer'));
462 }
463 }
464 print '</div>';
465 }
466
467
468 $ligne = new LignePrelevement($db);
469
470 // Lines into withdraw request
471 if ($salaryBonPl) {
472 $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user,";
473 $sql .= " u.rowid as socid, u.login as name";
474 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
475 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
476 $sql .= ", ".MAIN_DB_PREFIX."user as u";
477 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
478 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
479 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
480 $sql .= " AND pl.fk_user = u.rowid";
481 if ($socid) {
482 $sql .= " AND u.rowid = ".((int) $socid);
483 }
484 $sql .= $db->order($sortfield, $sortorder);
485 } else {
486 $sql = "SELECT pl.rowid, pl.statut, pl.amount,";
487 $sql .= " s.rowid as socid, s.nom as name";
488 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
489 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
490 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
491 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
492 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
493 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
494 $sql .= " AND pl.fk_soc = s.rowid";
495 if ($socid) {
496 $sql .= " AND s.rowid = ".((int) $socid);
497 }
498 $sql .= $db->order($sortfield, $sortorder);
499 }
500 // Count total nb of records
501 $nbtotalofrecords = '';
502 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
503 $result = $db->query($sql);
504 $nbtotalofrecords = $db->num_rows($result);
505 if (($page * $limit) > $nbtotalofrecords) {
506 // if total resultset is smaller then paging size (filtering), goto and load page 0
507 $page = 0;
508 $offset = 0;
509 }
510 }
511
512 $sql .= $db->plimit($limit + 1, $offset);
513
514 $result = $db->query($sql);
515
516 if ($result) {
517 $num = $db->num_rows($result);
518 $i = 0;
519
520 $urladd = "&id=".urlencode((string) ($id));
521 if ($limit > 0 && $limit != $conf->liste_limit) {
522 $urladd .= '&limit='.((int) $limit);
523 }
524
525 print '<form method="POST" action="'.$_SERVER ['PHP_SELF'].'" name="search_form">'."\n";
526 print '<input type="hidden" name="token" value="'.newToken().'"/>';
527 print '<input type="hidden" name="id" value="'.$id.'"/>';
528 print '<input type="hidden" name="socid" value="'.$socid.'"/>';
529 if (!empty($page)) {
530 print '<input type="hidden" name="page" value="'.$page.'"/>';
531 }
532 if (!empty($limit)) {
533 print '<input type="hidden" name="limit" value="'.$limit.'"/>';
534 }
535 if (!empty($sortfield)) {
536 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
537 }
538 if (!empty($sortorder)) {
539 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
540 }
541 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
542 print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
543
544 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
545 print '<table class="noborder liste centpercent">';
546 print '<tr class="liste_titre">';
547 print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder);
548 print_liste_field_titre((!$salaryBonPl ? "ThirdParty" : "Employee"), $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
549 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $urladd, 'class="right"', $sortfield, $sortorder);
551 print "</tr>\n";
552
553 $total = 0;
554
555 while ($i < min($num, $limit)) {
556 $obj = $db->fetch_object($result);
557
558 print '<tr class="oddeven">';
559
560 // Status of line
561 print "<td>";
562 print '<a class="valignmiddle" href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'&type='.$object->type.'&token='.newToken().'">';
563 print $ligne->LibStatut($obj->statut, 2);
564 print '<span class="paddingleft">'.$obj->rowid.'</span>';
565 print '</a></td>';
566 if (!$salaryBonPl) {
567 $thirdparty = new Societe($db);
568 $thirdparty->fetch($obj->socid);
569 $name = $thirdparty->getNomUrl(1);
570 } else {
571 $userSalary = new User($db);
572 $userSalary->fetch($obj->fk_user);
573 $name = $userSalary->getNomUrl(-1);
574 }
575 print '<td class="tdoverflowmax150">';
576 print($name);
577 print "</td>\n";
578
579 print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
580
581 print '<td class="right">';
582
583 if ($obj->statut == 3) {
584 print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
585 } else {
586 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
587 if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
588 if ($user->hasRight('prelevement', 'bons', 'credit')) {
589 //print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
590 print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'&token='.newToken().'">'.$langs->trans("StandingOrderReject").'</a>';
591 } else {
592 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
593 }
594 }
595 } else {
596 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine").'">'.$langs->trans("StandingOrderReject").'</a>';
597 }
598 }
599
600 print '</td></tr>';
601
602 $total += $obj->amount;
603
604 $i++;
605 }
606
607 if ($num > 0) {
608 $total = price2num($total, 'MT');
609
610 print '<tr class="liste_total">';
611 print '<td>'.$langs->trans("Total").'</td>';
612 print '<td>&nbsp;</td>';
613 print '<td class="right">';
614 if (empty($offset) && $num <= $limit) {
615 // If we have all record on same page, then the following test/warning can be done
616 if ($total != $object->amount) {
617 print img_warning($langs->trans("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
618 }
619 }
620 print price($total);
621 print "</td>\n";
622 print '<td>&nbsp;</td>';
623 print "</tr>\n";
624 }
625
626 print "</table>";
627 print '</div>';
628 print '</form>';
629
630 $db->free($result);
631 } else {
632 dol_print_error($db);
633 }
634}
635
636// End of page
637llxFooter();
638$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.
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.