list.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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_project = GETPOST('search_project', 'alpha');
  67. $search_users = GETPOST('search_users');
  68. $search_type = GETPOST('search_type', 'int');
  69. $search_account = GETPOST('search_account', 'int');
  70. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  71. $sortfield = GETPOST('sortfield', 'aZ09comma');
  72. $sortorder = GETPOST("sortorder", 'aZ09comma');
  73. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  74. if (empty($page) || $page == -1) {
  75. $page = 0; // If $page is not defined, or '' or -1
  76. }
  77. $offset = $limit * $page;
  78. $pageprev = $page - 1;
  79. $pagenext = $page + 1;
  80. if (!$sortfield) {
  81. $sortfield = "cs.date_ech";
  82. }
  83. if (!$sortorder) {
  84. $sortorder = "DESC";
  85. }
  86. $filtre = GETPOST("filtre", 'int');
  87. if (!GETPOSTISSET('search_typeid')) {
  88. $newfiltre = str_replace('filtre=', '', $filtre);
  89. $filterarray = explode('-', $newfiltre);
  90. foreach ($filterarray as $val) {
  91. $part = explode(':', $val);
  92. if ($part[0] == 'cs.fk_type') {
  93. $search_typeid = $part[1];
  94. }
  95. }
  96. } else {
  97. $search_typeid = GETPOST('search_typeid', 'int');
  98. }
  99. $arrayfields = array(
  100. 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
  101. 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20),
  102. 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
  103. 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40),
  104. 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50),
  105. 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enable'=>(!empty($conf->projet->enabled))),
  106. 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70),
  107. 'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"),
  108. 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100),
  109. 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110),
  110. );
  111. if (!empty($conf->banque->enabled)) {
  112. $arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount");
  113. }
  114. $arrayfields = dol_sort_array($arrayfields, 'position');
  115. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  116. $hookmanager->initHooks(array('sclist'));
  117. $object = new ChargeSociales($db);
  118. // Security check
  119. $socid = GETPOST("socid", 'int');
  120. if ($user->socid) {
  121. $socid = $user->socid;
  122. }
  123. $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
  124. /*
  125. * Actions
  126. */
  127. $parameters = array('socid'=>$socid);
  128. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  129. if ($reshook < 0) {
  130. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  131. }
  132. if (empty($reshook)) {
  133. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  134. // All tests are required to be compatible with all browsers
  135. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  136. $search_ref = '';
  137. $search_label = '';
  138. $search_amount = '';
  139. $search_status = '';
  140. $search_typeid = '';
  141. $search_date_startday = '';
  142. $search_date_startmonth = '';
  143. $search_date_startyear = '';
  144. $search_date_endday = '';
  145. $search_date_endmonth = '';
  146. $search_date_endyear = '';
  147. $search_date_start = '';
  148. $search_date_end = '';
  149. $search_date_limit_startday = '';
  150. $search_date_limit_startmonth = '';
  151. $search_date_limit_startyear = '';
  152. $search_date_limit_endday = '';
  153. $search_date_limit_endmonth = '';
  154. $search_date_limit_endyear = '';
  155. $search_date_limit_start = '';
  156. $search_date_limit_end = '';
  157. $search_project_ref = '';
  158. $search_project = '';
  159. $search_users = '';
  160. $search_type = '';
  161. $search_account = '';
  162. $search_array_options = array();
  163. }
  164. }
  165. /*
  166. * View
  167. */
  168. $form = new Form($db);
  169. $formother = new FormOther($db);
  170. $bankstatic = new Account($db);
  171. $formsocialcontrib = new FormSocialContrib($db);
  172. $chargesociale_static = new ChargeSociales($db);
  173. if (!empty($conf->projet->enabled)) {
  174. $projectstatic = new Project($db);
  175. }
  176. llxHeader('', $langs->trans("SocialContributions"));
  177. $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
  178. $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
  179. if (!empty($conf->projet->enabled)) {
  180. $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
  181. }
  182. $sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,";
  183. $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,";
  184. $sql .= " SUM(pc.amount) as alreadypayed, pay.code as payment_code";
  185. $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
  186. $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
  187. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)";
  188. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)';
  189. if (!empty($conf->projet->enabled)) {
  190. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
  191. }
  192. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
  193. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)";
  194. $sql .= " WHERE cs.fk_type = c.id";
  195. $sql .= " AND cs.entity = ".((int) $conf->entity);
  196. // Search criteria
  197. if ($search_ref) {
  198. $sql .= " AND cs.ref = '".$db->escape($search_ref)."'";
  199. }
  200. if ($search_label) {
  201. $sql .= natural_search("cs.libelle", $search_label);
  202. }
  203. if (!empty($conf->projet->enabled)) {
  204. if ($search_project_ref != '') {
  205. $sql .= natural_search("p.ref", $search_project_ref);
  206. }
  207. }
  208. if (!empty($search_users)) {
  209. $sql .= ' AND cs.fk_user IN('.implode(', ', $search_users).')';
  210. }
  211. if (!empty($search_type) && $search_type > 0) {
  212. $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type);
  213. }
  214. if (!empty($search_account) && $search_account > 0) {
  215. $sql .= ' AND cs.fk_account='.((int) $search_account);
  216. }
  217. if ($search_amount) {
  218. $sql .= natural_search("cs.amount", $search_amount, 1);
  219. }
  220. if ($search_status != '' && $search_status >= 0) {
  221. $sql .= " AND cs.paye = ".((int) $search_status);
  222. }
  223. if ($search_date_start) {
  224. $sql .= " AND cs.date_ech >= '".$db->idate($search_date_start)."'";
  225. }
  226. if ($search_date_end) {
  227. $sql .= " AND cs.date_ech <= '".$db->idate($search_date_end)."'";
  228. }
  229. if ($search_date_limit_start) {
  230. $sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
  231. }
  232. if ($search_date_limit_end) {
  233. $sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
  234. }
  235. if ($search_typeid > 0) {
  236. $sql .= " AND cs.fk_type = ".((int) $search_typeid);
  237. }
  238. $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";
  239. if (!empty($conf->projet->enabled)) {
  240. $sql .= ", p.rowid, p.ref, p.title";
  241. }
  242. $sql .= $db->order($sortfield, $sortorder);
  243. $totalnboflines = 0;
  244. $result = $db->query($sql);
  245. if ($result) {
  246. $totalnboflines = $db->num_rows($result);
  247. }
  248. $sql .= $db->plimit($limit + 1, $offset);
  249. $resql = $db->query($sql);
  250. if (!$resql) {
  251. dol_print_error($db);
  252. llxFooter();
  253. $db->close();
  254. exit;
  255. }
  256. $num = $db->num_rows($resql);
  257. $i = 0;
  258. $param = '';
  259. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  260. $param .= '&contextpage='.urlencode($contextpage);
  261. }
  262. if ($limit > 0 && $limit != $conf->liste_limit) {
  263. $param .= '&limit='.urlencode($limit);
  264. }
  265. if ($search_ref) {
  266. $param .= '&search_ref='.urlencode($search_ref);
  267. }
  268. if ($search_label) {
  269. $param .= '&search_label='.urlencode($search_label);
  270. }
  271. if ($search_project_ref >= 0) {
  272. $param .= "&search_project_ref=".urlencode($search_project_ref);
  273. }
  274. if ($search_amount) {
  275. $param .= '&search_amount='.urlencode($search_amount);
  276. }
  277. if ($search_typeid) {
  278. $param .= '&search_typeid='.urlencode($search_typeid);
  279. }
  280. if ($search_users) {
  281. foreach ($search_users as $id_user) {
  282. $param .= '&search_users[]='.urlencode($id_user);
  283. }
  284. }
  285. if ($search_type) {
  286. $param .= '&search_type='.urlencode($search_type);
  287. }
  288. if ($search_account) {
  289. $param .= '&search_account='.$search_account;
  290. }
  291. if ($search_status != '' && $search_status != '-1') {
  292. $param .= '&search_status='.urlencode($search_status);
  293. }
  294. if ($search_date_startday) {
  295. $param .= '&search_date_startday='.urlencode($search_date_startday);
  296. }
  297. if ($search_date_startmonth) {
  298. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  299. }
  300. if ($search_date_startyear) {
  301. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  302. }
  303. if ($search_date_endday) {
  304. $param .= '&search_date_endday='.urlencode($search_date_endday);
  305. }
  306. if ($search_date_endmonth) {
  307. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  308. }
  309. if ($search_date_endyear) {
  310. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  311. }
  312. if ($search_date_limit_startday) {
  313. $param .= '&search_date_limit_startday='.urlencode($search_date_limit_startday);
  314. }
  315. if ($search_date_limit_startmonth) {
  316. $param .= '&search_date_limit_startmonth='.urlencode($search_date_limit_startmonth);
  317. }
  318. if ($search_date_limit_startyear) {
  319. $param .= '&search_date_limit_startyear='.urlencode($search_date_limit_startyear);
  320. }
  321. if ($search_date_limit_endday) {
  322. $param .= '&search_date_limit_endday='.urlencode($search_date_limit_endday);
  323. }
  324. if ($search_date_limit_endmonth) {
  325. $param .= '&search_date_limit_endmonth='.urlencode($search_date_limit_endmonth);
  326. }
  327. if ($search_date_limit_endyear) {
  328. $param .= '&search_date_limit_endyear='.urlencode($search_date_limit_endyear);
  329. }
  330. $newcardbutton = '';
  331. if ($user->rights->tax->charges->creer) {
  332. $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create');
  333. }
  334. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  335. if ($optioncss != '') {
  336. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  337. }
  338. print '<input type="hidden" name="token" value="'.newToken().'">';
  339. print '<input type="hidden" name="action" value="list">';
  340. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  341. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  342. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  343. print '<input type="hidden" name="search_status" value="'.$search_status.'">';
  344. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  345. $center = '';
  346. print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
  347. if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
  348. print '<div class="error">';
  349. $langs->load("errors");
  350. $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
  351. print $countrynotdefined;
  352. print '</div>';
  353. print '</form>';
  354. llxFooter();
  355. $db->close();
  356. }
  357. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  358. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  359. if ($massactionbutton) {
  360. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  361. }
  362. print '<div class="div-table-responsive">';
  363. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
  364. print '<tr class="liste_titre_filter">';
  365. // Filters: Line number (placeholder)
  366. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  367. print '<td class="liste_titre">';
  368. print '</td>';
  369. }
  370. // Filter: Ref
  371. if (!empty($arrayfields['cs.rowid']['checked'])) {
  372. print '<td class="liste_titre">';
  373. print '<input class="flat maxwidth75" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  374. print '</td>';
  375. }
  376. // Filter: Label
  377. if (!empty($arrayfields['cs.rowid']['checked'])) {
  378. print '<td class="liste_titre">';
  379. print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  380. print '</td>';
  381. }
  382. // Filter: Type
  383. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  384. print '<td class="liste_titre">';
  385. $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1);
  386. print '</td>';
  387. }
  388. // Filter: Date (placeholder)
  389. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  390. print '<td class="liste_titre center">';
  391. print '<div class="nowrap">';
  392. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  393. print '</div>';
  394. print '<div class="nowrap">';
  395. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  396. print '</div>';
  397. print '</td>';
  398. }
  399. // Filter: Period end date
  400. if (!empty($arrayfields['cs.periode']['checked'])) {
  401. print '<td class="liste_titre center">';
  402. print '<div class="nowrap">';
  403. 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'));
  404. print '</div>';
  405. print '<div class="nowrap">';
  406. 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'));
  407. print '</div>';
  408. print '</td>';
  409. }
  410. // Filter: Project ref
  411. if (!empty($arrayfields['p.ref']['checked'])) {
  412. print '<td class="liste_titre">';
  413. print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.$search_project_ref.'">';
  414. print '</td>';
  415. }
  416. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  417. // Employee
  418. print '<td class="liste_titre">';
  419. print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', '0', 0, '', 0, '', '', 0, 0, true);
  420. }
  421. // Filter: Type
  422. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  423. print '<td class="liste_titre">';
  424. $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150');
  425. print '</td>';
  426. }
  427. // Filter: Bank Account
  428. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  429. print '<td class="liste_titre">';
  430. $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
  431. print '</td>';
  432. }
  433. // Filter: Amount
  434. if (!empty($arrayfields['cs.amount']['checked'])) {
  435. print '<td class="liste_titre right">';
  436. print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
  437. print '</td>';
  438. }
  439. // Filter: Status
  440. if (!empty($arrayfields['cs.paye']['checked'])) {
  441. print '<td class="liste_titre maxwidthonsmartphone right">';
  442. $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid"));
  443. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1);
  444. print '</td>';
  445. }
  446. // Fields from hook
  447. $parameters = array('arrayfields'=>$arrayfields);
  448. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  449. print $hookmanager->resPrint;
  450. // Filter: Buttons
  451. print '<td class="liste_titre maxwidthsearch">';
  452. print $form->showFilterAndCheckAddButtons(0);
  453. print '</td>';
  454. print '</tr>';
  455. print '<tr class="liste_titre">';
  456. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  457. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  458. }
  459. if (!empty($arrayfields['cs.rowid']['checked'])) {
  460. print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder);
  461. }
  462. if (!empty($arrayfields['cs.libelle']['checked'])) {
  463. print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
  464. }
  465. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  466. print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder);
  467. }
  468. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  469. print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
  470. }
  471. if (!empty($arrayfields['cs.periode']['checked'])) {
  472. print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
  473. }
  474. if (!empty($arrayfields['p.ref']['checked'])) {
  475. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
  476. }
  477. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  478. print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
  479. }
  480. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  481. print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder);
  482. }
  483. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  484. print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder);
  485. }
  486. if (!empty($arrayfields['cs.amount']['checked'])) {
  487. print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
  488. }
  489. if (!empty($arrayfields['cs.paye']['checked'])) {
  490. print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
  491. }
  492. // Hook fields
  493. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  494. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  495. print $hookmanager->resPrint;
  496. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
  497. print '</tr>';
  498. $i = 0;
  499. $totalarray = $TLoadedUsers = array();
  500. while ($i < min($num, $limit)) {
  501. $obj = $db->fetch_object($resql);
  502. $chargesociale_static->id = $obj->rowid;
  503. $chargesociale_static->ref = $obj->rowid;
  504. $chargesociale_static->label = $obj->label;
  505. $chargesociale_static->type_label = $obj->type_label;
  506. if (!empty($conf->projet->enabled)) {
  507. $projectstatic->id = $obj->project_id;
  508. $projectstatic->ref = $obj->project_ref;
  509. $projectstatic->title = $obj->project_label;
  510. }
  511. print '<tr class="oddeven">';
  512. // Line number
  513. if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
  514. print '<td>'.(($offset * $limit) + $i).'</td>';
  515. if (!$i) {
  516. $totalarray['nbfield']++;
  517. }
  518. }
  519. // Ref
  520. if (!empty($arrayfields['cs.rowid']['checked'])) {
  521. print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
  522. if (!$i) {
  523. $totalarray['nbfield']++;
  524. }
  525. }
  526. // Label
  527. if (!empty($arrayfields['cs.libelle']['checked'])) {
  528. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
  529. if (!$i) {
  530. $totalarray['nbfield']++;
  531. }
  532. }
  533. // Type
  534. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  535. $typelabeltoshow = $obj->type_label;
  536. $typelabelpopup = $obj->type_label;
  537. if (!empty($conf->accounting->enabled)) {
  538. $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
  539. }
  540. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
  541. if (!$i) {
  542. $totalarray['nbfield']++;
  543. }
  544. }
  545. // Date
  546. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  547. print '<td class="center">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
  548. if (!$i) {
  549. $totalarray['nbfield']++;
  550. }
  551. }
  552. // Date end period
  553. if (!empty($arrayfields['cs.periode']['checked'])) {
  554. print '<td class="center">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
  555. if (!$i) {
  556. $totalarray['nbfield']++;
  557. }
  558. }
  559. // Project ref
  560. if (!empty($arrayfields['p.ref']['checked'])) {
  561. print '<td class="nowrap">';
  562. if ($obj->project_id > 0) {
  563. print $projectstatic->getNomUrl(1);
  564. }
  565. print '</td>';
  566. if (!$i) {
  567. $totalarray['nbfield']++;
  568. }
  569. }
  570. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  571. // Employee
  572. print "<td>";
  573. if (!empty($obj->fk_user)) {
  574. if (!empty($TLoadedUsers[$obj->fk_user])) {
  575. $ustatic = $TLoadedUsers[$obj->fk_user];
  576. } else {
  577. $ustatic = new User($db);
  578. $ustatic->fetch($obj->fk_user);
  579. $TLoadedUsers[$obj->fk_user] = $ustatic;
  580. }
  581. print $ustatic->getNomUrl(-1);
  582. }
  583. print "</td>\n";
  584. if (!$i) {
  585. $totalarray['nbfield']++;
  586. }
  587. }
  588. // Type
  589. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  590. print '<td>';
  591. if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code);
  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>';
  641. $i++;
  642. }
  643. // Show total line
  644. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  645. print '</table>';
  646. print '</div>';
  647. print '</form>';
  648. // End of page
  649. llxFooter();
  650. $db->close();