summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/templates/location-info.html
blob: 9e4e886de811eb87b9ebf7daa212ed81df15b2f7 (plain) (blame)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<div>
<h1>{{lang_mainHeader}}</h1>

<!-- The Modal -->
<div id="popup" class="modal">
  <!-- Modal content -->
  <div class="modal-content">
    <span class="close" onclick="closePopup()">x</span>
    <label id=1></label>
    <br>

    <!--  vvvv TEST STUFF vvvv-->
    <table class="table table-condensed locations" style="margin-bottom:0px">
      <tr>
        <th>{{lang_day}}</th>
        <th>{{lang_openingTime}}</th>
        <th>{{lang_closingTime}}</th>
      </tr>

      <tr>
        <td>Monday</td>
        <td>08:00</td>
        <td>16:00</td>
      </tr>

      <tr>
        <td>MO, DI, MI, DO, FR, SA</td>
        <td>08:00</td>
        <td>21:00</td>
      </tr>

      <tr>
        <td>SO</td>
        <td>10:00</td>
        <td>12:00</td>
      </tr>

      <tr>
        <td>MON, TUE, WED, THU, FRI, SAT, SUN</td>
        <td>10:00</td>
        <td>12:00</td>
      </tr>

      <tr>
        <td>
          <label><input type="checkbox" value="Monday">{{lang_shortMonday}}</label>
          <label><input type="checkbox" value="Tuesday">{{lang_shortTuesday}}</label>
          <label><input type="checkbox" value="Wednesday">{{lang_shortWednesday}}</label>
          <label><input type="checkbox" value="Thursday">{{lang_shortThursday}}</label>
          <label><input type="checkbox" value="Friday">{{lang_shortFriday}}</label>
          <label><input type="checkbox" value="Saturday">{{lang_shortSaturday}}</label>
          <label><input type="checkbox" value="Sunday">{{lang_shortSunday}}</label>
        </td>
        <td>
          <label><input type="text" onkeypress="return isNumber(event)" style="width:35px;"> :</label>
          <input type="text" onkeypress="return isNumber(event)" style="width:35px;">
        </td>
        <td>
          <label><input type="text" onkeypress="return isNumber(event)" style="width:35px;"> :</label>
          <input type="text" onkeypress="return isNumber(event)" style="width:35px;">
        </td>
      </tr>
    </table>

    <!--  ^^^^ TEST STUFF ^^^^-->

    <button class="btn btn-success btn-sm">Add</button>
    <button class="btn btn-sm btn-danger">Delete</button>


    <br><br>
		<button class="btn btn-primary">Save</button>
    <div class="divider"></div>
		<button class="btn btn-sm btn-danger" onclick="closePopup()">Cancel</button>
  </div>

</div>
<script>

// Get the modal
var modal = document.getElementById('popup');

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on the button, open the modal
function openPopup(locID) {
    modal.style.display = "block";

    $('#1').text('Location ID: ' + locID);
}

// When the user clicks on <span> (x), close the modal
function closePopup() {
    modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}
</script>

<table class="table table-condensed locations" style="margin-bottom:0px">

	<tr>
		<th>{{lang_locationID}}</th>
		<th>{{lang_locationInUse}}</th>
    <th width=50>{{lang_locationIsHidden}}</th>
    <th width=50>{{lang_locationSettings}}</th>
	</tr>

{{#list}}
	<tr class="tablerow" onclick="slxOpenLocationInfo(this, {{locationid}})">
		<td>
			<div style="display:inline-block;width:{{depth}}em"></div>
			<a href="#" >{{locationid}}<b class="caret"></b></a>
		</td>
		<td>{{inUse}} / {{totalPcs}}</td>
  	<!-- <td>{{hidden}}</td> -->
		<!-- <td><form><input type="checkbox" id={{locationid}} value={{hidden}}></form></td> -->
		<td id={{locationid}} onclick="event.cancelBubble = true;" align="center"></td>
		<script>
			var cbh = document.getElementById('{{locationid}}');
    	var cb = document.createElement('input');
    	cb.type = 'checkbox';

    	cbh.appendChild(cb);
    	cb.id = 'cb' + {{locationid}};
    	cb.value = {{hidden}};
			if ({{hidden}} == 1) {
				cb.checked = true;
			}
			cb.addEventListener("click", function() { cbClick(this, {{locationid}}); });
    </script>

		<td><button onclick="event.cancelBubble = true; openPopup({{locationid}})">{{lang_locationSettings}}</button></td>

	</tr>
{{/list}}

</table>

<script type="text/javascript"><!--

function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}

var x = false;

var lastPcSubTable = false;

function cbClick(cb, locID) {
	// TODO TOGGLE CB and set db Value
	//alert("TODO set db value and toggle cb: " + locID);
	var value;

	if (cb.checked == true) {
		value = 1;
	} else {
		value = 0;
	}
	window.location.href = "?do=locationinfo&action=hide&id=" + locID + "&value=" + value;
}

function slxOpenLocationInfo(e, locationId) {
	if (lastPcSubTable !== false) {
		lastPcSubTable.hide();
		$(lastPcSubTable).prev().removeClass('active slx-bold');
	}

	var existing = $('#subtable' + locationId);
	if (existing.length > 0) {
		if (existing.is(lastPcSubTable)) {
			lastPcSubTable = false;
		} else {
			existing.show();
			$(e).closest('tr').addClass('active slx-bold');
			lastPcSubTable = existing;
		}
		return;
	}

	var td = $('<td>').attr('colspan', '2').css('padding', '0px 0px 12px');
	var tr = $('<tr>').attr('id', 'subtable' + locationId);
	tr.append(td);
	$(e).closest('tr').addClass('active slx-bold').after(tr);
	td.load("?do=locationinfo&action=pcsubtable&id=" + locationId);
	lastPcSubTable = tr;
}
	// -->
</script>