dolibarr 21.0.0-beta
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 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// check if salary pl
84$salaryBonPl = $object->checkIfSalaryBonPrelevement();
85if ($type == 'bank-transfer') {
86 $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
87
88 $permissiontoadd = $user->hasRight('paymentbybanktransfer', 'create');
89 $permissiontosend = $user->hasRight('paymentbybanktransfer', 'send');
90 $permissiontocreditdebit = $user->hasRight('paymentbybanktransfer', 'debit');
91 $permissiontodelete = $user->hasRight('paymentbybanktransfer', 'read');
92} else {
93 $result = restrictedArea($user, 'prelevement', '', '', 'bons');
94
95 $permissiontoadd = $user->hasRight('prelevement', 'bons', 'creer');
96 $permissiontosend = $user->hasRight('prelevement', 'bons', 'send');
97 $permissiontocreditdebit = $user->hasRight('prelevement', 'bons', 'credit');
98 $permissiontodelete = $user->hasRight('prelevement', 'bons', 'read');
99}
100
101
102
103/*
104 * Actions
105 */
106
107$parameters = array('socid' => $socid);
108$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
109if ($reshook < 0) {
110 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
111}
112
113if (empty($reshook)) {
114 if ($action == 'setbankaccount' && $permissiontoadd) {
115 $object->oldcopy = dol_clone($object, 2);
116 $object->fk_bank_account = GETPOSTINT('fk_bank_account');
117
118 $object->update($user);
119 }
120
121 // date of upload
122 if ($action == 'setdate_trans' && $permissiontosend) {
123 $result = $object->setValueFrom('date_trans', $date_trans, '', null, 'date');
124 if ($result < 0) {
125 setEventMessages($object->error, $object->errors, 'errors');
126 }
127 }
128
129 if ($action == 'infotrans' && $permissiontosend) {
130 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
131
132 $dt = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
133
134 /*
135 if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
136 {
137 $dir = $conf->prelevement->dir_output.'/receipts';
138
139 if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
140 {
141 $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
142 }
143
144 header("Location: card.php?id=".$id);
145 exit;
146 }
147 else
148 {
149 dol_syslog("File invalid",LOG_WARNING);
150 $mesg='BadFile';
151 }*/
152
153 $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
154
155 if ($error) {
156 header("Location: card.php?id=".$id."&error=$error");
157 exit;
158 }
159 }
160
161 // Set direct debit order to credited, create payment and close invoices
162 if ($action == 'setinfocredit' && $permissiontocreditdebit) {
163 $dt = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
164
165 if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
166 $error = 1;
167 setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors');
168 } else {
169 $error = $object->set_infocredit($user, $dt, ($salaryBonPl ? 'salary' : ''));
170 }
171
172 if ($error) {
173 setEventMessages($object->error, $object->errors, 'errors');
174 }
175 }
176
177 if ($action == 'reopen' && $permissiontocreditdebit) {
178 $savtype = $object->type;
179 $res = $object->setStatut(BonPrelevement::STATUS_TRANSFERED);
180 if ($res <= 0) {
181 setEventMessages($object->error, $object->errors, 'errors');
182 }
183 }
184
185 if ($action == 'confirm_delete' && $permissiontodelete) {
186 $savtype = $object->type;
187 $res = $object->delete($user);
188 if ($res > 0) {
189 if ($savtype == 'bank-transfer') {
190 header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
191 } else {
192 header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
193 }
194 exit;
195 }
196 }
197}
198
199
200
201/*
202 * View
203 */
204
205$form = new Form($db);
206
207llxHeader('', $langs->trans("WithdrawalsReceipts"));
208
209if ($id > 0 || $ref) {
211 print dol_get_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
212
213 if (GETPOST('error', 'alpha') != '') {
214 print '<div class="error">'.$object->getErrorString(GETPOST('error', 'alpha')).'</div>';
215 }
216
217 $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>';
218
219 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
220
221 print '<div class="fichecenter">';
222 print '<div class="underbanner clearboth"></div>';
223 print '<table class="border centpercent tableforfield">';
224
225 // Date for payment
226 print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
227
228 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
229
230 // Upload file
231 if (!empty($object->date_trans)) {
232 $muser = new User($db);
233 $muser->fetch($object->user_trans);
234
235 // Date upload
236 print '<tr><td>';
237 print '<table class="nobordernopadding centpercent"><tr><td>';
238 print $langs->trans('TransData');
239 print '</td>';
240 if ($action != 'editdate_trans' && $permissiontosend) {
241 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>';
242 }
243 print '</tr></table>';
244 print '</td><td>';
245 if ($action == 'editdate_trans' && $permissiontosend) {
246 print '<form name="setdate_trans" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
247 print '<input type="hidden" name="token" value="'.newToken().'">';
248 print '<input type="hidden" name="action" value="setdate_trans">';
249 print $form->selectDate($object->date_trans ? $object->date_trans : -1, 'date_trans', 0, 0, 0, "setdate_trans");
250 print '<input type="submit" class="button button-edit smallpaddingimp valign middle" value="'.$langs->trans('Modify').'">';
251 print '</form>';
252 } else {
253 print $object->date_trans ? dol_print_date($object->date_trans, 'day') : '';
254 print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td>';
255 }
256 print '</td>';
257 print '</tr>';
258
259 // Method upload
260 print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
261 print $object->methodes_trans[$object->method_trans];
262 print '</td></tr>';
263 }
264
265 // Date real payment
266 if (!empty($object->date_credit)) {
267 print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
268 print dol_print_date($object->date_credit, 'day');
269 print '</td></tr>';
270 }
271
272 print '</table>';
273
274 print '<br>';
275
276 print '<div class="underbanner clearboth"></div>';
277 print '<table class="border centpercent tableforfield">';
278
279 // Get bank account for the payment
280 $acc = new Account($db);
281 $fk_bank_account = $object->fk_bank_account;
282 if (empty($fk_bank_account)) {
283 $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
284 }
285 if ($fk_bank_account > 0) {
286 $result = $acc->fetch($fk_bank_account);
287 }
288
289 // Bank account
290 $labelofbankfield = "BankToReceiveWithdraw";
291 if ($object->type == 'bank-transfer') {
292 $labelofbankfield = 'BankToPayCreditTransfer';
293 }
294 //print $langs->trans($labelofbankfield);
295 $caneditbank = $permissiontoadd;
296 if ($object->status != $object::STATUS_DRAFT) {
297 $caneditbank = 0;
298 }
299 /*
300 print '<tr><td class="titlefieldcreate">';
301 print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank);
302 print '</td>';
303 print '<td>';
304 print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl');
305 print '</td>';
306 print '</tr>';
307 */
308 print '<tr><td class="titlefieldcreate">';
309 print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
310 print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
311 print '<td>';
312 if (($action != 'editbankaccount') && $caneditbank) {
313 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>';
314 }
315 print '</tr></table>';
316 print '</td><td>';
317 if ($action == 'editfkbankaccount') {
318 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'fk_bank_account', 0);
319 } else {
320 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'none');
321 }
322 print "</td>";
323 print '</tr>';
324
325 // Download file
326 print '<tr><td class="titlefieldcreate">';
327 $labelfororderfield = 'WithdrawalFile';
328 if ($object->type == 'bank-transfer') {
329 $labelfororderfield = 'CreditTransferFile';
330 }
331 print $langs->trans($labelfororderfield).'</td><td>';
332
333 $modulepart = 'prelevement';
334 if ($object->type == 'bank-transfer') {
335 $modulepart = 'paymentbybanktransfer';
336 }
337
338 if (isModEnabled('multicompany')) {
339 $labelentity = $conf->entity;
340 $relativepath = 'receipts/'.$object->ref.'-'.$labelentity.'.xml';
341
342 if ($type != 'bank-transfer') {
343 $dir = $conf->prelevement->dir_output;
344 } else {
345 $dir = $conf->paymentbybanktransfer->dir_output;
346 }
347 if (!dol_is_file($dir.'/'.$relativepath)) { // For backward compatibility
348 $relativepath = 'receipts/'.$object->ref.'.xml';
349 }
350 } else {
351 $relativepath = 'receipts/'.$object->ref.'.xml';
352 }
353
354 print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
355 print img_picto('', 'download', 'class="paddingleft"');
356 print '</a>';
357 print '</td></tr>';
358
359 // Other attributes
360 $parameters = array();
361 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
362 print $hookmanager->resPrint;
363
364 print '</table>';
365
366 print '</div>';
367
368 print dol_get_fiche_end();
369
370
371 $formconfirm = '';
372
373 // Confirmation to delete
374 if ($action == 'delete') {
375 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
376 }
377
378 // Call Hook formConfirm
379 /*$parameters = array('formConfirm' => $formconfirm);
380 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
381 if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
382 elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/
383
384 // Print form confirm
385 print $formconfirm;
386
387
388 if (empty($object->date_trans) && (($user->hasRight('prelevement', 'bons', 'send') && $object->type != 'bank-transfer') || ($user->hasRight('paymentbybanktransfer', 'send') && $object->type == 'bank-transfer')) && $action == 'settransmitted') {
389 print '<form method="post" name="userfile" action="card.php?id='.$object->id.'" enctype="multipart/form-data">';
390 print '<input type="hidden" name="token" value="'.newToken().'">';
391 print '<input type="hidden" name="action" value="infotrans">';
392 print '<table class="noborder centpercent">';
393 print '<tr class="liste_titre">';
394 print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
395 print '<tr class="oddeven"><td>'.$langs->trans("TransData").'</td><td>';
396 print $form->selectDate('', '', 0, 0, 0, "userfile", 1, 1);
397 print '</td></tr>';
398 print '<tr class="oddeven"><td>'.$langs->trans("TransMetod").'</td><td>';
399 print $form->selectarray("methode", $object->methodes_trans);
400 print '</td></tr>';
401 print '</table>';
402 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("SetToStatusSent")).'"></div>';
403 print '</form>';
404 print '<br>';
405 }
406
407 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') {
408 $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited");
409 print '<form name="infocredit" method="post" action="card.php?id='.$object->id.'">';
410 print '<input type="hidden" name="token" value="'.newToken().'">';
411 print '<input type="hidden" name="action" value="setinfocredit">';
412 print '<table class="noborder centpercent">';
413 print '<tr class="liste_titre">';
414 print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
415 print '<tr class="oddeven"><td>'.$langs->trans('CreditDate').'</td><td>';
416 print $form->selectDate(-1, '', 0, 0, 0, "infocredit", 1, 1, 0, '', '', array(array('adddateof' => $object->date_trans, 'labeladddateof' => $langs->transnoentitiesnoconv('TransData'))));
417 print '</td></tr>';
418 print '</table>';
419 print '<br><div class="center"><span class="opacitymedium">'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice").'</span></div>';
420 print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).'"></div>';
421 print '</form>';
422 print '<br>';
423 }
424
425 // Actions
426 if ($action != 'settransmitted' && $action != 'setcredited') {
427 print "\n".'<div class="tabsAction">'."\n";
428 $parameters = array();
429 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
430 if (empty($reshook)) {
431 if (empty($object->date_trans)) {
432 if ($object->type == 'bank-transfer') {
433 print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'send'));
434 } else {
435 print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'send'));
436 }
437 }
438
439 if ($object->status == BonPrelevement::STATUS_TRANSFERED) {
440 if ($object->type == 'bank-transfer') {
441 print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit'));
442 } else {
443 print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit'));
444 }
445 }
446
447 if (getDolGlobalString('BANK_CAN_REOPEN_DIRECT_DEBIT_OR_CREDIT_TRANSFER')) {
448 if ($object->status == BonPrelevement::STATUS_DEBITED || $object->status == BonPrelevement::STATUS_CREDITED) {
449 if ($object->type == 'bank-transfer') {
450 print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit'));
451 } else {
452 print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit'));
453 }
454 }
455 }
456
457 if ($object->type == 'bank-transfer') {
458 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'create'));
459 } else {
460 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'creer'));
461 }
462 }
463 print '</div>';
464 }
465
466
467 $ligne = new LignePrelevement($db);
468
469 // Lines into withdraw request
470 if ($salaryBonPl) {
471 $sql = "SELECT pl.rowid, pl.statut, pl.amount, pl.fk_user,";
472 $sql .= " u.rowid as socid, u.login as name";
473 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
474 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
475 $sql .= ", ".MAIN_DB_PREFIX."user as u";
476 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
477 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
478 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
479 $sql .= " AND pl.fk_user = u.rowid";
480 if ($socid) {
481 $sql .= " AND u.rowid = ".((int) $socid);
482 }
483 $sql .= $db->order($sortfield, $sortorder);
484 } else {
485 $sql = "SELECT pl.rowid, pl.statut, pl.amount,";
486 $sql .= " s.rowid as socid, s.nom as name";
487 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
488 $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
489 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
490 $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
491 $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
492 $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
493 $sql .= " AND pl.fk_soc = s.rowid";
494 if ($socid) {
495 $sql .= " AND s.rowid = ".((int) $socid);
496 }
497 $sql .= $db->order($sortfield, $sortorder);
498 }
499 // Count total nb of records
500 $nbtotalofrecords = '';
501 if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
502 $result = $db->query($sql);
503 $nbtotalofrecords = $db->num_rows($result);
504 if (($page * $limit) > $nbtotalofrecords) {
505 // if total resultset is smaller then paging size (filtering), goto and load page 0
506 $page = 0;
507 $offset = 0;
508 }
509 }
510
511 $sql .= $db->plimit($limit + 1, $offset);
512
513 $result = $db->query($sql);
514
515 if ($result) {
516 $num = $db->num_rows($result);
517 $i = 0;
518
519 $urladd = "&id=".urlencode((string) ($id));
520 if ($limit > 0 && $limit != $conf->liste_limit) {
521 $urladd .= '&limit='.((int) $limit);
522 }
523
524 print '<form method="POST" action="'.$_SERVER ['PHP_SELF'].'" name="search_form">'."\n";
525 print '<input type="hidden" name="token" value="'.newToken().'"/>';
526 print '<input type="hidden" name="id" value="'.$id.'"/>';
527 print '<input type="hidden" name="socid" value="'.$socid.'"/>';
528 if (!empty($page)) {
529 print '<input type="hidden" name="page" value="'.$page.'"/>';
530 }
531 if (!empty($limit)) {
532 print '<input type="hidden" name="limit" value="'.$limit.'"/>';
533 }
534 if (!empty($sortfield)) {
535 print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
536 }
537 if (!empty($sortorder)) {
538 print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
539 }
540 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
541 print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
542
543 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
544 print '<table class="noborder liste centpercent">';
545 print '<tr class="liste_titre">';
546 print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder);
547 print_liste_field_titre((!$salaryBonPl ? "ThirdParty" : "Employee"), $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
548 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $urladd, 'class="right"', $sortfield, $sortorder);
550 print "</tr>\n";
551
552 $total = 0;
553
554 while ($i < min($num, $limit)) {
555 $obj = $db->fetch_object($result);
556
557 print '<tr class="oddeven">';
558
559 // Status of line
560 print "<td>";
561 print '<a class="valignmiddle" href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'&type='.$object->type.'&token='.newToken().'">';
562 print $ligne->LibStatut($obj->statut, 2);
563 print '<span class="paddingleft">'.$obj->rowid.'</span>';
564 print '</a></td>';
565 if (!$salaryBonPl) {
566 $thirdparty = new Societe($db);
567 $thirdparty->fetch($obj->socid);
568 $name = $thirdparty->getNomUrl(1);
569 } else {
570 $userSalary = new User($db);
571 $userSalary->fetch($obj->fk_user);
572 $name = $userSalary->getNomUrl(-1);
573 }
574 print '<td class="tdoverflowmax150">';
575 print($name);
576 print "</td>\n";
577
578 print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
579
580 print '<td class="right">';
581
582 if ($obj->statut == 3) {
583 print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
584 } else {
585 if ($object->statut == BonPrelevement::STATUS_CREDITED) {
586 if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
587 if ($user->hasRight('prelevement', 'bons', 'credit')) {
588 //print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
589 print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'&token='.newToken().'">'.$langs->trans("StandingOrderReject").'</a>';
590 } else {
591 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
592 }
593 }
594 } else {
595 //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine").'">'.$langs->trans("StandingOrderReject").'</a>';
596 }
597 }
598
599 print '</td></tr>';
600
601 $total += $obj->amount;
602
603 $i++;
604 }
605
606 if ($num > 0) {
607 $total = price2num($total, 'MT');
608
609 print '<tr class="liste_total">';
610 print '<td>'.$langs->trans("Total").'</td>';
611 print '<td>&nbsp;</td>';
612 print '<td class="right">';
613 if (empty($offset) && $num <= $limit) {
614 // If we have all record on same page, then the following test/warning can be done
615 if ($total != $object->amount) {
616 print img_warning($langs->trans("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
617 }
618 }
619 print price($total);
620 print "</td>\n";
621 print '<td>&nbsp;</td>';
622 print "</tr>\n";
623 }
624
625 print "</table>";
626 print '</div>';
627 print '</form>';
628
629 $db->free($result);
630 } else {
631 dol_print_error($db);
632 }
633}
634
635// End of page
636llxFooter();
637$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
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.
llxFooter()
Footer empty.
Definition document.php:107
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_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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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_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_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.
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.
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.