listbyyear.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?php
  2. /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  4. * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. /**
  21. * \file htdocs/accountancy/bookkeeping/listbyyear.php
  22. * \ingroup Advanced accountancy
  23. * \brief Book keeping by year
  24. */
  25. require '../../main.inc.php';
  26. // Class
  27. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
  29. require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
  31. // Langs
  32. $langs->load("accountancy");
  33. $page = GETPOST("page");
  34. $sortorder = GETPOST("sortorder");
  35. $sortfield = GETPOST("sortfield");
  36. $limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
  37. $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
  38. $search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
  39. $search_doc_type = GETPOST('search_doc_type', 'alpha');
  40. $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
  41. $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
  42. $search_numero_compte = GETPOST('search_numero_compte', 'alpha');
  43. $search_numero_compte_start = GETPOST('search_numero_compte_start', 'alpha');
  44. if ($search_numero_compte_start == - 1) {
  45. $search_numero_compte_start = '';
  46. }
  47. $search_numero_compte_end = GETPOST('search_numero_compte_end', 'alpha');
  48. if ($search_numero_compte_end == - 1) {
  49. $search_numero_compte_end = '';
  50. }
  51. $search_code_tiers = GETPOST('search_code_tiers', 'alpha');
  52. $search_code_tiers_start = GETPOST('search_code_tiers_start', 'alpha');
  53. if ($search_code_tiers_start == - 1) {
  54. $search_code_tiers_start = '';
  55. }
  56. $search_code_tiers_end = GETPOST('search_code_tiers_end', 'alpha');
  57. if ($search_code_tiers_end == - 1) {
  58. $search_code_tiers_end = '';
  59. }
  60. $search_label_compte = GETPOST('search_label_compte', 'alpha');
  61. $search_sens = GETPOST('search_sens', 'alpha');
  62. $search_code_journal = GETPOST('search_code_journal', 'alpha');
  63. $object = new BookKeeping($db);
  64. $form = new Form($db);
  65. $formaccounting = new FormAccounting($db);
  66. // Filter
  67. if (empty($search_date_start)) {
  68. $search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
  69. $search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
  70. }
  71. if ($sortorder == "")
  72. $sortorder = "ASC";
  73. if ($sortfield == "")
  74. $sortfield = "t.rowid";
  75. $offset = $limit * $page;
  76. llxHeader('', $langs->trans("Bookkeeping"));
  77. if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
  78. {
  79. $search_doc_type = "";
  80. $search_doc_date = "";
  81. $search_doc_ref = "";
  82. $search_numero_compte = "";
  83. $search_code_tiers = "";
  84. $search_label_compte = "";
  85. $search_sens = "";
  86. $search_code_journal = "";
  87. }
  88. $options = '';
  89. $filter = array ();
  90. if (! empty($search_date_start)) {
  91. $filter['t.doc_date>='] = $search_date_start;
  92. $options .= '&amp;date_startmonth=' . GETPOST('date_startmonth', 'int') . '&amp;date_startday=' . GETPOST('date_startday', 'int') . '&amp;date_startyear=' . GETPOST('date_startyear', 'int');
  93. }
  94. if (! empty($search_date_end)) {
  95. $filter['t.doc_date<='] = $search_date_end;
  96. $options .= '&amp;date_endmonth=' . GETPOST('date_endmonth', 'int') . '&amp;date_endday=' . GETPOST('date_endday', 'int') . '&amp;date_endyear=' . GETPOST('date_endyear', 'int');
  97. }
  98. if (! empty($search_doc_type)) {
  99. $filter['t.doc_type'] = $search_doc_type;
  100. $options .= '&amp;search_doc_type=' . $search_doc_type;
  101. }
  102. if (! empty($search_doc_date)) {
  103. $filter['t.doc_date'] = $search_doc_date;
  104. $options .= '&amp;doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&amp;doc_dateday=' . GETPOST('doc_dateday', 'int') . '&amp;doc_dateyear=' . GETPOST('doc_dateyear', 'int');
  105. }
  106. if (! empty($search_doc_ref)) {
  107. $filter['t.doc_ref'] = $search_doc_ref;
  108. $options .= '&amp;search_doc_ref=' . $search_doc_ref;
  109. }
  110. if (! empty($search_numero_compte)) {
  111. $filter['t.numero_compte'] = $search_numero_compte;
  112. $options .= '&amp;search_numero_compte=' . $search_numero_compte;
  113. }
  114. if (! empty($search_numero_compte_start)) {
  115. $filter['t.numero_compte>='] = $search_numero_compte_start;
  116. $options .= '&amp;search_numero_compte_start=' . $search_numero_compte_start;
  117. }
  118. if (! empty($search_numero_compte_end)) {
  119. $filter['t.numero_compte<='] = $search_numero_compte_end;
  120. $options .= '&amp;search_numero_compte_end=' . $search_numero_compte_end;
  121. }
  122. if (! empty($search_code_tiers)) {
  123. $filter['t.code_tiers'] = $search_code_tiers;
  124. $options .= '&amp;search_code_tiers=' . $search_code_tiers;
  125. }
  126. if (! empty($search_code_tiers_start)) {
  127. $filter['t.code_tiers>='] = $search_code_tiers_start;
  128. $options .= '&amp;search_code_tiers_start=' . $search_code_tiers_start;
  129. }
  130. if (! empty($search_code_tiers_end)) {
  131. $filter['t.code_tiers<='] = $search_code_tiers_end;
  132. $options .= '&amp;search_code_tiers_end=' . $search_code_tiers_end;
  133. }
  134. if (! empty($search_label_compte)) {
  135. $filter['t.label_compte'] = $search_label_compte;
  136. $options .= '&amp;search_label_compte=' . $search_label_compte;
  137. }
  138. if (! empty($search_sens)) {
  139. $filter['t.sens'] = $search_sens;
  140. $options .= '&amp;search_sens=' . $search_sens;
  141. }
  142. if (! empty($search_code_journal)) {
  143. $filter['t.code_journal'] = $search_code_journal;
  144. $options .= '&amp;search_code_journal=' . $search_code_journal;
  145. }
  146. /*
  147. * Mode List
  148. */
  149. $nbtotalofrecords = '';
  150. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  151. $nbtotalofrecords = $object->fetchAll($sortorder, $sortfield, 0, 0);
  152. if ($nbtotalofrecords < 0) {
  153. setEventMessages($object->error, $object->errors, 'errors');
  154. }
  155. }
  156. $result = $object->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
  157. if ($result < 0) {
  158. setEventMessages($object->error, $object->errors, 'errors');
  159. }
  160. print_barre_liste($langs->trans("Bookkeeping") . ' ' . dol_print_date($search_date_start) . '-' . dol_print_date($search_date_end), $page, $_SERVER['PHP_SELF'], $options, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy');
  161. print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
  162. print '<div class="liste_titre">';
  163. print $langs->trans('DateStart') . ': ';
  164. print $form->select_date($search_date_start, 'date_start');
  165. print $langs->trans('DateEnd') . ': ';
  166. print $form->select_date($search_date_end, 'date_end');
  167. print '</div>';
  168. print '<div class="liste_titre">';
  169. print $langs->trans('From') . ' ' . $langs->trans('AccountAccounting') . ': ';
  170. print $formaccounting->select_account($search_numero_compte_start, 'search_numero_compte_start', 1, array (), 1, 1, '');
  171. print $langs->trans('To') . ' ' . $langs->trans('AccountAccounting') . ': ';
  172. print $formaccounting->select_account($search_numero_compte_end, 'search_numero_compte_end', 1, array (), 1, 1, '');
  173. print '</div>';
  174. print '<div class="liste_titre">';
  175. print $langs->trans('From') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
  176. print $formaccounting->select_auxaccount($search_code_tiers_start, 'search_code_tiers_start', 1);
  177. print $langs->trans('To') . ' ' . $langs->trans('ThirdPartyAccount') . ': ';
  178. print $formaccounting->select_auxaccount($search_code_tiers_end, 'searchcode_tiers_end', 1);
  179. print '</div>';
  180. print "<table class=\"noborder\" width=\"100%\">";
  181. print '<tr class="liste_titre">';
  182. print_liste_field_titre($langs->trans("NumPiece"), $_SERVER['PHP_SELF'], "t.piece_num", "", $options, "", $sortfield, $sortorder);
  183. print_liste_field_titre($langs->trans("Doctype"), $_SERVER['PHP_SELF'], "t.doc_type", "", $options, "", $sortfield, $sortorder);
  184. print_liste_field_titre($langs->trans("Date"), $_SERVER['PHP_SELF'], "t.doc_date", "", $options, 'align="center"', $sortfield, $sortorder);
  185. print_liste_field_titre($langs->trans("Docref"), $_SERVER['PHP_SELF'], "t.doc_ref", "", $options, "", $sortfield, $sortorder);
  186. print_liste_field_titre($langs->trans("AccountAccounting"), $_SERVER['PHP_SELF'], "t.numero_compte", "", $options, "", $sortfield, $sortorder);
  187. print_liste_field_titre($langs->trans("ThirdPartyAccount"), $_SERVER['PHP_SELF'], "t.code_tiers", "", $options, "", $sortfield, $sortorder);
  188. print_liste_field_titre($langs->trans("Label"), $_SERVER['PHP_SELF'], "t.label_compte", "", $options, "", $sortfield, $sortorder);
  189. print_liste_field_titre($langs->trans("Debit"), $_SERVER['PHP_SELF'], "t.debit", "", $options, "", $sortfield, $sortorder);
  190. print_liste_field_titre($langs->trans("Credit"), $_SERVER['PHP_SELF'], "t.credit", "", $options, 'align="center"', $sortfield, $sortorder);
  191. print_liste_field_titre($langs->trans("Amount"), $_SERVER['PHP_SELF'], "t.montant", "", $options, 'align="center"', $sortfield, $sortorder);
  192. print_liste_field_titre($langs->trans("Sens"), $_SERVER['PHP_SELF'], "t.sens", "", $options, 'align="center"', $sortfield, $sortorder);
  193. print_liste_field_titre($langs->trans("Codejournal"), $_SERVER['PHP_SELF'], "t.code_journal", "", $options, 'align="center"', $sortfield, $sortorder);
  194. print_liste_field_titre($langs->trans("Action"), $_SERVER["PHP_SELF"], "", $options, "", 'width="60" align="center"', $sortfield, $sortorder);
  195. print "</tr>\n";
  196. print '<tr class="liste_titre">';
  197. print '<td class="liste_titre">';
  198. print '<input type="text" size=4 class="flat" name="search_piece_num" value="' . $search_piece_num . '"/>';
  199. print '</td>';
  200. print '<td class="liste_titre">';
  201. print '<input type="text" size=7 class="flat" name="search_doc_type" value="' . $search_doc_type . '"/>';
  202. print '</td>';
  203. print '<td class="liste_titre">';
  204. print $form->select_date($search_doc_date, 'doc_date', 0, 0, 1);
  205. print '</td>';
  206. print '<td class="liste_titre">';
  207. print '<input type="text" size=6 class="flat" name="search_doc_ref" value="' . $search_doc_ref . '"/>';
  208. print '</td>';
  209. print '<td class="liste_titre">';
  210. print '<input type="text" size=6 class="flat" name="search_numero_compte" value="' . $search_numero_compte . '"/>';
  211. print '</td>';
  212. print '<td class="liste_titre">';
  213. print '<input type="text" size=6 class="flat" name="search_code_tiers" value="' . $search_code_tiers . '"/>';
  214. print '</td>';
  215. print '<td class="liste_titre">';
  216. print '<input type="text" size=6 class="flat" name="search_label_compte" value="' . $search_label_compte . '"/>';
  217. print '</td>';
  218. print '<td class="liste_titre">';
  219. print '</td>';
  220. print '<td class="liste_titre">';
  221. print '</td>';
  222. print '<td class="liste_titre">';
  223. print '</td>';
  224. print '<td class="liste_titre" align="center">';
  225. print '<input type="text" size=2 class="flat" name="search_sens" value="' . $search_sens . '"/>';
  226. print '</td>';
  227. print '<td class="liste_titre" align="center">';
  228. print '<input type="text" size=3 class="flat" name="search_code_journal" value="' . $search_code_journal . '"/>';
  229. print '</td>';
  230. print '<td align="right" colspan="2" class="liste_titre">';
  231. print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" name="button_search" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
  232. print '&nbsp;';
  233. print '<input type="image" class="liste_titre" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" name="button_removefilter" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
  234. print '</td>';
  235. print "</tr>\n";
  236. $var = True;
  237. foreach ( $object->lines as $line ) {
  238. print '<tr class="oddeven">';
  239. print '<td>' . $line->piece_num . '</td>' . "\n";
  240. print '<td>' . $line->doc_type . '</td>' . "\n";
  241. print '<td align="center">' . dol_print_date($line->doc_date) . '</td>';
  242. print '<td>' . $line->doc_ref . '</td>';
  243. print '<td>' . length_accountg($line->numero_compte) . '</td>';
  244. print '<td>' . length_accounta($line->code_tiers) . '</td>';
  245. print '<td>' . $line->label_compte . '</td>';
  246. print '<td align="right">' . price($line->debit) . '</td>';
  247. print '<td align="right">' . price($line->credit) . '</td>';
  248. print '<td align="right">' . price($line->montant) . '</td>';
  249. print '<td align="center">' . $line->sens . '</td>';
  250. print '<td align="right">' . $line->code_journal . '</td>';
  251. print '<td align="center"><a href="./card.php?action=update&amp;piece_num=' . $line->piece_num . '">' . img_edit() . '</a></td>';
  252. print "</tr>\n";
  253. }
  254. print "</table>";
  255. print '</form>';
  256. llxFooter();
  257. $db->close();