Repository navigation
Expand file tree
/
Copy pathjavascript.js
More file actions
113 lines (97 loc) · 3.66 KB
/
Copy pathjavascript.js
File metadata and controls
113 lines (97 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
function toggle(source) {
checkboxes = document.getElementsByName('id[]');
checkboxes.forEach(
function toogleCheckboxes(checkbox, index) { // checkbox je HTML element
if (document.getElementById('row_' + checkbox.value).style.display === 'none') {
checkbox.checked = false;
}
else {
checkbox.checked = source.checked;
}
}
);
}
function searchChanged() {
var search = document.getElementById('search').value;
rows = document.querySelectorAll('[name^="row_"]');
rows.forEach(
function research(row, index) {
var toHide = true;
if ((row.cells[2].innerHTML).indexOf(search) != -1 ||
(row.cells[3].innerHTML).indexOf(search) != -1 ||
(row.cells[5].innerHTML).indexOf(search) != -1 ||
(row.cells[6].innerHTML).indexOf(search) != -1 ||
(row.cells[7].innerHTML).indexOf(search) != -1)
{ toHide = false; }
if (toHide == true) {
row.style.display = 'none';
row.cells[0].getElementsByTagName('input')[0].checked = false;
}
else { row.style.display = ''; }
}
);
}
function changeFilter(preselectedValue) {
// FILTER LOCATION
var filter = prompt("Nastavit filtr:", preselectedValue);
var filterValue = filter.replace("*", "%");
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
window.location = 'index.php?order=' + urlParams.get('order') + '&sort=' + urlParams.get('sort') + '&action=filterLocation&value=' + filterValue;
}
function changeAction() {
// CHANGE LOCATION
if(document.getElementById('changeSelect').value === 'change_location') {
var moveTo = prompt("Kam přemístit?");
if (moveTo == null) { return false; }
else { document.getElementsByName('changeValue')[0].value = moveTo; }
document.getElementById("mainForm").submit();
}
// CHANGE BATCH
else if(document.getElementById('changeSelect').value === 'change_batch') {
var batchTo = prompt("Na jakou šarži změnit?");
if (batchTo == null) { return false; }
else { document.getElementsByName('changeValue')[0].value = batchTo; }
document.getElementById("mainForm").submit();
}
// EXPORT SELECTION - does not work
else if(document.getElementById('changeSelect').value === 'export_selection') {
var ids = [];
checkboxes = document.getElementsByName('id[]');
checkboxes.forEach(
function toogleCheckboxes(checkbox, index) { // checkbox je HTML element
if (document.getElementById('row_' + checkbox.value).style.display !== 'none') {
ids.push(checkbox.value);
}
}
);
if(ids.length > 0) {
var ids_joined = ids.join(',');
window.location = 'export.php?ids=' + ids_joined;
}
}
// DELETE SELECTION
else if(document.getElementById('changeSelect').value === 'delete_selection') {
var conf = confirm("Opravdu nenávratně VŠE vybrané smazat?");
if (conf === true) { document.getElementById("mainForm").submit(); }
else { return false; }
}
// ELSE
else {
alert('Musíte vybrat možnost!');
return false;
}
}
function changeActionLocation() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
if(document.getElementById('changeSelectLocation').value === '0') {
// reload to same URL remove "mainlocation"
urlParams.delete("mainlocation");
}
else {
// reload same URL add/edit "mainlocation" = document.getElementById('changeSelectLocation').value
urlParams.set("mainlocation", document.getElementById('changeSelectLocation').value);
}
window.location = 'index.php?' + urlParams.toString();
}