| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539 |
- <?php
- /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
- * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- /**
- * \file settlements/settlementsindex.php
- * \ingroup settlements
- * \brief Home page of settlements top menu
- */
- // Load Dolibarr environment
- $res = 0;
- // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
- if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
- $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
- }
- // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
- $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
- $tmp2 = realpath(__FILE__);
- $i = strlen($tmp) - 1;
- $j = strlen($tmp2) - 1;
- while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
- $i--;
- $j--;
- }
- if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) {
- $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
- }
- if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) {
- $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
- }
- // Try main.inc.php using relative path
- if (!$res && file_exists("../main.inc.php")) {
- $res = @include "../main.inc.php";
- }
- if (!$res && file_exists("../../main.inc.php")) {
- $res = @include "../../main.inc.php";
- }
- if (!$res && file_exists("../../../main.inc.php")) {
- $res = @include "../../../main.inc.php";
- }
- if (!$res) {
- die("Include of main fails");
- }
- use Luracast\Restler\RestException;
- require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
- require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/groupusers.class.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/usernaplo.class.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/helper.class.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/grouptoolstools.class.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/toolnaplo.class.php';
- require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/packagetool.class.php';
- // Include the main TCPDF library (search for installation path).
- require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/examples/tcpdf_include.php';
- require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/tcpdf.php';
- // create new PDF document
- // Load translation files required by the page
- $langs->loadLangs(array("settlements@settlements"));
- $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
- $massactionadd = GETPOST('massactionadd', 'alpha'); // The bulk action (combo box choice into lists)
- $action = GETPOST('action', 'aZ09');
- $cancel = GETPOST('cancel', 'int');
- $id = GETPOST('id', 'int');
- $idmenu = GETPOST('idmenu', 'int');
- $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
- $toselectnewtool = GETPOST('toselectnewtool', 'array'); // Array of ids of elements selected into a list
- $reduction = GETPOST('reduction', 'array'); // Array of ids of elements selected into a list
- $search_title = GETPOST('search_title', 'alpha');
- $confirmbutton = GETPOST('confirmbutton', 'int');
- $printbutton = GETPOST('printbutton', 'int');
- $confirm = GETPOST('confirm', 'alpha');
- $confirmtools = GETPOST('confirmtools', 'alpha');
- $delete = GETPOST('delete', 'int');
- $toolclearall = GETPOST('toolclearall', 'int');
- $confirmmassaction = GETPOST('confirmmassaction', 'alpha');
- $socid = GETPOST('socid', 'int');
- if (isset($user->socid) && $user->socid > 0) {
- $action = '';
- $socid = $user->socid;
- }
- $max = 5;
- $now = dol_now();
- $form = new Form($db);
- $formfile = new FormFile($db);
- $toolNaplo = new ToolNaplo($db);
- $helper = new Helper($db);
- $entities = $helper->getAllEntities();
- $entitiesArray = [];
- $selectedEntities = '';
- //$entitiesArrayIsEmpty = true;
- foreach ($entities as $key => $value) {
- $val = GETPOST('entity_' . $key, 'int');
- $entitiesArray[$key] = $val;
- /*if ($val != '') {
- $entitiesArrayIsEmpty = false;
- }*/
- }
- if(empty(array_filter($entitiesArray))){
- $entitiesArray[1] = 1;
- }
- $selectedEntities = $helper->getEntities($entitiesArrayIsEmpty, $entities, $entitiesArray);
- $packages = $helper->getPackagesFromPackageClass($db, $selectedEntities);
- if (empty($id) || $id == 0) {
- foreach ($packages as $package) {
- $keys[] = $package['rowid'];
- }
- unset($_SESSION['devices_array']);
- $id = $keys[0];
- }
- if ($delete == 1) {
- unset($_SESSION['devices_array']);
- }
- #
- # Massactions
- #
- if ($confirm == 'delete') {
- $assignedDeviceObj = new Inventory($db);
- $packageTools = new PackageTool($db);
- foreach ($toselect as $toolid) {
- $moredata = explode('_', $toolid);
- $assignedDeviceObj->fetch($moredata[1]);
- $packageTools->deleteLine($user, $moredata[0]);
- $data = $helper->createDataToolArray($id, $confirm, $moredata[1]);
- $toolNaplo->createToolsNaplo($user, $data);
- if (isset($assignedDeviceObj->array_options['options_assigned_device'])) {
- $packageTools->deleteLineByPackage_idAndDeviceId($user, $id, $assignedDeviceObj->array_options['options_assigned_device']);
- $data = $helper->createDataToolArray($id, $confirm, $assignedDeviceObj->array_options['options_assigned_device']);
- $toolNaplo->createToolsNaplo($user, $data);
- }
- dol_syslog("A {$toolid} szamu eszkoz torlesre kerult.", LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERR);
- }
- unset($_SESSION['devices_array']);
- setEventMessage($langs->trans("toolsdeleted"), 'errors');
- }
- if ($massactionadd == 'add' && $confirmmassaction != '') {
- if ((!isset($toselectnewtool) || empty($toselectnewtool)) && isset($_SESSION['devices_array'])) {
- $toselectnewtool = array_filter($_SESSION['devices_array'], function ($elem) {
- return !empty($elem);
- });
- }
- if (!empty($toselectnewtool)) {
- $assignedDeviceObj = new Inventory($db);
- $packageTools = new PackageTool($db);
- foreach ($_SESSION['devices_array'] as $newtool) {
- $assignedDeviceObj->fetch($newtool);
- $helper->saveToolsData($packageTools, $id, $newtool, $langs, $massactionadd);
- if (isset($assignedDeviceObj->array_options['options_assigned_device'])) {
- $helper->saveToolsData($packageTools, $id, $assignedDeviceObj->array_options['options_assigned_device'], $langs, $massactionadd);
- }
- }
- unset($_SESSION['devices_array']);
- $massactionadd = 0;
- $confirmmassaction = 0;
- setEventMessage($langs->trans("tooladded"));
- }
- }
- if ($confirmtools == 'confirm') {
- foreach ($toselect as $selected) {
- $moredata = explode('_', $selected);
- $data = $helper->createDataToolArray($id, 'add', $moredata[1]);
- $toolNaplo->createToolsNaplo($user, $data);
- }
- $url = $_SERVER["PHP_SELF"] . '?id=' . $id;
- header("Location: " . $url);
- }
- if (!empty($id)) {
- $devicesArray = $helper->getToolsById($db, $id);
- $allTools = $helper->getAllToolsFromSelectedEntity($db, $id);
- $confirmButtonDisplay = empty($helper->getToolsFromNaploToday($db, $id)) && !empty($devicesArray) ? "display:block;" : "display:none;";
- //$PrintButtonDisplay = !empty($helper->getToolsFromNaploToday($db, $id)) && !empty($devicesArray) ? "display:block;" : "display:none;";
- //$buttonContent = $helper->createButtonContent($db, $id, $devicesArray, $confirmButtonDisplay, $PrintButtonDisplay);
- $PrintButtonDisplay = !empty($devicesArray) ? "display:block;" : "display:none;";
- $buttonContent = '<tr style="width=100%; height:40px;"><td colspan="3" class="center"><button class="btn" name="printbutton" value="1" onclick=""
- style="width:100%; height:45px; cursor:pointer; background-color: yellow; ' . $PrintButtonDisplay . '">Nyomtatás</button></td></tr>';
- }
- if ($printbutton) {
- $html = $helper->createHTML($devicesArray, $id);
- include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/printPDF.tpl.php';
- }
- $permissiontoclearall = $user->hasRight('settlements', 'settlementsgroup', 'clearall');
- llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
- include DOL_DOCUMENT_ROOT . '/custom/settlements/core/actions_addupdatedelete.inc.php';
- $url = $_SERVER["PHP_SELF"] . '?idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu=&id=' . $id;
- print '<form method="POST" id="searchFormList" action="' . $url . '" onkeyup="submitFormAjaxTools()">' . "\n";
- print '<input type="hidden" name="token" value="' . newToken() . '">';
- print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
- print '<input type="hidden" name="action" value="list">';
- print '<input type="hidden" name="delete" id="delete" value="">';
- /*print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
- print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
- print '<input type="hidden" name="page" value="' . $page . '">';
- print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';*/
- print '<input type="hidden" id ="groupid" name="groupid" value="' . $id . '">';
- if ($permissiontoclearall) {
- if ($helper->toolGroupsAreEmpty()) {
- print '<div style="text-align: center; color:red; margin-bottom: 30px;">' . $langs->trans('EmptyToolsGroup') . '</div>';
- } else {
- include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/toolclearall.tpl.php';
- }
- }
- print load_fiche_titre($langs->trans("PackagesTools"), '', 'settlements.png@settlements');
- if ($massaction == 'delete') {
- print $helper->massactionDelete();
- }
- if ($confirmbutton) {
- print $helper->confirmButtonConfirmeText();
- }
- include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/toolcheckboxes.tpl.php';
- print '<div style="width:100%; padding-bottom: 50px;">';
- $columnWidth = 100 / count($entities);
- foreach ($entities as $key => $value) {
- if (!$entitiesArrayIsEmpty) {
- $checked = $entitiesArray[$key] == $key ? 'checked' : '';
- } else {
- $checked = 'checked';
- }
- 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>';
- }
- print '</div>';
- print '<div style="clear:both;></div>';
- //---------------------------------------------
- # 1
- //---------------------------------------------
- print '<div class=""><div class="" style="width:33%;float:left;">';
- print '<table style="width:100%;">';
- print '<tr style="width: 100%; height: 45px; text-align: center; background-color: lightgrey;"><td colspan="2">' . $langs->trans("PackageName") . '</td></tr>';
- if (!empty($packages)) {
- foreach ($packages as $package) {
- $coloredLine = $id == $package['rowid'] ? ' background-color: #b0c4de' : '';
- print '<tr class="submitFormLink" data-value="' . $package['rowid'] . '" style="height:30px; cursor:pointer;' . $coloredLine . '">
- <td><span class="fa fa-group pictofixedwidth"></span> ' . $package['ref'] . '</td>
- <td>' . $package['entity'] . '</td>
- </tr>';
- }
- } else {
- print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('nogroup') . '</td></tr>';
- }
- print '</table>';
- //---------------------------------------------
- #2
- //---------------------------------------------
- $isClosed = $helper->isClosed($id);
- $disabledCheckbox = $isClosed ? '' : 'disabled';
- $packageName = $helper->getPackageName($packages, $id);
- print '</div><div class="" style="width:33%;float:left;">';
- print '<table style="width:100%;">';
- 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>';
- if (!empty($devicesArray)) {
- 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>';
- foreach ($devicesArray as $tool) {
- $status2 = $tool['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
- $selected = in_array($tool['rowid'] . '_' . $tool['device_id'], $toselect) ? 'checked' : '';
- $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=';
- if ($tool['device_type'] == 1) {
- print '<tr style="height:30px; background-color: lightgrey;">
- <td><span class="fa fa-mobile pictofixedwidth"></span> <a href="' . $url . '">' . $tool['ref'] . '</a> ' . $status2 . '</td>
- <td>' . $tool['title'] . '<p>IMEI: ' . $tool['unique_identifier'] . '</p></td>
- <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>
- </tr>';
- $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=';
- $statusAssigned2 = $tool['assigned_device_data']['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
- print '<tr style="height:30px; background-color: lightgrey;">
- <td> <span class="fa fa-credit-card pictofixedwidth"></span> <a href="' . $urlAssigned_device . '">' . $tool['assigned_device_data']['ref'] . ' ' . $statusAssigned2 . '</td>
- <td>' . $tool['assigned_device_data']['title'] . '</td>
- <td class="nowrap center"></td>
- </tr>';
- } elseif ($tool['device_type'] == 0 || $tool['device_type'] == 3 || $tool['device_type'] == 4 || $tool['device_type'] == 5) {
- //} else {
- print '<tr style="height:30px;">
- <td><span class="fa fa-toolbox pictofixedwidth"></span><a href="' . $url . '"> ' . $tool['ref'] . '</a> ' . $status2 . '</td>
- <td>' . $tool['title'] . '</td>
- <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>
- </tr>';
- }
- }
- } else {
- print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('nodeviceassigned') . '</td></tr>';
- }
- print '</table>';
- //---------------------------------------------
- #3
- //---------------------------------------------
- print '</div><div class="" style="width:33%;float:left;">';
- print '<table style="width:100%;">';
- print '<tr style="width: 100%; height: 45px; text-align: center; background-color: lightgrey;"><td colspan="3">' . $langs->trans("freedevices") . '</td></tr>';
- 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>
- <td id="delete_search" class="center" onclick="deleteFunction()"><div style="cursor: pointer;"><span class="fa fa-trash"></span></div>
- </td></tr>';
- if ($isClosed) {
- if (is_array($allTools['freeTools']) && !empty($packages)) {
- print '<td colspan="3"><div id="searchedToolsDiv">
- <table style="width:100%;">';
- foreach ($allTools['freeTools'] as $freeTool) {
- $status3 = $freeTool['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
- $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=';
- if ($freeTool['device_type'] == 1) {
- $disabled = !isset($freeTool['assigned_device_data']) ? 'disabled' : '';
- print '
- <tr style="height:30px; background-color: lightgrey;">
- <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>
- <td><span class="fa fa-mobile pictofixedwidth"></span> <a href="' . $url_3 . '">' . $freeTool['ref'] . '</a> - ' . $freeTool['title'] . ' ' . $status . '</td>
- </tr>';
- $statusAssigned3 = $freeTool['assigned_device_data']['status'] != 115 ? '<span class="fa fa-exclamation pictofixedwidth" style="color:red;"></span>' : '';
- print '
- <tr style="height:30px; background-color: lightgrey;">';
- $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=';
- print '<td class="nowrap center"></td>';
- if (!isset($freeTool['assigned_device_data'])) {
- print '<td style="color: red;"> <span class="fa fa-credit-card pictofixedwidth"></span>' . $langs->trans('NoCardreadder') . '</td>';
- } else {
- print '<td> <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>';
- }
- print '</tr>';
- } elseif ($freeTool['device_type'] == 0 || $freeTool['device_type'] == 3 || $freeTool['device_type'] == 4 || $freeTool['device_type'] == 5) {
- print '
- <tr style="height:30px;">
- <td class="nowrap center"><input id="id_3_' . $freeTool['rowid'] . '" class="flat checkforselectadd" type="checkbox" onclick="submitFormAddTool(event)" name="toselectnewtool[]" value="' . $freeTool['rowid'] . '"></td>
- <td><span class="fa fa-toolbox pictofixedwidth"></span> <a href="' . $url_3 . '">' . $freeTool['ref'] . '</a> - ' . $freeTool['title'] . ' ' . $status3 . '</td>
- </tr>';
- }
- }
- print '</table>';
- print $helper->addedToolsDiv($allTools);
- print '</div></td>';
- }
- } else {
- print '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('ClosedPackage') . '</td></tr>';
- }
- print '</div></div>';
- print '</form>' . "\n";
- // End of page
- llxFooter();
- $db->close();
- ?>
- <script>
- $(document).ready(function () {
- // Az űrlap elküldése, ha a checkbox változik
- $('.entitiesChk').change(function () {
- $('#searchFormList').submit();
- });
- var elements = document.getElementsByClassName('submitFormLink');
- for (var i = 0; i < elements.length; i++) {
- elements[i].addEventListener('click', function (event) {
- event.preventDefault();
- var form = document.getElementById('searchFormList');
- var actionValue = form.getAttribute('action');
- var clickedElementValue = this.getAttribute('data-value');
- lastIndex = actionValue.lastIndexOf('&');
- var trimmedQueryString = actionValue.substring(0, lastIndex);
- form.action = trimmedQueryString + '&id=' + clickedElementValue;
- document.getElementById('searchFormList').submit();
- });
- }
- });
- function groupconfirm() {
- $('.checkforselect').prop('checked', true);
- }
- function deleteFunction() {
- $("#name_search").val('');
- $(".checkforselectadd").prop('checked', false);
- $("#delete").val(1);
- document.getElementById("searchFormList").submit();
- }
- function submitFormAjaxTools() {
- var input = document.getElementById("name_search");
- var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
- var values = Array.from(checkboxes).map(function (checkbox) {
- return checkbox.value;
- });
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "ajaxtools.php?search_title=" + input.value + "&toselectnewtool=" + values + "&groupid=" + groupid.value, true);
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4 && xhr.status === 200) {
- $("#searchedToolsDiv").html(xhr.responseText);
- }
- };
- xhr.send();
- }
- function submitFormAddTool(event) {
- //alert('asd');
- var checkbox = event.target;
- var groupid = document.getElementById("groupid");
- if (checkbox.checked) {
- var input = document.getElementById("name_search");
- var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
- var values = Array.from(checkboxes).map(function (checkbox1) {
- return checkbox1.value;
- });
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "ajaxtools.php?search_title=" + input.value + "&toselectnewtool=" + values + "&groupid=" + groupid.value, true);
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4 && xhr.status === 200) {
- $("#searchedToolsDiv").html(xhr.responseText);
- }
- };
- xhr.send();
- } else {
- var input = document.getElementById("name_search");
- var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
- var values = Array.from(checkboxes).map(function (checkbox1) {
- return checkbox1.value;
- });
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "ajaxtools.php?search_title=" + input.value + "&reduction=" + values + "&groupid=" + groupid.value, true);
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4 && xhr.status === 200) {
- $("#searchedToolsDiv").html(xhr.responseText);
- }
- };
- xhr.send();
- }
- }
- $('.massactionaddconfirmed').click(function () {
- $("#name_search").val('');
- })
- $('.massactionconfirmed').click(function () {
- $("#name_search").val('');
- $("#deletechk").val(1);
- })
- $('.checkforallselect').click(function () {
- if ($(this).is(':checked')) {
- $('.checkforselect').prop('checked', true);
- $('#divDelete').css('display', 'inline-block');
- $('#massaction').css('display', 'inline-block');
- $('.massactionselect ').css('display', '');
- $('.massactionconfirmed ').css('display', '');
- } else {
- $('#divDelete').css('display', 'none');
- $('.checkforselect').prop('checked', false);
- $('#massaction').css('display', 'none');
- $('.massactionselect ').css('display', 'none');
- $('.massactionconfirmed ').css('display', 'none');
- }
- })
- $('.checkforselect').click(function () {
- if ($(this).is(':checked')) {
- $('#divDelete').css('display', 'inline-block');
- $('#massaction').css('display', 'inline-block');
- $('.massactionselect ').css('display', '');
- $('.massactionconfirmed ').css('display', '');
- } else {
- $('#massaction').css('display', 'none');
- $('#divDelete').css('display', 'none');
- $('.massactionselect ').css('display', 'none');
- $('.massactionconfirmed ').css('display', 'none');
- }
- })
- $('.checkforselectadd').click(function () {
- if ($(this).is(':checked')) {
- $('#divAdd').css('display', 'inline-block');
- $('#massactionadd').css('display', 'inline-block');
- $('.massactionaddselect ').css('display', '');
- $('.massactionaddconfirmed ').css('display', '');
- } else {
- $('#divAdd').css('display', 'none');
- $('#massactionadd').css('display', 'none');
- $('.massactionaddselect ').css('display', 'none');
- $('.massactionaddconfirmed ').css('display', 'none');
- }
- })
- var input = document.getElementById("name_search");
- input.focus();
- input.setSelectionRange(input.value.length, input.value.length);
- </script>
|