list.php 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. <?php
  2. /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
  4. * Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  5. * Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/accountancy/bookkeeping/list.php
  23. * \ingroup Accountancy (Double entries)
  24. * \brief List operation of book keeping
  25. */
  26. require '../../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
  30. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.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.'/core/class/html.formaccounting.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  37. // Load translation files required by the page
  38. $langs->loadLangs(array("accountancy", "compta"));
  39. $socid = GETPOST('socid', 'int');
  40. $action = GETPOST('action', 'aZ09');
  41. $massaction = GETPOST('massaction', 'alpha');
  42. $confirm = GETPOST('confirm', 'alpha');
  43. $toselect = GETPOST('toselect', 'array');
  44. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepinglist';
  45. $search_mvt_num = GETPOST('search_mvt_num', 'int');
  46. $search_doc_type = GETPOST("search_doc_type", 'alpha');
  47. $search_doc_ref = GETPOST("search_doc_ref", 'alpha');
  48. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  49. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  50. $search_date_startday = GETPOST('search_date_startday', 'int');
  51. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  52. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  53. $search_date_endday = GETPOST('search_date_endday', 'int');
  54. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
  55. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  56. $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
  57. $search_date_creation_startyear = GETPOST('search_date_creation_startyear', 'int');
  58. $search_date_creation_startmonth = GETPOST('search_date_creation_startmonth', 'int');
  59. $search_date_creation_startday = GETPOST('search_date_creation_startday', 'int');
  60. $search_date_creation_endyear = GETPOST('search_date_creation_endyear', 'int');
  61. $search_date_creation_endmonth = GETPOST('search_date_creation_endmonth', 'int');
  62. $search_date_creation_endday = GETPOST('search_date_creation_endday', 'int');
  63. $search_date_creation_start = dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
  64. $search_date_creation_end = dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
  65. $search_date_modification_startyear = GETPOST('search_date_modification_startyear', 'int');
  66. $search_date_modification_startmonth = GETPOST('search_date_modification_startmonth', 'int');
  67. $search_date_modification_startday = GETPOST('search_date_modification_startday', 'int');
  68. $search_date_modification_endyear = GETPOST('search_date_modification_endyear', 'int');
  69. $search_date_modification_endmonth = GETPOST('search_date_modification_endmonth', 'int');
  70. $search_date_modification_endday = GETPOST('search_date_modification_endday', 'int');
  71. $search_date_modification_start = dol_mktime(0, 0, 0, $search_date_modification_startmonth, $search_date_modification_startday, $search_date_modification_startyear);
  72. $search_date_modification_end = dol_mktime(23, 59, 59, $search_date_modification_endmonth, $search_date_modification_endday, $search_date_modification_endyear);
  73. $search_date_export_startyear = GETPOST('search_date_export_startyear', 'int');
  74. $search_date_export_startmonth = GETPOST('search_date_export_startmonth', 'int');
  75. $search_date_export_startday = GETPOST('search_date_export_startday', 'int');
  76. $search_date_export_endyear = GETPOST('search_date_export_endyear', 'int');
  77. $search_date_export_endmonth = GETPOST('search_date_export_endmonth', 'int');
  78. $search_date_export_endday = GETPOST('search_date_export_endday', 'int');
  79. $search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
  80. $search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
  81. $search_date_validation_startyear = GETPOST('search_date_validation_startyear', 'int');
  82. $search_date_validation_startmonth = GETPOST('search_date_validation_startmonth', 'int');
  83. $search_date_validation_startday = GETPOST('search_date_validation_startday', 'int');
  84. $search_date_validation_endyear = GETPOST('search_date_validation_endyear', 'int');
  85. $search_date_validation_endmonth = GETPOST('search_date_validation_endmonth', 'int');
  86. $search_date_validation_endday = GETPOST('search_date_validation_endday', 'int');
  87. $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
  88. $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
  89. $search_import_key = GETPOST("search_import_key", 'alpha');
  90. //var_dump($search_date_start);exit;
  91. if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
  92. $action = 'delbookkeepingyear';
  93. }
  94. if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOST("button_export_file")) {
  95. $action = 'export_file';
  96. }
  97. $search_accountancy_code = GETPOST("search_accountancy_code");
  98. $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
  99. if ($search_accountancy_code_start == - 1) {
  100. $search_accountancy_code_start = '';
  101. }
  102. $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
  103. if ($search_accountancy_code_end == - 1) {
  104. $search_accountancy_code_end = '';
  105. }
  106. $search_accountancy_aux_code = GETPOST("search_accountancy_aux_code", 'alpha');
  107. $search_accountancy_aux_code_start = GETPOST('search_accountancy_aux_code_start', 'alpha');
  108. if ($search_accountancy_aux_code_start == - 1) {
  109. $search_accountancy_aux_code_start = '';
  110. }
  111. $search_accountancy_aux_code_end = GETPOST('search_accountancy_aux_code_end', 'alpha');
  112. if ($search_accountancy_aux_code_end == - 1) {
  113. $search_accountancy_aux_code_end = '';
  114. }
  115. $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
  116. $search_direction = GETPOST('search_direction', 'alpha');
  117. $search_debit = GETPOST('search_debit', 'alpha');
  118. $search_credit = GETPOST('search_credit', 'alpha');
  119. $search_ledger_code = GETPOST('search_ledger_code', 'array');
  120. $search_lettering_code = GETPOST('search_lettering_code', 'alpha');
  121. $search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
  122. // Load variable for pagination
  123. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
  124. $sortfield = GETPOST('sortfield', 'aZ09comma');
  125. $sortorder = GETPOST('sortorder', 'aZ09comma');
  126. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  127. if (empty($page) || $page < 0) {
  128. $page = 0;
  129. }
  130. $offset = $limit * $page;
  131. $pageprev = $page - 1;
  132. $pagenext = $page + 1;
  133. if ($sortorder == "") {
  134. $sortorder = "ASC";
  135. }
  136. if ($sortfield == "") {
  137. $sortfield = "t.piece_num,t.rowid";
  138. }
  139. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  140. $object = new BookKeeping($db);
  141. $hookmanager->initHooks(array('bookkeepinglist'));
  142. $formaccounting = new FormAccounting($db);
  143. $form = new Form($db);
  144. if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) {
  145. if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) {
  146. $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
  147. $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
  148. $res = $db->query($query);
  149. if ($res->num_rows > 0) {
  150. $fiscalYear = $db->fetch_object($res);
  151. $search_date_start = strtotime($fiscalYear->date_start);
  152. $search_date_end = strtotime($fiscalYear->date_end);
  153. } else {
  154. $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
  155. $year_start = dol_print_date(dol_now(), '%Y');
  156. if (dol_print_date(dol_now(), '%m') < $month_start) {
  157. $year_start--; // If current month is lower that starting fiscal month, we start last year
  158. }
  159. $year_end = $year_start + 1;
  160. $month_end = $month_start - 1;
  161. if ($month_end < 1) {
  162. $month_end = 12;
  163. $year_end--;
  164. }
  165. $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
  166. $search_date_end = dol_get_last_day($year_end, $month_end);
  167. }
  168. }
  169. }
  170. $arrayfields = array(
  171. 't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
  172. 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
  173. 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
  174. 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
  175. 't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
  176. 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
  177. 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
  178. 't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
  179. 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
  180. 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
  181. 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
  182. 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
  183. 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
  184. 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1),
  185. 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100),
  186. );
  187. if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
  188. unset($arrayfields['t.lettering_code']);
  189. }
  190. $accountancyexport = new AccountancyExport($db);
  191. $listofformat = $accountancyexport->getType();
  192. $formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV;
  193. if (empty($listofformat[$formatexportset])) {
  194. $formatexportset = 1;
  195. }
  196. $error = 0;
  197. if (empty($conf->accounting->enabled)) {
  198. accessforbidden();
  199. }
  200. if ($user->socid > 0) {
  201. accessforbidden();
  202. }
  203. if (empty($user->rights->accounting->mouvements->lire)) {
  204. accessforbidden();
  205. }
  206. /*
  207. * Actions
  208. */
  209. $param = '';
  210. if (GETPOST('cancel', 'alpha')) {
  211. $action = 'list'; $massaction = '';
  212. }
  213. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'preunlettering' && $massaction != 'predeletebookkeepingwriting') {
  214. $massaction = '';
  215. }
  216. $parameters = array('socid'=>$socid);
  217. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  218. if ($reshook < 0) {
  219. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  220. }
  221. if (empty($reshook)) {
  222. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  223. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  224. $search_mvt_num = '';
  225. $search_doc_type = '';
  226. $search_doc_ref = '';
  227. $search_doc_date = '';
  228. $search_accountancy_code = '';
  229. $search_accountancy_code_start = '';
  230. $search_accountancy_code_end = '';
  231. $search_accountancy_aux_code = '';
  232. $search_accountancy_aux_code_start = '';
  233. $search_accountancy_aux_code_end = '';
  234. $search_mvt_label = '';
  235. $search_direction = '';
  236. $search_ledger_code = array();
  237. $search_date_startyear = '';
  238. $search_date_startmonth = '';
  239. $search_date_startday = '';
  240. $search_date_endyear = '';
  241. $search_date_endmonth = '';
  242. $search_date_endday = '';
  243. $search_date_start = '';
  244. $search_date_end = '';
  245. $search_date_creation_startyear = '';
  246. $search_date_creation_startmonth = '';
  247. $search_date_creation_startday = '';
  248. $search_date_creation_endyear = '';
  249. $search_date_creation_endmonth = '';
  250. $search_date_creation_endday = '';
  251. $search_date_creation_start = '';
  252. $search_date_creation_end = '';
  253. $search_date_modification_startyear = '';
  254. $search_date_modification_startmonth = '';
  255. $search_date_modification_startday = '';
  256. $search_date_modification_endyear = '';
  257. $search_date_modification_endmonth = '';
  258. $search_date_modification_endday = '';
  259. $search_date_modification_start = '';
  260. $search_date_modification_end = '';
  261. $search_date_export_startyear = '';
  262. $search_date_export_startmonth = '';
  263. $search_date_export_startday = '';
  264. $search_date_export_endyear = '';
  265. $search_date_export_endmonth = '';
  266. $search_date_export_endday = '';
  267. $search_date_export_start = '';
  268. $search_date_export_end = '';
  269. $search_date_validation_startyear = '';
  270. $search_date_validation_startmonth = '';
  271. $search_date_validation_startday = '';
  272. $search_date_validation_endyear = '';
  273. $search_date_validation_endmonth = '';
  274. $search_date_validation_endday = '';
  275. $search_date_validation_start = '';
  276. $search_date_validation_end = '';
  277. $search_debit = '';
  278. $search_credit = '';
  279. $search_lettering_code = '';
  280. $search_not_reconciled = '';
  281. $search_import_key = '';
  282. $toselect = array();
  283. }
  284. // Must be after the remove filter action, before the export.
  285. $filter = array();
  286. if (!empty($search_date_start)) {
  287. $filter['t.doc_date>='] = $search_date_start;
  288. $tmp = dol_getdate($search_date_start);
  289. $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']);
  290. }
  291. if (!empty($search_date_end)) {
  292. $filter['t.doc_date<='] = $search_date_end;
  293. $tmp = dol_getdate($search_date_end);
  294. $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']);
  295. }
  296. if (!empty($search_doc_date)) {
  297. $filter['t.doc_date'] = $search_doc_date;
  298. $tmp = dol_getdate($search_doc_date);
  299. $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']);
  300. }
  301. if (!empty($search_doc_type)) {
  302. $filter['t.doc_type'] = $search_doc_type;
  303. $param .= '&search_doc_type='.urlencode($search_doc_type);
  304. }
  305. if (!empty($search_doc_ref)) {
  306. $filter['t.doc_ref'] = $search_doc_ref;
  307. $param .= '&search_doc_ref='.urlencode($search_doc_ref);
  308. }
  309. if (!empty($search_accountancy_code)) {
  310. $filter['t.numero_compte'] = $search_accountancy_code;
  311. $param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
  312. }
  313. if (!empty($search_accountancy_code_start)) {
  314. $filter['t.numero_compte>='] = $search_accountancy_code_start;
  315. $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
  316. }
  317. if (!empty($search_accountancy_code_end)) {
  318. $filter['t.numero_compte<='] = $search_accountancy_code_end;
  319. $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
  320. }
  321. if (!empty($search_accountancy_aux_code_start)) {
  322. $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
  323. $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
  324. }
  325. if (!empty($search_accountancy_aux_code_end)) {
  326. $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
  327. $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
  328. }
  329. if (!empty($search_mvt_label)) {
  330. $filter['t.label_operation'] = $search_mvt_label;
  331. $param .= '&search_mvt_label='.urlencode($search_mvt_label);
  332. }
  333. if (!empty($search_direction)) {
  334. $filter['t.sens'] = $search_direction;
  335. $param .= '&search_direction='.urlencode($search_direction);
  336. }
  337. if (!empty($search_ledger_code)) {
  338. $filter['t.code_journal'] = $search_ledger_code;
  339. foreach ($search_ledger_code as $code) {
  340. $param .= '&search_ledger_code[]='.urlencode($code);
  341. }
  342. }
  343. if (!empty($search_mvt_num)) {
  344. $filter['t.piece_num'] = $search_mvt_num;
  345. $param .= '&search_mvt_num='.urlencode($search_mvt_num);
  346. }
  347. if (!empty($search_date_creation_start)) {
  348. $filter['t.date_creation>='] = $search_date_creation_start;
  349. $tmp = dol_getdate($search_date_creation_start);
  350. $param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']);
  351. }
  352. if (!empty($search_date_creation_end)) {
  353. $filter['t.date_creation<='] = $search_date_creation_end;
  354. $tmp = dol_getdate($search_date_creation_end);
  355. $param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']);
  356. }
  357. if (!empty($search_date_modification_start)) {
  358. $filter['t.tms>='] = $search_date_modification_start;
  359. $tmp = dol_getdate($search_date_modification_start);
  360. $param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']);
  361. }
  362. if (!empty($search_date_modification_end)) {
  363. $filter['t.tms<='] = $search_date_modification_end;
  364. $tmp = dol_getdate($search_date_modification_end);
  365. $param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']);
  366. }
  367. if (!empty($search_date_export_start)) {
  368. $filter['t.date_export>='] = $search_date_export_start;
  369. $tmp = dol_getdate($search_date_export_start);
  370. $param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']);
  371. }
  372. if (!empty($search_date_export_end)) {
  373. $filter['t.date_export<='] = $search_date_export_end;
  374. $tmp = dol_getdate($search_date_export_end);
  375. $param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']);
  376. }
  377. if (!empty($search_date_validation_start)) {
  378. $filter['t.date_validated>='] = $search_date_validation_start;
  379. $tmp = dol_getdate($search_date_validation_start);
  380. $param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']);
  381. }
  382. if (!empty($search_date_validation_end)) {
  383. $filter['t.date_validated<='] = $search_date_validation_end;
  384. $tmp = dol_getdate($search_date_validation_end);
  385. $param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']);
  386. }
  387. if (!empty($search_debit)) {
  388. $filter['t.debit'] = $search_debit;
  389. $param .= '&search_debit='.urlencode($search_debit);
  390. }
  391. if (!empty($search_credit)) {
  392. $filter['t.credit'] = $search_credit;
  393. $param .= '&search_credit='.urlencode($search_credit);
  394. }
  395. if (!empty($search_lettering_code)) {
  396. $filter['t.lettering_code'] = $search_lettering_code;
  397. $param .= '&search_lettering_code='.urlencode($search_lettering_code);
  398. }
  399. if (!empty($search_not_reconciled)) {
  400. $filter['t.reconciled_option'] = $search_not_reconciled;
  401. $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
  402. }
  403. if (!empty($search_import_key)) {
  404. $filter['t.import_key'] = $search_import_key;
  405. $param .= '&search_import_key='.urlencode($search_import_key);
  406. }
  407. //if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
  408. // $delmonth = GETPOST('delmonth', 'int');
  409. // $delyear = GETPOST('delyear', 'int');
  410. // if ($delyear == -1) {
  411. // $delyear = 0;
  412. // }
  413. // $deljournal = GETPOST('deljournal', 'alpha');
  414. // if ($deljournal == -1) {
  415. // $deljournal = 0;
  416. // }
  417. //
  418. // if (!empty($delmonth) || !empty($delyear) || !empty($deljournal)) {
  419. // $result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
  420. // if ($result < 0) {
  421. // setEventMessages($object->error, $object->errors, 'errors');
  422. // } else {
  423. // setEventMessages("RecordDeleted", null, 'mesgs');
  424. // }
  425. //
  426. // // Make a redirect to avoid to launch the delete later after a back button
  427. // header("Location: list.php".($param ? '?'.$param : ''));
  428. // exit;
  429. // } else {
  430. // setEventMessages("NoRecordDeleted", null, 'warnings');
  431. // }
  432. //}
  433. if ($action == 'setreexport') {
  434. $setreexport = GETPOST('value', 'int');
  435. if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
  436. $error++;
  437. }
  438. if (!$error) {
  439. if ($conf->global->ACCOUNTING_REEXPORT == 1) {
  440. setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs');
  441. } else {
  442. setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs');
  443. }
  444. } else {
  445. setEventMessages($langs->trans("Error"), null, 'errors');
  446. }
  447. }
  448. // Mass actions
  449. $objectclass = 'Bookkeeping';
  450. $objectlabel = 'Bookkeeping';
  451. $permissiontoread = $user->rights->societe->lire;
  452. $permissiontodelete = $user->rights->societe->supprimer;
  453. $permissiontoadd = $user->rights->societe->creer;
  454. $uploaddir = $conf->societe->dir_output;
  455. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  456. if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->rights->accounting->mouvements->supprimer) {
  457. $nbok = 0;
  458. foreach ($toselect as $toselectid) {
  459. $result = $object->fetch($toselectid);
  460. if ($result > 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
  461. $result = $object->deleteMvtNum($object->piece_num);
  462. if ($result > 0) {
  463. $nbok++;
  464. } else {
  465. setEventMessages($object->error, $object->errors, 'errors');
  466. $error++;
  467. break;
  468. }
  469. } elseif ($result < 0) {
  470. setEventMessages($object->error, $object->errors, 'errors');
  471. $error++;
  472. break;
  473. }
  474. }
  475. // Message for elements well deleted
  476. if ($nbok > 1) {
  477. setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
  478. } elseif ($nbok > 0) {
  479. setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
  480. } elseif (!$error) {
  481. setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
  482. }
  483. if (!$error) {
  484. header("Location: ".$_SERVER["PHP_SELF"]."?noreset=1".($param ? '&'.$param : ''));
  485. exit;
  486. }
  487. }
  488. // others mass actions
  489. if (!$error && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
  490. if ($massaction == 'lettering') {
  491. $lettering = new Lettering($db);
  492. $nb_lettering = $lettering->bookkeepingLetteringAll($toselect);
  493. if ($nb_lettering < 0) {
  494. setEventMessages('', $lettering->errors, 'errors');
  495. $error++;
  496. $nb_lettering = max(0, abs($nb_lettering) - 2);
  497. } elseif ($nb_lettering == 0) {
  498. $nb_lettering = 0;
  499. setEventMessages($langs->trans('AccountancyNoLetteringModified'), array(), 'mesgs');
  500. }
  501. if ($nb_lettering == 1) {
  502. setEventMessages($langs->trans('AccountancyOneLetteringModifiedSuccessfully'), array(), 'mesgs');
  503. } elseif ($nb_lettering > 1) {
  504. setEventMessages($langs->trans('AccountancyLetteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
  505. }
  506. if (!$error) {
  507. header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
  508. exit();
  509. }
  510. } elseif ($action == 'unlettering' && $confirm == "yes") {
  511. $lettering = new Lettering($db);
  512. $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
  513. if ($nb_lettering < 0) {
  514. setEventMessages('', $lettering->errors, 'errors');
  515. $error++;
  516. $nb_lettering = max(0, abs($nb_lettering) - 2);
  517. } elseif ($nb_lettering == 0) {
  518. $nb_lettering = 0;
  519. setEventMessages($langs->trans('AccountancyNoUnletteringModified'), array(), 'mesgs');
  520. }
  521. if ($nb_lettering == 1) {
  522. setEventMessages($langs->trans('AccountancyOneUnletteringModifiedSuccessfully'), array(), 'mesgs');
  523. } elseif ($nb_lettering > 1) {
  524. setEventMessages($langs->trans('AccountancyUnletteringModifiedSuccessfully', $nb_lettering), array(), 'mesgs');
  525. }
  526. if (!$error) {
  527. header('Location: ' . $_SERVER['PHP_SELF'] . '?noreset=1' . $param);
  528. exit();
  529. }
  530. }
  531. }
  532. }
  533. // Build and execute select (used by page and export action)
  534. // must de set after the action that set $filter
  535. // --------------------------------------------------------------------
  536. $sql = 'SELECT';
  537. $sql .= ' t.rowid,';
  538. $sql .= " t.doc_date,";
  539. $sql .= " t.doc_type,";
  540. $sql .= " t.doc_ref,";
  541. $sql .= " t.fk_doc,";
  542. $sql .= " t.fk_docdet,";
  543. $sql .= " t.thirdparty_code,";
  544. $sql .= " t.subledger_account,";
  545. $sql .= " t.subledger_label,";
  546. $sql .= " t.numero_compte,";
  547. $sql .= " t.label_compte,";
  548. $sql .= " t.label_operation,";
  549. $sql .= " t.debit,";
  550. $sql .= " t.credit,";
  551. $sql .= " t.lettering_code,";
  552. $sql .= " t.montant as amount,";
  553. $sql .= " t.sens,";
  554. $sql .= " t.fk_user_author,";
  555. $sql .= " t.import_key,";
  556. $sql .= " t.code_journal,";
  557. $sql .= " t.journal_label,";
  558. $sql .= " t.piece_num,";
  559. $sql .= " t.date_creation,";
  560. $sql .= " t.tms as date_modification,";
  561. $sql .= " t.date_export,";
  562. $sql .= " t.date_validated as date_validation,";
  563. $sql .= " t.import_key";
  564. $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t';
  565. // Manage filter
  566. $sqlwhere = array();
  567. if (count($filter) > 0) {
  568. foreach ($filter as $key => $value) {
  569. if ($key == 't.doc_date') {
  570. $sqlwhere[] = $key."='".$db->idate($value)."'";
  571. } elseif ($key == 't.doc_date>=' || $key == 't.doc_date<=') {
  572. $sqlwhere[] = $key."'".$db->idate($value)."'";
  573. } elseif ($key == 't.numero_compte>=' || $key == 't.numero_compte<=' || $key == 't.subledger_account>=' || $key == 't.subledger_account<=') {
  574. $sqlwhere[] = $key."'".$db->escape($value)."'";
  575. } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') {
  576. $sqlwhere[] = $key.'='.((int) $value);
  577. } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') {
  578. $sqlwhere[] = $key." LIKE '".$db->escape($value)."%'";
  579. } elseif ($key == 't.subledger_account') {
  580. $sqlwhere[] = natural_search($key, $value, 0, 1);
  581. } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') {
  582. $sqlwhere[] = $key."'".$db->idate($value)."'";
  583. } elseif ($key == 't.tms>=' || $key == 't.tms<=') {
  584. $sqlwhere[] = $key."'".$db->idate($value)."'";
  585. } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') {
  586. $sqlwhere[] = $key."'".$db->idate($value)."'";
  587. } elseif ($key == 't.date_validated>=' || $key == 't.date_validated<=') {
  588. $sqlwhere[] = $key."'".$db->idate($value)."'";
  589. } elseif ($key == 't.credit' || $key == 't.debit') {
  590. $sqlwhere[] = natural_search($key, $value, 1, 1);
  591. } elseif ($key == 't.reconciled_option') {
  592. $sqlwhere[] = 't.lettering_code IS NULL';
  593. } elseif ($key == 't.code_journal' && !empty($value)) {
  594. $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
  595. } else {
  596. $sqlwhere[] = natural_search($key, $value, 0, 1);
  597. }
  598. }
  599. }
  600. $sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
  601. if (empty($conf->global->ACCOUNTING_REEXPORT)) {
  602. $sql .= " AND t.date_export IS NULL";
  603. }
  604. if (count($sqlwhere) > 0) {
  605. $sql .= ' AND '.implode(' AND ', $sqlwhere);
  606. }
  607. if (!empty($sortfield)) {
  608. $sql .= $db->order($sortfield, $sortorder);
  609. }
  610. //print $sql;
  611. // Export into a file with format defined into setup (FEC, CSV, ...)
  612. // Must be after definition of $sql
  613. if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
  614. // TODO Replace the fetchAll to get all ->line followed by call to ->export(). It consumew too much memory on large export. Replace this with the query($sql) and loop on each line to export them.
  615. $result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
  616. if ($result < 0) {
  617. setEventMessages($object->error, $object->errors, 'errors');
  618. } else {
  619. // Export files
  620. $accountancyexport = new AccountancyExport($db);
  621. $accountancyexport->export($object->lines, $formatexportset);
  622. $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha');
  623. $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha');
  624. if (!empty($accountancyexport->errors)) {
  625. setEventMessages('', $accountancyexport->errors, 'errors');
  626. } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) {
  627. // Specify as export : update field date_export or date_validated
  628. $error = 0;
  629. $db->begin();
  630. if (is_array($object->lines)) {
  631. foreach ($object->lines as $movement) {
  632. $now = dol_now();
  633. $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
  634. $sql .= " SET";
  635. if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) {
  636. $sql .= " date_export = '".$db->idate($now)."'";
  637. $sql .= ", date_validated = '".$db->idate($now)."'";
  638. } elseif (!empty($notifiedexportdate)) {
  639. $sql .= " date_export = '".$db->idate($now)."'";
  640. } elseif (!empty($notifiedvalidationdate)) {
  641. $sql .= " date_validated = '".$db->idate($now)."'";
  642. }
  643. $sql .= " WHERE rowid = ".((int) $movement->id);
  644. dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG);
  645. $result = $db->query($sql);
  646. if (!$result) {
  647. $error++;
  648. break;
  649. }
  650. }
  651. }
  652. if (!$error) {
  653. $db->commit();
  654. // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExportedOrValidated"), null, 'mesgs');
  655. } else {
  656. $error++;
  657. $db->rollback();
  658. setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated"), null, 'errors');
  659. }
  660. }
  661. exit;
  662. }
  663. }
  664. /*
  665. * View
  666. */
  667. $formother = new FormOther($db);
  668. $formfile = new FormFile($db);
  669. $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
  670. // Count total nb of records
  671. $nbtotalofrecords = '';
  672. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  673. $resql = $db->query($sql);
  674. $nbtotalofrecords = $db->num_rows($resql);
  675. if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
  676. $page = 0;
  677. $offset = 0;
  678. }
  679. }
  680. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
  681. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
  682. $num = $nbtotalofrecords;
  683. } else {
  684. $sql .= $db->plimit($limit + 1, $offset);
  685. $resql = $db->query($sql);
  686. if (!$resql) {
  687. dol_print_error($db);
  688. exit;
  689. }
  690. $num = $db->num_rows($resql);
  691. }
  692. $arrayofselected = is_array($toselect) ? $toselect : array();
  693. // Output page
  694. // --------------------------------------------------------------------
  695. llxHeader('', $title_page);
  696. $formconfirm = '';
  697. if ($action == 'export_file') {
  698. $form_question = array();
  699. // If 1 or not set, we check by default.
  700. $checked = (!isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE));
  701. $form_question['notifiedexportdate'] = array(
  702. 'name' => 'notifiedexportdate',
  703. 'type' => 'checkbox',
  704. 'label' => $langs->trans('NotifiedExportDate'),
  705. 'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
  706. );
  707. $form_question['separator'] = array('name'=>'separator', 'type'=>'separator');
  708. // If 0 or not set, we NOT check by default.
  709. $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE));
  710. $form_question['notifiedvalidationdate'] = array(
  711. 'name' => 'notifiedvalidationdate',
  712. 'type' => 'checkbox',
  713. 'label' => $langs->trans('NotifiedValidationDate'),
  714. 'value' => $checked,
  715. );
  716. $form_question['separator2'] = array('name'=>'separator2', 'type'=>'separator');
  717. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600);
  718. }
  719. //if ($action == 'delbookkeepingyear') {
  720. // $form_question = array();
  721. // $delyear = GETPOST('delyear', 'int');
  722. // $deljournal = GETPOST('deljournal', 'alpha');
  723. //
  724. // if (empty($delyear)) {
  725. // $delyear = dol_print_date(dol_now(), '%Y');
  726. // }
  727. // $month_array = array();
  728. // for ($i = 1; $i <= 12; $i++) {
  729. // $month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
  730. // }
  731. // $year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
  732. // $journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
  733. //
  734. // $form_question['delmonth'] = array(
  735. // 'name' => 'delmonth',
  736. // 'type' => 'select',
  737. // 'label' => $langs->trans('DelMonth'),
  738. // 'values' => $month_array,
  739. // 'morecss' => 'minwidth150',
  740. // 'default' => ''
  741. // );
  742. // $form_question['delyear'] = array(
  743. // 'name' => 'delyear',
  744. // 'type' => 'select',
  745. // 'label' => $langs->trans('DelYear'),
  746. // 'values' => $year_array,
  747. // 'default' => $delyear
  748. // );
  749. // $form_question['deljournal'] = array(
  750. // 'name' => 'deljournal',
  751. // 'type' => 'other', // We don't use select here, the journal_array is already a select html component
  752. // 'label' => $langs->trans('DelJournal'),
  753. // 'value' => $journal_array,
  754. // 'default' => $deljournal
  755. // );
  756. //
  757. // $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 320);
  758. //}
  759. // Print form confirm
  760. print $formconfirm;
  761. //$param=''; param started before
  762. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  763. $param .= '&contextpage='.urlencode($contextpage);
  764. }
  765. if ($limit > 0 && $limit != $conf->liste_limit) {
  766. $param .= '&limit='.urlencode($limit);
  767. }
  768. // List of mass actions available
  769. $arrayofmassactions = array();
  770. /*
  771. if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && $user->rights->accounting->mouvements->creer) {
  772. $arrayofmassactions['lettering'] = img_picto('', 'check', 'class="pictofixedwidth"') . $langs->trans('Lettering');
  773. $arrayofmassactions['preunlettering'] = img_picto('', 'uncheck', 'class="pictofixedwidth"') . $langs->trans('Unlettering');
  774. }
  775. */
  776. if ($user->rights->accounting->mouvements->supprimer) {
  777. $arrayofmassactions['predeletebookkeepingwriting'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  778. }
  779. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('preunlettering', 'predeletebookkeepingwriting'))) {
  780. $arrayofmassactions = array();
  781. }
  782. $massactionbutton = $form->selectMassAction($massaction, $arrayofmassactions);
  783. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  784. print '<input type="hidden" name="token" value="'.newToken().'">';
  785. print '<input type="hidden" name="action" value="list">';
  786. if ($optioncss != '') {
  787. print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
  788. }
  789. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  790. print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">';
  791. print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">';
  792. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  793. if (count($filter)) {
  794. $buttonLabel = $langs->trans("ExportFilteredList");
  795. } else {
  796. $buttonLabel = $langs->trans("ExportList");
  797. }
  798. $parameters = array();
  799. $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  800. if (empty($reshook)) {
  801. // Button re-export
  802. if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
  803. $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
  804. } else {
  805. $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
  806. }
  807. $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
  808. if (!empty($user->rights->accounting->mouvements->export)) {
  809. $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
  810. }
  811. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
  812. $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
  813. $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?type=sub'.$param, '', 1, array('morecss' => 'marginleftonly'));
  814. $url = './card.php?action=create';
  815. if (!empty($socid)) {
  816. $url .= '&socid='.$socid;
  817. }
  818. $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
  819. }
  820. print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
  821. if ($massaction == 'preunlettering') {
  822. print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassUnlettering"), $langs->trans("ConfirmMassUnletteringQuestion", count($toselect)), "unlettering", null, '', 0, 200, 500, 1);
  823. } elseif ($massaction == 'predeletebookkeepingwriting') {
  824. print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeleteBookkeepingWriting"), $langs->trans("ConfirmMassDeleteBookkeepingWritingQuestion", count($toselect)), "deletebookkeepingwriting", null, '', 0, 200, 500, 1);
  825. }
  826. //$topicmail = "Information";
  827. //$modelmail = "accountingbookkeeping";
  828. //$objecttmp = new BookKeeping($db);
  829. //$trackid = 'bk'.$object->id;
  830. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  831. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  832. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  833. if ($massactionbutton && $contextpage != 'poslist') {
  834. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  835. }
  836. $parameters = array();
  837. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
  838. if (empty($reshook)) {
  839. $moreforfilter .= $hookmanager->resPrint;
  840. } else {
  841. $moreforfilter = $hookmanager->resPrint;
  842. }
  843. print '<div class="div-table-responsive">';
  844. print '<table class="tagtable liste centpercent">';
  845. // Filters lines
  846. print '<tr class="liste_titre_filter">';
  847. // Movement number
  848. if (!empty($arrayfields['t.piece_num']['checked'])) {
  849. print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
  850. }
  851. // Code journal
  852. if (!empty($arrayfields['t.code_journal']['checked'])) {
  853. print '<td class="liste_titre center">';
  854. print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth150');
  855. print '</td>';
  856. }
  857. // Date document
  858. if (!empty($arrayfields['t.doc_date']['checked'])) {
  859. print '<td class="liste_titre center">';
  860. print '<div class="nowrap">';
  861. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  862. print '</div>';
  863. print '<div class="nowrap">';
  864. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  865. print '</div>';
  866. print '</td>';
  867. }
  868. // Ref document
  869. if (!empty($arrayfields['t.doc_ref']['checked'])) {
  870. print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
  871. }
  872. // Accountancy account
  873. if (!empty($arrayfields['t.numero_compte']['checked'])) {
  874. print '<td class="liste_titre">';
  875. print '<div class="nowrap">';
  876. print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth150', 'account');
  877. print '</div>';
  878. print '<div class="nowrap">';
  879. print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth150', 'account');
  880. print '</div>';
  881. print '</td>';
  882. }
  883. // Subledger account
  884. if (!empty($arrayfields['t.subledger_account']['checked'])) {
  885. print '<td class="liste_titre">';
  886. // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
  887. // use setup of keypress to select thirdparty and this hang browser on large database.
  888. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
  889. print '<div class="nowrap">';
  890. //print $langs->trans('From').' ';
  891. print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', $langs->trans('From'), 'maxwidth250', 'subledgeraccount');
  892. print '</div>';
  893. print '<div class="nowrap">';
  894. print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
  895. print '</div>';
  896. } else {
  897. print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.$search_accountancy_aux_code.'">';
  898. }
  899. print '</td>';
  900. }
  901. // Label operation
  902. if (!empty($arrayfields['t.label_operation']['checked'])) {
  903. print '<td class="liste_titre">';
  904. print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
  905. print '</td>';
  906. }
  907. // Debit
  908. if (!empty($arrayfields['t.debit']['checked'])) {
  909. print '<td class="liste_titre right">';
  910. print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
  911. print '</td>';
  912. }
  913. // Credit
  914. if (!empty($arrayfields['t.credit']['checked'])) {
  915. print '<td class="liste_titre right">';
  916. print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
  917. print '</td>';
  918. }
  919. // Lettering code
  920. if (!empty($arrayfields['t.lettering_code']['checked'])) {
  921. print '<td class="liste_titre center">';
  922. print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
  923. print '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
  924. print '</td>';
  925. }
  926. // Fields from hook
  927. $parameters = array('arrayfields'=>$arrayfields);
  928. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  929. print $hookmanager->resPrint;
  930. // Date creation
  931. if (!empty($arrayfields['t.date_creation']['checked'])) {
  932. print '<td class="liste_titre center">';
  933. print '<div class="nowrap">';
  934. print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  935. print '</div>';
  936. print '<div class="nowrap">';
  937. print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  938. print '</div>';
  939. print '</td>';
  940. }
  941. // Date modification
  942. if (!empty($arrayfields['t.tms']['checked'])) {
  943. print '<td class="liste_titre center">';
  944. print '<div class="nowrap">';
  945. print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  946. print '</div>';
  947. print '<div class="nowrap">';
  948. print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  949. print '</div>';
  950. print '</td>';
  951. }
  952. // Date export
  953. if (!empty($arrayfields['t.date_export']['checked'])) {
  954. print '<td class="liste_titre center">';
  955. print '<div class="nowrap">';
  956. print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  957. print '</div>';
  958. print '<div class="nowrap">';
  959. print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  960. print '</div>';
  961. print '</td>';
  962. }
  963. // Date validation
  964. if (!empty($arrayfields['t.date_validated']['checked'])) {
  965. print '<td class="liste_titre center">';
  966. print '<div class="nowrap">';
  967. print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
  968. print '</div>';
  969. print '<div class="nowrap">';
  970. print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
  971. print '</div>';
  972. print '</td>';
  973. }
  974. if (!empty($arrayfields['t.import_key']['checked'])) {
  975. print '<td class="liste_titre center">';
  976. print '<input class="flat searchstring maxwidth50" type="text" name="search_import_key" value="'.dol_escape_htmltag($search_import_key).'">';
  977. print '</td>';
  978. }
  979. // Action column
  980. print '<td class="liste_titre center">';
  981. $searchpicto = $form->showFilterButtons();
  982. print $searchpicto;
  983. print '</td>';
  984. print "</tr>\n";
  985. print '<tr class="liste_titre">';
  986. if (!empty($arrayfields['t.piece_num']['checked'])) {
  987. print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder);
  988. }
  989. if (!empty($arrayfields['t.code_journal']['checked'])) {
  990. print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
  991. }
  992. if (!empty($arrayfields['t.doc_date']['checked'])) {
  993. print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
  994. }
  995. if (!empty($arrayfields['t.doc_ref']['checked'])) {
  996. print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
  997. }
  998. if (!empty($arrayfields['t.numero_compte']['checked'])) {
  999. print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
  1000. }
  1001. if (!empty($arrayfields['t.subledger_account']['checked'])) {
  1002. print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $param, "", $sortfield, $sortorder);
  1003. }
  1004. if (!empty($arrayfields['t.label_operation']['checked'])) {
  1005. print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
  1006. }
  1007. if (!empty($arrayfields['t.debit']['checked'])) {
  1008. print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
  1009. }
  1010. if (!empty($arrayfields['t.credit']['checked'])) {
  1011. print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
  1012. }
  1013. if (!empty($arrayfields['t.lettering_code']['checked'])) {
  1014. print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
  1015. }
  1016. // Hook fields
  1017. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  1018. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  1019. print $hookmanager->resPrint;
  1020. if (!empty($arrayfields['t.date_creation']['checked'])) {
  1021. print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
  1022. }
  1023. if (!empty($arrayfields['t.tms']['checked'])) {
  1024. print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
  1025. }
  1026. if (!empty($arrayfields['t.date_export']['checked'])) {
  1027. print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
  1028. }
  1029. if (!empty($arrayfields['t.date_validated']['checked'])) {
  1030. print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
  1031. }
  1032. if (!empty($arrayfields['t.import_key']['checked'])) {
  1033. print_liste_field_titre($arrayfields['t.import_key']['label'], $_SERVER["PHP_SELF"], "t.import_key", "", $param, '', $sortfield, $sortorder, 'center ');
  1034. }
  1035. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  1036. print "</tr>\n";
  1037. $line = new BookKeepingLine();
  1038. // Loop on record
  1039. // --------------------------------------------------------------------
  1040. $i = 0;
  1041. $totalarray = array();
  1042. while ($i < min($num, $limit)) {
  1043. $obj = $db->fetch_object($resql);
  1044. if (empty($obj)) {
  1045. break; // Should not happen
  1046. }
  1047. $line->id = $obj->rowid;
  1048. $line->doc_date = $db->jdate($obj->doc_date);
  1049. $line->doc_type = $obj->doc_type;
  1050. $line->doc_ref = $obj->doc_ref;
  1051. $line->fk_doc = $obj->fk_doc;
  1052. $line->fk_docdet = $obj->fk_docdet;
  1053. $line->thirdparty_code = $obj->thirdparty_code;
  1054. $line->subledger_account = $obj->subledger_account;
  1055. $line->subledger_label = $obj->subledger_label;
  1056. $line->numero_compte = $obj->numero_compte;
  1057. $line->label_compte = $obj->label_compte;
  1058. $line->label_operation = $obj->label_operation;
  1059. $line->debit = $obj->debit;
  1060. $line->credit = $obj->credit;
  1061. $line->montant = $obj->amount; // deprecated
  1062. $line->amount = $obj->amount;
  1063. $line->sens = $obj->sens;
  1064. $line->lettering_code = $obj->lettering_code;
  1065. $line->fk_user_author = $obj->fk_user_author;
  1066. $line->import_key = $obj->import_key;
  1067. $line->code_journal = $obj->code_journal;
  1068. $line->journal_label = $obj->journal_label;
  1069. $line->piece_num = $obj->piece_num;
  1070. $line->date_creation = $db->jdate($obj->date_creation);
  1071. $line->date_modification = $db->jdate($obj->date_modification);
  1072. $line->date_export = $db->jdate($obj->date_export);
  1073. $line->date_validation = $db->jdate($obj->date_validation);
  1074. $total_debit += $line->debit;
  1075. $total_credit += $line->credit;
  1076. print '<tr class="oddeven">';
  1077. // Piece number
  1078. if (!empty($arrayfields['t.piece_num']['checked'])) {
  1079. print '<td>';
  1080. $object->id = $line->id;
  1081. $object->piece_num = $line->piece_num;
  1082. print $object->getNomUrl(1, '', 0, '', 1);
  1083. print '</td>';
  1084. if (!$i) {
  1085. $totalarray['nbfield']++;
  1086. }
  1087. }
  1088. // Journal code
  1089. if (!empty($arrayfields['t.code_journal']['checked'])) {
  1090. $accountingjournal = new AccountingJournal($db);
  1091. $result = $accountingjournal->fetch('', $line->code_journal);
  1092. $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
  1093. print '<td class="center">'.$journaltoshow.'</td>';
  1094. if (!$i) {
  1095. $totalarray['nbfield']++;
  1096. }
  1097. }
  1098. // Document date
  1099. if (!empty($arrayfields['t.doc_date']['checked'])) {
  1100. print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
  1101. if (!$i) {
  1102. $totalarray['nbfield']++;
  1103. }
  1104. }
  1105. // Document ref
  1106. if (!empty($arrayfields['t.doc_ref']['checked'])) {
  1107. if ($line->doc_type == 'customer_invoice') {
  1108. $langs->loadLangs(array('bills'));
  1109. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  1110. $objectstatic = new Facture($db);
  1111. $objectstatic->fetch($line->fk_doc);
  1112. //$modulepart = 'facture';
  1113. $filename = dol_sanitizeFileName($line->doc_ref);
  1114. $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
  1115. $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
  1116. $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  1117. } elseif ($line->doc_type == 'supplier_invoice') {
  1118. $langs->loadLangs(array('bills'));
  1119. require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  1120. $objectstatic = new FactureFournisseur($db);
  1121. $objectstatic->fetch($line->fk_doc);
  1122. //$modulepart = 'invoice_supplier';
  1123. $filename = dol_sanitizeFileName($line->doc_ref);
  1124. $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
  1125. $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
  1126. $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
  1127. } elseif ($line->doc_type == 'expense_report') {
  1128. $langs->loadLangs(array('trips'));
  1129. require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  1130. $objectstatic = new ExpenseReport($db);
  1131. $objectstatic->fetch($line->fk_doc);
  1132. //$modulepart = 'expensereport';
  1133. $filename = dol_sanitizeFileName($line->doc_ref);
  1134. $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
  1135. $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
  1136. $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
  1137. } elseif ($line->doc_type == 'bank') {
  1138. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  1139. $objectstatic = new AccountLine($db);
  1140. $objectstatic->fetch($line->fk_doc);
  1141. } else {
  1142. // Other type
  1143. }
  1144. $labeltoshow = '';
  1145. $labeltoshowalt = '';
  1146. if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
  1147. $labeltoshow .= $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
  1148. $labeltoshow .= $documentlink;
  1149. $labeltoshowalt .= $objectstatic->ref;
  1150. } elseif ($line->doc_type == 'bank') {
  1151. $labeltoshow .= $objectstatic->getNomUrl(1);
  1152. $labeltoshowalt .= $objectstatic->ref;
  1153. $bank_ref = strstr($line->doc_ref, '-');
  1154. $labeltoshow .= " " . $bank_ref;
  1155. $labeltoshowalt .= " " . $bank_ref;
  1156. } else {
  1157. $labeltoshow .= $line->doc_ref;
  1158. $labeltoshowalt .= $line->doc_ref;
  1159. }
  1160. print '<td class="nowraponall tdoverflowmax200" title="'.dol_escape_htmltag($labeltoshowalt).'">';
  1161. print $labeltoshow;
  1162. print "</td>\n";
  1163. if (!$i) {
  1164. $totalarray['nbfield']++;
  1165. }
  1166. }
  1167. // Account number
  1168. if (!empty($arrayfields['t.numero_compte']['checked'])) {
  1169. print '<td>'.length_accountg($line->numero_compte).'</td>';
  1170. if (!$i) {
  1171. $totalarray['nbfield']++;
  1172. }
  1173. }
  1174. // Subledger account
  1175. if (!empty($arrayfields['t.subledger_account']['checked'])) {
  1176. print '<td>'.length_accounta($line->subledger_account).'</td>';
  1177. if (!$i) {
  1178. $totalarray['nbfield']++;
  1179. }
  1180. }
  1181. // Label operation
  1182. if (!empty($arrayfields['t.label_operation']['checked'])) {
  1183. print '<td class="small tdoverflowmax200" title="'.dol_escape_htmltag($line->label_operation).'">'.dol_escape_htmltag($line->label_operation).'</td>';
  1184. if (!$i) {
  1185. $totalarray['nbfield']++;
  1186. }
  1187. }
  1188. // Amount debit
  1189. if (!empty($arrayfields['t.debit']['checked'])) {
  1190. print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
  1191. if (!$i) {
  1192. $totalarray['nbfield']++;
  1193. }
  1194. if (!$i) {
  1195. $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
  1196. }
  1197. $totalarray['val']['totaldebit'] += $line->debit;
  1198. }
  1199. // Amount credit
  1200. if (!empty($arrayfields['t.credit']['checked'])) {
  1201. print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
  1202. if (!$i) {
  1203. $totalarray['nbfield']++;
  1204. }
  1205. if (!$i) {
  1206. $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
  1207. }
  1208. $totalarray['val']['totalcredit'] += $line->credit;
  1209. }
  1210. // Lettering code
  1211. if (!empty($arrayfields['t.lettering_code']['checked'])) {
  1212. print '<td class="center">'.$line->lettering_code.'</td>';
  1213. if (!$i) {
  1214. $totalarray['nbfield']++;
  1215. }
  1216. }
  1217. // Fields from hook
  1218. $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
  1219. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
  1220. print $hookmanager->resPrint;
  1221. // Creation operation date
  1222. if (!empty($arrayfields['t.date_creation']['checked'])) {
  1223. print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>';
  1224. if (!$i) {
  1225. $totalarray['nbfield']++;
  1226. }
  1227. }
  1228. // Modification operation date
  1229. if (!empty($arrayfields['t.tms']['checked'])) {
  1230. print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>';
  1231. if (!$i) {
  1232. $totalarray['nbfield']++;
  1233. }
  1234. }
  1235. // Exported operation date
  1236. if (!empty($arrayfields['t.date_export']['checked'])) {
  1237. print '<td class="center nowraponall">'.dol_print_date($line->date_export, 'dayhour').'</td>';
  1238. if (!$i) {
  1239. $totalarray['nbfield']++;
  1240. }
  1241. }
  1242. // Validated operation date
  1243. if (!empty($arrayfields['t.date_validated']['checked'])) {
  1244. print '<td class="center nowraponall">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
  1245. if (!$i) {
  1246. $totalarray['nbfield']++;
  1247. }
  1248. }
  1249. if (!empty($arrayfields['t.import_key']['checked'])) {
  1250. print '<td class="tdoverflowmax100">'.$obj->import_key."</td>\n";
  1251. if (!$i) {
  1252. $totalarray['nbfield']++;
  1253. }
  1254. }
  1255. // Action column
  1256. print '<td class="nowraponall center">';
  1257. if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  1258. $selected = 0;
  1259. if (in_array($line->id, $arrayofselected)) {
  1260. $selected = 1;
  1261. }
  1262. print '<input id="cb'.$line->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$line->id.'"'.($selected ? ' checked="checked"' : '').' />';
  1263. }
  1264. print '</td>';
  1265. if (!$i) {
  1266. $totalarray['nbfield']++;
  1267. }
  1268. print "</tr>\n";
  1269. $i++;
  1270. }
  1271. // Show total line
  1272. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  1273. print "</table>";
  1274. print '</div>';
  1275. // TODO Replace this with mass delete action
  1276. //if ($user->rights->accounting->mouvements->supprimer_tous) {
  1277. // print '<div class="tabsAction tabsActionNoBottom">'."\n";
  1278. // print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear&token='.newToken().($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
  1279. // print '</div>';
  1280. //}
  1281. print '</form>';
  1282. // End of page
  1283. llxFooter();
  1284. $db->close();