paiement.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996
  1. <?php
  2. /* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
  7. * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
  8. * Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
  9. * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
  10. * Copyright (C) 2015 Juanjo Menent <jmenent@2byte.es>
  11. * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
  12. * Copyright (C) 2023 Lenin Rivas <lenin.rivas777@gmail.com>
  13. * Copyright (C) 2023 Sylvain Legrand <technique@infras.fr>
  14. * Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr>
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 3 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  28. */
  29. /**
  30. * \file htdocs/compta/paiement.php
  31. * \ingroup facture
  32. * \brief Payment page for customers invoices
  33. */
  34. // Load Dolibarr environment
  35. require '../main.inc.php';
  36. require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
  37. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  38. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  39. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  40. // Load translation files required by the page
  41. $langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency'));
  42. $action = GETPOST('action', 'alpha');
  43. $confirm = GETPOST('confirm', 'alpha');
  44. $facid = GETPOST('facid', 'int');
  45. $accountid = GETPOST('accountid', 'int');
  46. $paymentnum = GETPOST('num_paiement', 'alpha');
  47. $socid = GETPOST('socid', 'int');
  48. $sortfield = GETPOST('sortfield', 'aZ09comma');
  49. $sortorder = GETPOST('sortorder', 'aZ09comma');
  50. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  51. $amounts = array();
  52. $amountsresttopay = array();
  53. $addwarning = 0;
  54. $multicurrency_amounts = array();
  55. $multicurrency_amountsresttopay = array();
  56. // Security check
  57. if ($user->socid > 0) {
  58. $socid = $user->socid;
  59. }
  60. $object = new Facture($db);
  61. // Load object
  62. if ($facid > 0) {
  63. $ret = $object->fetch($facid);
  64. }
  65. // Initialize technical object to manage hooks of paiements. Note that conf->hooks_modules contains array array
  66. $hookmanager->initHooks(array('paiementcard', 'globalcard'));
  67. $formquestion = array();
  68. $usercanissuepayment = $user->hasRight('facture', 'paiement');
  69. $fieldid = 'rowid';
  70. $isdraft = (($object->statut == Facture::STATUS_DRAFT) ? 1 : 0);
  71. $result = restrictedArea($user, 'facture', $object->id, '', '', 'fk_soc', $fieldid, $isdraft);
  72. /*
  73. * Actions
  74. */
  75. $parameters = array('socid'=>$socid);
  76. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  77. if ($reshook < 0) {
  78. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  79. }
  80. if (empty($reshook)) {
  81. if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) {
  82. $error = 0;
  83. $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  84. $paiement_id = 0;
  85. $totalpayment = 0;
  86. $multicurrency_totalpayment = 0;
  87. $atleastonepaymentnotnull = 0;
  88. $formquestion = array();
  89. $i = 0;
  90. // Generate payment array and check if there is payment higher than invoice and payment date before invoice date
  91. $tmpinvoice = new Facture($db);
  92. foreach ($_POST as $key => $value) {
  93. if (substr($key, 0, 7) == 'amount_' && GETPOST($key) != '') {
  94. $cursorfacid = substr($key, 7);
  95. $amounts[$cursorfacid] = price2num(GETPOST($key));
  96. $totalpayment = $totalpayment + $amounts[$cursorfacid];
  97. if (!empty($amounts[$cursorfacid])) {
  98. $atleastonepaymentnotnull++;
  99. }
  100. $result = $tmpinvoice->fetch($cursorfacid);
  101. if ($result <= 0) {
  102. dol_print_error($db);
  103. }
  104. $amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
  105. if ($amounts[$cursorfacid]) {
  106. // Check amount
  107. if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) {
  108. $addwarning = 1;
  109. $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
  110. }
  111. // Check date
  112. if ($datepaye && ($datepaye < $tmpinvoice->date)) {
  113. $langs->load("errors");
  114. //$error++;
  115. setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
  116. }
  117. }
  118. $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key));
  119. } elseif (substr($key, 0, 21) == 'multicurrency_amount_') {
  120. $cursorfacid = substr($key, 21);
  121. $multicurrency_amounts[$cursorfacid] = price2num(GETPOST($key));
  122. $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
  123. if (!empty($multicurrency_amounts[$cursorfacid])) {
  124. $atleastonepaymentnotnull++;
  125. }
  126. $result = $tmpinvoice->fetch($cursorfacid);
  127. if ($result <= 0) {
  128. dol_print_error($db);
  129. }
  130. $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
  131. if ($multicurrency_amounts[$cursorfacid]) {
  132. // Check amount
  133. if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) {
  134. $addwarning = 1;
  135. $formquestion['text'] = img_warning($langs->trans("PaymentHigherThanReminderToPay")).' '.$langs->trans("HelpPaymentHigherThanReminderToPay");
  136. }
  137. // Check date
  138. if ($datepaye && ($datepaye < $tmpinvoice->date)) {
  139. $langs->load("errors");
  140. //$error++;
  141. setEventMessages($langs->transnoentities("WarningPaymentDateLowerThanInvoiceDate", dol_print_date($datepaye, 'day'), dol_print_date($tmpinvoice->date, 'day'), $tmpinvoice->ref), null, 'warnings');
  142. }
  143. }
  144. $formquestion[$i++] = array('type' => 'hidden', 'name' => $key, 'value' => GETPOST($key, 'int'));
  145. }
  146. }
  147. // Check parameters
  148. if (!GETPOST('paiementcode')) {
  149. setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('PaymentMode')), null, 'errors');
  150. $error++;
  151. }
  152. if (isModEnabled("banque")) {
  153. // If bank module is on, account is required to enter a payment
  154. if (GETPOST('accountid') <= 0) {
  155. setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
  156. $error++;
  157. }
  158. }
  159. if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
  160. setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->trans('PaymentAmount')), null, 'errors');
  161. $error++;
  162. }
  163. if (empty($datepaye)) {
  164. setEventMessages($langs->transnoentities('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors');
  165. $error++;
  166. }
  167. // Check if payments in both currency
  168. if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
  169. $langs->load("errors");
  170. setEventMessages($langs->transnoentities('ErrorPaymentInBothCurrency'), null, 'errors');
  171. $error++;
  172. }
  173. }
  174. /*
  175. * Action add_paiement
  176. */
  177. if ($action == 'add_paiement') {
  178. if ($error) {
  179. $action = 'create';
  180. }
  181. // The next of this action is displayed at the page's bottom.
  182. }
  183. /*
  184. * Action confirm_paiement
  185. */
  186. if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) {
  187. $error = 0;
  188. $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzuser');
  189. $db->begin();
  190. $thirdparty = new Societe($db);
  191. if ($socid > 0) {
  192. $thirdparty->fetch($socid);
  193. }
  194. $multicurrency_code = array();
  195. $multicurrency_tx = array();
  196. // Clean parameters amount if payment is for a credit note
  197. foreach ($amounts as $key => $value) { // How payment is dispatched
  198. $tmpinvoice = new Facture($db);
  199. $tmpinvoice->fetch($key);
  200. if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
  201. $newvalue = price2num($value, 'MT');
  202. $amounts[$key] = - abs($newvalue);
  203. }
  204. $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
  205. $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
  206. }
  207. foreach ($multicurrency_amounts as $key => $value) { // How payment is dispatched
  208. $tmpinvoice = new Facture($db);
  209. $tmpinvoice->fetch($key);
  210. if ($tmpinvoice->type == Facture::TYPE_CREDIT_NOTE) {
  211. $newvalue = price2num($value, 'MT');
  212. $multicurrency_amounts[$key] = - abs($newvalue);
  213. }
  214. $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
  215. $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
  216. }
  217. if (isModEnabled("banque")) {
  218. // If the bank module is active, an account is required to input a payment
  219. if (GETPOST('accountid', 'int') <= 0) {
  220. setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('AccountToCredit')), null, 'errors');
  221. $error++;
  222. }
  223. }
  224. // Creation of payment line
  225. $paiement = new Paiement($db);
  226. $paiement->datepaye = $datepaye;
  227. $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id
  228. $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching
  229. $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching
  230. $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching
  231. $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1);
  232. $paiement->num_payment = GETPOST('num_paiement', 'alpha');
  233. $paiement->note_private = GETPOST('comment', 'alpha');
  234. $paiement->fk_account = GETPOST('accountid', 'int');
  235. if (!$error) {
  236. // Create payment and update this->multicurrency_amounts if this->amounts filled or
  237. // this->amounts if this->multicurrency_amounts filled.
  238. // This also set ->amount and ->multicurrency_amount
  239. $paiement_id = $paiement->create($user, (GETPOST('closepaidinvoices') == 'on' ? 1 : 0), $thirdparty); // This include closing invoices and regenerating documents
  240. if ($paiement_id < 0) {
  241. setEventMessages($paiement->error, $paiement->errors, 'errors');
  242. $error++;
  243. }
  244. }
  245. if (!$error) {
  246. $label = '(CustomerInvoicePayment)';
  247. if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) {
  248. $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note
  249. }
  250. $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank'));
  251. if ($result < 0) {
  252. setEventMessages($paiement->error, $paiement->errors, 'errors');
  253. $error++;
  254. }
  255. }
  256. if (!$error) {
  257. $db->commit();
  258. // If payment dispatching on more than one invoice, we stay on summary page, otherwise jump on invoice card
  259. $invoiceid = 0;
  260. foreach ($paiement->amounts as $key => $amount) {
  261. $facid = $key;
  262. if (is_numeric($amount) && $amount != 0) {
  263. if ($invoiceid != 0) {
  264. $invoiceid = -1; // There is more than one invoice payed by this payment
  265. } else {
  266. $invoiceid = $facid;
  267. }
  268. }
  269. }
  270. if ($invoiceid > 0) {
  271. $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid;
  272. } else {
  273. $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id;
  274. }
  275. header('Location: '.$loc);
  276. exit;
  277. } else {
  278. $db->rollback();
  279. }
  280. }
  281. }
  282. /*
  283. * View
  284. */
  285. $form = new Form($db);
  286. llxHeader('', $langs->trans("Payment"));
  287. if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paiement') {
  288. $facture = new Facture($db);
  289. $result = $facture->fetch($facid);
  290. if ($result >= 0) {
  291. $facture->fetch_thirdparty();
  292. $title = '';
  293. if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
  294. $title .= $langs->trans("EnterPaymentReceivedFromCustomer");
  295. }
  296. if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
  297. $title .= $langs->trans("EnterPaymentDueToCustomer");
  298. }
  299. print load_fiche_titre($title);
  300. // Initialize data for confirmation (this is used because data can be change during confirmation)
  301. if ($action == 'add_paiement') {
  302. $i = 0;
  303. $formquestion[$i++] = array('type' => 'hidden', 'name' => 'facid', 'value' => $facture->id);
  304. $formquestion[$i++] = array('type' => 'hidden', 'name' => 'socid', 'value' => $facture->socid);
  305. $formquestion[$i++] = array('type' => 'hidden', 'name' => 'type', 'value' => $facture->type);
  306. }
  307. // Invoice with Paypal transaction
  308. // TODO add hook here
  309. if (isModEnabled('paypalplus') && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) {
  310. if (getDolGlobalString('PAYPAL_BANK_ACCOUNT')) {
  311. $accountid = $conf->global->PAYPAL_BANK_ACCOUNT;
  312. }
  313. $paymentnum = $facture->ref_ext;
  314. }
  315. // Add realtime total information
  316. if (!empty($conf->use_javascript_ajax)) {
  317. print "\n".'<script type="text/javascript">';
  318. print '$(document).ready(function () {
  319. setPaiementCode();
  320. $("#selectpaiementcode").change(function() {
  321. setPaiementCode();
  322. });
  323. function setPaiementCode()
  324. {
  325. var code = $("#selectpaiementcode option:selected").val();
  326. console.log("setPaiementCode code="+code);
  327. if (code == \'CHQ\' || code == \'VIR\')
  328. {
  329. if (code == \'CHQ\')
  330. {
  331. $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
  332. }
  333. if ($(\'#fieldchqemetteur\').val() == \'\')
  334. {
  335. var emetteur = ('.$facture->type.' == '.Facture::TYPE_CREDIT_NOTE.') ? \''.dol_escape_js(dol_escape_htmltag(getDolGlobalString('MAIN_INFO_SOCIETE_NOM'))).'\' : jQuery(\'#thirdpartylabel\').val();
  336. $(\'#fieldchqemetteur\').val(emetteur);
  337. }
  338. }
  339. else
  340. {
  341. $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
  342. $(\'#fieldchqemetteur\').val(\'\');
  343. }
  344. }
  345. function _elemToJson(selector)
  346. {
  347. var subJson = {};
  348. $.map(selector.serializeArray(), function(n,i)
  349. {
  350. subJson[n["name"]] = n["value"];
  351. });
  352. return subJson;
  353. }
  354. function callForResult(imgId)
  355. {
  356. var json = {};
  357. var form = $("#payment_form");
  358. json["invoice_type"] = $("#invoice_type").val();
  359. json["amountPayment"] = $("#amountpayment").attr("value");
  360. json["amounts"] = _elemToJson(form.find("input.amount"));
  361. json["remains"] = _elemToJson(form.find("input.remain"));
  362. json["token"] = "'.currentToken().'";
  363. if (imgId != null) {
  364. json["imgClicked"] = imgId;
  365. }
  366. $.post("'.DOL_URL_ROOT.'/compta/ajaxpayment.php", json, function(data)
  367. {
  368. json = $.parseJSON(data);
  369. form.data(json);
  370. for (var key in json)
  371. {
  372. if (key == "result") {
  373. if (json["makeRed"]) {
  374. $("#"+key).addClass("error");
  375. } else {
  376. $("#"+key).removeClass("error");
  377. }
  378. json[key]=json["label"]+" "+json[key];
  379. $("#"+key).text(json[key]);
  380. } else {console.log(key);
  381. form.find("input[name*=\""+key+"\"]").each(function() {
  382. $(this).attr("value", json[key]);
  383. });
  384. }
  385. }
  386. });
  387. }
  388. $("#payment_form").find("input.amount").change(function() {
  389. callForResult();
  390. });
  391. $("#payment_form").find("input.amount").keyup(function() {
  392. callForResult();
  393. });
  394. ';
  395. print ' });'."\n";
  396. //Add js for AutoFill
  397. print ' $(document).ready(function () {';
  398. print ' $(".AutoFillAmout").on(\'click touchstart\', function(){
  399. $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
  400. });';
  401. print ' });'."\n";
  402. print ' </script>'."\n";
  403. }
  404. print '<form id="payment_form" name="add_paiement" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  405. print '<input type="hidden" name="token" value="'.newToken().'">';
  406. print '<input type="hidden" name="action" value="add_paiement">';
  407. print '<input type="hidden" name="facid" value="'.$facture->id.'">';
  408. print '<input type="hidden" name="socid" value="'.$facture->socid.'">';
  409. print '<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.'">';
  410. print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).'">';
  411. print '<input type="hidden" name="page_y" value="">';
  412. print dol_get_fiche_head();
  413. print '<table class="border centpercent">';
  414. // Third party
  415. print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans('Company').'</span></td><td>'.$facture->thirdparty->getNomUrl(4)."</td></tr>\n";
  416. // Date payment
  417. print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>';
  418. $datepayment = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  419. $datepayment = ($datepayment == '' ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $datepayment);
  420. print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date);
  421. print '</td></tr>';
  422. // Payment mode
  423. print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
  424. $form->select_types_paiements((GETPOST('paiementcode') ? GETPOST('paiementcode') : $facture->mode_reglement_code), 'paiementcode', '', 2);
  425. print "</td>\n";
  426. print '</tr>';
  427. // Bank account
  428. print '<tr>';
  429. if (isModEnabled("banque")) {
  430. if ($facture->type != 2) {
  431. print '<td><span class="fieldrequired">'.$langs->trans('AccountToCredit').'</span></td>';
  432. }
  433. if ($facture->type == 2) {
  434. print '<td><span class="fieldrequired">'.$langs->trans('AccountToDebit').'</span></td>';
  435. }
  436. print '<td>';
  437. print img_picto('', 'bank_account');
  438. print $form->select_comptes($accountid, 'accountid', 0, '', 2, '', 0, 'widthcentpercentminusx maxwidth500', 1);
  439. print '</td>';
  440. } else {
  441. print '<td>&nbsp;</td>';
  442. }
  443. print "</tr>\n";
  444. // Bank check number
  445. print '<tr><td>'.$langs->trans('Numero');
  446. print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
  447. print '</td>';
  448. print '<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.'"></td></tr>';
  449. // Check transmitter
  450. print '<tr><td class="'.(GETPOST('paiementcode') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn">'.$langs->trans('CheckTransmitter');
  451. print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
  452. print '</td>';
  453. print '<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
  454. // Bank name
  455. print '<tr><td>'.$langs->trans('Bank');
  456. print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
  457. print '</td>';
  458. print '<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
  459. // Comments
  460. print '<tr><td>'.$langs->trans('Comments').'</td>';
  461. print '<td class="tdtop">';
  462. print '<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('comment', 'restricthtml').'</textarea>';
  463. print '</td></tr>';
  464. // Go Source Invoice (useful when there are many invoices)
  465. if ($action != 'add_paiement' && getDolGlobalString('FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
  466. print '<tr><td></td>';
  467. print '<td class="tdtop right">';
  468. print '<a class="right" href="#amount_'.$facid.'">'.$langs->trans("GoSourceInvoice").'</a>';
  469. print '</td></tr>';
  470. }
  471. print '</table>';
  472. print dol_get_fiche_end();
  473. /*
  474. * List of unpaid invoices
  475. */
  476. $sql = 'SELECT f.rowid as facid, f.ref, f.total_ht, f.total_tva, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc, f.type,';
  477. $sql .= ' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
  478. $sql .= ' FROM '.MAIN_DB_PREFIX.'facture as f';
  479. $sql .= ' WHERE f.entity IN ('.getEntity('facture').')';
  480. $sql .= ' AND (f.fk_soc = '.((int) $facture->socid);
  481. // Can pay invoices of all child of parent company
  482. if (getDolGlobalString('FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
  483. $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->parent).')';
  484. }
  485. // Can pay invoices of all child of myself
  486. if (getDolGlobalString('FACTURE_PAYMENTS_ON_SUBSIDIARY_COMPANIES')) {
  487. $sql .= ' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.'societe WHERE parent = '.((int) $facture->thirdparty->id).')';
  488. }
  489. $sql .= ') AND f.paye = 0';
  490. $sql .= ' AND f.fk_statut = 1'; // Statut=0 => not validated, Statut=2 => canceled
  491. if ($facture->type != Facture::TYPE_CREDIT_NOTE) {
  492. $sql .= ' AND type IN (0,1,3,5)'; // Standard invoice, replacement, deposit, situation
  493. } else {
  494. $sql .= ' AND type = 2'; // If paying back a credit note, we show all credit notes
  495. }
  496. // Sort invoices by date and serial number: the older one comes first
  497. $sql .= ' ORDER BY f.datef ASC, f.ref ASC';
  498. $resql = $db->query($sql);
  499. if ($resql) {
  500. $num = $db->num_rows($resql);
  501. if ($num > 0) {
  502. $arraytitle = $langs->trans('Invoice');
  503. if ($facture->type == 2) {
  504. $arraytitle = $langs->trans("CreditNotes");
  505. }
  506. $alreadypayedlabel = $langs->trans('Received');
  507. $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived');
  508. if ($facture->type == 2) {
  509. $alreadypayedlabel = $langs->trans("PaidBack");
  510. $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack");
  511. }
  512. $remaindertopay = $langs->trans('RemainderToTake');
  513. $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake');
  514. if ($facture->type == 2) {
  515. $remaindertopay = $langs->trans("RemainderToPayBack");
  516. $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack");
  517. }
  518. $i = 0;
  519. //print '<tr><td colspan="3">';
  520. print '<br>';
  521. 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
  522. print '<table class="noborder centpercent">';
  523. print '<tr class="liste_titre">';
  524. print '<td>'.$arraytitle.'</td>';
  525. print '<td class="center">'.$langs->trans('Date').'</td>';
  526. print '<td class="center">'.$langs->trans('DateMaxPayment').'</td>';
  527. if (isModEnabled('multicurrency')) {
  528. print '<td>'.$langs->trans('Currency').'</td>';
  529. print '<td class="right">'.$langs->trans('MulticurrencyAmountTTC').'</td>';
  530. print '<td class="right">'.$multicurrencyalreadypayedlabel.'</td>';
  531. print '<td class="right">'.$multicurrencyremaindertopay.'</td>';
  532. print '<td class="right">'.$langs->trans('MulticurrencyPaymentAmount').'</td>';
  533. }
  534. print '<td class="right">'.$langs->trans('AmountTTC').'</td>';
  535. print '<td class="right">'.$alreadypayedlabel.'</td>';
  536. print '<td class="right">'.$remaindertopay.'</td>';
  537. print '<td class="right">'.$langs->trans('PaymentAmount').'</td>';
  538. $parameters = array();
  539. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook
  540. print '<td align="right">&nbsp;</td>';
  541. print "</tr>\n";
  542. $total_ttc = 0;
  543. $totalrecu = 0;
  544. $totalrecucreditnote = 0;
  545. $totalrecudeposits = 0;
  546. while ($i < $num) {
  547. $objp = $db->fetch_object($resql);
  548. $sign = 1;
  549. if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
  550. $sign = -1;
  551. }
  552. $soc = new Societe($db);
  553. $soc->fetch($objp->socid);
  554. $invoice = new Facture($db);
  555. $invoice->fetch($objp->facid);
  556. $paiement = $invoice->getSommePaiement();
  557. $creditnotes = $invoice->getSumCreditNotesUsed();
  558. $deposits = $invoice->getSumDepositsUsed();
  559. $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
  560. $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT');
  561. // Multicurrency Price
  562. if (isModEnabled('multicurrency')) {
  563. $multicurrency_payment = $invoice->getSommePaiement(1);
  564. $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
  565. $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
  566. $multicurrency_alreadypayed = price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits, 'MT');
  567. $multicurrency_remaintopay = price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits, 'MT');
  568. // Multicurrency full amount tooltip
  569. $tootltiponmulticurrencyfullamount = $langs->trans('AmountHT') . ": " . price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
  570. $tootltiponmulticurrencyfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
  571. $tootltiponmulticurrencyfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) . "<br>";
  572. }
  573. // Full amount tooltip
  574. $tootltiponfullamount = $langs->trans('AmountHT') . ": " . price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
  575. $tootltiponfullamount .= $langs->trans('AmountVAT') . ": " . price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
  576. $tootltiponfullamount .= $langs->trans('AmountTTC') . ": " . price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) . "<br>";
  577. print '<tr class="oddeven'.(($invoice->id == $facid) ? ' highlight' : '').'">';
  578. print '<td class="nowraponall">';
  579. print $invoice->getNomUrl(1, '');
  580. if ($objp->socid != $facture->thirdparty->id) {
  581. print ' - '.$soc->getNomUrl(1).' ';
  582. }
  583. print "</td>\n";
  584. // Date
  585. print '<td class="center">'.dol_print_date($db->jdate($objp->df), 'day')."</td>\n";
  586. // Due date
  587. if ($objp->dlr > 0) {
  588. print '<td class="nowraponall center">';
  589. print dol_print_date($db->jdate($objp->dlr), 'day');
  590. if ($invoice->hasDelay()) {
  591. print img_warning($langs->trans('Late'));
  592. }
  593. print '</td>';
  594. } else {
  595. print '<td align="center"></td>';
  596. }
  597. // Currency
  598. if (isModEnabled('multicurrency')) {
  599. print '<td class="center">'.$objp->multicurrency_code."</td>\n";
  600. }
  601. // Multicurrency full amount
  602. if (isModEnabled('multicurrency')) {
  603. print '<td class="right">';
  604. if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
  605. print '<span class="amount classfortooltip" title="'.$tootltiponmulticurrencyfullamount.'">' . price($sign * $objp->multicurrency_total_ttc);
  606. }
  607. print '</span></td>';
  608. // Multicurrency Price
  609. print '<td class="right">';
  610. if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
  611. print price($sign * $multicurrency_payment);
  612. if ($multicurrency_creditnotes) {
  613. print '+'.price($multicurrency_creditnotes);
  614. }
  615. if ($multicurrency_deposits) {
  616. print '+'.price($multicurrency_deposits);
  617. }
  618. }
  619. print '</td>';
  620. // Multicurrency remain to pay
  621. print '<td class="right">';
  622. if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
  623. print price($sign * $multicurrency_remaintopay);
  624. }
  625. print '</td>';
  626. print '<td class="right nowraponall">';
  627. // Add remind multicurrency amount
  628. $namef = 'multicurrency_amount_'.$objp->facid;
  629. $nameRemain = 'multicurrency_remain_'.$objp->facid;
  630. if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
  631. if ($action != 'add_paiement') {
  632. if (!empty($conf->use_javascript_ajax)) {
  633. print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'");
  634. }
  635. print '<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.'" value="'.GETPOST($namef).'">';
  636. print '<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.'" value="'.$multicurrency_remaintopay.'">';
  637. } else {
  638. print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.GETPOST($namef).'" disabled>';
  639. print '<input type="hidden" name="'.$namef.'" value="'.GETPOST($namef).'">';
  640. }
  641. }
  642. print "</td>";
  643. }
  644. // Full amount
  645. print '<td class="right"><span class="amount classfortooltip" title="'.$tootltiponfullamount.'">'.price($sign * $objp->total_ttc).'</span></td>';
  646. // Received + already paid
  647. print '<td class="right"><span class="amount">'.price($sign * $paiement);
  648. if ($creditnotes) {
  649. print '<span class="opacitymedium">+'.price($creditnotes).'</span>';
  650. }
  651. if ($deposits) {
  652. print '<span class="opacitymedium">+'.price($deposits).'</span>';
  653. }
  654. print '</span></td>';
  655. // Remain to take or to pay back
  656. print '<td class="right">';
  657. print price($sign * $remaintopay);
  658. if (isModEnabled('prelevement')) {
  659. $numdirectdebitopen = 0;
  660. $totaldirectdebit = 0;
  661. $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
  662. $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
  663. $sql .= " WHERE fk_facture = ".((int) $objp->facid);
  664. $sql .= " AND pfd.traite = 0";
  665. $sql .= " AND pfd.ext_payment_id IS NULL";
  666. $result_sql = $db->query($sql);
  667. if ($result_sql) {
  668. $obj = $db->fetch_object($result_sql);
  669. $numdirectdebitopen = $obj->nb;
  670. $totaldirectdebit = $obj->amount;
  671. } else {
  672. dol_print_error($db);
  673. }
  674. if ($numdirectdebitopen) {
  675. $langs->load("withdrawals");
  676. print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip');
  677. }
  678. }
  679. print '</td>';
  680. //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits));
  681. // Amount
  682. print '<td class="right nowraponall">';
  683. // Add remind amount
  684. $namef = 'amount_'.$objp->facid;
  685. $nameRemain = 'remain_'.$objp->facid;
  686. if ($action != 'add_paiement') {
  687. if (!empty($conf->use_javascript_ajax)) {
  688. print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'");
  689. }
  690. print '<input type="text" class="maxwidth75 amount" id="'.$namef.'" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
  691. print '<input type="hidden" class="remain" name="'.$nameRemain.'" value="'.$remaintopay.'">';
  692. } else {
  693. print '<input type="text" class="maxwidth75" name="'.$namef.'_disabled" value="'.dol_escape_htmltag(GETPOST($namef)).'" disabled>';
  694. print '<input type="hidden" name="'.$namef.'" value="'.dol_escape_htmltag(GETPOST($namef)).'">';
  695. }
  696. print "</td>";
  697. $parameters = array();
  698. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
  699. // Warning
  700. print '<td align="center" width="16">';
  701. //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."<br>";
  702. if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
  703. || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) {
  704. print ' '.img_warning($langs->trans("PaymentHigherThanReminderToPay"));
  705. }
  706. print '</td>';
  707. print "</tr>\n";
  708. $total_ttc += $objp->total_ttc;
  709. $totalrecu += $paiement;
  710. $totalrecucreditnote += $creditnotes;
  711. $totalrecudeposits += $deposits;
  712. $i++;
  713. }
  714. if ($i > 1) {
  715. // Print total
  716. print '<tr class="liste_total">';
  717. print '<td colspan="3" class="left">'.$langs->trans('TotalTTC').'</td>';
  718. if (isModEnabled('multicurrency')) {
  719. print '<td></td>';
  720. print '<td></td>';
  721. print '<td></td>';
  722. print '<td></td>';
  723. print '<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
  724. }
  725. print '<td class="right"><b>'.price($sign * $total_ttc).'</b></td>';
  726. print '<td class="right"><b>'.price($sign * $totalrecu);
  727. if ($totalrecucreditnote) {
  728. print '+'.price($totalrecucreditnote);
  729. }
  730. if ($totalrecudeposits) {
  731. print '+'.price($totalrecudeposits);
  732. }
  733. print '</b></td>';
  734. print '<td class="right"><b>'.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits, 'MT')).'</b></td>';
  735. print '<td class="right" id="result" style="font-weight: bold;"></td>'; // Autofilled
  736. print '<td align="center">&nbsp;</td>';
  737. print "</tr>\n";
  738. }
  739. print "</table>";
  740. print "</div>\n";
  741. }
  742. $db->free($resql);
  743. } else {
  744. dol_print_error($db);
  745. }
  746. $formconfirm = '';
  747. // Save button
  748. if ($action != 'add_paiement') {
  749. $checkboxlabel = $langs->trans("ClosePaidInvoicesAutomatically");
  750. if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
  751. $checkboxlabel = $langs->trans("ClosePaidCreditNotesAutomatically");
  752. }
  753. $buttontitle = $langs->trans('ToMakePayment');
  754. if ($facture->type == Facture::TYPE_CREDIT_NOTE) {
  755. $buttontitle = $langs->trans('ToMakePaymentBack');
  756. }
  757. print '<br><div class="center">';
  758. print '<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
  759. /*if (isModEnabled('prelevement')) {
  760. $langs->load("withdrawals");
  761. if (!empty($conf->global->WITHDRAW_DISABLE_AUTOCREATE_ONPAYMENTS)) print '<br>'.$langs->trans("IfInvoiceNeedOnWithdrawPaymentWontBeClosed");
  762. }*/
  763. print '<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).'"><br><br>';
  764. print '</div>';
  765. }
  766. // Form to confirm payment
  767. if ($action == 'add_paiement') {
  768. $preselectedchoice = $addwarning ? 'no' : 'yes';
  769. print '<br>';
  770. if (!empty($totalpayment)) {
  771. $text = $langs->trans('ConfirmCustomerPayment', $totalpayment, $langs->trans("Currency".$conf->currency));
  772. }
  773. if (!empty($multicurrency_totalpayment)) {
  774. $text .= '<br>'.$langs->trans('ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->trans("paymentInInvoiceCurrency"));
  775. }
  776. if (GETPOST('closepaidinvoices')) {
  777. $text .= '<br>'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed");
  778. print '<input type="hidden" name="closepaidinvoices" value="'.GETPOST('closepaidinvoices').'">';
  779. }
  780. $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?facid='.$facture->id.'&socid='.$facture->socid.'&type='.$facture->type, $langs->trans('ReceivedCustomersPayments'), $text, 'confirm_paiement', $formquestion, $preselectedchoice);
  781. }
  782. // Call Hook formConfirm
  783. $parameters = array('formConfirm' => $formconfirm);
  784. $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  785. if (empty($reshook)) {
  786. $formconfirm .= $hookmanager->resPrint;
  787. } elseif ($reshook > 0) {
  788. $formconfirm = $hookmanager->resPrint;
  789. }
  790. // Print form confirm
  791. print $formconfirm;
  792. print "</form>\n";
  793. }
  794. }
  795. /**
  796. * Show list of payments
  797. */
  798. if (!GETPOST('action', 'aZ09')) {
  799. if (empty($page) || $page == -1) {
  800. $page = 0;
  801. }
  802. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  803. $offset = $limit * $page;
  804. if (!$sortorder) {
  805. $sortorder = 'DESC';
  806. }
  807. if (!$sortfield) {
  808. $sortfield = 'p.datep';
  809. }
  810. $sql = 'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
  811. $sql .= ', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
  812. $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id';
  813. $sql .= ', '.MAIN_DB_PREFIX.'facture as f';
  814. $sql .= ' WHERE p.fk_facture = f.rowid';
  815. $sql .= ' AND f.entity IN ('.getEntity('invoice').')';
  816. if ($socid) {
  817. $sql .= ' AND f.fk_soc = '.((int) $socid);
  818. }
  819. $sql .= $db->order($sortfield, $sortorder);
  820. $sql .= $db->plimit($limit + 1, $offset);
  821. $resql = $db->query($sql);
  822. if ($resql) {
  823. $num = $db->num_rows($resql);
  824. $i = 0;
  825. print_barre_liste($langs->trans('Payments'), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num);
  826. print '<table class="noborder centpercent">';
  827. print '<tr class="liste_titre">';
  828. print_liste_field_titre('Invoice', $_SERVER["PHP_SELF"], 'f.ref', '', '', '', $sortfield, $sortorder);
  829. print_liste_field_titre('Date', $_SERVER["PHP_SELF"], 'p.datep', '', '', '', $sortfield, $sortorder);
  830. print_liste_field_titre('Type', $_SERVER["PHP_SELF"], 'c.libelle', '', '', '', $sortfield, $sortorder);
  831. print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], 'p.amount', '', '', '', $sortfield, $sortorder, 'right ');
  832. print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
  833. print "</tr>\n";
  834. while ($i < min($num, $limit)) {
  835. $objp = $db->fetch_object($resql);
  836. print '<tr class="oddeven">';
  837. print '<td><a href="'.DOL_URL_ROOT.'/compta/facture/card.php?facid='.$objp->facid.'">'.$objp->ref."</a></td>\n";
  838. print '<td>'.dol_print_date($db->jdate($objp->dp))."</td>\n";
  839. print '<td>'.$objp->paiement_type.' '.$objp->num_payment."</td>\n";
  840. print '<td class="right"><span class="amount">'.price($objp->amount).'</span></td>';
  841. print '<td>&nbsp;</td>';
  842. print '</tr>';
  843. $parameters = array();
  844. $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook
  845. $i++;
  846. }
  847. print '</table>';
  848. }
  849. }
  850. llxFooter();
  851. $db->close();