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