list.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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-2023 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. // Load Dolibarr environment
  30. require '../../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  35. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  36. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  37. // Load translation files required by the page
  38. $langs->loadLangs(array('compta', 'banks', 'bills', 'hrm', 'projects'));
  39. $action = GETPOST('action', 'aZ09');
  40. $massaction = GETPOST('massaction', 'alpha');
  41. $confirm = GETPOST('confirm', 'alpha');
  42. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  43. $optioncss = GETPOST('optioncss', 'alpha');
  44. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist';
  45. $mode = GETPOST('mode', 'alpha');
  46. $search_ref = GETPOST('search_ref', 'int');
  47. $search_label = GETPOST('search_label', 'alpha');
  48. $search_typeid = GETPOST('search_typeid', 'int');
  49. $search_amount = GETPOST('search_amount', 'alpha');
  50. $search_status = GETPOST('search_status', 'int');
  51. $search_date_startday = GETPOST('search_date_startday', 'int');
  52. $search_date_startmonth = GETPOST('search_date_startmonth', 'int');
  53. $search_date_startyear = GETPOST('search_date_startyear', 'int');
  54. $search_date_endday = GETPOST('search_date_endday', 'int');
  55. $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
  56. $search_date_endyear = GETPOST('search_date_endyear', 'int');
  57. $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
  58. $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
  59. $search_date_limit_startday = GETPOST('search_date_limit_startday', 'int');
  60. $search_date_limit_startmonth = GETPOST('search_date_limit_startmonth', 'int');
  61. $search_date_limit_startyear = GETPOST('search_date_limit_startyear', 'int');
  62. $search_date_limit_endday = GETPOST('search_date_limit_endday', 'int');
  63. $search_date_limit_endmonth = GETPOST('search_date_limit_endmonth', 'int');
  64. $search_date_limit_endyear = GETPOST('search_date_limit_endyear', 'int');
  65. $search_date_limit_start = dol_mktime(0, 0, 0, $search_date_limit_startmonth, $search_date_limit_startday, $search_date_limit_startyear);
  66. $search_date_limit_end = dol_mktime(23, 59, 59, $search_date_limit_endmonth, $search_date_limit_endday, $search_date_limit_endyear);
  67. $search_project_ref = GETPOST('search_project_ref', 'alpha');
  68. $search_users = GETPOST('search_users');
  69. $search_type = GETPOST('search_type', 'int');
  70. $search_account = GETPOST('search_account', 'int');
  71. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  72. $sortfield = GETPOST('sortfield', 'aZ09comma');
  73. $sortorder = GETPOST("sortorder", 'aZ09comma');
  74. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  75. if (empty($page) || $page == -1) {
  76. $page = 0; // If $page is not defined, or '' or -1
  77. }
  78. $offset = $limit * $page;
  79. $pageprev = $page - 1;
  80. $pagenext = $page + 1;
  81. if (!$sortfield) {
  82. $sortfield = "cs.date_ech";
  83. }
  84. if (!$sortorder) {
  85. $sortorder = "DESC";
  86. }
  87. $filtre = GETPOST("filtre", 'int');
  88. $arrayfields = array(
  89. 'cs.rowid' =>array('label'=>"Ref", 'checked'=>1, 'position'=>10),
  90. 'cs.libelle' =>array('label'=>"Label", 'checked'=>1, 'position'=>20),
  91. 'cs.fk_type' =>array('label'=>"Type", 'checked'=>1, 'position'=>30),
  92. 'cs.date_ech' =>array('label'=>"Date", 'checked'=>1, 'position'=>40),
  93. 'cs.periode' =>array('label'=>"PeriodEndDate", 'checked'=>1, 'position'=>50),
  94. 'p.ref' =>array('label'=>"ProjectRef", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled('project'))),
  95. 'cs.fk_user' =>array('label'=>"Employee", 'checked'=>1, 'position'=>70),
  96. 'cs.fk_mode_reglement' =>array('checked'=>-1, 'position'=>80, 'label'=>"DefaultPaymentMode"),
  97. 'cs.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>100),
  98. 'cs.paye' =>array('label'=>"Status", 'checked'=>1, 'position'=>110),
  99. );
  100. if (isModEnabled("banque")) {
  101. $arrayfields['cs.fk_account'] = array('checked'=>-1, 'position'=>90, 'label'=>"DefaultBankAccount");
  102. }
  103. $arrayfields = dol_sort_array($arrayfields, 'position');
  104. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  105. $hookmanager->initHooks(array('sclist'));
  106. $object = new ChargeSociales($db);
  107. $permissiontoadd = $user->hasRight('tax', 'charges', 'creer');
  108. $permissiontodelete = $user->hasRight('tax', 'charges', 'supprimer');
  109. // Security check
  110. $socid = GETPOST("socid", 'int');
  111. if ($user->socid) {
  112. $socid = $user->socid;
  113. }
  114. $result = restrictedArea($user, 'tax', '', 'chargesociales', 'charges');
  115. /*
  116. * Actions
  117. */
  118. $parameters = array('socid'=>$socid);
  119. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  120. if ($reshook < 0) {
  121. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  122. }
  123. if (empty($reshook)) {
  124. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  125. // All tests are required to be compatible with all browsers
  126. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  127. $search_ref = '';
  128. $search_label = '';
  129. $search_amount = '';
  130. $search_status = '';
  131. $search_typeid = '';
  132. $search_date_startday = '';
  133. $search_date_startmonth = '';
  134. $search_date_startyear = '';
  135. $search_date_endday = '';
  136. $search_date_endmonth = '';
  137. $search_date_endyear = '';
  138. $search_date_start = '';
  139. $search_date_end = '';
  140. $search_date_limit_startday = '';
  141. $search_date_limit_startmonth = '';
  142. $search_date_limit_startyear = '';
  143. $search_date_limit_endday = '';
  144. $search_date_limit_endmonth = '';
  145. $search_date_limit_endyear = '';
  146. $search_date_limit_start = '';
  147. $search_date_limit_end = '';
  148. $search_project_ref = '';
  149. $search_users = '';
  150. $search_type = '';
  151. $search_account = '';
  152. $search_array_options = array();
  153. $toselect = array();
  154. }
  155. // Mass actions
  156. $objectclass = 'ChargeSociales';
  157. $objectlabel = 'ChargeSociales';
  158. $uploaddir = $conf->tax->dir_output;
  159. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  160. }
  161. /*
  162. * View
  163. */
  164. $form = new Form($db);
  165. $formother = new FormOther($db);
  166. $bankstatic = new Account($db);
  167. $formsocialcontrib = new FormSocialContrib($db);
  168. $chargesociale_static = new ChargeSociales($db);
  169. $projectstatic = new Project($db);
  170. llxHeader('', $langs->trans("SocialContributions"));
  171. $arrayofselected = is_array($toselect) ? $toselect : array();
  172. $sql = "SELECT cs.rowid, cs.fk_type as type, cs.fk_user,";
  173. $sql .= " cs.amount, cs.date_ech, cs.libelle as label, cs.paye, cs.periode, cs.fk_account,";
  174. if (isModEnabled('project')) {
  175. $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,";
  176. }
  177. $sql .= " c.libelle as type_label, c.accountancy_code as type_accountancy_code,";
  178. $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,";
  179. $sql .= " pay.code as payment_code";
  180. $sqlfields = $sql; // $sql fields to remove for count total
  181. $sql .= ", SUM(pc.amount) as alreadypayed";
  182. $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,";
  183. $sql .= " ".MAIN_DB_PREFIX."chargesociales as cs";
  184. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (cs.fk_account = ba.rowid)";
  185. $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pay ON (cs.fk_mode_reglement = pay.id)';
  186. if (isModEnabled('project')) {
  187. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = cs.fk_projet";
  188. }
  189. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementcharge as pc ON pc.fk_charge = cs.rowid";
  190. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON (cs.fk_user = u.rowid)";
  191. $sql .= " WHERE cs.fk_type = c.id";
  192. $sql .= " AND cs.entity = ".((int) $conf->entity);
  193. // Search criteria
  194. if ($search_ref) {
  195. $sql .= " AND cs.ref = '".$db->escape($search_ref)."'";
  196. }
  197. if ($search_label) {
  198. $sql .= natural_search("cs.libelle", $search_label);
  199. }
  200. if (isModEnabled('project')) {
  201. if ($search_project_ref != '') {
  202. $sql .= natural_search("p.ref", $search_project_ref);
  203. }
  204. }
  205. if (!empty($search_users)) {
  206. $sql .= ' AND cs.fk_user IN ('.$db->sanitize(implode(', ', $search_users)).')';
  207. }
  208. if (!empty($search_type) && $search_type > 0) {
  209. $sql .= ' AND cs.fk_mode_reglement='.((int) $search_type);
  210. }
  211. if (!empty($search_account) && $search_account > 0) {
  212. $sql .= ' AND cs.fk_account='.((int) $search_account);
  213. }
  214. if ($search_amount) {
  215. $sql .= natural_search("cs.amount", $search_amount, 1);
  216. }
  217. if ($search_status != '' && $search_status >= 0) {
  218. $sql .= " AND cs.paye = ".((int) $search_status);
  219. }
  220. if ($search_date_start) {
  221. $sql .= " AND cs.date_ech >= '".$db->idate($search_date_start)."'";
  222. }
  223. if ($search_date_end) {
  224. $sql .= " AND cs.date_ech <= '".$db->idate($search_date_end)."'";
  225. }
  226. if ($search_date_limit_start) {
  227. $sql .= " AND cs.periode >= '".$db->idate($search_date_limit_start)."'";
  228. }
  229. if ($search_date_limit_end) {
  230. $sql .= " AND cs.periode <= '".$db->idate($search_date_limit_end)."'";
  231. }
  232. if ($search_typeid > 0) {
  233. $sql .= " AND cs.fk_type = ".((int) $search_typeid);
  234. }
  235. $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";
  236. if (isModEnabled('project')) {
  237. $sql .= ", p.rowid, p.ref, p.title";
  238. }
  239. // Count total nb of records
  240. $nbtotalofrecords = '';
  241. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  242. /* The fast and low memory method to get and count full list converts the sql into a sql count */
  243. $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(DISTINCT cs.rowid) as nbtotalofrecords', $sql);
  244. $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount);
  245. $resql = $db->query($sqlforcount);
  246. if ($resql) {
  247. $objforcount = $db->fetch_object($resql);
  248. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  249. } else {
  250. dol_print_error($db);
  251. }
  252. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  253. $page = 0;
  254. $offset = 0;
  255. }
  256. $db->free($resql);
  257. }
  258. // Complete request and execute it with limit
  259. $sql .= $db->order($sortfield, $sortorder);
  260. if ($limit) {
  261. $sql .= $db->plimit($limit + 1, $offset);
  262. }
  263. $resql = $db->query($sql);
  264. if (!$resql) {
  265. dol_print_error($db);
  266. llxFooter();
  267. $db->close();
  268. exit;
  269. }
  270. $num = $db->num_rows($resql);
  271. $i = 0;
  272. $param = '';
  273. if (!empty($mode)) {
  274. $param .= '&mode='.urlencode($mode);
  275. }
  276. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  277. $param .= '&contextpage='.urlencode($contextpage);
  278. }
  279. if ($limit > 0 && $limit != $conf->liste_limit) {
  280. $param .= '&limit='.((int) $limit);
  281. }
  282. if ($search_ref) {
  283. $param .= '&search_ref='.urlencode($search_ref);
  284. }
  285. if ($search_label) {
  286. $param .= '&search_label='.urlencode($search_label);
  287. }
  288. if ($search_project_ref >= 0) {
  289. $param .= "&search_project_ref=".urlencode($search_project_ref);
  290. }
  291. if ($search_amount) {
  292. $param .= '&search_amount='.urlencode($search_amount);
  293. }
  294. if ($search_typeid) {
  295. $param .= '&search_typeid='.urlencode($search_typeid);
  296. }
  297. if ($search_users) {
  298. foreach ($search_users as $id_user) {
  299. $param .= '&search_users[]='.urlencode($id_user);
  300. }
  301. }
  302. if ($search_type) {
  303. $param .= '&search_type='.urlencode($search_type);
  304. }
  305. if ($search_account) {
  306. $param .= '&search_account='.$search_account;
  307. }
  308. if ($search_status != '' && $search_status != '-1') {
  309. $param .= '&search_status='.urlencode($search_status);
  310. }
  311. if ($search_date_startday) {
  312. $param .= '&search_date_startday='.urlencode($search_date_startday);
  313. }
  314. if ($search_date_startmonth) {
  315. $param .= '&search_date_startmonth='.urlencode($search_date_startmonth);
  316. }
  317. if ($search_date_startyear) {
  318. $param .= '&search_date_startyear='.urlencode($search_date_startyear);
  319. }
  320. if ($search_date_endday) {
  321. $param .= '&search_date_endday='.urlencode($search_date_endday);
  322. }
  323. if ($search_date_endmonth) {
  324. $param .= '&search_date_endmonth='.urlencode($search_date_endmonth);
  325. }
  326. if ($search_date_endyear) {
  327. $param .= '&search_date_endyear='.urlencode($search_date_endyear);
  328. }
  329. if ($search_date_limit_startday) {
  330. $param .= '&search_date_limit_startday='.urlencode($search_date_limit_startday);
  331. }
  332. if ($search_date_limit_startmonth) {
  333. $param .= '&search_date_limit_startmonth='.urlencode($search_date_limit_startmonth);
  334. }
  335. if ($search_date_limit_startyear) {
  336. $param .= '&search_date_limit_startyear='.urlencode($search_date_limit_startyear);
  337. }
  338. if ($search_date_limit_endday) {
  339. $param .= '&search_date_limit_endday='.urlencode($search_date_limit_endday);
  340. }
  341. if ($search_date_limit_endmonth) {
  342. $param .= '&search_date_limit_endmonth='.urlencode($search_date_limit_endmonth);
  343. }
  344. if ($search_date_limit_endyear) {
  345. $param .= '&search_date_limit_endyear='.urlencode($search_date_limit_endyear);
  346. }
  347. $url = DOL_URL_ROOT.'/compta/sociales/card.php?action=create';
  348. $newcardbutton = '';
  349. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
  350. $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
  351. $newcardbutton .= dolGetButtonTitleSeparator();
  352. $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd);
  353. // List of mass actions available
  354. $arrayofmassactions = array();
  355. if (!empty($permissiontodelete)) {
  356. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  357. }
  358. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  359. $moreforfilter = '';
  360. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  361. if ($optioncss != '') {
  362. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  363. }
  364. print '<input type="hidden" name="token" value="'.newToken().'">';
  365. print '<input type="hidden" name="action" value="list">';
  366. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  367. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  368. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  369. print '<input type="hidden" name="search_status" value="'.$search_status.'">';
  370. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  371. print '<input type="hidden" name="mode" value="'.$mode.'">';
  372. print_barre_liste($langs->trans("SocialContributions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1);
  373. if (empty($mysoc->country_id) && empty($mysoc->country_code)) {
  374. print '<div class="error">';
  375. $langs->load("errors");
  376. $countrynotdefined = $langs->trans("ErrorSetACountryFirst");
  377. print $countrynotdefined;
  378. print '</div>';
  379. print '</form>';
  380. llxFooter();
  381. $db->close();
  382. }
  383. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  384. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
  385. if ($massactionbutton) {
  386. $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
  387. }
  388. $objecttmp = new ChargeSociales($db);
  389. $trackid = 'sc'.$object->id;
  390. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  391. print '<div class="div-table-responsive">';
  392. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">'."\n";
  393. print '<tr class="liste_titre_filter">';
  394. // Filter: Buttons
  395. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  396. print '<td class="liste_titre maxwidthsearch">';
  397. print $form->showFilterAndCheckAddButtons(0);
  398. print '</td>';
  399. }
  400. // Filters: Line number (placeholder)
  401. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
  402. print '<td class="liste_titre">';
  403. print '</td>';
  404. }
  405. // Filter: Ref
  406. if (!empty($arrayfields['cs.rowid']['checked'])) {
  407. print '<td class="liste_titre">';
  408. print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
  409. print '</td>';
  410. }
  411. // Filter: Label
  412. if (!empty($arrayfields['cs.rowid']['checked'])) {
  413. print '<td class="liste_titre">';
  414. print '<input type="text" class="flat maxwidth100" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
  415. print '</td>';
  416. }
  417. // Filter: Type
  418. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  419. print '<td class="liste_titre">';
  420. $formsocialcontrib->select_type_socialcontrib($search_typeid, 'search_typeid', 1, 0, 0, 'maxwidth150', 1);
  421. print '</td>';
  422. }
  423. // Filter: Date (placeholder)
  424. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  425. print '<td class="liste_titre center">';
  426. print '<div class="nowrapfordate">';
  427. print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  428. print '</div>';
  429. print '<div class="nowrapfordate">';
  430. print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  431. print '</div>';
  432. print '</td>';
  433. }
  434. // Filter: Period end date
  435. if (!empty($arrayfields['cs.periode']['checked'])) {
  436. print '<td class="liste_titre center">';
  437. print '<div class="nowrapfordate">';
  438. 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'));
  439. print '</div>';
  440. print '<div class="nowrapfordate">';
  441. 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'));
  442. print '</div>';
  443. print '</td>';
  444. }
  445. // Filter: Project ref
  446. if (!empty($arrayfields['p.ref']['checked'])) {
  447. print '<td class="liste_titre">';
  448. print '<input type="text" class="flat" size="6" name="search_project_ref" value="'.dol_escape_htmltag($search_project_ref).'">';
  449. print '</td>';
  450. }
  451. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  452. // Employee
  453. print '<td class="liste_titre">';
  454. print $form->select_dolusers($search_users, 'search_users', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth150', 0, 0, true);
  455. print '</td>';
  456. }
  457. // Filter: Type
  458. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  459. print '<td class="liste_titre">';
  460. print $form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 0, 1, 'maxwidth150', 1);
  461. print '</td>';
  462. }
  463. // Filter: Bank Account
  464. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  465. print '<td class="liste_titre">';
  466. $form->select_comptes($search_account, 'search_account', 0, '', 1, '', 0, 'maxwidth150');
  467. print '</td>';
  468. }
  469. // Filter: Amount
  470. if (!empty($arrayfields['cs.amount']['checked'])) {
  471. print '<td class="liste_titre right">';
  472. print '<input class="flat maxwidth75" type="text" name="search_amount" value="'.dol_escape_htmltag($search_amount).'">';
  473. print '</td>';
  474. }
  475. // Filter: Status
  476. if (!empty($arrayfields['cs.paye']['checked'])) {
  477. print '<td class="liste_titre right parentonrightofpage">';
  478. $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid"));
  479. print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1);
  480. print '</td>';
  481. }
  482. // Fields from hook
  483. $parameters = array('arrayfields'=>$arrayfields);
  484. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
  485. print $hookmanager->resPrint;
  486. // Filter: Buttons
  487. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  488. print '<td class="liste_titre maxwidthsearch">';
  489. print $form->showFilterAndCheckAddButtons(0);
  490. print '</td>';
  491. }
  492. print '</tr>';
  493. $totalarray = array();
  494. $totalarray['nbfield'] = 0;
  495. // Fields title label
  496. // --------------------------------------------------------------------
  497. print '<tr class="liste_titre">';
  498. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  499. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
  500. $totalarray['nbfield']++;
  501. }
  502. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
  503. print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
  504. $totalarray['nbfield']++;
  505. }
  506. if (!empty($arrayfields['cs.rowid']['checked'])) {
  507. print_liste_field_titre($arrayfields['cs.rowid']['label'], $_SERVER["PHP_SELF"], "cs.rowid", '', $param, '', $sortfield, $sortorder);
  508. $totalarray['nbfield']++;
  509. }
  510. if (!empty($arrayfields['cs.libelle']['checked'])) {
  511. print_liste_field_titre($arrayfields['cs.libelle']['label'], $_SERVER["PHP_SELF"], "cs.libelle,cs.periode", '', $param, '', $sortfield, $sortorder);
  512. $totalarray['nbfield']++;
  513. }
  514. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  515. print_liste_field_titre($arrayfields['cs.fk_type']['label'], $_SERVER["PHP_SELF"], "cs.fk_type,cs.periode", '', $param, '', $sortfield, $sortorder);
  516. $totalarray['nbfield']++;
  517. }
  518. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  519. print_liste_field_titre($arrayfields['cs.date_ech']['label'], $_SERVER["PHP_SELF"], "cs.date_ech,cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
  520. $totalarray['nbfield']++;
  521. }
  522. if (!empty($arrayfields['cs.periode']['checked'])) {
  523. print_liste_field_titre($arrayfields['cs.periode']['label'], $_SERVER["PHP_SELF"], "cs.periode", '', $param, '', $sortfield, $sortorder, 'center ');
  524. $totalarray['nbfield']++;
  525. }
  526. if (!empty($arrayfields['p.ref']['checked'])) {
  527. print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder);
  528. $totalarray['nbfield']++;
  529. }
  530. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  531. print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.lastname,cs.periode", "", $param, 'class="left"', $sortfield, $sortorder);
  532. $totalarray['nbfield']++;
  533. }
  534. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  535. print_liste_field_titre($arrayfields['cs.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "cs.fk_mode_reglement,cs.periode", '', $param, '', $sortfield, $sortorder);
  536. $totalarray['nbfield']++;
  537. }
  538. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  539. print_liste_field_titre($arrayfields['cs.fk_account']['label'], $_SERVER["PHP_SELF"], "cs.fk_account,cs.periode", '', $param, '', $sortfield, $sortorder);
  540. $totalarray['nbfield']++;
  541. }
  542. if (!empty($arrayfields['cs.amount']['checked'])) {
  543. print_liste_field_titre($arrayfields['cs.amount']['label'], $_SERVER["PHP_SELF"], "cs.amount,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
  544. $totalarray['nbfield']++;
  545. }
  546. if (!empty($arrayfields['cs.paye']['checked'])) {
  547. print_liste_field_titre($arrayfields['cs.paye']['label'], $_SERVER["PHP_SELF"], "cs.paye,cs.periode", '', $param, 'class="right"', $sortfield, $sortorder);
  548. $totalarray['nbfield']++;
  549. }
  550. // Hook fields
  551. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray);
  552. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
  553. print $hookmanager->resPrint;
  554. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  555. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
  556. $totalarray['nbfield']++;
  557. }
  558. print '</tr>';
  559. // Loop on record
  560. // --------------------------------------------------------------------
  561. $i = 0;
  562. $savnbfield = $totalarray['nbfield'];
  563. $totalarray = array();
  564. $totalarray['nbfield'] = 0;
  565. $totalarray['val'] = array('totalttcfield'=>0);
  566. $imaxinloop = ($limit ? min($num, $limit) : $num);
  567. while ($i < $imaxinloop) {
  568. $obj = $db->fetch_object($resql);
  569. $chargesociale_static->id = $obj->rowid;
  570. $chargesociale_static->ref = $obj->rowid;
  571. $chargesociale_static->label = $obj->label;
  572. $chargesociale_static->type_label = $obj->type_label;
  573. $chargesociale_static->amount = $obj->amount;
  574. $chargesociale_static->paye = $obj->paye;
  575. $chargesociale_static->date_ech = $obj->date_ech;
  576. if (isModEnabled('project')) {
  577. $projectstatic->id = $obj->project_id;
  578. $projectstatic->ref = $obj->project_ref;
  579. $projectstatic->title = $obj->project_label;
  580. }
  581. if ($mode == 'kanban') {
  582. if ($i == 0) {
  583. print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
  584. print '<div class="box-flex-container kanban">';
  585. }
  586. // Output Kanban
  587. print $chargesociale_static->getKanbanView('', array('project'=> $projectstatic, 'selected' => in_array($chargesociale_static->id, $arrayofselected)));
  588. if ($i == ($imaxinloop - 1)) {
  589. print '</div>';
  590. print '</td></tr>';
  591. }
  592. } else {
  593. print '<tr class="oddeven">';
  594. // Action column
  595. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  596. print '<td class="center">';
  597. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  598. $selected = 0;
  599. if (in_array($chargesociale_static->id, $arrayofselected)) {
  600. $selected = 1;
  601. }
  602. print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
  603. }
  604. print '</td>';
  605. if (!$i) {
  606. $totalarray['nbfield']++;
  607. }
  608. }
  609. // Line number
  610. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER_IN_LIST')) {
  611. print '<td>'.(($offset * $limit) + $i).'</td>';
  612. if (!$i) {
  613. $totalarray['nbfield']++;
  614. }
  615. }
  616. // Ref
  617. if (!empty($arrayfields['cs.rowid']['checked'])) {
  618. print '<td>'.$chargesociale_static->getNomUrl(1, '20').'</td>';
  619. if (!$i) {
  620. $totalarray['nbfield']++;
  621. }
  622. }
  623. // Label
  624. if (!empty($arrayfields['cs.libelle']['checked'])) {
  625. print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->label).'">'.dol_escape_htmltag($obj->label).'</td>';
  626. if (!$i) {
  627. $totalarray['nbfield']++;
  628. }
  629. }
  630. // Type
  631. if (!empty($arrayfields['cs.fk_type']['checked'])) {
  632. $typelabeltoshow = $obj->type_label;
  633. $typelabelpopup = $obj->type_label;
  634. if (isModEnabled('accounting')) {
  635. $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code;
  636. }
  637. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($typelabelpopup).'">'.dol_escape_htmltag($typelabeltoshow).'</td>';
  638. if (!$i) {
  639. $totalarray['nbfield']++;
  640. }
  641. }
  642. // Date
  643. if (!empty($arrayfields['cs.date_ech']['checked'])) {
  644. print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_ech), 'day').'</td>';
  645. if (!$i) {
  646. $totalarray['nbfield']++;
  647. }
  648. }
  649. // Date end period
  650. if (!empty($arrayfields['cs.periode']['checked'])) {
  651. print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->periode), 'day').'</td>';
  652. if (!$i) {
  653. $totalarray['nbfield']++;
  654. }
  655. }
  656. // Project ref
  657. if (!empty($arrayfields['p.ref']['checked'])) {
  658. print '<td class="nowraponall">';
  659. if ($obj->project_id > 0) {
  660. print $projectstatic->getNomUrl(1);
  661. }
  662. print '</td>';
  663. if (!$i) {
  664. $totalarray['nbfield']++;
  665. }
  666. }
  667. if (!empty($arrayfields['cs.fk_user']['checked'])) {
  668. // Employee
  669. print '<td class="tdoverflowmax150">';
  670. if (!empty($obj->fk_user)) {
  671. if (!empty($TLoadedUsers[$obj->fk_user])) {
  672. $ustatic = $TLoadedUsers[$obj->fk_user];
  673. } else {
  674. $ustatic = new User($db);
  675. $ustatic->fetch($obj->fk_user);
  676. $TLoadedUsers[$obj->fk_user] = $ustatic;
  677. }
  678. print $ustatic->getNomUrl(-1);
  679. }
  680. print "</td>\n";
  681. if (!$i) {
  682. $totalarray['nbfield']++;
  683. }
  684. }
  685. // Type
  686. if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) {
  687. print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($langs->trans("PaymentTypeShort".$obj->payment_code)).'">';
  688. if (!empty($obj->payment_code)) {
  689. print $langs->trans("PaymentTypeShort".$obj->payment_code);
  690. }
  691. print '</td>';
  692. if (!$i) {
  693. $totalarray['nbfield']++;
  694. }
  695. }
  696. // Account
  697. if (!empty($arrayfields['cs.fk_account']['checked'])) {
  698. print '<td class="toverflowmax150">';
  699. if ($obj->fk_account > 0) {
  700. $bankstatic->id = $obj->fk_account;
  701. $bankstatic->ref = $obj->bref;
  702. $bankstatic->number = $obj->bnumber;
  703. $bankstatic->iban = $obj->iban;
  704. $bankstatic->bic = $obj->bic;
  705. $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code);
  706. $bankstatic->account_number = $obj->account_number;
  707. $bankstatic->clos = $obj->clos;
  708. //$accountingjournal->fetch($obj->fk_accountancy_journal);
  709. //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
  710. $bankstatic->label = $obj->blabel;
  711. print $bankstatic->getNomUrl(1);
  712. }
  713. print '</td>';
  714. if (!$i) {
  715. $totalarray['nbfield']++;
  716. }
  717. }
  718. // Amount
  719. if (!empty($arrayfields['cs.amount']['checked'])) {
  720. print '<td class="nowraponall amount right">'.price($obj->amount).'</td>';
  721. if (!$i) {
  722. $totalarray['nbfield']++;
  723. $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield';
  724. }
  725. $totalarray['val']['totalttcfield'] += $obj->amount;
  726. }
  727. // Status
  728. if (!empty($arrayfields['cs.paye']['checked'])) {
  729. print '<td class="nowraponall right">'.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'</td>';
  730. if (!$i) {
  731. $totalarray['nbfield']++;
  732. }
  733. }
  734. // Action column
  735. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  736. print '<td class="center">';
  737. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  738. $selected = 0;
  739. if (in_array($chargesociale_static->id, $arrayofselected)) {
  740. $selected = 1;
  741. }
  742. print '<input id="cb'.$chargesociale_static->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$chargesociale_static->id.'"'.($selected ? ' checked="checked"' : '').'>';
  743. }
  744. print '</td>';
  745. if (!$i) {
  746. $totalarray['nbfield']++;
  747. }
  748. }
  749. print '</tr>'."\n";
  750. }
  751. $i++;
  752. }
  753. // Show total line
  754. include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
  755. // If no record found
  756. if ($num == 0) {
  757. $colspan = 1;
  758. foreach ($arrayfields as $key => $val) {
  759. if (!empty($val['checked'])) {
  760. $colspan++;
  761. }
  762. }
  763. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  764. }
  765. $db->free($resql);
  766. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  767. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook
  768. print $hookmanager->resPrint;
  769. print '</table>'."\n";
  770. print '</div>'."\n";
  771. print '</form>'."\n";
  772. // End of page
  773. llxFooter();
  774. $db->close();