Nothing serious:
Code: Select all
<script>
$(document).ready(function() {
if (<?= ((isset($action) && $action == 'new') ? 'true' : 'false')?>) {
onload();
}
});
function applies_to_onclick() {
var a = document.new_discount_code.applies_to, b = document.getElementById("excluded_products_id"), c = document.getElementById("number_of_products"), d = document.getElementById("exclude_specials"), e = document.getElementById("products_id"), f = document.getElementById("categories_id"), g = document.getElementById("manufacturers_id");
for (var i = 0, n = a.length; i < n; i++) if (a[i].checked) { b.disabled = (a[i].value == 2 || a[i].value == 4 ? false : true); c.disabled = (a[i].value == 3 || a[i].value == 5 || a[i].value == 6 ? true : false); d.disabled = (a[i].value == 3 || a[i].value == 6 ? true : false); e.disabled = (a[i].value == 1 ? false : true); f.disabled = (a[i].value == 2 ? false : true); g.disabled = (a[i].value == 4 ? false : true) }
}
function customers_onclick() {
var d = document.getElementById("customers"), e = document.getElementById("customers_id"); e.disabled = !d.checked;
}
function onload() {
applies_to_onclick();
customers_onclick();
}
$('#expires_date').datepicker({
dateFormat: 'yy-mm-dd'
});
</script>Code: Select all
<script>
document.addEventListener('DOMContentLoaded', function () {
const actionIsNew = <?= ((isset($action) && $action == 'new') ? 'true' : 'false') ?>;
if (actionIsNew) {
onload();
}
});
function applies_to_onclick() {
const form = document.forms['new_discount_code'];
const applies_to = form?.elements['applies_to'];
const excluded_products_id = document.getElementById("excluded_products_id");
const number_of_products = document.getElementById("number_of_products");
const exclude_specials = document.getElementById("exclude_specials");
const products_id = document.getElementById("products_id");
const categories_id = document.getElementById("categories_id");
const manufacturers_id = document.getElementById("manufacturers_id");
if (!applies_to) return;
for (let i = 0; i < applies_to.length; i++) {
if (applies_to[i].checked) {
const val = parseInt(applies_to[i].value, 10);
excluded_products_id.disabled = !(val === 2 || val === 4);
number_of_products.disabled = (val === 3 || val === 5 || val === 6);
exclude_specials.disabled = (val === 3 || val === 6);
products_id.disabled = (val !== 1);
categories_id.disabled = (val !== 2);
manufacturers_id.disabled = (val !== 4);
break;
}
}
}
function customers_onclick() {
const customers = document.getElementById("customers");
const customers_id = document.getElementById("customers_id");
if (customers && customers_id) {
customers_id.disabled = !customers.checked;
}
}
function onload() {
applies_to_onclick();
customers_onclick();
}
</script>and line 115 changed from
Code: Select all
<div class="col-sm-6"><?= new Input('expires_date', ['value' => $dInfo->expires_date, 'min' => date('Y-m-d'), 'id' => 'expires_date', 'style' => 'width: 150px;', 'onfocus' => 'this.showPicker?.()'], 'date') ?>Code: Select all
<div class="col-sm-6"><?= new Input('expires_date', ['value' => $dInfo->expires_date, 'min' => date('Y-m-d'), 'id' => 'expires_date', 'style' => 'width: 150px;'], 'date') ?>Code: Select all
<div class="col-sm-6"><?= new Input('order_number', ['value' => $dInfo->order_number, 'id' => 'order_number', 'style' => 'width: 50px;']) ?>Code: Select all
<div class="col-sm-6"><?= new Input('order_number', ['value' => $dInfo->order_number, 'id' => 'order_number', 'style' => 'width: 150px;']) ?>