list.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. require '../../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
  29. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('compta', 'bills'));
  36. $action = GETPOST('action', 'alpha');
  37. $massaction = GETPOST('massaction', 'alpha');
  38. $confirm = GETPOST('confirm', 'alpha');
  39. $optioncss = GETPOST('optioncss', 'alpha');
  40. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist';
  41. $search_ref = GETPOST('search_ref', 'alpha');
  42. $search_label = GETPOST('search_label', 'alpha');
  43. $search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
  44. $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
  45. $search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int'));
  46. $search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int'));
  47. $search_type = GETPOST('search_type', 'int');
  48. $search_account = GETPOST('search_account', 'int');
  49. $search_amount = GETPOST('search_amount', 'alpha');
  50. $search_status = GETPOST('search_status', 'int');
  51. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  52. $sortfield = GETPOST('sortfield', 'aZ09comma');
  53. $sortorder = GETPOST('sortorder', 'aZ09comma');
  54. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
  55. if (empty($page) || $page == -1) {
  56. $page = 0; // If $page is not defined, or '' or -1
  57. }
  58. $offset = $limit * $page;
  59. $pageprev = $page - 1;
  60. $pagenext = $page + 1;
  61. if (!$sortfield) {
  62. $sortfield = 't.datev';
  63. }
  64. if (!$sortorder) {
  65. $sortorder = 'DESC';
  66. }
  67. $arrayfields = array(
  68. 't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",),
  69. 't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"),
  70. 't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"),
  71. 't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"DefaultPaymentMode"),
  72. 't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"),
  73. 't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"),
  74. );
  75. if (!empty($conf->banque->enabled)) {
  76. $arrayfields['t.fk_account'] = array('checked'=>1, 'position'=>60, 'label'=>"DefaultBankAccount");
  77. }
  78. $arrayfields = dol_sort_array($arrayfields, 'position');
  79. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  80. $hookmanager->initHooks(array('salestaxeslist'));
  81. $object = new Tva($db);
  82. // Security check
  83. $socid = GETPOST('socid', 'int');
  84. if ($user->socid) {
  85. $socid = $user->socid;
  86. }
  87. $result = restrictedArea($user, 'tax', '', 'tva', 'charges');
  88. /*
  89. * Actions
  90. */
  91. $parameters = array('socid'=>$socid);
  92. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  93. if ($reshook < 0) {
  94. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  95. }
  96. if (empty($reshook)) {
  97. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  98. 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
  99. $search_ref = '';
  100. $search_label = '';
  101. $search_dateend_start = '';
  102. $search_dateend_end = '';
  103. $search_datepayment_start = '';
  104. $search_datepayment_end = '';
  105. $search_type = '';
  106. $search_account = '';
  107. $search_amount = '';
  108. $search_status = '';
  109. }
  110. }
  111. /*
  112. * View
  113. */
  114. $form = new Form($db);
  115. $formother = new FormOther($db);
  116. $formfile = new FormFile($db);
  117. $tva_static = new Tva($db);
  118. $bankstatic = new Account($db);
  119. $accountingjournal = new AccountingJournal($db);
  120. $bankline = new AccountLine($db);
  121. llxHeader('', $langs->trans("VATDeclarations"));
  122. $sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.fk_account,';
  123. $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,';
  124. $sql.= ' t.num_payment, pst.code as payment_code,';
  125. $sql .= ' SUM(ptva.amount) as alreadypayed';
  126. $sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t';
  127. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON (t.fk_typepayment = pst.id)';
  128. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON (t.fk_account = ba.rowid)';
  129. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (ptva.fk_tva = t.rowid)";
  130. $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')';
  131. if (!empty($search_ref)) {
  132. $sql .= natural_search('t.rowid', $search_ref);
  133. }
  134. if (!empty($search_label)) {
  135. $sql .= natural_search('t.label', $search_label);
  136. }
  137. if (!empty($search_dateend_start)) {
  138. $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
  139. }
  140. if (!empty($search_dateend_end)) {
  141. $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
  142. }
  143. if (!empty($search_datepayment_start)) {
  144. $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
  145. }
  146. if (!empty($search_datepayment_end)) {
  147. $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
  148. }
  149. if (!empty($search_type) && $search_type > 0) {
  150. $sql .= ' AND t.fk_typepayment = '.((int) $search_type);
  151. }
  152. if (!empty($search_account) && $search_account > 0) {
  153. $sql .= ' AND t.fk_account = '.((int) $search_account);
  154. }
  155. if (!empty($search_amount)) {
  156. $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
  157. }
  158. if ($search_status != '' && $search_status >= 0) {
  159. $sql .= " AND t.paye = ".((int) $search_status);
  160. }
  161. $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";
  162. $sql .= $db->order($sortfield, $sortorder);
  163. $nbtotalofrecords = '';
  164. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  165. $result = $db->query($sql);
  166. $nbtotalofrecords = $db->num_rows($result);
  167. // if total resultset is smaller then paging size (filtering), goto and load page 0
  168. if (($page * $limit) > $nbtotalofrecords) {
  169. $page = 0;
  170. $offset = 0;
  171. }
  172. }
  173. $sql .= $db->plimit($limit + 1, $offset);
  174. $result = $db->query($sql);
  175. if (!$result) {
  176. dol_print_error($db);
  177. llxFooter();
  178. $db->close();
  179. exit;
  180. }
  181. $num = $db->num_rows($result);
  182. $param = '';
  183. if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) {
  184. $param .= '&contextpage='.$contextpage;
  185. }
  186. if ($limit > 0 && $limit != $conf->liste_limit) {
  187. $param .= '&limit='.$limit;
  188. }
  189. if ($optioncss != '') {
  190. $param .= '&optioncss='.urlencode($optioncss);
  191. }
  192. if (!empty($search_ref)) {
  193. $param .= '&search_ref="'.$search_ref.'"';
  194. }
  195. if (!empty($search_label)) {
  196. $param .= '&search_label="'.$search_label.'"';
  197. }
  198. if (!empty($search_dateend_start)) {
  199. $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int');
  200. }
  201. if (!empty($search_dateend_start)) {
  202. $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int');
  203. }
  204. if (!empty($search_dateend_start)) {
  205. $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int');
  206. }
  207. if (!empty($search_dateend_end)) {
  208. $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int');
  209. }
  210. if (!empty($search_dateend_end)) {
  211. $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int');
  212. }
  213. if (!empty($search_dateend_end)) {
  214. $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int');
  215. }
  216. if (!empty($search_datepayment_start)) {
  217. $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int');
  218. }
  219. if (!empty($search_datepayment_start)) {
  220. $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int');
  221. }
  222. if (!empty($search_datepayment_start)) {
  223. $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int');
  224. }
  225. if (!empty($search_datepayment_end)) {
  226. $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int');
  227. }
  228. if (!empty($search_datepayment_end)) {
  229. $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int');
  230. }
  231. if (!empty($search_datepayment_end)) {
  232. $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int');
  233. }
  234. if (!empty($search_type) && $search_type > 0) {
  235. $param .= '&search_type='.$search_type;
  236. }
  237. if (!empty($search_account) && $search_account > 0) {
  238. $param .= '&search_account='.$search_account;
  239. }
  240. if (!empty($search_amount)) {
  241. $param .= '&search_amount="'.$search_amount.'"';
  242. }
  243. if ($search_status != '' && $search_status != '-1') {
  244. $param .= '&search_status='.urlencode($search_status);
  245. }
  246. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  247. if ($optioncss != '') {
  248. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  249. }
  250. print '<input type="hidden" name="token" value="'.newToken().'">';
  251. print '<input type="hidden" name="action" value="list">';
  252. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  253. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  254. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  255. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  256. $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
  257. if (!empty($socid)) {
  258. $url .= '&socid='.$socid;
  259. }
  260. $newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
  261. print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
  262. $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
  263. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  264. if ($massactionbutton) {
  265. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  266. }
  267. print '<div class="div-table-responsive">';
  268. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
  269. print '<tr class="liste_titre_filter">';
  270. // Filters: Lines (placeholder)
  271. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  272. print '<td class="liste_titre">';
  273. print '</td>';
  274. }
  275. // Filter: Ref
  276. if (!empty($arrayfields['t.rowid']['checked'])) {
  277. print '<td class="liste_titre">';
  278. print '<input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  279. print '</td>';
  280. }
  281. // Filter: Label
  282. if (!empty($arrayfields['t.label']['checked'])) {
  283. print '<td class="liste_titre">';
  284. print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  285. print '</td>';
  286. }
  287. // Filter: Date end period
  288. if (!empty($arrayfields['t.datev']['checked'])) {
  289. print '<td class="liste_titre center">';
  290. print '<div class="nowrap">';
  291. print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  292. print '</div>';
  293. print '<div class="nowrap">';
  294. print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  295. print '</div>';
  296. print '</td>';
  297. }
  298. // Filter: Date payment
  299. /*if (!empty($arrayfields['t.datep']['checked'])) {
  300. print '<td class="liste_titre center">';
  301. print '<div class="nowrap">';
  302. print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  303. print '</div>';
  304. print '<div class="nowrap">';
  305. print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  306. print '</div>';
  307. print '</td>';
  308. }*/
  309. // Filter: Type
  310. if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
  311. print '<td class="liste_titre left">';
  312. $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16);
  313. print '</td>';
  314. }
  315. // Filter: Bank Account
  316. if (!empty($arrayfields['t.fk_account']['checked'])) {
  317. print '<td class="liste_titre left">';
  318. $form->select_comptes($search_account, 'search_account', 0, '', 1);
  319. print '</td>';
  320. }
  321. // Filter: Amount
  322. if (!empty($arrayfields['t.amount']['checked'])) {
  323. print '<td class="liste_titre right">';
  324. print '<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'">';
  325. print '</td>';
  326. }
  327. // Status
  328. if (!empty($arrayfields['t.status']['checked'])) {
  329. print '<td class="liste_titre maxwidthonsmartphone right">';
  330. $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid"));
  331. print $form->selectarray('search_status', $liststatus, $search_status, 1);
  332. print '</td>';
  333. }
  334. // Fields from hook
  335. $parameters = array('arrayfields'=>$arrayfields);
  336. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  337. print $hookmanager->resPrint;
  338. // Filter: Buttons
  339. print '<td class="liste_titre maxwidthsearch">';
  340. print $form->showFilterAndCheckAddButtons(0);
  341. print '</td>';
  342. print '</tr>';
  343. print '<tr class="liste_titre">';
  344. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  345. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  346. }
  347. if (!empty($arrayfields['t.rowid']['checked'])) {
  348. print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder);
  349. }
  350. if (!empty($arrayfields['t.label']['checked'])) {
  351. print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder);
  352. }
  353. if (!empty($arrayfields['t.datev']['checked'])) {
  354. print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder);
  355. }
  356. if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
  357. print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left ');
  358. }
  359. if (!empty($arrayfields['t.fk_account']['checked'])) {
  360. print_liste_field_titre($arrayfields['t.fk_account']['label'], $_SERVER['PHP_SELF'], 't.fk_account', '', $param, '', $sortfield, $sortorder, 'left ');
  361. }
  362. if (!empty($arrayfields['t.amount']['checked'])) {
  363. print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right ');
  364. }
  365. if (!empty($arrayfields['t.status']['checked'])) {
  366. print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder);
  367. }
  368. // Hook fields
  369. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  370. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  371. print $hookmanager->resPrint;
  372. print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
  373. print '</tr>';
  374. $i = 0;
  375. $totalarray = array();
  376. while ($i < min($num, $limit)) {
  377. $obj = $db->fetch_object($result);
  378. $tva_static->id = $obj->rowid;
  379. $tva_static->ref = $obj->rowid;
  380. $tva_static->label = $obj->label;
  381. print '<tr class="oddeven">';
  382. // No
  383. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  384. print '<td>'.(($offset * $limit) + $i).'</td>';
  385. if (!$i) {
  386. $totalarray['nbfield']++;
  387. }
  388. }
  389. // Ref
  390. if (!empty($arrayfields['t.rowid']['checked'])) {
  391. print '<td>';
  392. print $tva_static->getNomUrl(1);
  393. $filename = dol_sanitizeFileName($tva_static->ref);
  394. $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref);
  395. $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id;
  396. print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp');
  397. print '</td>';
  398. if (!$i) {
  399. $totalarray['nbfield']++;
  400. }
  401. }
  402. // Label
  403. if (!empty($arrayfields['t.label']['checked'])) {
  404. print '<td>'.dol_trunc($obj->label, 40).'</td>';
  405. if (!$i) {
  406. $totalarray['nbfield']++;
  407. }
  408. }
  409. // Date end period
  410. if (!empty($arrayfields['t.datev']['checked'])) {
  411. print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day').'</td>';
  412. if (!$i) {
  413. $totalarray['nbfield']++;
  414. }
  415. }
  416. // Date payment
  417. /*if (!empty($arrayfields['t.datep']['checked'])) {
  418. print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
  419. if (!$i) $totalarray['nbfield']++;
  420. }*/
  421. // Type
  422. if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
  423. print '<td>';
  424. if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code);
  425. print '</td>';
  426. if (!$i) {
  427. $totalarray['nbfield']++;
  428. }
  429. }
  430. // Account
  431. if (!empty($arrayfields['t.fk_account']['checked'])) {
  432. print '<td>';
  433. if ($obj->fk_account > 0) {
  434. $bankstatic->id = $obj->fk_account;
  435. $bankstatic->ref = $obj->bref;
  436. $bankstatic->number = $obj->bnumber;
  437. $bankstatic->iban = $obj->iban;
  438. $bankstatic->bic = $obj->bic;
  439. $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
  440. $bankstatic->account_number = $obj->account_number;
  441. $bankstatic->clos = $obj->clos;
  442. //$accountingjournal->fetch($obj->fk_accountancy_journal);
  443. //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  444. $bankstatic->label = $obj->blabel;
  445. print $bankstatic->getNomUrl(1);
  446. }
  447. print '</td>';
  448. if (!$i) $totalarray['nbfield']++;
  449. }
  450. // Amount
  451. if (!empty($arrayfields['t.amount']['checked'])) {
  452. $total = $total + $obj->amount;
  453. print '<td class="nowrap right"><span class="amount">' . price($obj->amount) . '</span></td>';
  454. if (!$i) {
  455. $totalarray['nbfield']++;
  456. }
  457. $totalarray['pos'][$totalarray['nbfield']] = 'amount';
  458. $totalarray['val']['amount'] += $obj->amount;
  459. }
  460. if (!empty($arrayfields['t.status']['checked'])) {
  461. print '<td class="nowrap right">' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '</td>';
  462. if (!$i) {
  463. $totalarray['nbfield']++;
  464. }
  465. if (!empty($arrayfields['t.amount']['checked'])) {
  466. $totalarray['pos'][$totalarray['nbfield']] = '';
  467. }
  468. }
  469. // Buttons
  470. print '<td></td>';
  471. print '</tr>';
  472. $i++;
  473. }
  474. // Add a buttons placeholder for the total line
  475. $totalarray['nbfield']++;
  476. // Show total line
  477. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  478. print '</table>';
  479. print '</div>';
  480. print '</form>';
  481. $db->free($result);
  482. // End of page
  483. llxFooter();
  484. $db->close();