create.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. <?php
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2010-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
  7. * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
  8. * Copyright (C) 2019 Markus Welters <markus@welters.de>
  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/prelevement/create.php
  25. * \ingroup prelevement
  26. * \brief Page to create a direct debit order or a credit transfer order
  27. */
  28. // Load Dolibarr environment
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
  37. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  38. // Load translation files required by the page
  39. $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills'));
  40. $type = GETPOST('type', 'aZ09');
  41. // Get supervariables
  42. $action = GETPOST('action', 'aZ09');
  43. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  44. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  45. $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
  46. $format = GETPOST('format', 'aZ09');
  47. $id_bankaccount = GETPOST('id_bankaccount', 'int');
  48. $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
  49. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  50. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  51. if (empty($page) || $page == -1) {
  52. $page = 0;
  53. } // If $page is not defined, or '' or -1
  54. $offset = $limit * $page;
  55. $hookmanager->initHooks(array('directdebitcreatecard', 'globalcard'));
  56. // Security check
  57. $socid = GETPOST('socid', 'int');
  58. if ($user->socid) {
  59. $socid = $user->socid;
  60. }
  61. if ($type == 'bank-transfer') {
  62. $result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
  63. } else {
  64. $result = restrictedArea($user, 'prelevement', '', '', 'bons');
  65. }
  66. $error = 0;
  67. $option = "";
  68. $mesg = '';
  69. /*
  70. * Actions
  71. */
  72. if (GETPOST('cancel', 'alpha')) {
  73. $massaction = '';
  74. }
  75. $parameters = array('mode' => $mode, 'format' => $format, 'limit' => $limit, 'page' => $page, 'offset' => $offset);
  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. // Change customer bank information to withdraw
  82. if ($action == 'modify') {
  83. for ($i = 1; $i < 9; $i++) {
  84. dolibarr_set_const($db, GETPOST("nom".$i), GETPOST("value".$i), 'chaine', 0, '', $conf->entity);
  85. }
  86. }
  87. if ($action == 'create') {
  88. $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
  89. //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit;
  90. if ($id_bankaccount != getDolGlobalInt($default_account)) {
  91. $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default
  92. }
  93. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  94. $bank = new Account($db);
  95. $bank->fetch($conf->global->{$default_account});
  96. // ICS is not mandatory with payment by bank transfer
  97. /*if ((empty($bank->ics) && $type !== 'bank-transfer')
  98. || (empty($bank->ics_transfer) && $type === 'bank-transfer')
  99. ) {*/
  100. if (empty($bank->ics) && $type !== 'bank-transfer') {
  101. $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}'));
  102. setEventMessages($errormessage, null, 'errors');
  103. $action = '';
  104. $error++;
  105. }
  106. $bprev = new BonPrelevement($db);
  107. if (!$error) {
  108. // getDolGlobalString('PRELEVEMENT_CODE_BANQUE') and getDolGlobalString('PRELEVEMENT_CODE_GUICHET') should be empty (we don't use them anymore)
  109. $result = $bprev->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $mode, $format, $executiondate, 0, $type);
  110. if ($result < 0) {
  111. setEventMessages($bprev->error, $bprev->errors, 'errors');
  112. } elseif ($result == 0) {
  113. $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
  114. setEventMessages($mesg, null, 'errors');
  115. $mesg .= '<br>'."\n";
  116. foreach ($bprev->invoice_in_error as $key => $val) {
  117. $mesg .= '<span class="warning">'.$val."</span><br>\n";
  118. }
  119. } else {
  120. if ($type != 'bank-transfer') {
  121. $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}');
  122. $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
  123. setEventMessages($texttoshow, null);
  124. } else {
  125. $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}');
  126. $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
  127. setEventMessages($texttoshow, null);
  128. }
  129. header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type));
  130. exit;
  131. }
  132. }
  133. }
  134. $objectclass = "BonPrelevement";
  135. if ($type == 'bank-transfer') {
  136. $uploaddir = $conf->paymentbybanktransfer->dir_output;
  137. } else {
  138. $uploaddir = $conf->prelevement->dir_output;
  139. }
  140. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  141. }
  142. /*
  143. * View
  144. */
  145. $form = new Form($db);
  146. $thirdpartystatic = new Societe($db);
  147. if ($type != 'bank-transfer') {
  148. $invoicestatic = new Facture($db);
  149. } else {
  150. $invoicestatic = new FactureFournisseur($db);
  151. }
  152. $bprev = new BonPrelevement($db);
  153. $arrayofselected = is_array($toselect) ? $toselect : array();
  154. // List of mass actions available
  155. $arrayofmassactions = array(
  156. );
  157. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  158. $arrayofmassactions = array();
  159. }
  160. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  161. if (prelevement_check_config($type) < 0) {
  162. $langs->load("errors");
  163. $modulenametoshow = "Withdraw";
  164. if ($type == 'bank-transfer') {
  165. $modulenametoshow = "PaymentByBankTransfer";
  166. }
  167. setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv($modulenametoshow)), null, 'errors');
  168. }
  169. $title = $langs->trans("NewStandingOrder");
  170. if ($type == 'bank-transfer') {
  171. $title = $langs->trans("NewPaymentByBankTransfer");
  172. }
  173. llxHeader('', $title);
  174. print load_fiche_titre($title);
  175. print dol_get_fiche_head();
  176. $nb = $bprev->nbOfInvoiceToPay($type);
  177. $pricetowithdraw = $bprev->SommeAPrelever($type);
  178. if ($nb < 0) {
  179. dol_print_error($bprev->error);
  180. }
  181. print '<table class="border centpercent tableforfield">';
  182. $labeltoshow = $langs->trans("NbOfInvoiceToWithdraw");
  183. if ($type == 'bank-transfer') {
  184. $labeltoshow = $langs->trans("NbOfInvoiceToPayByBankTransfer");
  185. }
  186. print '<tr><td class="titlefield">'.$labeltoshow.'</td>';
  187. print '<td class="nowraponall">';
  188. print dol_escape_htmltag($nb);
  189. print '</td></tr>';
  190. print '<tr><td>'.$langs->trans("AmountTotal").'</td>';
  191. print '<td class="amount nowraponall">';
  192. print price($pricetowithdraw, 0, $langs, 1, -1, -1, $conf->currency);
  193. print '</td>';
  194. print '</tr>';
  195. print '</table>';
  196. print '</div>';
  197. if ($mesg) {
  198. print $mesg;
  199. }
  200. print '<div class="tabsAction">'."\n";
  201. print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
  202. print '<input type="hidden" name="token" value="'.newToken().'">';
  203. print '<input type="hidden" name="type" value="'.$type.'">';
  204. if ($nb) {
  205. if ($pricetowithdraw) {
  206. $title = $langs->trans('BankToReceiveWithdraw').': ';
  207. if ($type == 'bank-transfer') {
  208. $title = $langs->trans('BankToPayCreditTransfer').': ';
  209. }
  210. print '<span class="hideonsmartphone">'.$title.'</span>';
  211. print img_picto('', 'bank_account');
  212. $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
  213. print $form->select_comptes(getDolGlobalInt($default_account), 'id_bankaccount', 0, "courant=1", 0, '', 0, 'widthcentpercentminusx maxwidth300', 1);
  214. print ' &nbsp; &nbsp; ';
  215. if (empty($executiondate)) {
  216. $delayindays = 0;
  217. if ($type != 'bank-transfer') {
  218. $delayindays = getDolGlobalInt('PRELEVEMENT_ADDDAYS');
  219. } else {
  220. $delayindays = getDolGlobalInt('PAYMENTBYBANKTRANSFER_ADDDAYS');
  221. }
  222. $executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd');
  223. }
  224. print $langs->trans('ExecutionDate').' ';
  225. $datere = $executiondate;
  226. print $form->selectDate($datere, 're');
  227. if ($mysoc->isInEEC()) {
  228. $title = $langs->trans("CreateForSepa");
  229. if ($type == 'bank-transfer') {
  230. $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
  231. }
  232. if ($type != 'bank-transfer') {
  233. print '<select name="format">';
  234. print '<option value="FRST"'.($format == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
  235. print '<option value="RCUR"'.($format == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
  236. print '</select>';
  237. }
  238. print '<input type="submit" class="butAction margintoponly maringbottomonly" value="'.$title.'"/>';
  239. } else {
  240. $title = $langs->trans("CreateAll");
  241. if ($type == 'bank-transfer') {
  242. $title = $langs->trans("CreateFileForPaymentByBankTransfer");
  243. }
  244. print '<input type="hidden" name="format" value="ALL">'."\n";
  245. print '<input type="submit" class="butAction margintoponly maringbottomonly" value="'.$title.'">'."\n";
  246. }
  247. } else {
  248. if ($mysoc->isInEEC()) {
  249. $title = $langs->trans("CreateForSepaFRST");
  250. if ($type == 'bank-transfer') {
  251. $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
  252. }
  253. print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#" title="'.$langs->trans("AmountMustBePositive").'">'.$title."</a>\n";
  254. if ($type != 'bank-transfer') {
  255. $title = $langs->trans("CreateForSepaRCUR");
  256. print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#" title="'.$langs->trans("AmountMustBePositive").'">'.$title."</a>\n";
  257. }
  258. } else {
  259. $title = $langs->trans("CreateAll");
  260. if ($type == 'bank-transfer') {
  261. $title = $langs->trans("CreateFileForPaymentByBankTransfer");
  262. }
  263. print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#">'.$title."</a>\n";
  264. }
  265. }
  266. } else {
  267. $titlefortab = $langs->transnoentitiesnoconv("StandingOrders");
  268. $title = $langs->trans("CreateAll");
  269. if ($type == 'bank-transfer') {
  270. $titlefortab = $langs->transnoentitiesnoconv("PaymentByBankTransfers");
  271. $title = $langs->trans("CreateFileForPaymentByBankTransfer");
  272. }
  273. print '<a class="butActionRefused classfortooltip margintoponly maringbottomonly" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoInvoiceToWithdraw", $titlefortab, $titlefortab)).'">';
  274. print $title;
  275. print "</a>\n";
  276. }
  277. print "</form>\n";
  278. print "</div>\n";
  279. print '</form>';
  280. print '<br>';
  281. /*
  282. * Invoices waiting for withdraw
  283. */
  284. $sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
  285. if ($type == 'bank-transfer') {
  286. $sql .= " f.ref_supplier,";
  287. }
  288. $sql .= " pfd.rowid as request_row_id, pfd.date_demande, pfd.amount";
  289. if ($type == 'bank-transfer') {
  290. $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
  291. } else {
  292. $sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
  293. }
  294. $sql .= " ".MAIN_DB_PREFIX."societe as s,";
  295. $sql .= " ".MAIN_DB_PREFIX."prelevement_demande as pfd";
  296. $sql .= " WHERE s.rowid = f.fk_soc";
  297. $sql .= " AND f.entity IN (".getEntity('invoice').")";
  298. if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
  299. $sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
  300. }
  301. //$sql .= " AND pfd.amount > 0";
  302. $sql .= " AND f.total_ttc > 0"; // Avoid credit notes
  303. $sql .= " AND pfd.traite = 0";
  304. $sql .= " AND pfd.ext_payment_id IS NULL";
  305. if ($type == 'bank-transfer') {
  306. $sql .= " AND pfd.fk_facture_fourn = f.rowid";
  307. } else {
  308. $sql .= " AND pfd.fk_facture = f.rowid";
  309. }
  310. if ($socid > 0) {
  311. $sql .= " AND f.fk_soc = ".((int) $socid);
  312. }
  313. $nbtotalofrecords = '';
  314. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  315. $result = $db->query($sql);
  316. $nbtotalofrecords = $db->num_rows($result);
  317. if (($page * $limit) > $nbtotalofrecords) {
  318. // if total resultset is smaller then paging size (filtering), goto and load page 0
  319. $page = 0;
  320. $offset = 0;
  321. }
  322. }
  323. $sql .= $db->plimit($limit + 1, $offset);
  324. $resql = $db->query($sql);
  325. if ($resql) {
  326. $num = $db->num_rows($resql);
  327. $i = 0;
  328. $param = '';
  329. if ($limit > 0 && $limit != $conf->liste_limit) {
  330. $param .= '&limit='.((int) $limit);
  331. }
  332. if ($socid) {
  333. $param .= '&socid='.urlencode($socid);
  334. }
  335. if ($option) {
  336. $param .= "&option=".urlencode($option);
  337. }
  338. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  339. print '<input type="hidden" name="token" value="'.newToken().'">';
  340. print '<input type="hidden" name="page" value="'.$page.'">';
  341. if (!empty($limit)) {
  342. print '<input type="hidden" name="limit" value="'.$limit.'"/>';
  343. }
  344. if ($type != '') {
  345. print '<input type="hidden" name="type" value="'.$type.'">';
  346. }
  347. $title = $langs->trans("InvoiceWaitingWithdraw");
  348. if ($type == 'bank-transfer') {
  349. $title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
  350. }
  351. print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
  352. $tradinvoice = "Invoice";
  353. if ($type == 'bank-transfer') {
  354. $tradinvoice = "SupplierInvoice";
  355. }
  356. print '<div class="div-table-responsive-no-min">';
  357. print '<table class="noborder centpercent">';
  358. print '<tr class="liste_titre">';
  359. print '<td>'.$langs->trans($tradinvoice).'</td>';
  360. if ($type == 'bank-transfer') {
  361. print '<td>'.$langs->trans("RefSupplier").'</td>';
  362. }
  363. print '<td>'.$langs->trans("ThirdParty").'</td>';
  364. print '<td>'.$langs->trans("RIB").'</td>';
  365. print '<td>'.$langs->trans("RUM").'</td>';
  366. print '<td class="right">'.$langs->trans("AmountTTC").'</td>';
  367. print '<td class="right">'.$langs->trans("DateRequest").'</td>';
  368. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  369. print '<td align="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
  370. }
  371. print '</tr>';
  372. if ($num) {
  373. require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
  374. $bac = new CompanyBankAccount($db);
  375. while ($i < $num && $i < $limit) {
  376. $obj = $db->fetch_object($resql);
  377. $bac->fetch(0, $obj->socid);
  378. $invoicestatic->id = $obj->rowid;
  379. $invoicestatic->ref = $obj->ref;
  380. $invoicestatic->ref_supplier = $obj->ref_supplier;
  381. print '<tr class="oddeven">';
  382. // Ref invoice
  383. print '<td class="tdoverflowmax150">';
  384. print $invoicestatic->getNomUrl(1, 'withdraw');
  385. print '</td>';
  386. if ($type == 'bank-transfer') {
  387. print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($invoicestatic->ref_supplier).'">';
  388. print dol_escape_htmltag($invoicestatic->ref_supplier);
  389. print '</td>';
  390. }
  391. // Thirdparty
  392. print '<td class="tdoverflowmax100">';
  393. $thirdpartystatic->fetch($obj->socid);
  394. print $thirdpartystatic->getNomUrl(1, 'ban');
  395. print '</td>';
  396. // RIB
  397. print '<td>';
  398. if ($bac->id > 0) {
  399. if (!empty($bac->iban) || !empty($bac->bic)) {
  400. print $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
  401. if ($bac->verif() <= 0) {
  402. print img_warning('Error on default bank number for IBAN : '.$langs->trans($bac->error_message));
  403. }
  404. } else {
  405. print img_warning($langs->trans("IBANNotDefined"));
  406. }
  407. } else {
  408. print img_warning($langs->trans("NoBankAccountDefined"));
  409. }
  410. print '</td>';
  411. // RUM
  412. print '<td>';
  413. $rumtoshow = $thirdpartystatic->display_rib('rum');
  414. if ($rumtoshow) {
  415. print $rumtoshow;
  416. $format = $thirdpartystatic->display_rib('format');
  417. if ($type != 'bank-transfer') {
  418. if ($format) {
  419. print ' ('.$format.')';
  420. }
  421. }
  422. } else {
  423. print img_warning($langs->trans("NoBankAccountDefined"));
  424. }
  425. print '</td>';
  426. // Amount
  427. print '<td class="right amount">';
  428. print price($obj->amount, 0, $langs, 0, 0, -1, $conf->currency);
  429. print '</td>';
  430. // Date
  431. print '<td class="right">';
  432. print dol_print_date($db->jdate($obj->date_demande), 'day');
  433. print '</td>';
  434. // Action column
  435. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  436. print '<td class="nowrap center">';
  437. $selected = 0;
  438. if (in_array($obj->request_row_id, $arrayofselected)) {
  439. $selected = 1;
  440. }
  441. print '<input id="cb'.$obj->request_row_id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->request_row_id.'"'.($selected ? ' checked="checked"' : '').'>';
  442. print '</td>';
  443. }
  444. print '</tr>';
  445. $i++;
  446. }
  447. } else {
  448. print '<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
  449. }
  450. print "</table>";
  451. print "</div>";
  452. print "</form>";
  453. print "<br>\n";
  454. } else {
  455. dol_print_error($db);
  456. }
  457. /*
  458. * List of latest withdraws
  459. */
  460. /*
  461. $limit=5;
  462. print load_fiche_titre($langs->trans("LastWithdrawalReceipts",$limit),'','');
  463. $sql = "SELECT p.rowid, p.ref, p.amount, p.statut";
  464. $sql.= ", p.datec";
  465. $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
  466. $sql.= " WHERE p.entity IN (".getEntity('invoice').")";
  467. $sql.= " ORDER BY datec DESC";
  468. $sql.=$db->plimit($limit);
  469. $result = $db->query($sql);
  470. if ($result)
  471. {
  472. $num = $db->num_rows($result);
  473. $i = 0;
  474. print"\n<!-- debut table -->\n";
  475. print '<table class="noborder centpercent">';
  476. print '<tr class="liste_titre"><td>'.$langs->trans("Ref").'</td>';
  477. print '<td class="center">'.$langs->trans("Date").'</td><td class="right">'.$langs->trans("Amount").'</td>';
  478. print '</tr>';
  479. while ($i < min($num,$limit))
  480. {
  481. $obj = $db->fetch_object($result);
  482. print '<tr class="oddeven">';
  483. print "<td>";
  484. $bprev->id=$obj->rowid;
  485. $bprev->ref=$obj->ref;
  486. print $bprev->getNomUrl(1);
  487. print "</td>\n";
  488. print '<td class="center">'.dol_print_date($db->jdate($obj->datec),'day')."</td>\n";
  489. print '<td class="right"><span class="amount">'.price($obj->amount,0,$langs,0,0,-1,$conf->currency)."</span></td>\n";
  490. print "</tr>\n";
  491. $i++;
  492. }
  493. print "</table><br>";
  494. $db->free($result);
  495. }
  496. else
  497. {
  498. dol_print_error($db);
  499. }
  500. */
  501. // End of page
  502. llxFooter();
  503. $db->close();