settlementpackagetoolssettingsindex.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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/helper.class.php';
  65. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/grouptoolstools.class.php';
  66. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/toolnaplo.class.php';
  67. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/packagetool.class.php';
  68. // Include the main TCPDF library (search for installation path).
  69. require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/examples/tcpdf_include.php';
  70. require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/tcpdf.php';
  71. // create new PDF document
  72. // Load translation files required by the page
  73. $langs->loadLangs(array("settlements@settlements"));
  74. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  75. $massactionadd = GETPOST('massactionadd', 'alpha'); // The bulk action (combo box choice into lists)
  76. $action = GETPOST('action', 'aZ09');
  77. $cancel = GETPOST('cancel', 'int');
  78. $id = GETPOST('id', 'int');
  79. $idmenu = GETPOST('idmenu', 'int');
  80. $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
  81. $toselectnewtool = GETPOST('toselectnewtool', 'array'); // Array of ids of elements selected into a list
  82. $reduction = GETPOST('reduction', 'array'); // Array of ids of elements selected into a list
  83. $search_title = GETPOST('search_title', 'alpha');
  84. $confirmbutton = GETPOST('confirmbutton', 'int');
  85. $printbutton = GETPOST('printbutton', 'int');
  86. $confirm = GETPOST('confirm', 'alpha');
  87. $confirmtools = GETPOST('confirmtools', 'alpha');
  88. $delete = GETPOST('delete', 'int');
  89. $toolclearall = GETPOST('toolclearall', 'int');
  90. $confirmmassaction = GETPOST('confirmmassaction', 'alpha');
  91. $socid = GETPOST('socid', 'int');
  92. if (isset($user->socid) && $user->socid > 0) {
  93. $action = '';
  94. $socid = $user->socid;
  95. }
  96. $max = 5;
  97. $now = dol_now();
  98. $form = new Form($db);
  99. $formfile = new FormFile($db);
  100. $toolNaplo = new ToolNaplo($db);
  101. $helper = new Helper($db);
  102. $entities = $helper->getAllEntities();
  103. $entitiesArray = [];
  104. $selectedEntities = '';
  105. //$entitiesArrayIsEmpty = true;
  106. foreach ($entities as $key => $value) {
  107. $val = GETPOST('entity_' . $key, 'int');
  108. $entitiesArray[$key] = $val;
  109. /*if ($val != '') {
  110. $entitiesArrayIsEmpty = false;
  111. }*/
  112. }
  113. if(empty(array_filter($entitiesArray))){
  114. $entitiesArray[1] = 1;
  115. }
  116. $selectedEntities = $helper->getEntities($entitiesArrayIsEmpty, $entities, $entitiesArray);
  117. $packages = $helper->getPackagesFromPackageClass($db, $selectedEntities);
  118. if (empty($id) || $id == 0) {
  119. foreach ($packages as $package) {
  120. $keys[] = $package['rowid'];
  121. }
  122. unset($_SESSION['devices_array']);
  123. $id = $keys[0];
  124. }
  125. if ($delete == 1) {
  126. unset($_SESSION['devices_array']);
  127. }
  128. #
  129. # Massactions
  130. #
  131. if ($confirm == 'delete') {
  132. $assignedDeviceObj = new Inventory($db);
  133. $packageTools = new PackageTool($db);
  134. foreach ($toselect as $toolid) {
  135. $moredata = explode('_', $toolid);
  136. $assignedDeviceObj->fetch($moredata[1]);
  137. $packageTools->deleteLine($user, $moredata[0]);
  138. $data = $helper->createDataToolArray($id, $confirm, $moredata[1]);
  139. $toolNaplo->createToolsNaplo($user, $data);
  140. if (isset($assignedDeviceObj->array_options['options_assigned_device'])) {
  141. $packageTools->deleteLineByPackage_idAndDeviceId($user, $id, $assignedDeviceObj->array_options['options_assigned_device']);
  142. $data = $helper->createDataToolArray($id, $confirm, $assignedDeviceObj->array_options['options_assigned_device']);
  143. $toolNaplo->createToolsNaplo($user, $data);
  144. }
  145. dol_syslog("A {$toolid} szamu eszkoz torlesre kerult.", LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERR);
  146. }
  147. unset($_SESSION['devices_array']);
  148. setEventMessage($langs->trans("toolsdeleted"), 'errors');
  149. }
  150. if ($massactionadd == 'add' && $confirmmassaction != '') {
  151. if ((!isset($toselectnewtool) || empty($toselectnewtool)) && isset($_SESSION['devices_array'])) {
  152. $toselectnewtool = array_filter($_SESSION['devices_array'], function ($elem) {
  153. return !empty($elem);
  154. });
  155. }
  156. if (!empty($toselectnewtool)) {
  157. $assignedDeviceObj = new Inventory($db);
  158. $packageTools = new PackageTool($db);
  159. foreach ($_SESSION['devices_array'] as $newtool) {
  160. $assignedDeviceObj->fetch($newtool);
  161. $helper->saveToolsData($packageTools, $id, $newtool, $langs, $massactionadd);
  162. if (isset($assignedDeviceObj->array_options['options_assigned_device'])) {
  163. $helper->saveToolsData($packageTools, $id, $assignedDeviceObj->array_options['options_assigned_device'], $langs, $massactionadd);
  164. }
  165. }
  166. unset($_SESSION['devices_array']);
  167. $massactionadd = 0;
  168. $confirmmassaction = 0;
  169. setEventMessage($langs->trans("tooladded"));
  170. }
  171. }
  172. if ($confirmtools == 'confirm') {
  173. foreach ($toselect as $selected) {
  174. $moredata = explode('_', $selected);
  175. $data = $helper->createDataToolArray($id, 'add', $moredata[1]);
  176. $toolNaplo->createToolsNaplo($user, $data);
  177. }
  178. $url = $_SERVER["PHP_SELF"] . '?id=' . $id;
  179. header("Location: " . $url);
  180. }
  181. if (!empty($id)) {
  182. $devicesArray = $helper->getToolsById($db, $id);
  183. $allTools = $helper->getAllToolsFromSelectedEntity($db, $id);
  184. $confirmButtonDisplay = empty($helper->getToolsFromNaploToday($db, $id)) && !empty($devicesArray) ? "display:block;" : "display:none;";
  185. //$PrintButtonDisplay = !empty($helper->getToolsFromNaploToday($db, $id)) && !empty($devicesArray) ? "display:block;" : "display:none;";
  186. //$buttonContent = $helper->createButtonContent($db, $id, $devicesArray, $confirmButtonDisplay, $PrintButtonDisplay);
  187. $PrintButtonDisplay = !empty($devicesArray) ? "display:block;" : "display:none;";
  188. $buttonContent = '<tr style="width=100%; height:40px;"><td colspan="3" class="center"><button class="btn" name="printbutton" value="1" onclick=""
  189. style="width:100%; height:45px; cursor:pointer; background-color: yellow; ' . $PrintButtonDisplay . '">Nyomtatás</button></td></tr>';
  190. }
  191. if ($printbutton) {
  192. $html = $helper->createHTML($devicesArray, $id);
  193. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/printPDF.tpl.php';
  194. }
  195. $permissiontoclearall = $user->hasRight('settlements', 'settlementsgroup', 'clearall');
  196. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  197. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/actions_addupdatedelete.inc.php';
  198. $url = $_SERVER["PHP_SELF"] . '?idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu=&id=' . $id;
  199. print '<form method="POST" id="searchFormList" action="' . $url . '" onkeyup="submitFormAjaxTools()">' . "\n";
  200. print '<input type="hidden" name="token" value="' . newToken() . '">';
  201. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  202. print '<input type="hidden" name="action" value="list">';
  203. print '<input type="hidden" name="delete" id="delete" value="">';
  204. /*print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
  205. print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
  206. print '<input type="hidden" name="page" value="' . $page . '">';
  207. print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';*/
  208. print '<input type="hidden" id ="groupid" name="groupid" value="' . $id . '">';
  209. if ($permissiontoclearall) {
  210. if ($helper->toolGroupsAreEmpty()) {
  211. print '<div style="text-align: center; color:red; margin-bottom: 30px;">' . $langs->trans('EmptyToolsGroup') . '</div>';
  212. } else {
  213. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/toolclearall.tpl.php';
  214. }
  215. }
  216. print load_fiche_titre($langs->trans("PackagesTools"), '', 'settlements.png@settlements');
  217. if ($massaction == 'delete') {
  218. print $helper->massactionDelete();
  219. }
  220. if ($confirmbutton) {
  221. print $helper->confirmButtonConfirmeText();
  222. }
  223. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/toolcheckboxes.tpl.php';
  224. print '<div style="width:100%; padding-bottom: 50px;">';
  225. $columnWidth = 100 / count($entities);
  226. foreach ($entities as $key => $value) {
  227. if (!$entitiesArrayIsEmpty) {
  228. $checked = $entitiesArray[$key] == $key ? 'checked' : '';
  229. } else {
  230. $checked = 'checked';
  231. }
  232. 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>';
  233. }
  234. print '</div>';
  235. print '<div style="clear:both;></div>';
  236. //---------------------------------------------
  237. # 1
  238. //---------------------------------------------
  239. print '<div class=""><div class="" style="width:33%;float:left;">';
  240. print '<table style="width:100%;">';
  241. print '<tr style="width: 100%; height: 45px; text-align: center; background-color: lightgrey;"><td colspan="2">' . $langs->trans("PackageName") . '</td></tr>';
  242. if (!empty($packages)) {
  243. foreach ($packages as $package) {
  244. $coloredLine = $id == $package['rowid'] ? ' background-color: #b0c4de' : '';
  245. print '<tr class="submitFormLink" data-value="' . $package['rowid'] . '" style="height:30px; cursor:pointer;' . $coloredLine . '">
  246. <td><span class="fa fa-group pictofixedwidth"></span> ' . $package['ref'] . '</td>
  247. <td>' . $package['entity'] . '</td>
  248. </tr>';
  249. }
  250. } else {
  251. print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('nogroup') . '</td></tr>';
  252. }
  253. print '</table>';
  254. //---------------------------------------------
  255. #2
  256. //---------------------------------------------
  257. $isClosed = $helper->isClosed($id);
  258. $disabledCheckbox = $isClosed ? '' : 'disabled';
  259. $packageName = $helper->getPackageName($packages, $id);
  260. print '</div><div class="" style="width:33%;float:left;">';
  261. print '<table style="width:100%;">';
  262. print '<tr style="width: 100%; height: 45px; text-align: center; background-color: lightgrey;"><td colspan="3"><div style="margin-left:10px;">' . $langs->trans("devicesofgroup", $packageName) . '</div></td></tr>';
  263. if (!empty($devicesArray)) {
  264. print '<tr><td class="right" style="color:gray;" colspan="2">' . $langs->trans('selectAll') . '</td><td class="nowrap center"><input id="cb912" class="flat checkforallselect" type="checkbox" ' . $disabledCheckbox . '></td></tr>';
  265. foreach ($devicesArray as $tool) {
  266. $status2 = $tool['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
  267. $selected = in_array($tool['rowid'] . '_' . $tool['device_id'], $toselect) ? 'checked' : '';
  268. $url = '/custom/rollerstorage/card.php?id=' . $tool['device_id'] . '&inventory_id=' . $tool['assigned_device_data']['warehouse'] . '&backtopage=/custom/rollerstorage/rollerstorageinventoryindex.php?inventory_id=' . $tool['assigned_device_data']['warehouse'] . '&idmenu=1599&leftmenu=';
  269. if ($tool['device_type'] == 1) {
  270. print '<tr style="height:30px; background-color: lightgrey;">
  271. <td><span class="fa fa-mobile pictofixedwidth"></span> <a href="' . $url . '">' . $tool['ref'] . '</a> ' . $status2 . '</td>
  272. <td>' . $tool['title'] . '<p>IMEI: ' . $tool['unique_identifier'] . '</p></td>
  273. <td class="nowrap center"><input id="id_2_' . $tool['rowid'] . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $tool['rowid'] . '_' . $tool['device_id'] . '"' . $selected . ' ' . $disabledCheckbox . '></td>
  274. </tr>';
  275. $urlAssigned_device = '/custom/rollerstorage/card.php?id=' . $tool['assigned_device_data']['rowid'] . '&inventory_id=' . $tool['assigned_device_data']['warehouse'] . '&backtopage=/custom/rollerstorage/rollerstorageinventoryindex.php?inventory_id=' . $tool['assigned_device_data']['warehouse'] . '&idmenu=1599&leftmenu=';
  276. $statusAssigned2 = $tool['assigned_device_data']['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
  277. print '<tr style="height:30px; background-color: lightgrey;">
  278. <td>&nbsp;&nbsp;&nbsp;&nbsp;<span class="fa fa-credit-card pictofixedwidth"></span> <a href="' . $urlAssigned_device . '">' . $tool['assigned_device_data']['ref'] . ' ' . $statusAssigned2 . '</td>
  279. <td>' . $tool['assigned_device_data']['title'] . '</td>
  280. <td class="nowrap center"></td>
  281. </tr>';
  282. } elseif ($tool['device_type'] == 0 || $tool['device_type'] == 3 || $tool['device_type'] == 4 || $tool['device_type'] == 5) {
  283. //} else {
  284. print '<tr style="height:30px;">
  285. <td><span class="fa fa-toolbox pictofixedwidth"></span><a href="' . $url . '"> ' . $tool['ref'] . '</a> ' . $status2 . '</td>
  286. <td>' . $tool['title'] . '</td>
  287. <td class="nowrap center"><input id="id_2_' . $tool['rowid'] . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $tool['rowid'] . '_' . $tool['device_id'] . '"' . $selected . ' ' . $disabledCheckbox . '></td>
  288. </tr>';
  289. }
  290. }
  291. } else {
  292. print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('nodeviceassigned') . '</td></tr>';
  293. }
  294. print '</table>';
  295. //---------------------------------------------
  296. #3
  297. //---------------------------------------------
  298. print '</div><div class="" style="width:33%;float:left;">';
  299. print '<table style="width:100%;">';
  300. print '<tr style="width: 100%; height: 45px; text-align: center; background-color: lightgrey;"><td colspan="3">' . $langs->trans("freedevices") . '</td></tr>';
  301. 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>
  302. <td id="delete_search" class="center" onclick="deleteFunction()"><div style="cursor: pointer;"><span class="fa fa-trash"></span></div>
  303. </td></tr>';
  304. if ($isClosed) {
  305. if (is_array($allTools['freeTools']) && !empty($packages)) {
  306. print '<td colspan="3"><div id="searchedToolsDiv">
  307. <table style="width:100%;">';
  308. foreach ($allTools['freeTools'] as $freeTool) {
  309. $status3 = $freeTool['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
  310. $url_3 = '/custom/rollerstorage/card.php?id=' . $freeTool['rowid'] . '&inventory_id=' . $freeTool['fk_warehouse'] . '&backtopage=/custom/rollerstorage/rollerstorageinventoryindex.php?inventory_id=' . $freeTool['fk_warehouse'] . '&idmenu=1599&leftmenu=';
  311. if ($freeTool['device_type'] == 1) {
  312. $disabled = !isset($freeTool['assigned_device_data']) ? 'disabled' : '';
  313. print '
  314. <tr style="height:30px; background-color: lightgrey;">
  315. <td class="nowrap center"><input id="id_3_' . $freeTool['rowid'] . '" class="flat checkforselectadd" type="checkbox" onclick="submitFormAddTool(event)" name="toselectnewtool[]" value="' . $freeTool['rowid'] . '" ' . $disabled . '></td>
  316. <td><span class="fa fa-mobile pictofixedwidth"></span> <a href="' . $url_3 . '">' . $freeTool['ref'] . '</a> - ' . $freeTool['title'] . ' ' . $status . '</td>
  317. </tr>';
  318. $statusAssigned3 = $freeTool['assigned_device_data']['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
  319. print '
  320. <tr style="height:30px; background-color: lightgrey;">';
  321. $url_3 = '/custom/rollerstorage/card.php?id=' . $freeTool['assigned_device_data']['rowid'] . '&inventory_id=' . $freeTool['fk_warehouse'] . '&backtopage=/custom/rollerstorage/rollerstorageinventoryindex.php?inventory_id=' . $freeTool['fk_warehouse'] . '&idmenu=1599&leftmenu=';
  322. print '<td class="nowrap center"></td>';
  323. if (!isset($freeTool['assigned_device_data'])) {
  324. print '<td style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;<span class="fa fa-credit-card pictofixedwidth"></span>' . $langs->trans('NoCardreadder') . '</td>';
  325. } else {
  326. print '<td>&nbsp;&nbsp;&nbsp;&nbsp;<span class="fa fa-credit-card pictofixedwidth"></span><a href="' . $url_3 . '"> ' . $freeTool['assigned_device_data']['ref'] . '</a> - ' . $freeTool['assigned_device_data']['title'] . ' ' . $statusAssigned3 . '</td>';
  327. }
  328. print '</tr>';
  329. } elseif ($freeTool['device_type'] == 0 || $freeTool['device_type'] == 3 || $freeTool['device_type'] == 4 || $freeTool['device_type'] == 5) {
  330. print '
  331. <tr style="height:30px;">
  332. <td class="nowrap center"><input id="id_3_' . $freeTool['rowid'] . '" class="flat checkforselectadd" type="checkbox" onclick="submitFormAddTool(event)" name="toselectnewtool[]" value="' . $freeTool['rowid'] . '"></td>
  333. <td><span class="fa fa-toolbox pictofixedwidth"></span> <a href="' . $url_3 . '">' . $freeTool['ref'] . '</a> - ' . $freeTool['title'] . ' ' . $status3 . '</td>
  334. </tr>';
  335. }
  336. }
  337. print '</table>';
  338. print $helper->addedToolsDiv($allTools);
  339. print '</div></td>';
  340. }
  341. } else {
  342. print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('ClosedPackage') . '</td></tr>';
  343. }
  344. print '</div></div>';
  345. print '</form>' . "\n";
  346. // End of page
  347. llxFooter();
  348. $db->close();
  349. ?>
  350. <script>
  351. $(document).ready(function () {
  352. // Az űrlap elküldése, ha a checkbox változik
  353. $('.entitiesChk').change(function () {
  354. $('#searchFormList').submit();
  355. });
  356. var elements = document.getElementsByClassName('submitFormLink');
  357. for (var i = 0; i < elements.length; i++) {
  358. elements[i].addEventListener('click', function (event) {
  359. event.preventDefault();
  360. var form = document.getElementById('searchFormList');
  361. var actionValue = form.getAttribute('action');
  362. var clickedElementValue = this.getAttribute('data-value');
  363. lastIndex = actionValue.lastIndexOf('&');
  364. var trimmedQueryString = actionValue.substring(0, lastIndex);
  365. form.action = trimmedQueryString + '&id=' + clickedElementValue;
  366. document.getElementById('searchFormList').submit();
  367. });
  368. }
  369. });
  370. function groupconfirm() {
  371. $('.checkforselect').prop('checked', true);
  372. }
  373. function deleteFunction() {
  374. $("#name_search").val('');
  375. $(".checkforselectadd").prop('checked', false);
  376. $("#delete").val(1);
  377. document.getElementById("searchFormList").submit();
  378. }
  379. function submitFormAjaxTools() {
  380. var input = document.getElementById("name_search");
  381. var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
  382. var values = Array.from(checkboxes).map(function (checkbox) {
  383. return checkbox.value;
  384. });
  385. var xhr = new XMLHttpRequest();
  386. xhr.open("GET", "ajaxtools.php?search_title=" + input.value + "&toselectnewtool=" + values + "&groupid=" + groupid.value, true);
  387. xhr.onreadystatechange = function () {
  388. if (xhr.readyState === 4 && xhr.status === 200) {
  389. $("#searchedToolsDiv").html(xhr.responseText);
  390. }
  391. };
  392. xhr.send();
  393. }
  394. function submitFormAddTool(event) {
  395. //alert('asd');
  396. var checkbox = event.target;
  397. var groupid = document.getElementById("groupid");
  398. if (checkbox.checked) {
  399. var input = document.getElementById("name_search");
  400. var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
  401. var values = Array.from(checkboxes).map(function (checkbox1) {
  402. return checkbox1.value;
  403. });
  404. var xhr = new XMLHttpRequest();
  405. xhr.open("GET", "ajaxtools.php?search_title=" + input.value + "&toselectnewtool=" + values + "&groupid=" + groupid.value, true);
  406. xhr.onreadystatechange = function () {
  407. if (xhr.readyState === 4 && xhr.status === 200) {
  408. $("#searchedToolsDiv").html(xhr.responseText);
  409. }
  410. };
  411. xhr.send();
  412. } else {
  413. var input = document.getElementById("name_search");
  414. var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
  415. var values = Array.from(checkboxes).map(function (checkbox1) {
  416. return checkbox1.value;
  417. });
  418. var xhr = new XMLHttpRequest();
  419. xhr.open("GET", "ajaxtools.php?search_title=" + input.value + "&reduction=" + values + "&groupid=" + groupid.value, true);
  420. xhr.onreadystatechange = function () {
  421. if (xhr.readyState === 4 && xhr.status === 200) {
  422. $("#searchedToolsDiv").html(xhr.responseText);
  423. }
  424. };
  425. xhr.send();
  426. }
  427. }
  428. $('.massactionaddconfirmed').click(function () {
  429. $("#name_search").val('');
  430. })
  431. $('.massactionconfirmed').click(function () {
  432. $("#name_search").val('');
  433. $("#deletechk").val(1);
  434. })
  435. $('.checkforallselect').click(function () {
  436. if ($(this).is(':checked')) {
  437. $('.checkforselect').prop('checked', true);
  438. $('#divDelete').css('display', 'inline-block');
  439. $('#massaction').css('display', 'inline-block');
  440. $('.massactionselect ').css('display', '');
  441. $('.massactionconfirmed ').css('display', '');
  442. } else {
  443. $('#divDelete').css('display', 'none');
  444. $('.checkforselect').prop('checked', false);
  445. $('#massaction').css('display', 'none');
  446. $('.massactionselect ').css('display', 'none');
  447. $('.massactionconfirmed ').css('display', 'none');
  448. }
  449. })
  450. $('.checkforselect').click(function () {
  451. if ($(this).is(':checked')) {
  452. $('#divDelete').css('display', 'inline-block');
  453. $('#massaction').css('display', 'inline-block');
  454. $('.massactionselect ').css('display', '');
  455. $('.massactionconfirmed ').css('display', '');
  456. } else {
  457. $('#massaction').css('display', 'none');
  458. $('#divDelete').css('display', 'none');
  459. $('.massactionselect ').css('display', 'none');
  460. $('.massactionconfirmed ').css('display', 'none');
  461. }
  462. })
  463. $('.checkforselectadd').click(function () {
  464. if ($(this).is(':checked')) {
  465. $('#divAdd').css('display', 'inline-block');
  466. $('#massactionadd').css('display', 'inline-block');
  467. $('.massactionaddselect ').css('display', '');
  468. $('.massactionaddconfirmed ').css('display', '');
  469. } else {
  470. $('#divAdd').css('display', 'none');
  471. $('#massactionadd').css('display', 'none');
  472. $('.massactionaddselect ').css('display', 'none');
  473. $('.massactionaddconfirmed ').css('display', 'none');
  474. }
  475. })
  476. var input = document.getElementById("name_search");
  477. input.focus();
  478. input.setSelectionRange(input.value.length, input.value.length);
  479. </script>