Skip to content

Commit de22875

Browse files
authored
Update productsView.tpl
- Translating danish to english - Added stock input field for later use
1 parent 72aafec commit de22875

1 file changed

Lines changed: 171 additions & 164 deletions

File tree

templates/admin/productsView.tpl

Lines changed: 171 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
<div class="card card-body">
77
<h1>Edit product</h1>
88

9-
<div>
9+
<div>
1010

11-
<!-- Button to open modal upload -->
12-
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#primaryImageModal">
13-
Select images and files
14-
</button>
11+
<!-- Button to open modal upload -->
12+
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#primaryImageModal">
13+
Select images and files
14+
</button>
1515

1616

17-
</div>
17+
</div>
1818

1919
<form method="post" action="/admin/products.php">
2020
<input type="hidden" name="action" value="update">
2121
<input type="hidden" name="id" value="{$smarty.get.id|default:0}">
2222

2323
<label class="active"></label>
2424

25-
<input type="checkbox" name="active" data-toggle="toggle" {if $productData.active=="1" }checked{/if}> Active<br>
25+
<input type="checkbox" name="active" data-toggle="toggle" {if $productData.active=="1" }checked{/if}>
26+
Active<br>
2627

2728
<label for="name">Name</label>
2829
<input type="text" name="name" class="form-control" value="{$productData.name}"><br>
@@ -49,9 +50,14 @@
4950
<input type="text" name="sku" class="form-control" value="{$productData.sku|default:''}"
5051
placeholder="Example: 5901234123457"><br>
5152

53+
<label for="name">Stock</label>
54+
<input type="text" name="sku" class="form-control" value="{$productData.stock|default:'1'}"
55+
placeholder="Example: 1"><br>
56+
5257

53-
<label for="name">Weight ({$settingStoreWeightType})</label>
54-
<input type="text" name="weight" class="form-control" value="{$productData.weight|default:''}"><br>
58+
59+
<label for="name">Weight ({$settingStoreWeightType})</label>
60+
<input type="text" name="weight" class="form-control" value="{$productData.weight|default:''}"><br>
5561

5662
<div style="border: 1px solid #cecece;padding: 20px;margin-bottom:20px;">
5763
<h2>Prices</h2>
@@ -143,7 +149,7 @@
143149
</table>
144150
<!--Table-->
145151

146-
152+
147153
</div>
148154

149155

@@ -155,174 +161,175 @@
155161

156162

157163
</div>
158-
159-
160-
161-
162-
<!-- Primary Image Modal -->
163-
<div class="modal fade" id="primaryImageModal" tabindex="-1" role="dialog" aria-labelledby="primaryImageModalLabel" aria-hidden="true">
164-
<div class="modal-dialog modal-xl" role="document">
165-
<div class="modal-content">
166-
<div class="modal-header">
167-
<h5 class="modal-title" id="primaryImageModalLabel">Select files</h5>
168-
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
169-
<span aria-hidden="true">&times;</span>
170-
</button>
171-
</div>
172-
<div class="modal-body">
173-
{include file='mediaSelect.tpl'}
174-
</div>
175-
<div class="modal-footer">
176-
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
164+
165+
166+
167+
168+
<!-- Primary Image Modal -->
169+
<div class="modal fade" id="primaryImageModal" tabindex="-1" role="dialog" aria-labelledby="primaryImageModalLabel"
170+
aria-hidden="true">
171+
<div class="modal-dialog modal-xl" role="document">
172+
<div class="modal-content">
173+
<div class="modal-header">
174+
<h5 class="modal-title" id="primaryImageModalLabel">Select files</h5>
175+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
176+
<span aria-hidden="true">&times;</span>
177+
</button>
178+
</div>
179+
<div class="modal-body">
180+
{include file='mediaSelect.tpl'}
181+
</div>
182+
<div class="modal-footer">
183+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
184+
</div>
177185
</div>
178186
</div>
179187
</div>
180-
</div>
181188

182189

