group_list.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  1. <?php
  2. /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2023 Szollősi László <szollosi.laszlo@smbinfo.hu>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file group_list.php
  20. * \ingroup settlements
  21. * \brief List page for group
  22. */
  23. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
  24. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
  25. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
  26. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs
  27. //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters
  28. //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters
  29. //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on).
  30. //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
  31. //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data
  32. //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu
  33. //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
  34. //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library
  35. //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too.
  36. //if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  37. //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value
  38. //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler
  39. //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message
  40. //if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies
  41. //if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
  42. //if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification
  43. //if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions
  44. // Load Dolibarr environment
  45. $res = 0;
  46. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  47. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  48. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
  49. }
  50. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  51. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
  52. $tmp2 = realpath(__FILE__);
  53. $i = strlen($tmp) - 1;
  54. $j = strlen($tmp2) - 1;
  55. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  56. $i--;
  57. $j--;
  58. }
  59. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) {
  60. $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
  61. }
  62. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) {
  63. $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
  64. }
  65. // Try main.inc.php using relative path
  66. if (!$res && file_exists("../main.inc.php")) {
  67. $res = @include "../main.inc.php";
  68. }
  69. if (!$res && file_exists("../../main.inc.php")) {
  70. $res = @include "../../main.inc.php";
  71. }
  72. if (!$res && file_exists("../../../main.inc.php")) {
  73. $res = @include "../../../main.inc.php";
  74. }
  75. if (!$res) {
  76. die("Include of main fails");
  77. }
  78. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
  79. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  80. require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
  81. // load settlements libraries
  82. require_once __DIR__ . '/class/group.class.php';
  83. // for other modules
  84. //dol_include_once('/othermodule/class/otherobject.class.php');
  85. // Load translation files required by the page
  86. $langs->loadLangs(array("settlements@settlements", "other"));
  87. $id = GETPOST('id', 'int');
  88. $ref = GETPOST('ref', 'alpha');
  89. $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
  90. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  91. $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
  92. $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
  93. $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
  94. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  95. $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)) . basename(__FILE__, '.php')); // To manage different context of search
  96. $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
  97. $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
  98. $mode = GETPOST('mode', 'aZ');
  99. // Load variable for pagination
  100. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  101. $sortfield = GETPOST('sortfield', 'aZ09comma');
  102. $sortorder = GETPOST('sortorder', 'aZ09comma');
  103. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  104. if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
  105. // If $page is not defined, or '' or -1 or if we click on clear filters
  106. $page = 0;
  107. }
  108. $offset = $limit * $page;
  109. $pageprev = $page - 1;
  110. $pagenext = $page + 1;
  111. // Initialize technical objects
  112. $object = new Group($db);
  113. $extrafields = new ExtraFields($db);
  114. $settlementsGroup = new Group($db);
  115. $diroutputmassaction = $conf->settlements->dir_output . '/temp/massgeneration/' . $user->id;
  116. $hookmanager->initHooks(array('grouplist')); // Note that conf->hooks_modules contains array
  117. // Fetch optionals attributes and labels
  118. $extrafields->fetch_name_optionals_label($object->table_element);
  119. //$extrafields->fetch_name_optionals_label($object->table_element_line);
  120. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  121. // Default sort order (if not yet defined by previous GETPOST)
  122. if (!$sortfield) {
  123. reset($object->fields); // Reset is required to avoid key() to return null.
  124. $sortfield = "t." . key($object->fields); // Set here default search field. By default 1st field in definition.
  125. }
  126. if (!$sortorder) {
  127. $sortorder = "ASC";
  128. }
  129. // Initialize array of search criterias
  130. $search_all = GETPOST('search_all', 'alphanohtml');
  131. $search = array();
  132. foreach ($object->fields as $key => $val) {
  133. if (GETPOST('search_' . $key, 'alpha') !== '') {
  134. $search[$key] = GETPOST('search_' . $key, 'alpha');
  135. }
  136. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  137. $search[$key . '_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_' . $key . '_dtstartmonth', 'int'), GETPOST('search_' . $key . '_dtstartday', 'int'), GETPOST('search_' . $key . '_dtstartyear', 'int'));
  138. $search[$key . '_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_' . $key . '_dtendmonth', 'int'), GETPOST('search_' . $key . '_dtendday', 'int'), GETPOST('search_' . $key . '_dtendyear', 'int'));
  139. }
  140. }
  141. // List of fields to search into when doing a "search in all"
  142. $fieldstosearchall = array();
  143. foreach ($object->fields as $key => $val) {
  144. if (!empty($val['searchall'])) {
  145. $fieldstosearchall['t.' . $key] = $val['label'];
  146. }
  147. }
  148. // Definition of array of fields for columns
  149. $arrayfields = array();
  150. foreach ($object->fields as $key => $val) {
  151. // If $val['visible']==0, then we never show the field
  152. if (!empty($val['visible'])) {
  153. $visible = (int) dol_eval($val['visible'], 1);
  154. $arrayfields['t.' . $key] = array(
  155. 'label' => $val['label'],
  156. 'checked' => (($visible < 0) ? 0 : 1),
  157. 'enabled' => (abs($visible) != 3 && dol_eval($val['enabled'], 1)),
  158. 'position' => $val['position'],
  159. 'help' => isset($val['help']) ? $val['help'] : ''
  160. );
  161. }
  162. }
  163. $entities = $settlementsGroup->getEntites();
  164. // Extra fields
  165. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php';
  166. $object->fields = dol_sort_array($object->fields, 'position');
  167. //$arrayfields['anotherfield'] = array('type'=>'integer', 'label'=>'AnotherField', 'checked'=>1, 'enabled'=>1, 'position'=>90, 'csslist'=>'right');
  168. $arrayfields = dol_sort_array($arrayfields, 'position');
  169. // There is several ways to check permission.
  170. // Set $enablepermissioncheck to 1 to enable a minimum low level of checks
  171. $enablepermissioncheck = 0;
  172. if ($enablepermissioncheck) {
  173. $permissiontoread = $user->rights->settlements->group->read;
  174. $permissiontoadd = $user->rights->settlements->group->write;
  175. $permissiontodelete = $user->rights->settlements->group->delete;
  176. } else {
  177. $permissiontoread = 1;
  178. $permissiontoadd = 1;
  179. $permissiontodelete = 1;
  180. }
  181. // Security check (enable the most restrictive one)
  182. if ($user->socid > 0)
  183. accessforbidden();
  184. //if ($user->socid > 0) accessforbidden();
  185. //$socid = 0; if ($user->socid > 0) $socid = $user->socid;
  186. //$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
  187. //restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
  188. if (empty($conf->settlements->enabled))
  189. accessforbidden('Module not enabled');
  190. if (!$permissiontoread)
  191. accessforbidden();
  192. /*
  193. * Actions
  194. */
  195. if (GETPOST('cancel', 'alpha')) {
  196. $action = 'list';
  197. $massaction = '';
  198. }
  199. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  200. $massaction = '';
  201. }
  202. $parameters = array();
  203. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  204. if ($reshook < 0) {
  205. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  206. }
  207. if (empty($reshook)) {
  208. // Selection of new fields
  209. include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
  210. // Purge search criteria
  211. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  212. foreach ($object->fields as $key => $val) {
  213. $search[$key] = '';
  214. if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  215. $search[$key . '_dtstart'] = '';
  216. $search[$key . '_dtend'] = '';
  217. }
  218. }
  219. $toselect = array();
  220. $search_array_options = array();
  221. }
  222. if (
  223. GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
  224. || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')
  225. ) {
  226. $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
  227. }
  228. // Mass actions
  229. $objectclass = 'Group';
  230. $objectlabel = 'Group';
  231. $uploaddir = $conf->settlements->dir_output;
  232. include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php';
  233. }
  234. /*
  235. * View
  236. */
  237. $form = new Form($db);
  238. $now = dol_now();
  239. $help_url = '';
  240. $title = $langs->trans("GroupList");
  241. $morejs = array();
  242. $morecss = array();
  243. // Build and execute select
  244. // --------------------------------------------------------------------
  245. $sql = 'SELECT ';
  246. $sql .= $object->getFieldList('t');
  247. // Add fields from extrafields
  248. if (!empty($extrafields->attributes[$object->table_element]['label'])) {
  249. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  250. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef." . $key . " as options_" . $key : '');
  251. }
  252. }
  253. // Add fields from hooks
  254. $parameters = array();
  255. $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
  256. $sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
  257. $sql = preg_replace('/,\s*$/', '', $sql);
  258. //$sql .= ", COUNT(rc.rowid) as anotherfield";
  259. $sql .= " FROM " . MAIN_DB_PREFIX . $object->table_element . " as t";
  260. //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."anothertable as rc ON rc.parent = t.rowid";
  261. if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  262. $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . $object->table_element . "_extrafields as ef on (t.rowid = ef.fk_object)";
  263. }
  264. // Add table from hooks
  265. $parameters = array();
  266. $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
  267. $sql .= $hookmanager->resPrint;
  268. if ($object->ismultientitymanaged == 1) {
  269. $sql .= " WHERE t.entity IN (" . getEntity($object->element) . ")";
  270. } else {
  271. $sql .= " WHERE 1 = 1";
  272. }
  273. foreach ($search as $key => $val) {
  274. if (array_key_exists($key, $object->fields)) {
  275. if ($key == 'status' && $search[$key] == -1) {
  276. continue;
  277. }
  278. $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
  279. if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
  280. if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
  281. $search[$key] = '';
  282. }
  283. $mode_search = 2;
  284. }
  285. if ($search[$key] != '') {
  286. if ($key == 'single_user_group' || $key == 'hotelgroup') {
  287. $sql .= natural_search("t." . $db->escape($key), $search[$key], 3);
  288. } else {
  289. $sql .= natural_search("t." . $db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search));
  290. }
  291. }
  292. } else {
  293. if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') {
  294. $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key);
  295. if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) {
  296. if (preg_match('/_dtstart$/', $key)) {
  297. $sql .= " AND t." . $db->escape($columnName) . " >= '" . $db->idate($search[$key]) . "'";
  298. }
  299. if (preg_match('/_dtend$/', $key)) {
  300. $sql .= " AND t." . $db->escape($columnName) . " <= '" . $db->idate($search[$key]) . "'";
  301. }
  302. }
  303. }
  304. }
  305. }
  306. if ($search_all) {
  307. $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
  308. }
  309. // Add where from extra fields
  310. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
  311. // Add where from hooks
  312. $parameters = array();
  313. $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
  314. $sql .= $hookmanager->resPrint;
  315. // Count total nb of records
  316. $nbtotalofrecords = '';
  317. if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
  318. $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
  319. $resql = $db->query($sqlforcount);
  320. if ($resql) {
  321. $objforcount = $db->fetch_object($resql);
  322. $nbtotalofrecords = $objforcount->nbtotalofrecords;
  323. } else {
  324. dol_print_error($db);
  325. }
  326. if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
  327. $page = 0;
  328. $offset = 0;
  329. }
  330. $db->free($resql);
  331. }
  332. // Complete request and execute it with limit
  333. $sql .= $db->order($sortfield, $sortorder);
  334. if ($limit) {
  335. $sql .= $db->plimit($limit + 1, $offset);
  336. }
  337. //print $sql;exit;
  338. $resql = $db->query($sql);
  339. if (!$resql) {
  340. dol_print_error($db);
  341. exit;
  342. }
  343. $num = $db->num_rows($resql);
  344. // Direct jump if only one record found
  345. if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
  346. $obj = $db->fetch_object($resql);
  347. $id = $obj->rowid;
  348. header("Location: " . dol_buildpath('/settlements/group_card.php', 1) . '?id=' . $id);
  349. exit;
  350. }
  351. // Output page
  352. // --------------------------------------------------------------------
  353. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist');
  354. $arrayofselected = is_array($toselect) ? $toselect : array();
  355. $param = '';
  356. if (!empty($mode)) {
  357. $param .= '&mode=' . urlencode($mode);
  358. }
  359. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  360. $param .= '&contextpage=' . urlencode($contextpage);
  361. }
  362. if ($limit > 0 && $limit != $conf->liste_limit) {
  363. $param .= '&limit=' . urlencode($limit);
  364. }
  365. foreach ($search as $key => $val) {
  366. if (is_array($search[$key])) {
  367. foreach ($search[$key] as $skey) {
  368. if ($skey != '') {
  369. $param .= '&search_' . $key . '[]=' . urlencode($skey);
  370. }
  371. }
  372. } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) {
  373. $param .= '&search_' . $key . 'month=' . ((int) GETPOST('search_' . $key . 'month', 'int'));
  374. $param .= '&search_' . $key . 'day=' . ((int) GETPOST('search_' . $key . 'day', 'int'));
  375. $param .= '&search_' . $key . 'year=' . ((int) GETPOST('search_' . $key . 'year', 'int'));
  376. } elseif ($search[$key] != '') {
  377. $param .= '&search_' . $key . '=' . urlencode($search[$key]);
  378. }
  379. }
  380. if ($optioncss != '') {
  381. $param .= '&optioncss=' . urlencode($optioncss);
  382. }
  383. // Add $param from extra fields
  384. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
  385. // Add $param from hooks
  386. $parameters = array();
  387. $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook
  388. $param .= $hookmanager->resPrint;
  389. // List of mass actions available
  390. $arrayofmassactions = array(
  391. //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"),
  392. //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
  393. //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
  394. //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
  395. );
  396. if (!empty($permissiontodelete)) {
  397. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"') . $langs->trans("Delete");
  398. }
  399. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
  400. $arrayofmassactions = array();
  401. }
  402. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  403. print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
  404. if ($optioncss != '') {
  405. print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
  406. }
  407. print '<input type="hidden" name="token" value="' . newToken() . '">';
  408. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  409. print '<input type="hidden" name="action" value="list">';
  410. print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
  411. print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
  412. print '<input type="hidden" name="page" value="' . $page . '">';
  413. print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';
  414. print '<input type="hidden" name="mode" value="' . $mode . '">';
  415. $newcardbutton = '';
  416. $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'));
  417. $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'));
  418. $newcardbutton .= dolGetButtonTitleSeparator();
  419. $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/settlements/group_card.php', 1) . '?action=create&backtopage=' . urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd);
  420. print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_' . $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
  421. // Add code for pre mass action (confirmation or email presend form)
  422. $topicmail = "SendGroupRef";
  423. $modelmail = "group";
  424. $objecttmp = new Group($db);
  425. $trackid = 'xxxx' . $object->id;
  426. include DOL_DOCUMENT_ROOT . '/core/tpl/massactions_pre.tpl.php';
  427. if ($search_all) {
  428. $setupstring = '';
  429. foreach ($fieldstosearchall as $key => $val) {
  430. $fieldstosearchall[$key] = $langs->trans($val);
  431. $setupstring .= $key . "=" . $val . ";";
  432. }
  433. print '<!-- Search done like if PRODUCT_QUICKSEARCH_ON_FIELDS = ' . $setupstring . ' -->' . "\n";
  434. print '<div class="divsearchfieldfilter">' . $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall) . '</div>' . "\n";
  435. }
  436. $moreforfilter = '';
  437. /*$moreforfilter.='<div class="divsearchfield">';
  438. $moreforfilter.= $langs->trans('MyFilter') . ': <input type="text" name="search_myfield" value="'.dol_escape_htmltag($search_myfield).'">';
  439. $moreforfilter.= '</div>';*/
  440. $parameters = array();
  441. $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  442. if (empty($reshook)) {
  443. $moreforfilter .= $hookmanager->resPrint;
  444. } else {
  445. $moreforfilter = $hookmanager->resPrint;
  446. }
  447. if (!empty($moreforfilter)) {
  448. print '<div class="liste_titre liste_titre_bydiv centpercent">';
  449. print $moreforfilter;
  450. print '</div>';
  451. }
  452. $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
  453. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields
  454. $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
  455. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  456. print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
  457. // Fields title search
  458. // --------------------------------------------------------------------
  459. print '<tr class="liste_titre">';
  460. // Action column
  461. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  462. print '<td class="liste_titre maxwidthsearch">';
  463. $searchpicto = $form->showFilterButtons('left');
  464. print $searchpicto;
  465. print '</td>';
  466. }
  467. foreach ($object->fields as $key => $val) {
  468. $searchkey = empty($search[$key]) ? '' : $search[$key];
  469. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  470. if ($key == 'status') {
  471. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  472. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  473. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  474. } elseif (in_array($val['type'], array('timestamp'))) {
  475. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  476. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  477. $cssforfield .= ($cssforfield ? ' ' : '') . 'left';
  478. }
  479. if (!empty($arrayfields['t.' . $key]['checked'])) {
  480. print '<td class="liste_titre' . ($cssforfield ? ' ' . $cssforfield : '') . '">';
  481. if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
  482. print $form->selectarray('search_' . $key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
  483. } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) {
  484. print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield . ' maxwidth250', 1);
  485. } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
  486. print '<div class="nowrap">';
  487. print $form->selectDate($search[$key . '_dtstart'] ? $search[$key . '_dtstart'] : '', "search_" . $key . "_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
  488. print '</div>';
  489. print '<div class="nowrap">';
  490. print $form->selectDate($search[$key . '_dtend'] ? $search[$key . '_dtend'] : '', "search_" . $key . "_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
  491. print '</div>';
  492. } elseif ($key == 'lang') {
  493. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
  494. $formadmin = new FormAdmin($db);
  495. print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2);
  496. } else {
  497. if ($key == 'fk_entity') {
  498. print '
  499. <select id="search_fk_entity" class="flat minwidth100imp --success select2-hidden-accessible" name="search_fk_entity" data-select2-id="search_fk_entity" tabindex="-1" aria-hidden="true">
  500. <option value="" data-select2-id="100">&nbsp;</option>';
  501. foreach ($entities as $keyEnt => $valueEnt) {
  502. $selected = $keyEnt == $search[$key] ? 'selected' : '';
  503. print '<option value="' . $keyEnt . '"' . $selected . '>' . $valueEnt . '</option>';
  504. }
  505. print '</select>';
  506. } elseif ($key == 'single_user_group') {
  507. print '<select id="search_single_user_group" class="flat minwidth100imp --success select2-hidden-accessible" name="search_single_user_group" data-select2-id="search_single_user_group" tabindex="-1" aria-hidden="true">
  508. <option value="" data-select2-id="100">&nbsp;</option>';
  509. $selected2 = $search[$key] ? 'selected' : '';
  510. print '<option value="1"' . $selected2 . '>Yes</option>';
  511. print '</select>';
  512. } elseif ($key == 'hotelgroup') {
  513. print '<select id="search_hotelgroup" class="flat minwidth100imp --success select2-hidden-accessible" name="search_hotelgroup" data-select2-id="search_hotelgroup" tabindex="-1" aria-hidden="true">
  514. <option value="" data-select2-id="100">&nbsp;</option>';
  515. $selected2 = $search[$key] ? 'selected' : '';
  516. print '<option value="1"' . $selected2 . '>Yes</option>';
  517. print '</select>';
  518. } else {
  519. print '<input type="text" class="flat maxwidth75" name="search_' . $key . '" value="' . dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '') . '">';
  520. }
  521. }
  522. print '</td>';
  523. }
  524. }
  525. // Extra fields
  526. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
  527. // Fields from hook
  528. $parameters = array('arrayfields' => $arrayfields);
  529. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
  530. print $hookmanager->resPrint;
  531. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  532. print '<td class="liste_titre"></td>';
  533. }*/
  534. // Action column
  535. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  536. print '<td class="liste_titre maxwidthsearch">';
  537. $searchpicto = $form->showFilterButtons();
  538. print $searchpicto;
  539. print '</td>';
  540. }
  541. print '</tr>' . "\n";
  542. $totalarray = array();
  543. $totalarray['nbfield'] = 0;
  544. // Fields title label
  545. // --------------------------------------------------------------------
  546. print '<tr class="liste_titre">';
  547. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  548. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
  549. }
  550. foreach ($object->fields as $key => $val) {
  551. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  552. if ($key == 'status') {
  553. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  554. } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  555. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  556. } elseif (in_array($val['type'], array('timestamp'))) {
  557. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  558. } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) {
  559. $cssforfield .= ($cssforfield ? ' ' : '') . 'left';
  560. }
  561. $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label
  562. if (!empty($arrayfields['t.' . $key]['checked'])) {
  563. print getTitleFieldOfList($arrayfields['t.' . $key]['label'], 0, $_SERVER['PHP_SELF'], 't.' . $key, '', $param, ($cssforfield ? 'class="' . $cssforfield . '"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield . ' ' : '')) . "\n";
  564. $totalarray['nbfield']++;
  565. }
  566. }
  567. // Extra fields
  568. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
  569. // Hook fields
  570. $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray);
  571. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  572. print $hookmanager->resPrint;
  573. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  574. print '<th class="liste_titre right">'.$langs->trans("AnotherField").'</th>';
  575. $totalarray['nbfield']++;
  576. }*/
  577. // Action column
  578. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  579. print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ') . "\n";
  580. }
  581. $totalarray['nbfield']++;
  582. print '</tr>' . "\n";
  583. // Detect if we need a fetch on each output line
  584. $needToFetchEachLine = 0;
  585. if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
  586. foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
  587. if (preg_match('/\$object/', $val)) {
  588. $needToFetchEachLine++; // There is at least one compute field that use $object
  589. }
  590. }
  591. }
  592. // Loop on record
  593. // --------------------------------------------------------------------
  594. $i = 0;
  595. $savnbfield = $totalarray['nbfield'];
  596. $totalarray = array();
  597. $totalarray['nbfield'] = 0;
  598. $imaxinloop = ($limit ? min($num, $limit) : $num);
  599. while ($i < $imaxinloop) {
  600. $obj = $db->fetch_object($resql);
  601. if (empty($obj)) {
  602. break; // Should not happen
  603. }
  604. // Store properties in $object
  605. $object->setVarsFromFetchObj($obj);
  606. if ($mode == 'kanban') {
  607. if ($i == 0) {
  608. print '<tr><td colspan="' . $savnbfield . '">';
  609. print '<div class="box-flex-container">';
  610. }
  611. // Output Kanban
  612. print $object->getKanbanView('');
  613. if ($i == ($imaxinloop - 1)) {
  614. print '</div>';
  615. print '</td></tr>';
  616. }
  617. } else {
  618. // Show here line of result
  619. $j = 0;
  620. print '<tr data-rowid="' . $object->id . '" class="oddeven">';
  621. // Action column
  622. if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  623. print '<td class="nowrap center">';
  624. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  625. $selected = 0;
  626. if (in_array($object->id, $arrayofselected)) {
  627. $selected = 1;
  628. }
  629. print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
  630. }
  631. print '</td>';
  632. }
  633. foreach ($object->fields as $key => $val) {
  634. $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']);
  635. if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
  636. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  637. } elseif ($key == 'status') {
  638. $cssforfield .= ($cssforfield ? ' ' : '') . 'center';
  639. }
  640. if (in_array($val['type'], array('timestamp'))) {
  641. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  642. } elseif ($key == 'ref') {
  643. $cssforfield .= ($cssforfield ? ' ' : '') . 'nowrap';
  644. }
  645. if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) {
  646. $cssforfield .= ($cssforfield ? ' ' : '') . 'left';
  647. }
  648. //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100';
  649. if (!empty($arrayfields['t.' . $key]['checked'])) {
  650. print '<td' . ($cssforfield ? ' class="' . $cssforfield . '"' : '');
  651. if (preg_match('/tdoverflow/', $cssforfield)) {
  652. print ' title="' . dol_escape_htmltag($object->$key) . '"';
  653. }
  654. print '>';
  655. if ($key == 'status') {
  656. print $object->getLibStatut(5);
  657. } elseif ($key == 'rowid') {
  658. print $object->showOutputField($val, $key, $object->id, '');
  659. } elseif ($key == 'fk_entity') {
  660. $contentOfFkEntity = $object->showOutputField($val, $key, $object->$key, '');
  661. print $entities[$contentOfFkEntity];
  662. } else {
  663. print $object->showOutputField($val, $key, $object->$key, '');
  664. }
  665. print '</td>';
  666. if (!$i) {
  667. $totalarray['nbfield']++;
  668. }
  669. if (!empty($val['isameasure']) && $val['isameasure'] == 1) {
  670. if (!$i) {
  671. $totalarray['pos'][$totalarray['nbfield']] = 't.' . $key;
  672. }
  673. if (!isset($totalarray['val'])) {
  674. $totalarray['val'] = array();
  675. }
  676. if (!isset($totalarray['val']['t.' . $key])) {
  677. $totalarray['val']['t.' . $key] = 0;
  678. }
  679. $totalarray['val']['t.' . $key] += $object->$key;
  680. }
  681. }
  682. }
  683. // Extra fields
  684. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php';
  685. // Fields from hook
  686. $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray);
  687. $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
  688. print $hookmanager->resPrint;
  689. /*if (!empty($arrayfields['anotherfield']['checked'])) {
  690. print '<td class="right">'.$obj->anotherfield.'</td>';
  691. }*/
  692. // Action column
  693. if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) {
  694. print '<td class="nowrap center">';
  695. if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
  696. $selected = 0;
  697. if (in_array($object->id, $arrayofselected)) {
  698. $selected = 1;
  699. }
  700. print '<input id="cb' . $object->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $object->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
  701. }
  702. print '</td>';
  703. }
  704. if (!$i) {
  705. $totalarray['nbfield']++;
  706. }
  707. print '</tr>' . "\n";
  708. }
  709. $i++;
  710. }
  711. // Show total line
  712. include DOL_DOCUMENT_ROOT . '/core/tpl/list_print_total.tpl.php';
  713. // If no record found
  714. if ($num == 0) {
  715. $colspan = 1;
  716. foreach ($arrayfields as $key => $val) {
  717. if (!empty($val['checked'])) {
  718. $colspan++;
  719. }
  720. }
  721. print '<tr><td colspan="' . $colspan . '"><span class="opacitymedium">' . $langs->trans("NoRecordFound") . '</span></td></tr>';
  722. }
  723. $db->free($resql);
  724. $parameters = array('arrayfields' => $arrayfields, 'sql' => $sql);
  725. $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  726. print $hookmanager->resPrint;
  727. print '</table>' . "\n";
  728. print '</div>' . "\n";
  729. print '</form>' . "\n";
  730. if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
  731. $hidegeneratedfilelistifempty = 1;
  732. if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
  733. $hidegeneratedfilelistifempty = 0;
  734. }
  735. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  736. $formfile = new FormFile($db);
  737. // Show list of available documents
  738. $urlsource = $_SERVER['PHP_SELF'] . '?sortfield=' . $sortfield . '&sortorder=' . $sortorder;
  739. $urlsource .= str_replace('&amp;', '&', $param);
  740. $filedir = $diroutputmassaction;
  741. $genallowed = $permissiontoread;
  742. $delallowed = $permissiontoadd;
  743. print $formfile->showdocuments('massfilesarea_settlements', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
  744. }
  745. // End of page
  746. llxFooter();
  747. $db->close();
  748. ?>
  749. <script>
  750. $(document).ready(function () {
  751. function initializeSelect2(elementId) {
  752. $('#' + elementId).select2({
  753. dir: 'ltr',
  754. width: 'resolve',
  755. minimumInputLength: 0,
  756. language: select2arrayoflanguage,
  757. containerCssClass: ':all:',
  758. selectionCssClass: ':all:',
  759. templateResult: function (data, container) {
  760. if (data.element) {
  761. $(container).addClass($(data.element).attr("class"));
  762. }
  763. if (data.id == -1 && $(data.element).attr("data-html") == undefined) {
  764. return '&nbsp;';
  765. }
  766. if ($(data.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(data.element).attr("data-html"));
  767. return data.text;
  768. },
  769. templateSelection: function (selection) {
  770. if (selection.id == -1) return '<span class="placeholder">' + selection.text + '</span>';
  771. return selection.text;
  772. },
  773. escapeMarkup: function (markup) {
  774. return markup;
  775. },
  776. dropdownCssClass: 'ui-dialog'
  777. });
  778. }
  779. initializeSelect2('search_fk_entity');
  780. initializeSelect2('search_hotelgroup');
  781. initializeSelect2('search_single_user_group');
  782. });
  783. </script>";