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