prelevement.php 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. <?php
  2. /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
  4. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  8. * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/compta/facture/prelevement.php
  25. * \ingroup facture
  26. * \brief Management of direct debit order or credit tranfer of invoices
  27. */
  28. // Load Dolibarr environment
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  36. require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  39. // Load translation files required by the page
  40. $langs->loadLangs(array('bills', 'banks', 'withdrawals', 'companies'));
  41. $id = (GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility
  42. $ref = GETPOST('ref', 'alpha');
  43. $socid = GETPOST('socid', 'int');
  44. $action = GETPOST('action', 'aZ09');
  45. $type = GETPOST('type', 'aZ09');
  46. $fieldid = (!empty($ref) ? 'ref' : 'rowid');
  47. if ($user->socid) {
  48. $socid = $user->socid;
  49. }
  50. $moreparam = '';
  51. if ($type == 'bank-transfer') {
  52. $object = new FactureFournisseur($db);
  53. $moreparam = '&type='.$type;
  54. } else {
  55. $object = new Facture($db);
  56. }
  57. // Load object
  58. if ($id > 0 || !empty($ref)) {
  59. $ret = $object->fetch($id, $ref);
  60. $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
  61. if ($ret > 0) {
  62. $object->fetch_thirdparty();
  63. }
  64. }
  65. $hookmanager->initHooks(array('directdebitcard', 'globalcard'));
  66. if ($type == 'bank-transfer') {
  67. $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', $fieldid, $isdraft);
  68. if (empty($user->rights->fournisseur->facture->lire)) {
  69. accessforbidden();
  70. }
  71. } else {
  72. $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft);
  73. if (!$user->rights->facture->lire) {
  74. accessforbidden();
  75. }
  76. }
  77. if ($type == 'bank-transfer') {
  78. $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
  79. } else {
  80. $usercancreate = $user->rights->facture->creer;
  81. }
  82. /*
  83. * Actions
  84. */
  85. $parameters = array('socid' => $socid);
  86. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  87. if ($reshook < 0) {
  88. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  89. }
  90. if (empty($reshook)) {
  91. if ($action == "new" && $usercancreate) {
  92. if ($object->id > 0) {
  93. $db->begin();
  94. $newtype = $type;
  95. $sourcetype = 'facture';
  96. if ($type == 'bank-transfer') {
  97. $sourcetype = 'supplier_invoice';
  98. $newtype = 'bank-transfer';
  99. }
  100. $paymentservice = GETPOST('paymentservice');
  101. $result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype);
  102. if ($result > 0) {
  103. $db->commit();
  104. setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
  105. } else {
  106. $db->rollback();
  107. setEventMessages($object->error, $object->errors, 'errors');
  108. }
  109. }
  110. $action = '';
  111. }
  112. if ($action == "delete" && $usercancreate) {
  113. if ($object->id > 0) {
  114. $result = $object->demande_prelevement_delete($user, GETPOST('did', 'int'));
  115. if ($result == 0) {
  116. header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type);
  117. exit;
  118. }
  119. }
  120. }
  121. // Payment with Direct Debit Stripe
  122. if ($action == 'sepastripepayment' && $usercancreate) {
  123. $result = $object->makeStripeSepaRequest($user, GETPOST('did', 'int'), 'direct-debit', 'facture');
  124. if ($result < 0) {
  125. setEventMessages($object->error, $object->errors, 'errors');
  126. } else {
  127. // We refresh object data
  128. $ret = $object->fetch($id, $ref);
  129. $isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
  130. if ($ret > 0) {
  131. $object->fetch_thirdparty();
  132. }
  133. }
  134. }
  135. // payments conditions
  136. if ($action == 'setconditions' && $usercancreate) {
  137. $object->fetch($id);
  138. $object->cond_reglement_code = 0; // To clean property
  139. $object->cond_reglement_id = 0; // To clean property
  140. $error = 0;
  141. $db->begin();
  142. if (!$error) {
  143. $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
  144. if ($result < 0) {
  145. $error++;
  146. setEventMessages($object->error, $object->errors, 'errors');
  147. }
  148. }
  149. if (!$error) {
  150. $old_date_echeance = $object->date_echeance;
  151. $new_date_echeance = $object->calculate_date_lim_reglement();
  152. if ($new_date_echeance > $old_date_echeance) {
  153. $object->date_echeance = $new_date_echeance;
  154. }
  155. if ($object->date_echeance < $object->date) {
  156. $object->date_echeance = $object->date;
  157. }
  158. $result = $object->update($user);
  159. if ($result < 0) {
  160. $error++;
  161. setEventMessages($object->error, $object->errors, 'errors');
  162. }
  163. }
  164. if ($error) {
  165. $db->rollback();
  166. } else {
  167. $db->commit();
  168. }
  169. } elseif ($action == 'setmode' && $usercancreate) {
  170. // payment mode
  171. $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
  172. } elseif ($action == 'setdatef' && $usercancreate) {
  173. $newdate = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int'), 'tzserver');
  174. if ($newdate > (dol_now('tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
  175. if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
  176. setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings');
  177. } else {
  178. setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings');
  179. }
  180. }
  181. $object->date = $newdate;
  182. $date_echence_calc = $object->calculate_date_lim_reglement();
  183. if (!empty($object->date_echeance) && $object->date_echeance < $date_echence_calc) {
  184. $object->date_echeance = $date_echence_calc;
  185. }
  186. if ($object->date_echeance && $object->date_echeance < $object->date) {
  187. $object->date_echeance = $object->date;
  188. }
  189. $result = $object->update($user);
  190. if ($result < 0) {
  191. dol_print_error($db, $object->error);
  192. }
  193. } elseif ($action == 'setdate_lim_reglement' && $usercancreate) {
  194. $object->date_echeance = dol_mktime(12, 0, 0, GETPOST('date_lim_reglementmonth', 'int'), GETPOST('date_lim_reglementday', 'int'), GETPOST('date_lim_reglementyear', 'int'));
  195. if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
  196. $object->date_echeance = $object->date;
  197. setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings');
  198. }
  199. $result = $object->update($user);
  200. if ($result < 0) {
  201. dol_print_error($db, $object->error);
  202. }
  203. }
  204. }
  205. /*
  206. * View
  207. */
  208. $form = new Form($db);
  209. $now = dol_now();
  210. if ($type == 'bank-transfer') {
  211. $title = $langs->trans('SupplierInvoice')." - ".$langs->trans('CreditTransfer');
  212. $helpurl = "";
  213. } else {
  214. $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('StandingOrders');
  215. $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
  216. }
  217. llxHeader('', $title, $helpurl);
  218. if ($object->id > 0) {
  219. $selleruserevenustamp = $mysoc->useRevenueStamp();
  220. $totalpaid = $object->getSommePaiement();
  221. $totalcreditnotes = $object->getSumCreditNotesUsed();
  222. $totaldeposits = $object->getSumDepositsUsed();
  223. //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits;
  224. // We can also use bcadd to avoid pb with floating points
  225. // For example print 239.2 - 229.3 - 9.9; does not return 0.
  226. //$resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT);
  227. //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
  228. $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
  229. if ($object->paye) {
  230. $resteapayer = 0;
  231. }
  232. $resteapayeraffiche = $resteapayer;
  233. if ($type == 'bank-transfer') {
  234. if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) { // Not recommended
  235. $filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
  236. $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
  237. } else {
  238. $filterabsolutediscount = "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
  239. $filtercreditnote = "fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
  240. }
  241. $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
  242. $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote, 0, 1);
  243. $absolute_discount = price2num($absolute_discount, 'MT');
  244. $absolute_creditnote = price2num($absolute_creditnote, 'MT');
  245. } else {
  246. if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Not recommended
  247. $filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
  248. $filtercreditnote = "fk_facture_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
  249. } else {
  250. $filterabsolutediscount = "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
  251. $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
  252. }
  253. $absolute_discount = $object->thirdparty->getAvailableDiscounts('', $filterabsolutediscount);
  254. $absolute_creditnote = $object->thirdparty->getAvailableDiscounts('', $filtercreditnote);
  255. $absolute_discount = price2num($absolute_discount, 'MT');
  256. $absolute_creditnote = price2num($absolute_creditnote, 'MT');
  257. }
  258. $author = new User($db);
  259. if ($object->fk_user_author) {
  260. $author->fetch($object->fk_user_author);
  261. }
  262. if ($type == 'bank-transfer') {
  263. $head = facturefourn_prepare_head($object);
  264. } else {
  265. $head = facture_prepare_head($object);
  266. }
  267. $numopen = 0;
  268. $pending = 0;
  269. $numclosed = 0;
  270. // How many Direct debit or Credit transfer open requests ?
  271. $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
  272. $sql .= " , pfd.date_traite as date_traite";
  273. $sql .= " , pfd.amount";
  274. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
  275. if ($type == 'bank-transfer') {
  276. $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
  277. } else {
  278. $sql .= " WHERE fk_facture = ".((int) $object->id);
  279. }
  280. $sql .= " AND pfd.traite = 0";
  281. $sql .= " AND pfd.ext_payment_id IS NULL";
  282. $sql .= " ORDER BY pfd.date_demande DESC";
  283. $resql = $db->query($sql);
  284. if ($resql) {
  285. $num = $db->num_rows($resql);
  286. $numopen = $num;
  287. } else {
  288. dol_print_error($db);
  289. }
  290. print dol_get_fiche_head($head, 'standingorders', $title, -1, ($type == 'bank-transfer' ? 'supplier_invoice' : 'bill'));
  291. // Invoice content
  292. if ($type == 'bank-transfer') {
  293. $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  294. } else {
  295. $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  296. }
  297. $morehtmlref = '<div class="refidno">';
  298. // Ref customer
  299. if ($type == 'bank-transfer') {
  300. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  301. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  302. } else {
  303. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
  304. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
  305. }
  306. // Thirdparty
  307. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
  308. if ($type == 'bank-transfer') {
  309. if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
  310. $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
  311. }
  312. } else {
  313. if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
  314. $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
  315. }
  316. }
  317. // Project
  318. if (isModEnabled('project')) {
  319. $langs->load("projects");
  320. $morehtmlref .= '<br>';
  321. if (0) {
  322. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  323. if ($action != 'classify') {
  324. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  325. }
  326. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  327. } else {
  328. if (!empty($object->fk_project)) {
  329. $proj = new Project($db);
  330. $proj->fetch($object->fk_project);
  331. $morehtmlref .= $proj->getNomUrl(1);
  332. if ($proj->title) {
  333. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  334. }
  335. }
  336. }
  337. }
  338. $morehtmlref .= '</div>';
  339. $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
  340. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $moreparam, 0, '', '');
  341. print '<div class="fichecenter">';
  342. print '<div class="fichehalfleft">';
  343. print '<div class="underbanner clearboth"></div>';
  344. print '<table class="border centpercent tableforfield">';
  345. // Type
  346. print '<tr><td class="titlefield fieldname_type">'.$langs->trans('Type').'</td><td colspan="3">';
  347. print '<span class="badgeneutral">';
  348. print $object->getLibType();
  349. print '</span>';
  350. if ($object->module_source) {
  351. print ' <span class="opacitymediumbycolor paddingleft">('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')</span>';
  352. }
  353. if ($object->type == $object::TYPE_REPLACEMENT) {
  354. if ($type == 'bank-transfer') {
  355. $facreplaced = new FactureFournisseur($db);
  356. } else {
  357. $facreplaced = new Facture($db);
  358. }
  359. $facreplaced->fetch($object->fk_facture_source);
  360. print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).'</span>';
  361. }
  362. if ($object->type == $object::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) {
  363. if ($type == 'bank-transfer') {
  364. $facusing = new FactureFournisseur($db);
  365. } else {
  366. $facusing = new Facture($db);
  367. }
  368. $facusing->fetch($object->fk_facture_source);
  369. print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).'</span>';
  370. }
  371. $facidavoir = $object->getListIdAvoirFromInvoice();
  372. if (count($facidavoir) > 0) {
  373. $invoicecredits = array();
  374. foreach ($facidavoir as $facid) {
  375. if ($type == 'bank-transfer') {
  376. $facavoir = new FactureFournisseur($db);
  377. } else {
  378. $facavoir = new Facture($db);
  379. }
  380. $facavoir->fetch($facid);
  381. $invoicecredits[] = $facavoir->getNomUrl(1);
  382. }
  383. print ' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities("InvoiceHasAvoir");
  384. print ' '. (count($invoicecredits) ? ' ' : '') . implode(',', $invoicecredits);
  385. print '</span>';
  386. }
  387. /*
  388. if ($objectidnext > 0) {
  389. $facthatreplace=new Facture($db);
  390. $facthatreplace->fetch($objectidnext);
  391. print ' <span class="opacitymediumbycolor paddingleft">'.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).'</span>';
  392. }
  393. */
  394. print '</td></tr>';
  395. // Relative and absolute discounts
  396. print '<!-- Discounts -->'."\n";
  397. print '<tr><td>'.$langs->trans('DiscountStillRemaining').'</td><td colspan="3">';
  398. if ($type == 'bank-transfer') {
  399. //$societe = new Fournisseur($db);
  400. //$result = $societe->fetch($object->socid);
  401. $thirdparty = $object->thirdparty;
  402. $discount_type = 1;
  403. } else {
  404. $thirdparty = $object->thirdparty;
  405. $discount_type = 0;
  406. }
  407. $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id);
  408. $cannotApplyDiscount = 1;
  409. include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php';
  410. print '</td></tr>';
  411. // Label
  412. if ($type == 'bank-transfer') {
  413. print '<tr>';
  414. print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, 0).'</td>';
  415. print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, 0).'</td>';
  416. print '</tr>';
  417. }
  418. // Date invoice
  419. print '<tr><td>';
  420. print '<table class="nobordernopadding centpercent"><tr><td>';
  421. print $langs->trans('DateInvoice');
  422. print '</td>';
  423. if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $user->rights->facture->creer) {
  424. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
  425. }
  426. print '</tr></table>';
  427. print '</td><td colspan="3">';
  428. if ($object->type != $object::TYPE_CREDIT_NOTE) {
  429. if ($action == 'editinvoicedate') {
  430. print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $object->date, 'invoicedate', 0, 0, 1, $type);
  431. } else {
  432. print dol_print_date($object->date, 'day');
  433. }
  434. } else {
  435. print dol_print_date($object->date, 'day');
  436. }
  437. print '</td>';
  438. print '</tr>';
  439. // Payment condition
  440. print '<tr><td>';
  441. print '<table class="nobordernopadding centpercent"><tr><td>';
  442. print $langs->trans('PaymentConditionsShort');
  443. print '</td>';
  444. if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editconditions' && !empty($object->brouillon) && $user->rights->facture->creer) {
  445. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
  446. }
  447. print '</tr></table>';
  448. print '</td><td colspan="3">';
  449. if ($object->type != $object::TYPE_CREDIT_NOTE) {
  450. if ($action == 'editconditions') {
  451. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 0, $type);
  452. } else {
  453. $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'none');
  454. }
  455. } else {
  456. print '&nbsp;';
  457. }
  458. print '</td></tr>';
  459. // Date payment term
  460. print '<tr><td>';
  461. print '<table class="nobordernopadding centpercent"><tr><td>';
  462. print $langs->trans('DateMaxPayment');
  463. print '</td>';
  464. if ($object->type != $object::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && !empty($object->brouillon) && $user->rights->facture->creer) {
  465. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editpaymentterm&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
  466. }
  467. print '</tr></table>';
  468. print '</td><td colspan="3">';
  469. if ($object->type != $object::TYPE_CREDIT_NOTE) {
  470. $duedate = $object->date_lim_reglement;
  471. if ($type == 'bank-transfer') {
  472. $duedate = $object->date_echeance;
  473. }
  474. if ($action == 'editpaymentterm') {
  475. print $form->form_date($_SERVER['PHP_SELF'].'?id='.$object->id, $duedate, 'paymentterm', 0, 0, 1, $type);
  476. } else {
  477. print dol_print_date($duedate, 'day');
  478. if ($object->hasDelay()) {
  479. print img_warning($langs->trans('Late'));
  480. }
  481. }
  482. } else {
  483. print '&nbsp;';
  484. }
  485. print '</td></tr>';
  486. // Payment mode
  487. print '<tr><td>';
  488. print '<table class="nobordernopadding centpercent"><tr><td>';
  489. print $langs->trans('PaymentMode');
  490. print '</td>';
  491. if ($action != 'editmode' && !empty($object->brouillon) && $user->rights->facture->creer) {
  492. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
  493. }
  494. print '</tr></table>';
  495. print '</td><td colspan="3">';
  496. $filtertype = 'CRDT';
  497. if ($type == 'bank-transfer') {
  498. $filtertype = 'DBIT';
  499. }
  500. if ($action == 'editmode') {
  501. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', $filtertype, 1, 0, $type);
  502. } else {
  503. $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none');
  504. }
  505. print '</td></tr>';
  506. // Bank Account
  507. print '<tr><td class="nowrap">';
  508. print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
  509. print $langs->trans('BankAccount');
  510. print '<td>';
  511. if (($action != 'editbankaccount') && $user->rights->commande->creer && !empty($object->brouillon)) {
  512. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&token='.newToken().'&id='.$object->id.'&type='.urlencode($type).'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
  513. }
  514. print '</tr></table>';
  515. print '</td><td colspan="3">';
  516. if ($action == 'editbankaccount') {
  517. $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
  518. } else {
  519. $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
  520. }
  521. print "</td>";
  522. print '</tr>';
  523. // IBAN of seller or supplier
  524. $title = 'CustomerIBAN';
  525. if ($type == 'bank-transfer') {
  526. $title = 'SupplierIBAN';
  527. }
  528. print '<tr><td>'.$langs->trans($title).'</td><td colspan="3">';
  529. $bac = new CompanyBankAccount($db);
  530. $bac->fetch(0, $object->thirdparty->id);
  531. print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
  532. if (!empty($bac->iban)) {
  533. if ($bac->verif() <= 0) {
  534. print img_warning('Error on default bank number for IBAN : '.$bac->error_message);
  535. }
  536. } else {
  537. if ($numopen || ($type != 'bank-transfer' && $object->mode_reglement_code == 'PRE') || ($type == 'bank-transfer' && $object->mode_reglement_code == 'VIR')) {
  538. print img_warning($langs->trans("NoDefaultIBANFound"));
  539. }
  540. }
  541. print '</td></tr>';
  542. print '</table>';
  543. print '</div>';
  544. print '<div class="fichehalfright">';
  545. print '<div class="underbanner clearboth"></div>';
  546. print '<table class="border centpercent tableforfield">';
  547. if (isModEnabled('multicurrency') && ($object->multicurrency_code != $conf->currency)) {
  548. // Multicurrency Amount HT
  549. print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
  550. print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
  551. print '</tr>';
  552. // Multicurrency Amount VAT
  553. print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>';
  554. print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
  555. print '</tr>';
  556. // Multicurrency Amount TTC
  557. print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>';
  558. print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
  559. print '</tr>';
  560. }
  561. // Amount
  562. print '<tr><td class="titlefield">'.$langs->trans('AmountHT').'</td>';
  563. print '<td class="nowrap">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
  564. // Vat
  565. print '<tr><td>'.$langs->trans('AmountVAT').'</td><td colspan="3" class="nowrap">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
  566. print '</tr>';
  567. // Amount Local Taxes
  568. if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1
  569. print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
  570. print '<td class="nowrap">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
  571. }
  572. if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2
  573. print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
  574. print '<td class=nowrap">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
  575. }
  576. // Revenue stamp
  577. if ($selleruserevenustamp) { // Test company use revenue stamp
  578. print '<tr><td>';
  579. print '<table class="nobordernopadding" width="100%"><tr><td>';
  580. print $langs->trans('RevenueStamp');
  581. print '</td>';
  582. if ($action != 'editrevenuestamp' && !empty($object->brouillon) && $user->rights->facture->creer) {
  583. print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editrevenuestamp&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetRevenuStamp'), 1).'</a></td>';
  584. }
  585. print '</tr></table>';
  586. print '</td><td>';
  587. print price($object->revenuestamp, 1, '', 1, - 1, - 1, $conf->currency);
  588. print '</td></tr>';
  589. }
  590. // Total with tax
  591. print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="nowrap">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
  592. $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT');
  593. // TODO Replace this by an include with same code to show already done payment visible in invoice card
  594. print '<tr><td>'.$langs->trans('RemainderToPay').'</td><td class="nowrap">'.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
  595. print '</table>';
  596. print '</div>';
  597. print '</div>';
  598. print '<div class="clearboth"></div>';
  599. print dol_get_fiche_end();
  600. // For which amount ?
  601. $sql = "SELECT SUM(pfd.amount) as amount";
  602. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
  603. if ($type == 'bank-transfer') {
  604. $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
  605. } else {
  606. $sql .= " WHERE fk_facture = ".((int) $object->id);
  607. }
  608. $sql .= " AND pfd.traite = 0";
  609. $sql .= " AND pfd.ext_payment_id IS NULL";
  610. $resql = $db->query($sql);
  611. if ($resql) {
  612. $obj = $db->fetch_object($resql);
  613. if ($obj) {
  614. $pending = $obj->amount;
  615. }
  616. } else {
  617. dol_print_error($db);
  618. }
  619. /*
  620. * Buttons
  621. */
  622. print "\n".'<div class="tabsAction">'."\n";
  623. $buttonlabel = $langs->trans("MakeWithdrawRequest");
  624. $user_perms = $user->rights->prelevement->bons->creer;
  625. if ($type == 'bank-transfer') {
  626. $buttonlabel = $langs->trans("MakeBankTransferOrder");
  627. $user_perms = $user->rights->paymentbybanktransfer->create;
  628. }
  629. // Add a transfer request
  630. if ($object->statut > $object::STATUS_DRAFT && $object->paye == 0 && $num == 0) {
  631. if ($resteapayer > 0) {
  632. if ($user_perms) {
  633. $remaintopaylesspendingdebit = $resteapayer - $pending;
  634. print '<form method="POST" action="">';
  635. print '<input type="hidden" name="token" value="'.newToken().'" />';
  636. print '<input type="hidden" name="id" value="'.$object->id.'" />';
  637. print '<input type="hidden" name="type" value="'.$type.'" />';
  638. print '<input type="hidden" name="action" value="new" />';
  639. print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
  640. print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />';
  641. print '<input type="submit" class="butAction" value="'.$buttonlabel.'" />';
  642. print '</form>';
  643. if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT_SHOW_BUTTON)) {
  644. // TODO Replace this with a checkbox for each payment mode: "Send request to PaymentModeManager immediatly..."
  645. print "<br>";
  646. //add stripe sepa button
  647. $buttonlabel = $langs->trans("MakeWithdrawRequestStripe");
  648. print '<form method="POST" action="">';
  649. print '<input type="hidden" name="token" value="'.newToken().'" />';
  650. print '<input type="hidden" name="id" value="'.$object->id.'" />';
  651. print '<input type="hidden" name="type" value="'.$type.'" />';
  652. print '<input type="hidden" name="action" value="new" />';
  653. print '<input type="hidden" name="paymenservice" value="stripesepa" />';
  654. print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
  655. print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />';
  656. print '<input type="submit" class="butAction" value="'.$buttonlabel.'" />';
  657. print '</form>';
  658. }
  659. } else {
  660. print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$buttonlabel.'</a>';
  661. }
  662. } else {
  663. print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("AmountMustBePositive")).'">'.$buttonlabel.'</a>';
  664. }
  665. } else {
  666. if ($num == 0) {
  667. if ($object->statut > $object::STATUS_DRAFT) {
  668. print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPaid")).'">'.$buttonlabel.'</a>';
  669. } else {
  670. print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("Draft")).'">'.$buttonlabel.'</a>';
  671. }
  672. } else {
  673. print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("RequestAlreadyDone")).'">'.$buttonlabel.'</a>';
  674. }
  675. }
  676. print "</div>\n";
  677. if ($type == 'bank-transfer') {
  678. print '<div class="opacitymedium">'.$langs->trans("DoCreditTransferBeforePayments");
  679. if (isModEnabled('stripe')) {
  680. print ' '.$langs->trans("DoStandingOrdersBeforePayments2");
  681. }
  682. print ' '.$langs->trans("DoStandingOrdersBeforePayments3");
  683. print '</div><br>';
  684. } else {
  685. print '<div class="opacitymedium">'.$langs->trans("DoStandingOrdersBeforePayments");
  686. if (isModEnabled('stripe')) {
  687. print ' '.$langs->trans("DoStandingOrdersBeforePayments2");
  688. }
  689. print ' '.$langs->trans("DoStandingOrdersBeforePayments3");
  690. print '</div><br>';
  691. }
  692. /*
  693. * Withdrawals
  694. */
  695. print '<div class="div-table-responsive-no-min">';
  696. print '<table class="noborder centpercent">';
  697. print '<tr class="liste_titre">';
  698. print '<td class="left">'.$langs->trans("DateRequest").'</td>';
  699. print '<td class="center">'.$langs->trans("User").'</td>';
  700. print '<td class="center">'.$langs->trans("Amount").'</td>';
  701. print '<td class="center">'.$langs->trans("DateProcess").'</td>';
  702. print '<td>&nbsp;</td>';
  703. if ($type == 'bank-transfer') {
  704. print '<td class="center">'.$langs->trans("BankTransferReceipt").'</td>';
  705. } else {
  706. print '<td class="center">'.$langs->trans("WithdrawalReceipt").'</td>';
  707. }
  708. print '<td>&nbsp;</td>';
  709. print '</tr>';
  710. $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
  711. $sql .= " pfd.date_traite as date_traite, pfd.amount,";
  712. $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
  713. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
  714. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
  715. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
  716. if ($type == 'bank-transfer') {
  717. $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
  718. } else {
  719. $sql .= " WHERE fk_facture = ".((int) $object->id);
  720. }
  721. $sql .= " AND pfd.traite = 0";
  722. $sql .= " AND pfd.ext_payment_id IS NULL";
  723. $sql .= " ORDER BY pfd.date_demande DESC";
  724. $resql = $db->query($sql);
  725. $num = 0;
  726. if ($resql) {
  727. $i = 0;
  728. $tmpuser = new User($db);
  729. $num = $db->num_rows($result);
  730. while ($i < $num) {
  731. $obj = $db->fetch_object($resql);
  732. $tmpuser->id = $obj->user_id;
  733. $tmpuser->login = $obj->login;
  734. $tmpuser->ref = $obj->login;
  735. $tmpuser->email = $obj->email;
  736. $tmpuser->lastname = $obj->lastname;
  737. $tmpuser->firstname = $obj->firstname;
  738. $tmpuser->statut = $obj->user_status;
  739. print '<tr class="oddeven">';
  740. // Date
  741. print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n";
  742. // User
  743. print '<td align="center">';
  744. print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
  745. print '</td>';
  746. // Amount
  747. print '<td class="center"><span class="amount">'.price($obj->amount).'</span></td>';
  748. // Ref of SEPA request
  749. print '<td class="center"><span class="opacitymedium">'.$langs->trans("OrderWaiting").'</span></td>';
  750. print '<td>';
  751. if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) {
  752. $langs->load("stripe");
  753. print '<a href="'.$_SERVER["PHP_SELF"].'?action=sepastripepayment&paymentservice=stripesepa&token='.newToken().'&did='.$obj->rowid.'&id='.$object->id.'&type='.urlencode($type).'">'.img_picto('', 'stripe', 'class="pictofixedwidth"').$langs->trans("RequestDirectDebitWithStripe").'</a>';
  754. }
  755. print '</td>';
  756. print '<td align="center">-</td>';
  757. print '<td class="right">';
  758. print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'&did='.$obj->rowid.'&type='.$type.'">';
  759. print img_delete();
  760. print '</a></td>';
  761. print "</tr>\n";
  762. $i++;
  763. }
  764. $db->free($resql);
  765. } else {
  766. dol_print_error($db);
  767. }
  768. // Past requests
  769. $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
  770. $sql .= " pb.ref,";
  771. $sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
  772. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
  773. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
  774. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
  775. if ($type == 'bank-transfer') {
  776. $sql .= " WHERE fk_facture_fourn = ".((int) $object->id);
  777. } else {
  778. $sql .= " WHERE fk_facture = ".((int) $object->id);
  779. }
  780. $sql .= " AND pfd.traite = 1";
  781. $sql .= " AND pfd.ext_payment_id IS NULL";
  782. $sql .= " ORDER BY pfd.date_demande DESC";
  783. $result = $db->query($sql);
  784. if ($result) {
  785. $num = $db->num_rows($result);
  786. $numclosed = $num;
  787. $i = 0;
  788. $tmpuser = new User($db);
  789. while ($i < $num) {
  790. $obj = $db->fetch_object($result);
  791. $tmpuser->id = $obj->user_id;
  792. $tmpuser->login = $obj->login;
  793. $tmpuser->ref = $obj->login;
  794. $tmpuser->email = $obj->email;
  795. $tmpuser->lastname = $obj->lastname;
  796. $tmpuser->firstname = $obj->firstname;
  797. $tmpuser->statut = $obj->user_status;
  798. print '<tr class="oddeven">';
  799. print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'day')."</td>\n";
  800. print '<td align="center">';
  801. print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
  802. print '</td>';
  803. // Amount
  804. print '<td class="center"><span class="amount">'.price($obj->amount).'</span></td>';
  805. print '<td class="center">';
  806. if ($obj->fk_prelevement_bons > 0) {
  807. $withdrawreceipt = new BonPrelevement($db);
  808. $withdrawreceipt->id = $obj->fk_prelevement_bons;
  809. $withdrawreceipt->ref = $obj->ref;
  810. print $withdrawreceipt->getNomUrl(1);
  811. }
  812. print "</td>\n";
  813. print '<td>&nbsp;</td>';
  814. print '<td class="center">'.dol_print_date($db->jdate($obj->date_traite), 'day')."</td>\n";
  815. print '<td>&nbsp;</td>';
  816. print "</tr>\n";
  817. $i++;
  818. }
  819. if (!$numopen && !$numclosed) {
  820. print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
  821. }
  822. $db->free($result);
  823. } else {
  824. dol_print_error($db);
  825. }
  826. print "</table>";
  827. print '</div>';
  828. }
  829. // End of page
  830. llxFooter();
  831. $db->close();