list.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <?php
  2. /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
  6. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  7. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/compta/tva/list.php
  24. * \ingroup tax
  25. * \brief List of VAT payments
  26. */
  27. // Load Dolibarr environment
  28. require '../../main.inc.php';
  29. require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('compta', 'bills'));
  37. $action = GETPOST('action', 'alpha');
  38. $massaction = GETPOST('massaction', 'alpha');
  39. $confirm = GETPOST('confirm', 'alpha');
  40. $optioncss = GETPOST('optioncss', 'alpha');
  41. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist';
  42. $search_ref = GETPOST('search_ref', 'alpha');
  43. $search_label = GETPOST('search_label', 'alpha');
  44. $search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
  45. $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
  46. $search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int'));
  47. $search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int'));
  48. $search_type = GETPOST('search_type', 'int');
  49. $search_account = GETPOST('search_account', 'int');
  50. $search_amount = GETPOST('search_amount', 'alpha');
  51. $search_status = GETPOST('search_status', 'int');
  52. $ltt = GETPOST("ltt", "int");
  53. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  54. $sortfield = GETPOST('sortfield', 'aZ09comma');
  55. $sortorder = GETPOST('sortorder', 'aZ09comma');
  56. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
  57. if (empty($page) || $page == -1) {
  58. $page = 0; // If $page is not defined, or '' or -1
  59. }
  60. $offset = $limit * $page;
  61. $pageprev = $page - 1;
  62. $pagenext = $page + 1;
  63. if (!$sortfield) {
  64. $sortfield = 't.datev';
  65. }
  66. if (!$sortorder) {
  67. $sortorder = 'DESC';
  68. }
  69. $arrayfields = array(
  70. 't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",),
  71. 't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"),
  72. 't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"),
  73. 't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"DefaultPaymentMode"),
  74. 't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"),
  75. 't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"),
  76. );
  77. if (isModEnabled("banque")) {
  78. $arrayfields['t.fk_account'] = array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount");
  79. }
  80. $arrayfields = dol_sort_array($arrayfields, 'position');
  81. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  82. $hookmanager->initHooks(array('salestaxeslist'));
  83. $object = new Tva($db);
  84. // Security check
  85. $socid = GETPOST('socid', 'int');
  86. if ($user->socid) {
  87. $socid = $user->socid;
  88. }
  89. $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
  90. /*
  91. * Actions
  92. */
  93. $parameters = array('socid'=>$socid);
  94. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  95. if ($reshook < 0) {
  96. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  97. }
  98. if (empty($reshook)) {
  99. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  100. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
  101. $search_ref = '';
  102. $search_label = '';
  103. $search_dateend_start = '';
  104. $search_dateend_end = '';
  105. $search_datepayment_start = '';
  106. $search_datepayment_end = '';
  107. $search_type = '';
  108. $search_account = '';
  109. $search_amount = '';
  110. $search_status = '';
  111. }
  112. }
  113. /*
  114. * View
  115. */
  116. $form = new Form($db);
  117. $formother = new FormOther($db);
  118. $formfile = new FormFile($db);
  119. $tva_static = new Tva($db);
  120. $bankstatic = new Account($db);
  121. $accountingjournal = new AccountingJournal($db);
  122. $bankline = new AccountLine($db);
  123. llxHeader('', $langs->trans("VATDeclarations"));
  124. $sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.fk_account,';
  125. $sql.= ' ba.label as blabel, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,';
  126. $sql.= ' t.num_payment, pst.code as payment_code,';
  127. $sql .= ' SUM(ptva.amount) as alreadypayed';
  128. $sqlfields = $sql; // $sql fields to remove for count total
  129. $sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t';
  130. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON (t.fk_typepayment = pst.id)';
  131. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON (t.fk_account = ba.rowid)';
  132. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (ptva.fk_tva = t.rowid)";
  133. $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')';
  134. if (!empty($search_ref)) {
  135. $sql .= natural_search('t.rowid', $search_ref);
  136. }
  137. if (!empty($search_label)) {
  138. $sql .= natural_search('t.label', $search_label);
  139. }
  140. if (!empty($search_dateend_start)) {
  141. $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
  142. }
  143. if (!empty($search_dateend_end)) {
  144. $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
  145. }
  146. if (!empty($search_datepayment_start)) {
  147. $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
  148. }
  149. if (!empty($search_datepayment_end)) {
  150. $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
  151. }
  152. if (!empty($search_type) && $search_type > 0) {
  153. $sql .= ' AND t.fk_typepayment = '.((int) $search_type);
  154. }
  155. if (!empty($search_account) && $search_account > 0) {
  156. $sql .= ' AND t.fk_account = '.((int) $search_account);
  157. }
  158. if (!empty($search_amount)) {
  159. $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
  160. }
  161. if ($search_status != '' && $search_status >= 0) {
  162. $sql .= " AND t.paye = ".((int) $search_status);
  163. }
  164. $sql .= " GROUP BY t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment, t.fk_account, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, t.num_payment, pst.code";
  165. // Count total nb of records
  166. $nbtotalofrecords = '';
  167. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  168. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  169. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql);
  170. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  171. $resql = $db->query($sqlforcount);
  172. if ($resql) {
  173. $objforcount = $db->fetch_object($resql);
  174. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  175. } else {
  176. dol_print_error($db);
  177. }
  178. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  179. $page = 0;
  180. $offset = 0;
  181. }
  182. $db->free($resql);
  183. }
  184. // Complete request and execute it with limit
  185. $sql .= $db->order($sortfield, $sortorder);
  186. if ($limit) {
  187. $sql .= $db->plimit($limit + 1, $offset);
  188. }
  189. $resql = $db->query($sql);
  190. if (!$resql) {
  191. dol_print_error($db);
  192. llxFooter();
  193. $db->close();
  194. exit;
  195. }
  196. $num = $db->num_rows($resql);
  197. $param = '';
  198. if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
  199. $param .= '&contextpage='.$contextpage;
  200. }
  201. if ($limit > 0 && $limit != $conf->liste_limit) {
  202. $param .= '&limit='.$limit;
  203. }
  204. if ($optioncss != '') {
  205. $param .= '&optioncss='.urlencode($optioncss);
  206. }
  207. if (!empty($search_ref)) {
  208. $param .= '&search_ref="'.$search_ref.'"';
  209. }
  210. if (!empty($search_label)) {
  211. $param .= '&search_label="'.$search_label.'"';
  212. }
  213. if (!empty($search_dateend_start)) {
  214. $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int');
  215. }
  216. if (!empty($search_dateend_start)) {
  217. $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int');
  218. }
  219. if (!empty($search_dateend_start)) {
  220. $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int');
  221. }
  222. if (!empty($search_dateend_end)) {
  223. $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int');
  224. }
  225. if (!empty($search_dateend_end)) {
  226. $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int');
  227. }
  228. if (!empty($search_dateend_end)) {
  229. $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int');
  230. }
  231. if (!empty($search_datepayment_start)) {
  232. $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int');
  233. }
  234. if (!empty($search_datepayment_start)) {
  235. $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int');
  236. }
  237. if (!empty($search_datepayment_start)) {
  238. $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int');
  239. }
  240. if (!empty($search_datepayment_end)) {
  241. $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int');
  242. }
  243. if (!empty($search_datepayment_end)) {
  244. $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int');
  245. }
  246. if (!empty($search_datepayment_end)) {
  247. $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int');
  248. }
  249. if (!empty($search_type) && $search_type > 0) {
  250. $param .= '&search_type='.$search_type;
  251. }
  252. if (!empty($search_account) && $search_account > 0) {
  253. $param .= '&search_account='.$search_account;
  254. }
  255. if (!empty($search_amount)) {
  256. $param .= '&search_amount="'.$search_amount.'"';
  257. }
  258. if ($search_status != '' && $search_status != '-1') {
  259. $param .= '&search_status='.urlencode($search_status);
  260. }
  261. $arrayofmassactions = array(
  262. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  263. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  264. );
  265. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  266. $moreforfilter = '';
  267. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  268. if ($optioncss != '') {
  269. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  270. }
  271. print '<input type="hidden" name="token" value="'.newToken().'">';
  272. print '<input type="hidden" name="action" value="list">';
  273. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  274. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  275. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  276. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  277. $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
  278. if (!empty($socid)) {
  279. $url .= '&socid='.$socid;
  280. }
  281. $newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
  282. print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
  283. $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
  284. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  285. if ($massactionbutton) {
  286. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  287. }
  288. print '<div class="div-table-responsive">';
  289. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
  290. print '<tr class="liste_titre_filter">';
  291. // Filters: Lines (placeholder)
  292. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  293. print '<td class="liste_titre">';
  294. print '</td>';
  295. }
  296. // Filter: Ref
  297. if (!empty($arrayfields['t.rowid']['checked'])) {
  298. print '<td class="liste_titre">';
  299. print '<input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  300. print '</td>';
  301. }
  302. // Filter: Label
  303. if (!empty($arrayfields['t.label']['checked'])) {
  304. print '<td class="liste_titre">';
  305. print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  306. print '</td>';
  307. }
  308. // Filter: Date end period
  309. if (!empty($arrayfields['t.datev']['checked'])) {
  310. print '<td class="liste_titre center">';
  311. print '<div class="nowrap">';
  312. print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  313. print '</div>';
  314. print '<div class="nowrap">';
  315. print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  316. print '</div>';
  317. print '</td>';
  318. }
  319. // Filter: Date payment
  320. /*if (!empty($arrayfields['t.datep']['checked'])) {
  321. print '<td class="liste_titre center">';
  322. print '<div class="nowrap">';
  323. print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  324. print '</div>';
  325. print '<div class="nowrap">';
  326. print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  327. print '</div>';
  328. print '</td>';
  329. }*/
  330. // Filter: Type
  331. if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
  332. print '<td class="liste_titre left">';
  333. print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16, 1, '', 1);
  334. print '</td>';
  335. }
  336. // Filter: Bank Account
  337. if (!empty($arrayfields['t.fk_account']['checked'])) {
  338. print '<td class="liste_titre left">';
  339. $form->select_comptes($search_account, 'search_account', 0, '', 1);
  340. print '</td>';
  341. }
  342. // Filter: Amount
  343. if (!empty($arrayfields['t.amount']['checked'])) {
  344. print '<td class="liste_titre right">';
  345. print '<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'">';
  346. print '</td>';
  347. }
  348. // Status
  349. if (!empty($arrayfields['t.status']['checked'])) {
  350. print '<td class="liste_titre maxwidthonsmartphone right">';
  351. $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
  352. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage');
  353. print '</td>';
  354. }
  355. // Fields from hook
  356. $parameters = array('arrayfields'=>$arrayfields);
  357. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  358. print $hookmanager->resPrint;
  359. // Filter: Buttons
  360. print '<td class="liste_titre maxwidthsearch">';
  361. print $form->showFilterAndCheckAddButtons(0);
  362. print '</td>';
  363. print '</tr>';
  364. print '<tr class="liste_titre">';
  365. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  366. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  367. }
  368. if (!empty($arrayfields['t.rowid']['checked'])) {
  369. print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder);
  370. }
  371. if (!empty($arrayfields['t.label']['checked'])) {
  372. print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder);
  373. }
  374. if (!empty($arrayfields['t.datev']['checked'])) {
  375. print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder);
  376. }
  377. if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
  378. print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left ');
  379. }
  380. if (!empty($arrayfields['t.fk_account']['checked'])) {
  381. print_liste_field_titre($arrayfields['t.fk_account']['label'], $_SERVER['PHP_SELF'], 't.fk_account', '', $param, '', $sortfield, $sortorder, 'left ');
  382. }
  383. if (!empty($arrayfields['t.amount']['checked'])) {
  384. print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right ');
  385. }
  386. if (!empty($arrayfields['t.status']['checked'])) {
  387. print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder);
  388. }
  389. // Hook fields
  390. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  391. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  392. print $hookmanager->resPrint;
  393. print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  394. print '</tr>';
  395. $i = 0;
  396. $totalarray = array();
  397. $totalarray['nbfield'] = 0;
  398. $total = 0;
  399. while ($i < min($num, $limit)) {
  400. $obj = $db->fetch_object($resql);
  401. $tva_static->id = $obj->rowid;
  402. $tva_static->ref = $obj->rowid;
  403. $tva_static->label = $obj->label;
  404. print '<tr class="oddeven">';
  405. // No
  406. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  407. print '<td>'.(($offset * $limit) + $i).'</td>';
  408. if (!$i) {
  409. $totalarray['nbfield']++;
  410. }
  411. }
  412. // Ref
  413. if (!empty($arrayfields['t.rowid']['checked'])) {
  414. print '<td>';
  415. print $tva_static->getNomUrl(1);
  416. $filename = dol_sanitizeFileName($tva_static->ref);
  417. $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref);
  418. $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id;
  419. print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp');
  420. print '</td>';
  421. if (!$i) {
  422. $totalarray['nbfield']++;
  423. }
  424. }
  425. // Label
  426. if (!empty($arrayfields['t.label']['checked'])) {
  427. print '<td>'.dol_trunc($obj->label, 40).'</td>';
  428. if (!$i) {
  429. $totalarray['nbfield']++;
  430. }
  431. }
  432. // Date end period
  433. if (!empty($arrayfields['t.datev']['checked'])) {
  434. print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day').'</td>';
  435. if (!$i) {
  436. $totalarray['nbfield']++;
  437. }
  438. }
  439. // Date payment
  440. /*if (!empty($arrayfields['t.datep']['checked'])) {
  441. print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
  442. if (!$i) $totalarray['nbfield']++;
  443. }*/
  444. // Type
  445. if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
  446. print '<td>';
  447. if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code);
  448. print '</td>';
  449. if (!$i) {
  450. $totalarray['nbfield']++;
  451. }
  452. }
  453. // Account
  454. if (!empty($arrayfields['t.fk_account']['checked'])) {
  455. print '<td>';
  456. if ($obj->fk_account > 0) {
  457. $bankstatic->id = $obj->fk_account;
  458. $bankstatic->ref = $obj->bref;
  459. $bankstatic->number = $obj->bnumber;
  460. $bankstatic->iban = $obj->iban;
  461. $bankstatic->bic = $obj->bic;
  462. $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
  463. $bankstatic->account_number = $obj->account_number;
  464. $bankstatic->clos = $obj->clos;
  465. //$accountingjournal->fetch($obj->fk_accountancy_journal);
  466. //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  467. $bankstatic->label = $obj->blabel;
  468. print $bankstatic->getNomUrl(1);
  469. }
  470. print '</td>';
  471. if (!$i) $totalarray['nbfield']++;
  472. }
  473. // Amount
  474. if (!empty($arrayfields['t.amount']['checked'])) {
  475. $total = $total + $obj->amount;
  476. print '<td class="nowrap right"><span class="amount">' . price($obj->amount) . '</span></td>';
  477. if (!$i) {
  478. $totalarray['nbfield']++;
  479. }
  480. $totalarray['pos'][$totalarray['nbfield']] = 'amount';
  481. if (empty($totalarray['val']['amount'])) {
  482. $totalarray['val']['amount'] = $obj->amount;
  483. } else {
  484. $totalarray['val']['amount'] += $obj->amount;
  485. }
  486. }
  487. if (!empty($arrayfields['t.status']['checked'])) {
  488. print '<td class="nowrap right">' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '</td>';
  489. if (!$i) {
  490. $totalarray['nbfield']++;
  491. }
  492. if (!empty($arrayfields['t.amount']['checked'])) {
  493. $totalarray['pos'][$totalarray['nbfield']] = '';
  494. }
  495. }
  496. // Buttons
  497. print '<td></td>';
  498. print '</tr>';
  499. $i++;
  500. }
  501. // Add a buttons placeholder for the total line
  502. $totalarray['nbfield']++;
  503. // Show total line
  504. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  505. // If no record found
  506. if ($num == 0) {
  507. $colspan = 1;
  508. foreach ($arrayfields as $key => $val) {
  509. if (!empty($val['checked'])) {
  510. $colspan++;
  511. }
  512. }
  513. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  514. }
  515. $db->free($resql);
  516. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  517. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
  518. print $hookmanager->resPrint;
  519. print '</table>'."\n";
  520. print '</div>'."\n";
  521. print '</form>'."\n";
  522. // End of page
  523. llxFooter();
  524. $db->close();