card.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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. /**
  21. * \file htdocs/compta/prelevement/card.php
  22. * \ingroup prelevement
  23. * \brief Card of a direct debit
  24. */
  25. // Load Dolibarr environment
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  31. // Load translation files required by the page
  32. $langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
  33. // Get supervariables
  34. $action = GETPOST('action', 'aZ09');
  35. $id = GETPOST('id', 'int');
  36. $ref = GETPOST('ref', 'alpha');
  37. $socid = GETPOST('socid', 'int');
  38. $type = GETPOST('type', 'aZ09');
  39. // Load variable for pagination
  40. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  41. $sortfield = GETPOST('sortfield', 'aZ09comma');
  42. $sortorder = GETPOST('sortorder', 'aZ09comma');
  43. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  44. if (empty($page) || $page == -1) {
  45. $page = 0;
  46. } // If $page is not defined, or '' or -1
  47. $offset = $limit * $page;
  48. $pageprev = $page - 1;
  49. $pagenext = $page + 1;
  50. if (!$sortfield) {
  51. $sortfield = 'pl.rowid';
  52. }
  53. if (!$sortorder) {
  54. $sortorder = 'ASC';
  55. }
  56. $object = new BonPrelevement($db);
  57. // Load object
  58. include 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
  59. $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
  60. $type = $object->type;
  61. if ($type == 'bank-transfer') {
  62. $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
  63. $permissiontoadd = $user->hasRight('paymentbybanktransfer', 'read');
  64. $permissiontosend = $user->hasRight('paymentbybanktransfer', 'send');
  65. $permissiontocreditdebit = $user->hasRight('paymentbybanktransfer', 'debit');
  66. $permissiontodelete = $user->hasRight('paymentbybanktransfer', 'read');
  67. } else {
  68. $result = restrictedArea($user, 'prelevement', '', '', 'bons');
  69. $permissiontoadd = $user->hasRight('prelevement', 'bons', 'read');
  70. $permissiontosend = $user->hasRight('prelevement', 'bons', 'send');
  71. $permissiontocreditdebit = $user->hasRight('prelevement', 'bons', 'credit');
  72. $permissiontodelete = $user->hasRight('prelevement', 'bons', 'read');
  73. }
  74. /*
  75. * Actions
  76. */
  77. $parameters = array('socid' => $socid);
  78. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  79. if ($reshook < 0) {
  80. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  81. }
  82. if (empty($reshook)) {
  83. if ($action == 'setbankaccount' && $permissiontoadd) {
  84. $object->oldcopy = dol_clone($object);
  85. $object->fk_bank_account = GETPOST('fk_bank_account', 'int');
  86. $object->update($user);
  87. }
  88. if ($action == 'infotrans' && $permissiontosend) {
  89. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  90. $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  91. /*
  92. if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
  93. {
  94. $dir = $conf->prelevement->dir_output.'/receipts';
  95. if (dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $dir . "/" . dol_unescapefile($_FILES['userfile']['name']),1) > 0)
  96. {
  97. $object->set_infotrans($user, $dt, GETPOST('methode','alpha'));
  98. }
  99. header("Location: card.php?id=".$id);
  100. exit;
  101. }
  102. else
  103. {
  104. dol_syslog("Fichier invalide",LOG_WARNING);
  105. $mesg='BadFile';
  106. }*/
  107. $error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
  108. if ($error) {
  109. header("Location: card.php?id=".$id."&error=$error");
  110. exit;
  111. }
  112. }
  113. // Set direct debit order to credited, create payment and close invoices
  114. if ($action == 'infocredit' && $permissiontocreditdebit) {
  115. $dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  116. if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
  117. $error = 1;
  118. setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors');
  119. } else {
  120. $error = $object->set_infocredit($user, $dt);
  121. }
  122. if ($error) {
  123. setEventMessages($object->error, $object->errors, 'errors');
  124. }
  125. }
  126. if ($action == 'confirm_delete' && $permissiontodelete) {
  127. $savtype = $object->type;
  128. $res = $object->delete($user);
  129. if ($res > 0) {
  130. if ($savtype == 'bank-transfer') {
  131. header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
  132. } else {
  133. header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
  134. }
  135. exit;
  136. }
  137. }
  138. }
  139. /*
  140. * View
  141. */
  142. $form = new Form($db);
  143. llxHeader('', $langs->trans("WithdrawalsReceipts"));
  144. if ($id > 0 || $ref) {
  145. $head = prelevement_prepare_head($object);
  146. print dol_get_fiche_head($head, 'prelevement', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
  147. if (GETPOST('error', 'alpha') != '') {
  148. print '<div class="error">'.$object->getErrorString(GETPOST('error', 'alpha')).'</div>';
  149. }
  150. $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>';
  151. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
  152. print '<div class="fichecenter">';
  153. print '<div class="underbanner clearboth"></div>';
  154. print '<table class="border centpercent tableforfield">';
  155. print '<tr><td class="titlefieldcreate">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
  156. print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount).'</span></td></tr>';
  157. if (!empty($object->date_trans)) {
  158. $muser = new User($db);
  159. $muser->fetch($object->user_trans);
  160. print '<tr><td>'.$langs->trans("TransData").'</td><td>';
  161. print dol_print_date($object->date_trans, 'day');
  162. print ' &nbsp; <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getNomUrl(-1).'</td></tr>';
  163. print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
  164. print $object->methodes_trans[$object->method_trans];
  165. print '</td></tr>';
  166. }
  167. if (!empty($object->date_credit)) {
  168. print '<tr><td>'.$langs->trans('CreditDate').'</td><td>';
  169. print dol_print_date($object->date_credit, 'day');
  170. print '</td></tr>';
  171. }
  172. print '</table>';
  173. print '<br>';
  174. print '<div class="underbanner clearboth"></div>';
  175. print '<table class="border centpercent tableforfield">';
  176. // Get bank account for the payment
  177. $acc = new Account($db);
  178. $fk_bank_account = $object->fk_bank_account;
  179. if (empty($fk_bank_account)) {
  180. $fk_bank_account = ($object->type == 'bank-transfer' ? getDolGlobalInt('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT') : getDolGlobalInt('PRELEVEMENT_ID_BANKACCOUNT'));
  181. }
  182. if ($fk_bank_account > 0) {
  183. $result = $acc->fetch($fk_bank_account);
  184. }
  185. // Bank account
  186. $labelofbankfield = "BankToReceiveWithdraw";
  187. if ($object->type == 'bank-transfer') {
  188. $labelofbankfield = 'BankToPayCreditTransfer';
  189. }
  190. //print $langs->trans($labelofbankfield);
  191. $caneditbank = $permissiontoadd;
  192. if ($object->status != $object::STATUS_DRAFT) {
  193. $caneditbank = 0;
  194. }
  195. /*
  196. print '<tr><td class="titlefieldcreate">';
  197. print $form->editfieldkey($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $object, $caneditbank);
  198. print '</td>';
  199. print '<td>';
  200. print $form->editfieldval($langs->trans($labelofbankfield), 'fk_bank_account', $acc->id, $acc, $caneditbank, 'string', '', null, null, '', 1, 'getNomUrl');
  201. print '</td>';
  202. print '</tr>';
  203. */
  204. print '<tr><td class="titlefieldcreate">';
  205. print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
  206. print $form->textwithpicto($langs->trans("BankAccount"), $langs->trans($labelofbankfield));
  207. print '<td>';
  208. if (($action != 'editbankaccount') && $caneditbank) {
  209. 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>';
  210. }
  211. print '</tr></table>';
  212. print '</td><td>';
  213. if ($action == 'editfkbankaccount') {
  214. $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'fk_bank_account', 0);
  215. } else {
  216. $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $fk_bank_account, 'none');
  217. }
  218. print "</td>";
  219. print '</tr>';
  220. // Donwload file
  221. print '<tr><td class="titlefieldcreate">';
  222. $labelfororderfield = 'WithdrawalFile';
  223. if ($object->type == 'bank-transfer') {
  224. $labelfororderfield = 'CreditTransferFile';
  225. }
  226. print $langs->trans($labelfororderfield).'</td><td>';
  227. $relativepath = 'receipts/'.$object->ref.'.xml';
  228. $modulepart = 'prelevement';
  229. if ($object->type == 'bank-transfer') {
  230. $modulepart = 'paymentbybanktransfer';
  231. }
  232. print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath;
  233. print img_picto('', 'download', 'class="paddingleft"');
  234. print '</a>';
  235. print '</td></tr>';
  236. // Other attributes
  237. $parameters = array();
  238. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  239. print $hookmanager->resPrint;
  240. print '</table>';
  241. print '</div>';
  242. print dol_get_fiche_end();
  243. $formconfirm = '';
  244. // Confirmation to delete
  245. if ($action == 'delete') {
  246. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
  247. }
  248. // Call Hook formConfirm
  249. /*$parameters = array('formConfirm' => $formconfirm);
  250. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  251. if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
  252. elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/
  253. // Print form confirm
  254. print $formconfirm;
  255. if (empty($object->date_trans) && (($user->rights->prelevement->bons->send && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type == 'bank-transfer')) && $action == 'settransmitted') {
  256. print '<form method="post" name="userfile" action="card.php?id='.$object->id.'" enctype="multipart/form-data">';
  257. print '<input type="hidden" name="token" value="'.newToken().'">';
  258. print '<input type="hidden" name="action" value="infotrans">';
  259. print '<table class="noborder centpercent">';
  260. print '<tr class="liste_titre">';
  261. print '<td colspan="3">'.$langs->trans("NotifyTransmision").'</td></tr>';
  262. print '<tr class="oddeven"><td>'.$langs->trans("TransData").'</td><td>';
  263. print $form->selectDate('', '', '', '', '', "userfile", 1, 1);
  264. print '</td></tr>';
  265. print '<tr class="oddeven"><td>'.$langs->trans("TransMetod").'</td><td>';
  266. print $form->selectarray("methode", $object->methodes_trans);
  267. print '</td></tr>';
  268. print '</table>';
  269. print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("SetToStatusSent")).'"></div>';
  270. print '</form>';
  271. print '<br>';
  272. }
  273. if (!empty($object->date_trans) && empty($object->date_credit) && (($user->rights->prelevement->bons->credit && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->debit && $object->type == 'bank-transfer')) && $action == 'setcredited') {
  274. $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited");
  275. print '<form name="infocredit" method="post" action="card.php?id='.$object->id.'">';
  276. print '<input type="hidden" name="token" value="'.newToken().'">';
  277. print '<input type="hidden" name="action" value="infocredit">';
  278. print '<table class="noborder centpercent">';
  279. print '<tr class="liste_titre">';
  280. print '<td colspan="3">'.$langs->trans("NotifyCredit").'</td></tr>';
  281. print '<tr class="oddeven"><td>'.$langs->trans('CreditDate').'</td><td>';
  282. print $form->selectDate(-1, '', '', '', '', "infocredit", 1, 1);
  283. print '</td></tr>';
  284. print '</table>';
  285. print '<br><div class="center"><span class="opacitymedium">'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice").'</span></div>';
  286. print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($btnLabel).'"></div>';
  287. print '</form>';
  288. print '<br>';
  289. }
  290. // Actions
  291. if ($action != 'settransmitted' && $action != 'setcredited') {
  292. print "\n".'<div class="tabsAction">'."\n";
  293. $parameters = array();
  294. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  295. if (empty($reshook)) {
  296. if (empty($object->date_trans)) {
  297. if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->send);
  298. else print dolGetButtonAction($langs->trans("SetToStatusSent"), '', 'default', 'card.php?action=settransmitted&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->send);
  299. }
  300. if (!empty($object->date_trans) && empty($object->date_credit)) {
  301. if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->debit);
  302. else print dolGetButtonAction($langs->trans("ClassCredited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->credit);
  303. }
  304. if ($object->type == 'bank-transfer') print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->paymentbybanktransfer->create);
  305. else print dolGetButtonAction($langs->trans("Delete"), '', 'delete', 'card.php?action=delete&token='.newToken().'&id='.$object->id, '', $user->rights->prelevement->bons->creer);
  306. }
  307. print '</div>';
  308. }
  309. $ligne = new LignePrelevement($db);
  310. /*
  311. * Lines into withdraw request
  312. */
  313. $sql = "SELECT pl.rowid, pl.statut, pl.amount,";
  314. $sql .= " s.rowid as socid, s.nom as name";
  315. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
  316. $sql .= ", ".MAIN_DB_PREFIX."prelevement_bons as pb";
  317. $sql .= ", ".MAIN_DB_PREFIX."societe as s";
  318. $sql .= " WHERE pl.fk_prelevement_bons = ".((int) $id);
  319. $sql .= " AND pl.fk_prelevement_bons = pb.rowid";
  320. $sql .= " AND pb.entity = ".((int) $conf->entity); // No sharing of entity here
  321. $sql .= " AND pl.fk_soc = s.rowid";
  322. if ($socid) {
  323. $sql .= " AND s.rowid = ".((int) $socid);
  324. }
  325. $sql .= $db->order($sortfield, $sortorder);
  326. // Count total nb of records
  327. $nbtotalofrecords = '';
  328. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  329. $result = $db->query($sql);
  330. $nbtotalofrecords = $db->num_rows($result);
  331. if (($page * $limit) > $nbtotalofrecords) {
  332. // if total resultset is smaller then paging size (filtering), goto and load page 0
  333. $page = 0;
  334. $offset = 0;
  335. }
  336. }
  337. $sql .= $db->plimit($limit + 1, $offset);
  338. $result = $db->query($sql);
  339. if ($result) {
  340. $num = $db->num_rows($result);
  341. $i = 0;
  342. $urladd = "&id=".urlencode($id);
  343. if ($limit > 0 && $limit != $conf->liste_limit) {
  344. $urladd .= '&limit='.((int) $limit);
  345. }
  346. print '<form method="POST" action="'.$_SERVER ['PHP_SELF'].'" name="search_form">'."\n";
  347. print '<input type="hidden" name="token" value="'.newToken().'"/>';
  348. print '<input type="hidden" name="id" value="'.$id.'"/>';
  349. print '<input type="hidden" name="socid" value="'.$socid.'"/>';
  350. if (!empty($page)) {
  351. print '<input type="hidden" name="page" value="'.$page.'"/>';
  352. }
  353. if (!empty($limit)) {
  354. print '<input type="hidden" name="limit" value="'.$limit.'"/>';
  355. }
  356. if (!empty($sortfield)) {
  357. print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
  358. }
  359. if (!empty($sortorder)) {
  360. print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
  361. }
  362. print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit);
  363. 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
  364. print '<table class="noborder liste" width="100%" cellpadding="4">';
  365. print '<tr class="liste_titre">';
  366. print_liste_field_titre("Lines", $_SERVER["PHP_SELF"], "pl.rowid", '', $urladd, '', $sortfield, $sortorder);
  367. print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd, '', $sortfield, $sortorder);
  368. print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $urladd, 'class="right"', $sortfield, $sortorder);
  369. print_liste_field_titre('');
  370. print "</tr>\n";
  371. $total = 0;
  372. while ($i < min($num, $limit)) {
  373. $obj = $db->fetch_object($result);
  374. print '<tr class="oddeven">';
  375. // Status of line
  376. print "<td>";
  377. print '<a class="valignmiddle" href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'&type='.$object->type.'&token='.newToken().'">';
  378. print $ligne->LibStatut($obj->statut, 2);
  379. print '<span class="paddingleft">'.$obj->rowid.'</span>';
  380. print '</a></td>';
  381. $thirdparty = new Societe($db);
  382. $thirdparty->fetch($obj->socid);
  383. print '<td>';
  384. print $thirdparty->getNomUrl(1);
  385. print "</td>\n";
  386. print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
  387. print '<td class="right">';
  388. if ($obj->statut == 3) {
  389. print '<b>'.$langs->trans("StatusRefused").'</b>';
  390. } else {
  391. if ($object->statut == BonPrelevement::STATUS_CREDITED) {
  392. if ($obj->statut == 2) {
  393. if ($user->rights->prelevement->bons->credit) {
  394. //print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
  395. print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'&token='.newToken().'">'.$langs->trans("StandingOrderReject").'</a>';
  396. } else {
  397. //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
  398. }
  399. }
  400. } else {
  401. //print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotPossibleForThisStatusOfWithdrawReceiptORLine").'">'.$langs->trans("StandingOrderReject").'</a>';
  402. }
  403. }
  404. print '</td></tr>';
  405. $total += $obj->amount;
  406. $i++;
  407. }
  408. if ($num > 0) {
  409. $total = price2num($total, 'MT');
  410. print '<tr class="liste_total">';
  411. print '<td>'.$langs->trans("Total").'</td>';
  412. print '<td>&nbsp;</td>';
  413. print '<td class="right">';
  414. if (empty($offset) && $num <= $limit) {
  415. // If we have all record on same page, then the following test/warning can be done
  416. if ($total != $object->amount) {
  417. print img_warning($langs->trans("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"));
  418. }
  419. }
  420. print price($total);
  421. print "</td>\n";
  422. print '<td>&nbsp;</td>';
  423. print "</tr>\n";
  424. }
  425. print "</table>";
  426. print '</div>';
  427. print '</form>';
  428. $db->free($result);
  429. } else {
  430. dol_print_error($db);
  431. }
  432. }
  433. // End of page
  434. llxFooter();
  435. $db->close();