list.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <?php
  2. /* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2016 Frédéric France <frederic.france@free.fr>
  6. * Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
  7. * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
  8. * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
  9. * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/compta/sociales/list.php
  26. * \ingroup tax
  27. * \brief Page to list all social contributions
  28. */
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  35. if (!empty($conf->projet->enabled)) {
  36. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  37. }
  38. // Load translation files required by the page
  39. $langs->loadLangs(array('compta', 'banks', 'bills', 'hrm', 'projects'));
  40. $action = GETPOST('action', 'aZ09');
  41. $massaction = GETPOST('massaction', 'alpha');
  42. $confirm = GETPOST('confirm', 'alpha');
  43. $optioncss = GETPOST('optioncss', 'alpha');
  44. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
  45. $search_ref = GETPOST('search_ref', 'int');
  46. $search_label = GETPOST('search_label', 'alpha');
  47. $search_amount = GETPOST('search_amount', 'alpha');
  48. $search_status = GETPOST('search_status', 'int');
  49. $search_date_startday = GETPOST('search_date_startday', 'int');
  50. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  51. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  52. $search_date_endday = GETPOST('search_date_endday', 'int');
  53. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  54. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  55. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  56. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  57. $search_date_limit_startday = GETPOST('search_date_limit_startday', 'int');
  58. $search_date_limit_startmonth = GETPOST('search_date_limit_startmonth', 'int');
  59. $search_date_limit_startyear = GETPOST('search_date_limit_startyear', 'int');
  60. $search_date_limit_endday = GETPOST('search_date_limit_endday', 'int');
  61. $search_date_limit_endmonth = GETPOST('search_date_limit_endmonth', 'int');
  62. $search_date_limit_endyear = GETPOST('search_date_limit_endyear', 'int');
  63. $search_date_limit_start = dol_mktime(0, 0, 0, $search_date_limit_startmonth, $search_date_limit_startday, $search_date_limit_startyear);
  64. $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $search_date_limit_endday, $search_date_limit_endyear);
  65. $search_project_ref = GETPOST('search_project_ref', 'alpha');
  66. $search_users = GETPOST('search_users');
  67. $search_type = GETPOST('search_type', 'int');
  68. $search_account = GETPOST('search_account', 'int');
  69. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  70. $sortfield = GETPOST('sortfield', 'aZ09comma');
  71. $sortorder = GETPOST("sortorder", 'aZ09comma');
  72. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  73. if (empty($page) || $page == -1) {
  74. $page = 0; // If $page is not defined, or '' or -1
  75. }
  76. $offset = $limit * $page;
  77. $pageprev = $page - 1;
  78. $pagenext = $page + 1;
  79. if (!$sortfield) {
  80. $sortfield = "cs.date_ech";
  81. }
  82. if (!$sortorder) {
  83. $sortorder = "DESC";
  84. }
  85. $filtre = GETPOST("filtre", 'int');
  86. if (!GETPOSTISSET('search_typeid')) {
  87. $newfiltre = str_replace('filtre=', '', $filtre);
  88. $filterarray = explode('-', $newfiltre);
  89. foreach ($filterarray as $val) {
  90. $part = explode(':', $val);
  91. if ($part[0] == 'cs.fk_type') {
  92. $search_typeid = $part[1];
  93. }
  94. }
  95. } else {
  96. $search_typeid = GETPOST('search_typeid', 'int');
  97. }
  98. $arrayfields = array(
  99. 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
  100. 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20),
  101. 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
  102. 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40),
  103. 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50),
  104. 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->projet->enabled))),
  105. 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70),
  106. 'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"),
  107. 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100),
  108. 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110),
  109. );
  110. if (!empty($conf->banque->enabled)) {
  111. $arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount");
  112. }
  113. $arrayfields = dol_sort_array($arrayfields, 'position');
  114. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  115. $hookmanager->initHooks(array('sclist'));
  116. $object = new ChargeSociales($db);
  117. // Security check
  118. $socid = GETPOST("socid", 'int');
  119. if ($user->socid) {
  120. $socid = $user->socid;
  121. }
  122. $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
  123. /*
  124. * Actions
  125. */
  126. $parameters = array('socid'=>$socid);
  127. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  128. if ($reshook < 0) {
  129. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  130. }
  131. if (empty($reshook)) {
  132. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  133. // All tests are required to be compatible with all browsers
  134. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  135. $search_ref = '';
  136. $search_label = '';
  137. $search_amount = '';
  138. $search_status = '';
  139. $search_typeid = '';
  140. $search_date_startday = '';
  141. $search_date_startmonth = '';
  142. $search_date_startyear = '';
  143. $search_date_endday = '';
  144. $search_date_endmonth = '';
  145. $search_date_endyear = '';
  146. $search_date_start = '';
  147. $search_date_end = '';
  148. $search_date_limit_startday = '';
  149. $search_date_limit_startmonth = '';
  150. $search_date_limit_startyear = '';
  151. $search_date_limit_endday = '';
  152. $search_date_limit_endmonth = '';
  153. $search_date_limit_endyear = '';
  154. $search_date_limit_start = '';
  155. $search_date_limit_end = '';
  156. $search_project_ref = '';
  157. $search_users = '';
  158. $search_type = '';
  159. $search_account = '';
  160. $search_array_options = array();
  161. }
  162. }
  163. /*
  164. * View
  165. */
  166. $form = new Form($db);
  167. $formother = new FormOther($db);
  168. $bankstatic = new Account($db);
  169. $formsocialcontrib = new FormSocialContrib($db);
  170. $chargesociale_static = new ChargeSociales($db);
  171. if (!empty($conf->projet->enabled)) {
  172. $projectstatic = new Project($db);
  173. }
  174. llxHeader('', $langs->trans("SocialContributions"));
  175. $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
  176. $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
  177. if (!empty($conf->projet->enabled)) {
  178. $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
  179. }
  180. $sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,";
  181. $sql .= " ba.label as blabel, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos,";
  182. $sql .= " SUM(pc.amount) as alreadypayed, pay.code as payment_code";
  183. $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
  184. $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
  185. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)";
  186. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)';
  187. if (!empty($conf->projet->enabled)) {
  188. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
  189. }
  190. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
  191. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)";
  192. $sql .= " WHERE cs.fk_type = c.id";
  193. $sql .= " AND cs.entity = ".((int) $conf->entity);
  194. // Search criteria
  195. if ($search_ref) {
  196. $sql .= " AND cs.ref = '".$db->escape($search_ref)."'";
  197. }
  198. if ($search_label) {
  199. $sql .= natural_search("cs.libelle", $search_label);
  200. }
  201. if (!empty($conf->projet->enabled)) {
  202. if ($search_project_ref != '') {
  203. $sql .= natural_search("p.ref", $search_project_ref);
  204. }
  205. }
  206. if (!empty($search_users)) {
  207. $sql .= ' AND cs.fk_user IN ('.$db->sanitize(implode(', ', $search_users)).')';
  208. }
  209. if (!empty($search_type) && $search_type > 0) {
  210. $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type);
  211. }
  212. if (!empty($search_account) && $search_account > 0) {
  213. $sql .= ' AND cs.fk_account='.((int) $search_account);
  214. }
  215. if ($search_amount) {
  216. $sql .= natural_search("cs.amount", $search_amount, 1);
  217. }
  218. if ($search_status != '' && $search_status >= 0) {
  219. $sql .= " AND cs.paye = ".((int) $search_status);
  220. }
  221. if ($search_date_start) {
  222. $sql .= " AND cs.date_ech >= '".$db->idate($search_date_start)."'";
  223. }
  224. if ($search_date_end) {
  225. $sql .= " AND cs.date_ech <= '".$db->idate($search_date_end)."'";
  226. }
  227. if ($search_date_limit_start) {
  228. $sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
  229. }
  230. if ($search_date_limit_end) {
  231. $sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
  232. }
  233. if ($search_typeid > 0) {
  234. $sql .= " AND cs.fk_type = ".((int) $search_typeid);
  235. }
  236. $sql .= " GROUP BY cs.rowid, cs.fk_type, cs.fk_user, cs.amount, cs.date_ech, cs.libelle, cs.paye, cs.periode, cs.fk_account, c.libelle, c.accountancy_code, ba.label, ba.ref, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.clos, pay.code, u.lastname";
  237. if (!empty($conf->projet->enabled)) {
  238. $sql .= ", p.rowid, p.ref, p.title";
  239. }
  240. $sql .= $db->order($sortfield, $sortorder);
  241. $totalnboflines = 0;
  242. $result = $db->query($sql);
  243. if ($result) {
  244. $totalnboflines = $db->num_rows($result);
  245. }
  246. $sql .= $db->plimit($limit + 1, $offset);
  247. $resql = $db->query($sql);
  248. if (!$resql) {
  249. dol_print_error($db);
  250. llxFooter();
  251. $db->close();
  252. exit;
  253. }
  254. $num = $db->num_rows($resql);
  255. $i = 0;
  256. $param = '';
  257. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  258. $param .= '&contextpage='.urlencode($contextpage);
  259. }
  260. if ($limit > 0 && $limit != $conf->liste_limit) {
  261. $param .= '&limit='.urlencode($limit);
  262. }
  263. if ($search_ref) {
  264. $param .= '&search_ref='.urlencode($search_ref);
  265. }
  266. if ($search_label) {
  267. $param .= '&search_label='.urlencode($search_label);
  268. }
  269. if ($search_project_ref >= 0) {
  270. $param .= "&search_project_ref=".urlencode($search_project_ref);
  271. }
  272. if ($search_amount) {
  273. $param .= '&search_amount='.urlencode($search_amount);
  274. }
  275. if ($search_typeid) {
  276. $param .= '&search_typeid='.urlencode($search_typeid);
  277. }
  278. if ($search_users) {
  279. foreach ($search_users as $id_user) {
  280. $param .= '&search_users[]='.urlencode($id_user);
  281. }
  282. }
  283. if ($search_type) {
  284. $param .= '&search_type='.urlencode($search_type);
  285. }
  286. if ($search_account) {
  287. $param .= '&search_account='.$search_account;
  288. }
  289. if ($search_status != '' && $search_status != '-1') {
  290. $param .= '&search_status='.urlencode($search_status);
  291. }
  292. if ($search_date_startday) {
  293. $param .= '&search_date_startday='.urlencode($search_date_startday);
  294. }
  295. if ($search_date_startmonth) {
  296. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  297. }
  298. if ($search_date_startyear) {
  299. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  300. }
  301. if ($search_date_endday) {
  302. $param .= '&search_date_endday='.urlencode($search_date_endday);
  303. }
  304. if ($search_date_endmonth) {
  305. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  306. }
  307. if ($search_date_endyear) {
  308. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  309. }
  310. if ($search_date_limit_startday) {
  311. $param .= '&search_date_limit_startday='.urlencode($search_date_limit_startday);
  312. }
  313. if ($search_date_limit_startmonth) {
  314. $param .= '&search_date_limit_startmonth='.urlencode($search_date_limit_startmonth);
  315. }
  316. if ($search_date_limit_startyear) {
  317. $param .= '&search_date_limit_startyear='.urlencode($search_date_limit_startyear);
  318. }
  319. if ($search_date_limit_endday) {
  320. $param .= '&search_date_limit_endday='.urlencode($search_date_limit_endday);
  321. }
  322. if ($search_date_limit_endmonth) {
  323. $param .= '&search_date_limit_endmonth='.urlencode($search_date_limit_endmonth);
  324. }
  325. if ($search_date_limit_endyear) {
  326. $param .= '&search_date_limit_endyear='.urlencode($search_date_limit_endyear);
  327. }
  328. $newcardbutton = '';
  329. if ($user->rights->tax->charges->creer) {
  330. $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create');
  331. }
  332. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  333. if ($optioncss != '') {
  334. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  335. }
  336. print '<input type="hidden" name="token" value="'.newToken().'">';
  337. print '<input type="hidden" name="action" value="list">';
  338. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  339. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  340. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  341. print '<input type="hidden" name="search_status" value="'.$search_status.'">';
  342. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  343. $center = '';
  344. print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
  345. if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
  346. print '<div class="error">';
  347. $langs->load("errors");
  348. $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
  349. print $countrynotdefined;
  350. print '</div>';
  351. print '</form>';
  352. llxFooter();
  353. $db->close();
  354. }
  355. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  356. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  357. if ($massactionbutton) {
  358. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  359. }
  360. print '<div class="div-table-responsive">';
  361. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
  362. print '<tr class="liste_titre_filter">';
  363. // Filters: Line number (placeholder)
  364. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  365. print '<td class="liste_titre">';
  366. print '</td>';
  367. }
  368. // Filter: Ref
  369. if (!empty($arrayfields['cs.rowid']['checked'])) {
  370. print '<td class="liste_titre">';
  371. print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  372. print '</td>';
  373. }
  374. // Filter: Label
  375. if (!empty($arrayfields['cs.rowid']['checked'])) {
  376. print '<td class="liste_titre">';
  377. print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  378. print '</td>';
  379. }
  380. // Filter: Type
  381. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  382. print '<td class="liste_titre">';
  383. $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1);
  384. print '</td>';
  385. }
  386. // Filter: Date (placeholder)
  387. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  388. print '<td class="liste_titre center">';
  389. print '<div class="nowrap">';
  390. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  391. print '</div>';
  392. print '<div class="nowrap">';
  393. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  394. print '</div>';
  395. print '</td>';
  396. }
  397. // Filter: Period end date
  398. if (!empty($arrayfields['cs.periode']['checked'])) {
  399. print '<td class="liste_titre center">';
  400. print '<div class="nowrap">';
  401. print $form->selectDate($search_date_limit_start ? $search_date_limit_start : -1, 'search_date_limit_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  402. print '</div>';
  403. print '<div class="nowrap">';
  404. print $form->selectDate($search_date_limit_end ? $search_date_limit_end : -1, 'search_date_limit_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  405. print '</div>';
  406. print '</td>';
  407. }
  408. // Filter: Project ref
  409. if (!empty($arrayfields['p.ref']['checked'])) {
  410. print '<td class="liste_titre">';
  411. print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'">';
  412. print '</td>';
  413. }
  414. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  415. // Employee
  416. print '<td class="liste_titre">';
  417. print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true);
  418. }
  419. // Filter: Type
  420. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  421. print '<td class="liste_titre">';
  422. $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150');
  423. print '</td>';
  424. }
  425. // Filter: Bank Account
  426. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  427. print '<td class="liste_titre">';
  428. $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
  429. print '</td>';
  430. }
  431. // Filter: Amount
  432. if (!empty($arrayfields['cs.amount']['checked'])) {
  433. print '<td class="liste_titre right">';
  434. print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
  435. print '</td>';
  436. }
  437. // Filter: Status
  438. if (!empty($arrayfields['cs.paye']['checked'])) {
  439. print '<td class="liste_titre maxwidthonsmartphone right">';
  440. $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid"));
  441. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
  442. print '</td>';
  443. }
  444. // Fields from hook
  445. $parameters = array('arrayfields'=>$arrayfields);
  446. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  447. print $hookmanager->resPrint;
  448. // Filter: Buttons
  449. print '<td class="liste_titre maxwidthsearch">';
  450. print $form->showFilterAndCheckAddButtons(0);
  451. print '</td>';
  452. print '</tr>';
  453. print '<tr class="liste_titre">';
  454. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  455. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  456. }
  457. if (!empty($arrayfields['cs.rowid']['checked'])) {
  458. print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder);
  459. }
  460. if (!empty($arrayfields['cs.libelle']['checked'])) {
  461. print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
  462. }
  463. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  464. print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder);
  465. }
  466. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  467. print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
  468. }
  469. if (!empty($arrayfields['cs.periode']['checked'])) {
  470. print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
  471. }
  472. if (!empty($arrayfields['p.ref']['checked'])) {
  473. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
  474. }
  475. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  476. print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
  477. }
  478. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  479. print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder);
  480. }
  481. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  482. print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder);
  483. }
  484. if (!empty($arrayfields['cs.amount']['checked'])) {
  485. print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
  486. }
  487. if (!empty($arrayfields['cs.paye']['checked'])) {
  488. print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
  489. }
  490. // Hook fields
  491. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  492. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  493. print $hookmanager->resPrint;
  494. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
  495. print '</tr>';
  496. $i = 0;
  497. $totalarray = $TLoadedUsers = array();
  498. while ($i < min($num, $limit)) {
  499. $obj = $db->fetch_object($resql);
  500. $chargesociale_static->id = $obj->rowid;
  501. $chargesociale_static->ref = $obj->rowid;
  502. $chargesociale_static->label = $obj->label;
  503. $chargesociale_static->type_label = $obj->type_label;
  504. if (!empty($conf->projet->enabled)) {
  505. $projectstatic->id = $obj->project_id;
  506. $projectstatic->ref = $obj->project_ref;
  507. $projectstatic->title = $obj->project_label;
  508. }
  509. print '<tr class="oddeven">';
  510. // Line number
  511. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  512. print '<td>'.(($offset * $limit) + $i).'</td>';
  513. if (!$i) {
  514. $totalarray['nbfield']++;
  515. }
  516. }
  517. // Ref
  518. if (!empty($arrayfields['cs.rowid']['checked'])) {
  519. print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
  520. if (!$i) {
  521. $totalarray['nbfield']++;
  522. }
  523. }
  524. // Label
  525. if (!empty($arrayfields['cs.libelle']['checked'])) {
  526. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
  527. if (!$i) {
  528. $totalarray['nbfield']++;
  529. }
  530. }
  531. // Type
  532. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  533. $typelabeltoshow = $obj->type_label;
  534. $typelabelpopup = $obj->type_label;
  535. if (!empty($conf->accounting->enabled)) {
  536. $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
  537. }
  538. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
  539. if (!$i) {
  540. $totalarray['nbfield']++;
  541. }
  542. }
  543. // Date
  544. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  545. print '<td class="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
  546. if (!$i) {
  547. $totalarray['nbfield']++;
  548. }
  549. }
  550. // Date end period
  551. if (!empty($arrayfields['cs.periode']['checked'])) {
  552. print '<td class="center">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
  553. if (!$i) {
  554. $totalarray['nbfield']++;
  555. }
  556. }
  557. // Project ref
  558. if (!empty($arrayfields['p.ref']['checked'])) {
  559. print '<td class="nowrap">';
  560. if ($obj->project_id > 0) {
  561. print $projectstatic->getNomUrl(1);
  562. }
  563. print '</td>';
  564. if (!$i) {
  565. $totalarray['nbfield']++;
  566. }
  567. }
  568. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  569. // Employee
  570. print "<td>";
  571. if (!empty($obj->fk_user)) {
  572. if (!empty($TLoadedUsers[$obj->fk_user])) {
  573. $ustatic = $TLoadedUsers[$obj->fk_user];
  574. } else {
  575. $ustatic = new User($db);
  576. $ustatic->fetch($obj->fk_user);
  577. $TLoadedUsers[$obj->fk_user] = $ustatic;
  578. }
  579. print $ustatic->getNomUrl(-1);
  580. }
  581. print "</td>\n";
  582. if (!$i) {
  583. $totalarray['nbfield']++;
  584. }
  585. }
  586. // Type
  587. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  588. print '<td>';
  589. if (!empty($obj->payment_code)) {
  590. print $langs->trans("PaymentTypeShort".$obj->payment_code);
  591. }
  592. print '</td>';
  593. if (!$i) {
  594. $totalarray['nbfield']++;
  595. }
  596. }
  597. // Account
  598. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  599. print '<td>';
  600. if ($obj->fk_account > 0) {
  601. $bankstatic->id = $obj->fk_account;
  602. $bankstatic->ref = $obj->bref;
  603. $bankstatic->number = $obj->bnumber;
  604. $bankstatic->iban = $obj->iban;
  605. $bankstatic->bic = $obj->bic;
  606. $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
  607. $bankstatic->account_number = $obj->account_number;
  608. $bankstatic->clos = $obj->clos;
  609. //$accountingjournal->fetch($obj->fk_accountancy_journal);
  610. //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  611. $bankstatic->label = $obj->blabel;
  612. print $bankstatic->getNomUrl(1);
  613. }
  614. print '</td>';
  615. if (!$i) $totalarray['nbfield']++;
  616. }
  617. // Amount
  618. if (!empty($arrayfields['cs.amount']['checked'])) {
  619. print '<td class="nowrap amount right">'.price($obj->amount).'</td>';
  620. if (!$i) {
  621. $totalarray['nbfield']++;
  622. }
  623. if (!$i) {
  624. $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
  625. }
  626. $totalarray['val']['totalttcfield'] += $obj->amount;
  627. }
  628. // Status
  629. if (!empty($arrayfields['cs.paye']['checked'])) {
  630. print '<td class="nowrap right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
  631. if (!$i) {
  632. $totalarray['nbfield']++;
  633. }
  634. }
  635. // Buttons
  636. print '<td></td>';
  637. if (!$i) {
  638. $totalarray['nbfield']++;
  639. }
  640. print '</tr>'."\n";
  641. $i++;
  642. }
  643. // Show total line
  644. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  645. // If no record found
  646. if ($num == 0) {
  647. $colspan = 1;
  648. foreach ($arrayfields as $key => $val) {
  649. if (!empty($val['checked'])) {
  650. $colspan++;
  651. }
  652. }
  653. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  654. }
  655. $db->free($resql);
  656. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  657. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
  658. print $hookmanager->resPrint;
  659. print '</table>'."\n";
  660. print '</div>'."\n";
  661. print '</form>'."\n";
  662. // End of page
  663. llxFooter();
  664. $db->close();