list.php 58 KB

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