183190
<!-- JavaScript til filtrering og modal -->
184-
<script>
185-
document.getElementById('fileSearch').addEventListener('input', function () {
186-
var searchQuery = this.value.toLowerCase();
187-
var fileRows = document.querySelectorAll('.file-row');
188-
189-
fileRows.forEach(function(row) {
190-
var fileName = row.querySelector('td').textContent.toLowerCase();
191-
if (fileName.includes(searchQuery)) {
192-
row.style.display = '';
193-
} else {
194-
row.style.display = 'none';
195-
}
191+
<script>
192+
document.getElementById('fileSearch').addEventListener('input', function () {
193+
var searchQuery = this.value.toLowerCase();
194+
var fileRows = document.querySelectorAll('.file-row');
195+
196+
fileRows.forEach(function (row) {
197+
var fileName = row.querySelector('td').textContent.toLowerCase();
198+
if (fileName.includes(searchQuery)) {
199+
row.style.display = '';
200+
} else {
201+
row.style.display = 'none';
202+
}
203+
});
196204
});
197-
});
198-
199-
// Event listener for knapperne
200-
document.querySelectorAll('.make-primary-btn').forEach(function(button) {
201-
button.addEventListener('click', function() {
202-
var fileName = this.getAttribute('data-file');
203-
var currentFolder = this.getAttribute('data-currentFolder');
204-
var action = this.getAttribute('data-action');
205-
var id = this.getAttribute('data-id');
206-
207-
// Send AJAX request to /admin/inc/mediaSelect.php
208-
var xhr = new XMLHttpRequest();
209-
xhr.open('POST', '/admin/inc/mediaSelect.php', true);
210-
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
211-
212-
xhr.onload = function() {
213-
if (xhr.status === 200) {
214-
var response = JSON.parse(xhr.responseText);
215-
if (response.status === 'success') {
216-
// Skift tekst på knappen for at vise 'Remove as Primary' eller 'Make Primary'
217-
if (action === 'makePrimary') {
218-
button.textContent = 'Remove as Primary';
219-
button.setAttribute('data-action', 'removePrimary');
205+
206+
// Event listener for knapperne
207+
document.querySelectorAll('.make-primary-btn').forEach(function (button) {
208+
button.addEventListener('click', function () {
209+
var fileName = this.getAttribute('data-file');
210+
var currentFolder = this.getAttribute('data-currentFolder');
211+
var action = this.getAttribute('data-action');
212+
var id = this.getAttribute('data-id');
213+
214+
// Send AJAX request to /admin/inc/mediaSelect.php
215+
var xhr = new XMLHttpRequest();
216+
xhr.open('POST', '/admin/inc/mediaSelect.php', true);
217+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
218+
219+
xhr.onload = function () {
220+
if (xhr.status === 200) {
221+
var response = JSON.parse(xhr.responseText);
222+
if (response.status === 'success') {
223+
// Switch text on button 'Remove as Primary' or 'Make Primary'
224+
if (action === 'makePrimary') {
225+
button.textContent = 'Remove as Primary';
226+
button.setAttribute('data-action', 'removePrimary');
227+
} else {
228+
button.textContent = 'Make Primary';
229+
button.setAttribute('data-action', 'makePrimary');
230+
}
231+
alert(response.message);
232+
} else {
233+
alert('Error: ' + response.message);
234+
}
220235
} else {
221-
button.textContent = 'Make Primary';
222-
button.setAttribute('data-action', 'makePrimary');
236+
alert('Error: ' + xhr.statusText);
223237
}
224-
alert(response.message);
225-
} else {
226-
alert('Error: ' + response.message);
227-
}
228-
} else {
229-
alert('Error: ' + xhr.statusText);
230-
}
231-
};
232-
233-
xhr.onerror = function() {
234-
alert('Request failed');
235-
};
236-
237-
xhr.send('fileName=' + encodeURIComponent(fileName) + '&currentFolder=' + encodeURIComponent(currentFolder) + '&action=' + encodeURIComponent(action) + '&id=' + encodeURIComponent(id));
238-
});
239-
});
240-
241-
// Event listener for knapperne til 'Make Gallery'
242-
document.querySelectorAll('.make-gallery-btn').forEach(function(button) {
243-
button.addEventListener('click', function() {
244-
var fileName = this.getAttribute('data-file');
245-
var currentFolder = this.getAttribute('data-currentFolder');
246-
var action = this.getAttribute('data-action');
247-
var id = this.getAttribute('data-id');
248-
249-
// Send AJAX request to /admin/inc/mediaSelect.php
250-
var xhr = new XMLHttpRequest();
251-
xhr.open('POST', '/admin/inc/mediaSelect.php', true);
252-
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
253-
254-
xhr.onload = function() {
255-
if (xhr.status === 200) {
256-
var response = JSON.parse(xhr.responseText);
257-
if (response.status === 'success') {
258-
// Skift tekst på knappen for at vise 'Remove from Gallery' eller 'Make Gallery'
259-
if (action === 'makeGallery') {
260-
button.textContent = 'Remove from Gallery';
261-
button.setAttribute('data-action', 'removeGallery');
238+
};
239+
240+
xhr.onerror = function () {
241+
alert('Request failed');
242+
};
243+
244+
xhr.send('fileName=' + encodeURIComponent(fileName) + '&currentFolder=' + encodeURIComponent(currentFolder) + '&action=' + encodeURIComponent(action) + '&id=' + encodeURIComponent(id));
245+
});
246+
});
247+
248+
// Event listener for 'Make Gallery' buttons
249+
document.querySelectorAll('.make-gallery-btn').forEach(function (button) {
250+
button.addEventListener('click', function () {
251+
var fileName = this.getAttribute('data-file');
252+
var currentFolder = this.getAttribute('data-currentFolder');
253+
var action = this.getAttribute('data-action');
254+
var id = this.getAttribute('data-id');
255+
256+
// Send AJAX request to /admin/inc/mediaSelect.php
257+
var xhr = new XMLHttpRequest();
258+
xhr.open('POST', '/admin/inc/mediaSelect.php', true);
259+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
260+
261+
xhr.onload = function () {
262+
if (xhr.status === 200) {
263+
var response = JSON.parse(xhr.responseText);
264+
if (response.status === 'success') {
265+
// Switch text on button 'Remove from Gallery' or 'Make Gallery'
266+
if (action === 'makeGallery') {
267+
button.textContent = 'Remove from Gallery';
268+
button.setAttribute('data-action', 'removeGallery');
269+
} else {
270+
button.textContent = 'Make Gallery';
271+
button.setAttribute('data-action', 'makeGallery');
272+
}
273+
alert(response.message);
274+
} else {
275+
alert('Error: ' + response.message);
276+
}
262277
} else {
263-
button.textContent = 'Make Gallery';
264-
button.setAttribute('data-action', 'makeGallery');
278+
alert('Error: ' + xhr.statusText);
265279
}
266-
alert(response.message);
267-
} else {
268-
alert('Error: ' + response.message);
269-
}
270-
} else {
271-
alert('Error: ' + xhr.statusText);
272-
}
273-
};
274-
275-
xhr.onerror = function() {
276-
alert('Request failed');
277-
};
278-
279-
xhr.send('fileName=' + encodeURIComponent(fileName) + '&currentFolder=' + encodeURIComponent(currentFolder) + '&action=' + encodeURIComponent(action) + '&id=' + encodeURIComponent(id));
280-
});
281-
});
282-
283-
// Event listener for knapperne til 'Make Additional'
284-
document.querySelectorAll('.make-additional-btn').forEach(function(button) {
285-
button.addEventListener('click', function() {
286-
var fileName = this.getAttribute('data-file');
287-
var currentFolder = this.getAttribute('data-currentFolder');
288-
var action = this.getAttribute('data-action');
289-
var id = this.getAttribute('data-id');
290-
291-
// Send AJAX request to /admin/inc/mediaSelect.php
292-
var xhr = new XMLHttpRequest();
293-
xhr.open('POST', '/admin/inc/mediaSelect.php', true);
294-
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
295-
296-
xhr.onload = function() {
297-
if (xhr.status === 200) {
298-
var response = JSON.parse(xhr.responseText);
299-
if (response.status === 'success') {
300-
// Skift tekst på knappen for at vise 'Remove from Additional' eller 'Make Additional'
301-
if (action === 'makeAdditional') {
302-
button.textContent = 'Remove from Additional';
303-
button.setAttribute('data-action', 'removeAdditional');
280+
};
281+
282+
xhr.onerror = function () {
283+
alert('Request failed');
284+
};
285+
286+
xhr.send('fileName=' + encodeURIComponent(fileName) + '&currentFolder=' + encodeURIComponent(currentFolder) + '&action=' + encodeURIComponent(action) + '&id=' + encodeURIComponent(id));
287+
});
288+
});
289+
290+
// Event listener for button 'Make Additional'
291+
document.querySelectorAll('.make-additional-btn').forEach(function (button) {
292+
button.addEventListener('click', function () {
293+
var fileName = this.getAttribute('data-file');
294+
var currentFolder = this.getAttribute('data-currentFolder');
295+
var action = this.getAttribute('data-action');
296+
var id = this.getAttribute('data-id');
297+
298+
// Send AJAX request to /admin/inc/mediaSelect.php
299+
var xhr = new XMLHttpRequest();
300+
xhr.open('POST', '/admin/inc/mediaSelect.php', true);
301+
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
302+
303+
xhr.onload = function () {
304+
if (xhr.status === 200) {
305+
var response = JSON.parse(xhr.responseText);
306+
if (response.status === 'success') {
307+
// Switch text on button 'Remove from Additional' or 'Make Additional'
308+
if (action === 'makeAdditional') {
309+
button.textContent = 'Remove from Additional';
310+
button.setAttribute('data-action', 'removeAdditional');
311+
} else {
312+
button.textContent = 'Make Additional';
313+
button.setAttribute('data-action', 'makeAdditional');
314+
}
315+
alert(response.message);
316+
} else {
317+
alert('Error: ' + response.message);
318+
}
304319
} else {
305-
button.textContent = 'Make Additional';
306-
button.setAttribute('data-action', 'makeAdditional');
320+
alert('Error: ' + xhr.statusText);
307321
}
308-
alert(response.message);
309-
} else {
310-
alert('Error: ' + response.message);
311-
}
312-
} else {
313-
alert('Error: ' + xhr.statusText);
314-
}
315-
};
322+
};
316323
317-
xhr.onerror = function() {
318-
alert('Request failed');
319-
};
324+
xhr.onerror = function () {
325+
alert('Request failed');
326+
};
327+
328+
xhr.send('fileName=' + encodeURIComponent(fileName) + '&currentFolder=' + encodeURIComponent(currentFolder) + '&action=' + encodeURIComponent(action) + '&id=' + encodeURIComponent(id));
329+
});
330+
});
320331
321-
xhr.send('fileName=' + encodeURIComponent(fileName) + '&currentFolder=' + encodeURIComponent(currentFolder) + '&action=' + encodeURIComponent(action) + '&id=' + encodeURIComponent(id));
322-
});
323-
});
324332
333+
</script>
325334

326-
</script>
327-
328-
{include file='template-parts/footer.tpl'}
335+
{include file='template-parts/footer.tpl'}

0 commit comments

Comments
 (0)