subaccount.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <?php
  2. /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2024 Alexandre Spangaro <aspangaro@easya.solutions>
  4. * Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/accountancy/admin/subaccount.php
  21. * \ingroup Accountancy (Double entries)
  22. * \brief List of accounting sub-account (auxiliary accounts)
  23. */
  24. // Load Dolibarr environment
  25. require '../../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("accountancy", "admin", "bills", "compta", "errors", "hrm", "salaries"));
  30. $mesg = '';
  31. $action = GETPOST('action', 'aZ09');
  32. $cancel = GETPOST('cancel', 'alpha');
  33. $id = GETPOST('id', 'int');
  34. $rowid = GETPOST('rowid', 'int');
  35. $massaction = GETPOST('massaction', 'aZ09');
  36. $optioncss = GETPOST('optioncss', 'alpha');
  37. $mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...)
  38. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'accountingsubaccountlist'; // To manage different context of search
  39. $search_subaccount = GETPOST('search_subaccount', 'alpha');
  40. $search_label = GETPOST('search_label', 'alpha');
  41. $search_type = GETPOST('search_type', 'int');
  42. // Security check
  43. if ($user->socid > 0) {
  44. accessforbidden();
  45. }
  46. if (!$user->hasRight('accounting', 'chartofaccount')) {
  47. accessforbidden();
  48. }
  49. // Load variable for pagination
  50. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  51. $sortfield = GETPOST('sortfield', 'aZ09comma');
  52. $sortorder = GETPOST('sortorder', 'aZ09comma');
  53. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  54. if (empty($page) || $page == -1) {
  55. $page = 0;
  56. } // If $page is not defined, or '' or -1
  57. $offset = $limit * $page;
  58. $pageprev = $page - 1;
  59. $pagenext = $page + 1;
  60. if (!$sortfield) {
  61. $sortfield = "label";
  62. }
  63. if (!$sortorder) {
  64. $sortorder = "ASC";
  65. }
  66. $arrayfields = array(
  67. 'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
  68. 'label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
  69. 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
  70. 'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1)
  71. );
  72. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
  73. unset($arrayfields['reconcilable']);
  74. }
  75. /*
  76. * Actions
  77. */
  78. if (GETPOST('cancel', 'alpha')) {
  79. $action = 'list';
  80. $massaction = '';
  81. }
  82. if (!GETPOST('confirmmassaction', 'alpha')) {
  83. $massaction = '';
  84. }
  85. $parameters = array();
  86. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  87. if ($reshook < 0) {
  88. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  89. }
  90. if (empty($reshook)) {
  91. if (!empty($cancel)) {
  92. $action = '';
  93. }
  94. include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  95. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
  96. $search_subaccount = "";
  97. $search_label = "";
  98. $search_type = "";
  99. $search_array_options = array();
  100. }
  101. }
  102. /*
  103. * View
  104. */
  105. $form = new Form($db);
  106. // Page Header
  107. $help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
  108. $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
  109. llxHeader('', $title, $help_url);
  110. // Customer
  111. $sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature";
  112. $sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
  113. $sql .= " WHERE sa.entity IN (".getEntity('societe').")";
  114. $sql .= " AND sa.code_compta <> ''";
  115. //print $sql;
  116. if (strlen(trim($search_subaccount))) {
  117. $lengthpaddingaccount = 0;
  118. if (getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
  119. $lengthpaddingaccount = getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT');
  120. }
  121. $search_subaccount_tmp = $search_subaccount;
  122. $weremovedsomezero = 0;
  123. if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
  124. for ($i = 0; $i < $lengthpaddingaccount; $i++) {
  125. if (preg_match('/0$/', $search_subaccount_tmp)) {
  126. $weremovedsomezero++;
  127. $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
  128. }
  129. }
  130. }
  131. //var_dump($search_subaccount); exit;
  132. if ($search_subaccount_tmp) {
  133. if ($weremovedsomezero) {
  134. $search_subaccount_tmp_clean = $search_subaccount_tmp;
  135. $search_subaccount_clean = $search_subaccount;
  136. $startchar = '%';
  137. if (strpos($search_subaccount_tmp, '^') === 0) {
  138. $startchar = '';
  139. $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
  140. $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
  141. }
  142. $sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
  143. $sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
  144. } else {
  145. $sql .= natural_search("sa.code_compta", $search_subaccount_tmp);
  146. }
  147. }
  148. }
  149. if (strlen(trim($search_label))) {
  150. $sql .= natural_search("sa.nom", $search_label);
  151. }
  152. if (!empty($search_type) && $search_type >= 0) {
  153. $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
  154. }
  155. // Supplier
  156. $sql .= " UNION ";
  157. $sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, '0' as nature FROM ".MAIN_DB_PREFIX."societe sa";
  158. $sql .= " WHERE sa.entity IN (".getEntity('societe').")";
  159. $sql .= " AND sa.code_compta_fournisseur <> ''";
  160. //print $sql;
  161. if (strlen(trim($search_subaccount))) {
  162. $lengthpaddingaccount = 0;
  163. if (getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
  164. $lengthpaddingaccount = getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT');
  165. }
  166. $search_subaccount_tmp = $search_subaccount;
  167. $weremovedsomezero = 0;
  168. if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
  169. for ($i = 0; $i < $lengthpaddingaccount; $i++) {
  170. if (preg_match('/0$/', $search_subaccount_tmp)) {
  171. $weremovedsomezero++;
  172. $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
  173. }
  174. }
  175. }
  176. //var_dump($search_subaccount); exit;
  177. if ($search_subaccount_tmp) {
  178. if ($weremovedsomezero) {
  179. $search_subaccount_tmp_clean = $search_subaccount_tmp;
  180. $search_subaccount_clean = $search_subaccount;
  181. $startchar = '%';
  182. if (strpos($search_subaccount_tmp, '^') === 0) {
  183. $startchar = '';
  184. $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
  185. $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
  186. }
  187. $sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
  188. $sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
  189. } else {
  190. $sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp);
  191. }
  192. }
  193. }
  194. if (strlen(trim($search_label))) {
  195. $sql .= natural_search("sa.nom", $search_label);
  196. }
  197. if (!empty($search_type) && $search_type >= 0) {
  198. $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
  199. }
  200. // User - Employee
  201. $sql .= " UNION ";
  202. $sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature FROM ".MAIN_DB_PREFIX."user u";
  203. $sql .= " WHERE u.entity IN (".getEntity('user').")";
  204. $sql .= " AND u.accountancy_code <> ''";
  205. //print $sql;
  206. if (strlen(trim($search_subaccount))) {
  207. $lengthpaddingaccount = 0;
  208. if (getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT')) {
  209. $lengthpaddingaccount = getDolGlobalInt('ACCOUNTING_LENGTH_AACCOUNT');
  210. }
  211. $search_subaccount_tmp = $search_subaccount;
  212. $weremovedsomezero = 0;
  213. if (strlen($search_subaccount_tmp) <= $lengthpaddingaccount) {
  214. for ($i = 0; $i < $lengthpaddingaccount; $i++) {
  215. if (preg_match('/0$/', $search_subaccount_tmp)) {
  216. $weremovedsomezero++;
  217. $search_subaccount_tmp = preg_replace('/0$/', '', $search_subaccount_tmp);
  218. }
  219. }
  220. }
  221. //var_dump($search_subaccount); exit;
  222. if ($search_subaccount_tmp) {
  223. if ($weremovedsomezero) {
  224. $search_subaccount_tmp_clean = $search_subaccount_tmp;
  225. $search_subaccount_clean = $search_subaccount;
  226. $startchar = '%';
  227. if (strpos($search_subaccount_tmp, '^') === 0) {
  228. $startchar = '';
  229. $search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
  230. $search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
  231. }
  232. $sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
  233. $sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
  234. } else {
  235. $sql .= natural_search("u.accountancy_code", $search_subaccount_tmp);
  236. }
  237. }
  238. }
  239. if (strlen(trim($search_label))) {
  240. $sql .= natural_search("u.lastname", $search_label);
  241. }
  242. if (!empty($search_type) && $search_type >= 0) {
  243. $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
  244. }
  245. $sql .= $db->order($sortfield, $sortorder);
  246. // Count total nb of records
  247. $nbtotalofrecords = '';
  248. if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
  249. $resql = $db->query($sql);
  250. $nbtotalofrecords = $db->num_rows($resql);
  251. if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
  252. $page = 0;
  253. $offset = 0;
  254. }
  255. }
  256. $sql .= $db->plimit($limit + 1, $offset);
  257. dol_syslog('accountancy/admin/subaccount.php:: $sql='.$sql);
  258. $resql = $db->query($sql);
  259. if ($resql) {
  260. $num = $db->num_rows($resql);
  261. $param = '';
  262. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  263. $param .= '&contextpage='.urlencode($contextpage);
  264. }
  265. if ($limit > 0 && $limit != $conf->liste_limit) {
  266. $param .= '&limit='.((int) $limit);
  267. }
  268. if ($search_subaccount) {
  269. $param .= '&search_subaccount='.urlencode($search_subaccount);
  270. }
  271. if ($search_label) {
  272. $param .= '&search_label='.urlencode($search_label);
  273. }
  274. if ($optioncss != '') {
  275. $param .= '&optioncss='.urlencode($optioncss);
  276. }
  277. // List of mass actions available
  278. $arrayofmassactions = array();
  279. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  280. if ($optioncss != '') {
  281. print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  282. }
  283. print '<input type="hidden" name="token" value="'.newToken().'">';
  284. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  285. print '<input type="hidden" name="action" value="list">';
  286. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  287. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  288. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  289. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
  290. print '<div class="info">'.$langs->trans("WarningCreateSubAccounts").'</div>';
  291. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  292. $selectedfields = ($mode != 'kanban' ? $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')) : ''); // This also change content of $arrayfields
  293. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  294. $moreforfilter = '';
  295. $massactionbutton = '';
  296. print '<div class="div-table-responsive">';
  297. print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
  298. // Line for search fields
  299. print '<tr class="liste_titre_filter">';
  300. // Action column
  301. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  302. print '<td class="liste_titre center maxwidthsearch">';
  303. $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
  304. print $searchpicto;
  305. print '</td>';
  306. }
  307. if (!empty($arrayfields['subaccount']['checked'])) {
  308. print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>';
  309. }
  310. if (!empty($arrayfields['label']['checked'])) {
  311. print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
  312. }
  313. if (!empty($arrayfields['type']['checked'])) {
  314. print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
  315. }
  316. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
  317. if (!empty($arrayfields['reconcilable']['checked'])) {
  318. print '<td class="liste_titre">&nbsp;</td>';
  319. }
  320. }
  321. // Action column
  322. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  323. print '<td class="liste_titre maxwidthsearch">';
  324. $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
  325. print $searchpicto;
  326. print '</td>';
  327. }
  328. print '</tr>';
  329. print '<tr class="liste_titre">';
  330. // Action column
  331. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  332. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  333. }
  334. if (!empty($arrayfields['subaccount']['checked'])) {
  335. print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
  336. }
  337. if (!empty($arrayfields['label']['checked'])) {
  338. print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
  339. }
  340. if (!empty($arrayfields['type']['checked'])) {
  341. print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
  342. }
  343. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
  344. if (!empty($arrayfields['reconcilable']['checked'])) {
  345. print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center ');
  346. }
  347. }
  348. // Action column
  349. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  350. print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
  351. }
  352. print "</tr>\n";
  353. $totalarray = array();
  354. $totalarray['nbfield'] = 0;
  355. $i = 0;
  356. while ($i < min($num, $limit)) {
  357. $obj = $db->fetch_object($resql);
  358. print '<tr class="oddeven">';
  359. // Action column
  360. if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  361. print '<td class="center">';
  362. $e = '';
  363. // Customer
  364. if ($obj->type == 1) {
  365. $e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
  366. } elseif ($obj->type == 2) {
  367. // Supplier
  368. $e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
  369. } elseif ($obj->type == 3) {
  370. // User - Employee
  371. $e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
  372. }
  373. print $e;
  374. print '</td>'."\n";
  375. if (!$i) {
  376. $totalarray['nbfield']++;
  377. }
  378. }
  379. // Account number
  380. if (!empty($arrayfields['subaccount']['checked'])) {
  381. print "<td>";
  382. print length_accounta($obj->subaccount);
  383. print "</td>\n";
  384. if (!$i) {
  385. $totalarray['nbfield']++;
  386. }
  387. }
  388. // Subaccount label
  389. if (!empty($arrayfields['label']['checked'])) {
  390. print "<td>";
  391. print dol_escape_htmltag($obj->label);
  392. print "</td>\n";
  393. if (!$i) {
  394. $totalarray['nbfield']++;
  395. }
  396. }
  397. // Type
  398. if (!empty($arrayfields['type']['checked'])) {
  399. print '<td class="center">';
  400. $s = '';
  401. // Customer
  402. if ($obj->type == 1) {
  403. $s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>';
  404. } elseif ($obj->type == 2) {
  405. // Supplier
  406. $s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
  407. } elseif ($obj->type == 3) {
  408. // User - Employee
  409. $s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->rowid.'">'.$langs->trans("Employee").'</a>';
  410. }
  411. print $s;
  412. if ($obj->nature == 2) {
  413. print ' <span class="warning bold">('.$langs->trans("Prospect").')</span>';
  414. }
  415. print '</td>';
  416. if (!$i) {
  417. $totalarray['nbfield']++;
  418. }
  419. }
  420. if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
  421. // Activated or not reconciliation on accounting account
  422. if (!empty($arrayfields['reconcilable']['checked'])) {
  423. print '<td class="center">';
  424. if (empty($obj->reconcilable)) {
  425. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&token='.newToken().'">';
  426. print img_picto($langs->trans("Disabled"), 'switch_off');
  427. print '</a>';
  428. } else {
  429. print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&token='.newToken().'">';
  430. print img_picto($langs->trans("Activated"), 'switch_on');
  431. print '</a>';
  432. }
  433. print '</td>';
  434. if (!$i) {
  435. $totalarray['nbfield']++;
  436. }
  437. }
  438. }
  439. // Action column
  440. if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
  441. print '<td class="center">';
  442. $e = '';
  443. // Customer
  444. if ($obj->type == 1) {
  445. $e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
  446. } elseif ($obj->type == 2) {
  447. // Supplier
  448. $e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&token='.newToken().'&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
  449. } elseif ($obj->type == 3) {
  450. // User - Employee
  451. $e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
  452. }
  453. print $e;
  454. print '</td>'."\n";
  455. if (!$i) {
  456. $totalarray['nbfield']++;
  457. }
  458. }
  459. print '</tr>'."\n";
  460. $i++;
  461. }
  462. // If no record found
  463. if ($num == 0) {
  464. $colspan = 1;
  465. foreach ($arrayfields as $key => $val) {
  466. if (!empty($val['checked'])) {
  467. $colspan++;
  468. }
  469. }
  470. print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
  471. }
  472. $db->free($resql);
  473. $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
  474. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
  475. print $hookmanager->resPrint;
  476. print "</table>";
  477. print "</div>";
  478. print '</form>';
  479. } else {
  480. dol_print_error($db);
  481. }
  482. // End of page
  483. llxFooter();
  484. $db->close();