settlementshotelgroupindex.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file settlements/settlementsindex.php
  22. * \ingroup settlements
  23. * \brief Home page of settlements top menu
  24. */
  25. // Load Dolibarr environment
  26. $res = 0;
  27. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  28. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  29. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
  30. }
  31. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  32. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
  33. $tmp2 = realpath(__FILE__);
  34. $i = strlen($tmp) - 1;
  35. $j = strlen($tmp2) - 1;
  36. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  37. $i--;
  38. $j--;
  39. }
  40. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) {
  41. $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
  42. }
  43. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) {
  44. $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
  45. }
  46. // Try main.inc.php using relative path
  47. if (!$res && file_exists("../main.inc.php")) {
  48. $res = @include "../main.inc.php";
  49. }
  50. if (!$res && file_exists("../../main.inc.php")) {
  51. $res = @include "../../main.inc.php";
  52. }
  53. if (!$res && file_exists("../../../main.inc.php")) {
  54. $res = @include "../../../main.inc.php";
  55. }
  56. if (!$res) {
  57. die("Include of main fails");
  58. }
  59. use Luracast\Restler\RestException;
  60. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  61. require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php';
  62. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/groupusers.class.php';
  63. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/usernaplo.class.php';
  64. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/clearallusernaplo.class.php';
  65. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/helper.class.php';
  66. //print_r($_REQUEST);
  67. // Load translation files required by the page
  68. $langs->loadLangs(array("settlements@settlements"));
  69. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  70. $massactionadd = GETPOST('massactionadd', 'alpha'); // The bulk action (combo box choice into lists)
  71. $action = GETPOST('action', 'aZ09');
  72. $cancel = GETPOST('cancel', 'int');
  73. $id = GETPOST('id', 'int');
  74. $idmenu = GETPOST('idmenu', 'int');
  75. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  76. $toselectnewuser = GETPOST('toselectnewuser', 'array'); // Array of ids of elements selected into a list
  77. $search_title = GETPOST('search_title', 'alpha');
  78. $confirmbutton = GETPOST('confirmbutton', 'int');
  79. $userclearall = GETPOST('userclearall', 'int');
  80. $deleteall = GETPOST('deleteall', 'int');
  81. // Security check
  82. // if (! $user->rights->settlements->myobject->read) {
  83. // accessforbidden();
  84. // }
  85. if ($deleteall) {
  86. unset($_SESSION['usersArray']);
  87. }
  88. $socid = GETPOST('socid', 'int');
  89. if (isset($user->socid) && $user->socid > 0) {
  90. $action = '';
  91. $socid = $user->socid;
  92. }
  93. $max = 5;
  94. $now = dol_now();
  95. $form = new Form($db);
  96. $formfile = new FormFile($db);
  97. $userNaplo = new UserNaplo($db);
  98. $clearAllUserNaplo = new ClearAllUserNaplo($db);
  99. $groupUsers = new GroupUsers($db);
  100. $helper = new Helper($db);
  101. $entities = $helper->getAllEntities();
  102. $entitiesArray = [];
  103. $selectedEntities = '';
  104. $entitiesArrayIsEmpty = true;
  105. foreach ($entities as $key => $value) {
  106. $val = GETPOST('entity_' . $key, 'int');
  107. $entitiesArray[$key] = $val;
  108. if ($val != '') {
  109. $entitiesArrayIsEmpty = false;
  110. }
  111. }
  112. $selectedEntities = $helper->getEntities($entitiesArrayIsEmpty, $entities, $entitiesArray);
  113. $groups = $helper->getHotelGroupsFromGroupClass($db, $selectedEntities);
  114. if (empty($id) || $id == 0) {
  115. foreach ($groups as $key => $val) {
  116. $keys[] = $key;
  117. }
  118. unset($_SESSION['usersArray']);
  119. $id = $keys[0];
  120. }
  121. if ($massaction == 'delete') {
  122. $groupusers = new GroupUsers($db);
  123. foreach ($toselect as $userId) {
  124. $moredata = explode('_', $userId);
  125. $groupusers->deleteLine($user, $moredata[0]);
  126. $data = $helper->createDataArray($id, $massaction, $moredata[1]);
  127. $userNaplo->createUserNaplo($user, $data);
  128. dol_syslog("A {$userId} szamu felhasznalo torlesre kerult.", LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERR);
  129. }
  130. setEventMessage($langs->trans("usersdeleted"), 'errors');
  131. unset($_SESSION['usersArray']);
  132. }
  133. if ($massactionadd == 'add') {
  134. $usersOfGroups = $helper->getUsersById($db, $id);
  135. $usersOfGroupsFromNaploToday = $helper->getUsersOfGroupsFromNaploToday($db, $id);
  136. $confirmed = !empty($usersOfGroupsFromNaploToday) && !empty($usersOfGroups);
  137. $db->begin();
  138. $error = 0;
  139. $userObj = new User($db);
  140. $groupObj = new Group($db);
  141. $groupResult = $groupObj->fetch($id);
  142. $groupEntity = $groupObj->fk_entity;
  143. foreach ($_SESSION['usersArray'] as $newuser) {
  144. //print $newuser . '<br>';
  145. $createResult = $groupUsers->createGroupUsers($id, $newuser);
  146. if ($createResult < 0) {
  147. $error++;
  148. }
  149. $data = $helper->createDataArray($id, $massactionadd, $newuser);
  150. $naploResult = $userNaplo->createUserNaplo($user, $data);
  151. if ($naploResult < 0) {
  152. $error++;
  153. }
  154. $userUpdateResult = $helper->updateUserEntityInUser($newuser, $groupEntity);
  155. if ($userUpdateResult < 0) {
  156. $error++;
  157. }
  158. }
  159. if ($error) {
  160. $db->rollback();
  161. unset($_SESSION['usersArray']);
  162. setEventMessage($langs->trans("PackageUserFailed", 'error'));
  163. } else {
  164. $db->commit();
  165. unset($_SESSION['usersArray']);
  166. $helper->returnWindowLocation($_SERVER["PHP_SELF"], $id, $idmenu);
  167. //setEventMessage($langs->trans("useradded"));
  168. }
  169. unset($_SESSION['usersArray']);
  170. }
  171. /* if ($confirmbutton) {
  172. $db->begin();
  173. $error = 0;
  174. $groupusers = new GroupUsers($db);
  175. $groupObj = new Group($db);
  176. $groupResult = $groupObj->fetch($id);
  177. $groupEntity = $groupObj->fk_entity;
  178. foreach ($toselect as $selected) {
  179. $moredata = explode('_', $selected);
  180. $deleteResult = $groupusers->deleteLine($user, $moredata[0]);
  181. if ($deleteResult < 0) {
  182. $error++;
  183. }
  184. $createResult = $groupUsers->createGroupUsers($confirmbutton, $moredata[1]);
  185. if ($createResult < 0) {
  186. $error++;
  187. }
  188. $dataAdd = $helper->createDataArray($confirmbutton, 'add', $moredata[1]);
  189. $naploResult = $userNaplo->createUserNaplo($user, $dataAdd);
  190. if ($naploResult < 0) {
  191. $error++;
  192. }
  193. $userUpdateResult = $helper->updateUserEntityInUser($moredata[1], $groupEntity);
  194. if ($userUpdateResult < 0) {
  195. $error++;
  196. }
  197. }
  198. if ($error) {
  199. $db->rollback();
  200. unset($toselect);
  201. setEventMessage($langs->trans("PackageUserFailed", 'error'));
  202. } else {
  203. $confirmbutton = null;
  204. $db->commit();
  205. $helper->returnWindowLocation($_SERVER["PHP_SELF"], $id, $idmenu);
  206. //setEventMessage($langs->trans("usersconfirmed"));
  207. }
  208. } */
  209. $allUsers = $helper->getAllUsers($db);
  210. $usersOfGroups = $helper->getUsersById($db, $id);
  211. $confirmButtonDisplay = empty($helper->getUsersOfGroupsFromNaploToday($db, $id)) && !empty($usersOfGroups) ? "display:block;" : "display:none;";
  212. $permissiontoclearall = $user->hasRight('settlements', 'settlementsgroup', 'clearall');
  213. $title = '';
  214. $help_url = '';
  215. $morejs = '';
  216. $morecss = '';
  217. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  218. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/actions_addupdatedelete.inc.php';
  219. $url = $_SERVER["PHP_SELF"] . '?idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu=&id=' . $id;
  220. /* if ($massaction!=0 || $massactionadd != 0) {
  221. $url .= "&id={$id}";
  222. } */
  223. print '<form method="POST" id="searchFormList" action="' . $url . '" onkeyup="submitFormAjaxUser()">' . "\n";
  224. print '<input type="hidden" name="token" value="' . newToken() . '">';
  225. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  226. print '<input type="hidden" name="action" value="list">';
  227. /*print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
  228. print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
  229. print '<input type="hidden" name="page" value="' . $page . '">';
  230. print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';*/
  231. print load_fiche_titre($langs->trans("HotelGroups"), '', 'settlements.png@settlements');
  232. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/usercheckboxes.tpl.php';
  233. /* if ($permissiontoclearall) {
  234. if ($helper->userGroupsAreEmpty()) {
  235. print '<div style="text-align: center; color:red; margin-bottom: 30px;">' . $langs->trans('EmptyUsersGroup') . '</div>';
  236. } else {
  237. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/userclearall.tpl.php';
  238. }
  239. } */
  240. print '<div style="width:100%; padding-bottom: 50px;">';
  241. $columnWidth = 100 / count($entities);
  242. foreach ($entities as $key => $value) {
  243. if (!$entitiesArrayIsEmpty) {
  244. $checked = $entitiesArray[$key] == $key ? 'checked' : '';
  245. } else {
  246. $checked = 'checked';
  247. }
  248. print '<div class="entitiesChk" style="float:left; width:' . $columnWidth . '%; text-align:center;"><input type="checkbox" id="entity_' . $key . '" name="entity_' . $key . '" value="' . $key . '" ' . $checked . '><label for="' . $key . '">' . $value . '</label></div>';
  249. }
  250. print '</div>';
  251. print '<div style="clear:both;></div>';
  252. //---------------------------------------------
  253. # 1
  254. //---------------------------------------------
  255. print '<div class=""><div class="" style="width:33%;float:left;">';
  256. print '<table style="width:100%;">';
  257. print '<tr style="width: 100%; height: 40px; text-align: center; background-color: lightgrey;"><td colspan="2">' . $langs->trans("groupname") . '</td></tr>';
  258. foreach ($groups as $key => $val) {
  259. $coloredLine = $id == $key ? ' background-color: #b0c4de;' : '';
  260. print '<tr style="height:30px;' . $coloredLine . ' cursor:pointer;" class="submitFormLink" data-value="' . $key . '"><td><span class="fa fa-group pictofixedwidth"></span> ' . $val . '</td>
  261. </tr>';
  262. }
  263. print '</table>';
  264. //---------------------------------------------
  265. # 2
  266. //---------------------------------------------
  267. print '</div><div class="" style="width:33%;float:left;">';
  268. print '<table style="width:100%;">';
  269. print '<tr style="width: 100%; height: 40px; text-align: center; background-color: lightgrey;"><td colspan="2">' . $langs->trans("usersofgroup") . '</td></tr>';
  270. print '<tr style="width: 100%; height: 40px; text-align: center; background-color: rgb(163,0,51); color:white;"><td colspan="2">' . $groups[$id] . '</td></tr>';
  271. //print '<tr style="width=100%; height:40px;"><td colspan="2" class="center"><button class="btn" name="confirmbutton" value="' . $id . '" onclick="groupconfirm()" style="width:100%; height:40px; cursor:pointer; background-color: #98FB98; ' . $confirmButtonDisplay . '">' . $langs->trans("confirm") . '</button></td></tr>';
  272. if (!empty($usersOfGroups)) {
  273. print '<tr><td class="right" style="color:gray;">' . $langs->trans("selectall") . '</td><td class="nowrap center"><input id="cb912" class="flat checkforallselect" type="checkbox"></td></tr>';
  274. foreach ($usersOfGroups as $user) {
  275. print '<tr style="height:30px;">
  276. <td><span class="fa fa-user pictofixedwidth"></span> ' . $user['lastname'] . ' ' . $user['firstname'] . ' (' . $user['login'] . ')</td>
  277. <td class="nowrap center"><input id="cb911" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $user['rowid'] . '_' . $user['fk_user'] . '"></td>
  278. </tr>';
  279. }
  280. } else {
  281. print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('nouser') . '</td></tr>';
  282. }
  283. print '</table>';
  284. //---------------------------------------------
  285. # 3
  286. //---------------------------------------------
  287. print '</div><div class="" style="width:33%;float:left;">';
  288. print '<table style="width:100%;">';
  289. print '<tr style="width: 100%; height: 40px; text-align: center; background-color: lightgrey;"><td colspan="3">' . $langs->trans("freeusers") . '</td></tr>';
  290. print '<tr><td class="liste_titre"><input id="name_search" style="width:100%; height:30px;" type="text" class="" name="search_title" value="' . $search_title . '" placeholder="' . $langs->trans("search") . '" ></td>
  291. <td id="delete_search" class="center"><div style="cursor: pointer;"><a href="' . $_SERVER["PHP_SELF"] . '?idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu=&id=' . $id . '&deleteall=1"><span class="fa fa-trash"></span></a></div>
  292. </td></tr>';
  293. if (is_array($allUsers['freeUsers'])) {
  294. print '<td colspan="3"><div id="searchedUsersDiv">
  295. <table style="width:100%;">';
  296. foreach ($allUsers['freeUsers'] as $freeUser) {
  297. $nickname = isset($freeUser['nickname']) ? '<b>' . $freeUser['nickname'] . '</b> - ' : '';
  298. print '<tr style="height:30px;">
  299. <td><span class="fa fa-user pictofixedwidth"></span>' . $nickname . $freeUser['lastname'] . ' ' . $freeUser['firstname'] . ' (' . $freeUser['login'] . ')</td>
  300. <td class="nowrap center"><input id="cb912" class="flat checkforselectadd" type="checkbox" onclick="submitFormAddUser(event)" name="toselectnewuser[]" value="' . $freeUser['rowid'] . '"></td>
  301. </tr>';
  302. }
  303. } else {
  304. print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('pleaseConfirm') . '</td></tr>';
  305. }
  306. print '</table><table style="width:100%; color: red;">';
  307. if (is_array($allUsers['addedUsers'])) {
  308. foreach ($allUsers['addedUsers'] as $addedUser) {
  309. $nickname = isset($addedUser['nickname']) ? '<b>' . $addedUser['nickname'] . '</b> - ' : '';
  310. print '<tr style="height:30px;">
  311. <td rowspan="2"><span class="fa fa-user pictofixedwidth"></span></td>
  312. <td>' . $nickname . $addedUser['lastname'] . ' ' . $addedUser['firstname'] . ' (' . $addedUser['login'] . ')</td>';
  313. print '<tr>
  314. <td class="nowrap">' . $addedUser['groupref'] . '</td>
  315. </tr>';
  316. }
  317. }
  318. print '</table>';
  319. print '</div></td>';
  320. print '</div></div>';
  321. print '</form>' . "\n";
  322. // End of page
  323. llxFooter();
  324. $db->close();
  325. ?>
  326. <script>
  327. $(document).ready(function () {
  328. // Az űrlap elküldése, ha a checkbox változik
  329. $('.entitiesChk').change(function () {
  330. $('#searchFormList').submit();
  331. });
  332. var elements = document.getElementsByClassName('submitFormLink');
  333. for (var i = 0; i < elements.length; i++) {
  334. elements[i].addEventListener('click', function (event) {
  335. event.preventDefault();
  336. var form = document.getElementById('searchFormList');
  337. var actionValue = form.getAttribute('action');
  338. var clickedElementValue = this.getAttribute('data-value');
  339. lastIndex = actionValue.lastIndexOf('&');
  340. var trimmedQueryString = actionValue.substring(0, lastIndex);
  341. form.action = trimmedQueryString + '&id=' + clickedElementValue;
  342. document.getElementById('searchFormList').submit();
  343. });
  344. }
  345. });
  346. function groupconfirm() {
  347. $('.checkforselect').prop('checked', true);
  348. }
  349. $('.massactionaddconfirmed').click(function () {
  350. $("#name_search").val('');
  351. groupconfirm();
  352. })
  353. $('.massactionconfirmed').click(function () {
  354. $("#name_search").val('');
  355. $("#deletechk").val(1);
  356. })
  357. $('.checkforallselect').click(function () {
  358. if ($(this).is(':checked')) {
  359. $('.checkforselect').prop('checked', true);
  360. $('#divDelete').css('display', 'inline-block');
  361. $('#massaction').css('display', 'inline-block');
  362. $('.massactionselect ').css('display', '');
  363. $('.massactionconfirmed ').css('display', '');
  364. } else {
  365. $('#divDelete').css('display', 'none');
  366. $('.checkforselect').prop('checked', false);
  367. $('#massaction').css('display', 'none');
  368. $('.massactionselect ').css('display', 'none');
  369. $('.massactionconfirmed ').css('display', 'none');
  370. }
  371. })
  372. $('.checkforselect').click(function () {
  373. if ($(this).is(':checked')) {
  374. $('#divDelete').css('display', 'inline-block');
  375. $('#massaction').css('display', 'inline-block');
  376. $('.massactionselect ').css('display', '');
  377. $('.massactionconfirmed ').css('display', '');
  378. } else {
  379. $('#massaction').css('display', 'none');
  380. $('#divDelete').css('display', 'none');
  381. $('.massactionselect ').css('display', 'none');
  382. $('.massactionconfirmed ').css('display', 'none');
  383. }
  384. })
  385. $('.checkforselectadd').click(function () {
  386. if ($(this).is(':checked')) {
  387. $('#divAdd').css('display', 'inline-block');
  388. $('#massactionadd').css('display', 'inline-block');
  389. $('.massactionaddselect ').css('display', '');
  390. $('.massactionaddconfirmed ').css('display', '');
  391. } else {
  392. $('#divAdd').css('display', 'none');
  393. $('#massactionadd').css('display', 'none');
  394. $('.massactionaddselect ').css('display', 'none');
  395. $('.massactionaddconfirmed ').css('display', 'none');
  396. }
  397. })
  398. function deleteFunction() {
  399. $("#name_search").val('');
  400. document.getElementById("searchFormList").submit();
  401. }
  402. function submitFormAjaxUser() {
  403. var input = document.getElementById("name_search");
  404. var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
  405. var values = Array.from(checkboxes).map(function (checkbox) {
  406. return checkbox.value;
  407. });
  408. var xhr = new XMLHttpRequest();
  409. xhr.open("GET", "ajaxUser.php?search_title=" + input.value + "&toselectnewuser=" + values, true);
  410. xhr.onreadystatechange = function () {
  411. if (xhr.readyState === 4 && xhr.status === 200) {
  412. $("#searchedUsersDiv").html(xhr.responseText);
  413. }
  414. };
  415. xhr.send();
  416. }
  417. function submitFormAddUser(event) {
  418. var checkbox = event.target;
  419. if (checkbox.checked) {
  420. var input = document.getElementById("name_search");
  421. var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
  422. var values = Array.from(checkboxes).map(function (checkbox1) {
  423. return checkbox1.value;
  424. });
  425. var xhr = new XMLHttpRequest();
  426. xhr.open("GET", "ajaxUser.php?search_title=" + input.value + "&toselectnewuser=" + values, true);
  427. xhr.onreadystatechange = function () {
  428. if (xhr.readyState === 4 && xhr.status === 200) {
  429. $("#searchedUsersDiv").html(xhr.responseText);
  430. }
  431. };
  432. xhr.send();
  433. } else {
  434. var input = document.getElementById("name_search");
  435. var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
  436. var values = Array.from(checkboxes).map(function (checkbox1) {
  437. return checkbox1.value;
  438. });
  439. var xhr = new XMLHttpRequest();
  440. xhr.open("GET", "ajaxUser.php?search_title=" + input.value + "&reduction=" + values, true);
  441. xhr.onreadystatechange = function () {
  442. if (xhr.readyState === 4 && xhr.status === 200) {
  443. $("#searchedUsersDiv").html(xhr.responseText);
  444. }
  445. };
  446. xhr.send();
  447. }
  448. }
  449. var input = document.getElementById("name_search");
  450. input.focus();
  451. input.setSelectionRange(input.value.length, input.value.length);
  452. </script>