commit 24/10/2025
This commit is contained in:
@@ -66,8 +66,8 @@ function fill_schedulebanktablebody(vv) {
|
||||
* @param {String} value from input date, which is in format yyyy-mm-dd
|
||||
* @returns {String} converted date in format dd/mm/yyyy
|
||||
*/
|
||||
function Convert_input_date_to_string(value){
|
||||
if (value && value.length>0 && value.includes('-')){
|
||||
function Convert_input_date_to_string(value) {
|
||||
if (value && value.length > 0 && value.includes('-')) {
|
||||
let parts = value.split('-');
|
||||
if (parts.length === 3) {
|
||||
let year = parts[0];
|
||||
@@ -84,8 +84,8 @@ function Convert_input_date_to_string(value){
|
||||
* @param {String} value string date in format dd/mm/yyyy
|
||||
* @returns {String} converted date in format yyyy-mm-dd
|
||||
*/
|
||||
function Convert_string_to_input_date(value){
|
||||
if (value && value.length>0 && value.includes('/')){
|
||||
function Convert_string_to_input_date(value) {
|
||||
if (value && value.length > 0 && value.includes('/')) {
|
||||
let parts = value.split('/');
|
||||
if (parts.length === 3) {
|
||||
let day = parts[0];
|
||||
@@ -190,7 +190,7 @@ $(document).ready(function () {
|
||||
width: '100%',
|
||||
dropdownParent: $('#schedulemodal')
|
||||
});
|
||||
|
||||
|
||||
$scheduledate.prop('disabled', true).val('');
|
||||
$schedulezones.empty().select2({
|
||||
data: window.BroadcastZoneList.map(zone => ({ id: zone.description, text: zone.description })),
|
||||
@@ -295,7 +295,6 @@ $(document).ready(function () {
|
||||
const hour = parseInt($schedulehour.val(), 10);
|
||||
const minute = parseInt($scheduleminute.val(), 10);
|
||||
const _Time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
||||
console.log(`Adding schedule: Description=${Description}, Day=${_Day}, Time=${_Time}, Message=${Message}, Repeat=${Repeat}, Enable=${Enable}, BroadcastZones=${broadcastZones}, Language=${Language}`);
|
||||
if (Description.length > 0) {
|
||||
if (_Day.length > 0) {
|
||||
if (Message.length > 0) {
|
||||
@@ -367,7 +366,6 @@ $(document).ready(function () {
|
||||
BroadcastZones: cells.eq(7).text(),
|
||||
Language: cells.eq(8).text()
|
||||
}
|
||||
console.log('Editing schedule:', sr);
|
||||
if (confirm(`Are you sure to edit schedule [${sr.index}] Description=${sr.Description}?`)) {
|
||||
$schedulemodal.modal('show');
|
||||
clearScheduleModal();
|
||||
@@ -387,8 +385,13 @@ $(document).ready(function () {
|
||||
case 'Everyday':
|
||||
$scheduleeveryday.click();
|
||||
break;
|
||||
case 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday':
|
||||
console.log(`Setting weekly schedule for day: ${sr.Day}`);
|
||||
case 'Sunday' :
|
||||
case 'Monday':
|
||||
case 'Tuesday':
|
||||
case 'Wednesday':
|
||||
case 'Thursday':
|
||||
case 'Friday':
|
||||
case 'Saturday':
|
||||
$scheduleweekly.click();
|
||||
$weeklyselect.val(sr.Day).trigger('change');
|
||||
break;
|
||||
@@ -415,49 +418,50 @@ $(document).ready(function () {
|
||||
if ($scheduleeveryday.is(':checked')) {
|
||||
Day = "Everyday";
|
||||
} else if ($schedulespecialdate.is(':checked')) {
|
||||
Day = $scheduledate.val();
|
||||
} else {
|
||||
if ($schedulesunday.is(':checked')) Day = "Sunday";
|
||||
if ($schedulemonday.is(':checked')) Day = "Monday";
|
||||
if ($scheduletuesday.is(':checked')) Day = "Tuesday";
|
||||
if ($schedulewednesday.is(':checked')) Day = "Wednesday";
|
||||
if ($schedulethursday.is(':checked')) Day = "Thursday";
|
||||
if ($schedulefriday.is(':checked')) Day = "Friday";
|
||||
if ($schedulesaturday.is(':checked')) Day = "Saturday";
|
||||
// convert date from yyyy-mm-dd to dd/mm/yyyy
|
||||
Day = Convert_input_date_to_string($scheduledate.val());
|
||||
} else if ($scheduleweekly.is(':checked')) {
|
||||
Day = $weeklyselect.val();
|
||||
}
|
||||
// Broadcast zones (assuming comma-separated string)
|
||||
const BroadcastZones = $schedulezones.val();
|
||||
|
||||
// Validate required fields
|
||||
if (!Description || !Soundpath || Day === "") {
|
||||
alert("Description, sound path, and day are required.");
|
||||
return;
|
||||
}
|
||||
|
||||
const BroadcastZones = $schedulezones.val().join(';');
|
||||
const Language = $languageselect.val().join(';');
|
||||
// Format time as HH:mm
|
||||
const hour = parseInt($schedulehour.val(), 10);
|
||||
const minute = parseInt($scheduleminute.val(), 10);
|
||||
const Time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
||||
if (Description && Description.length > 0) {
|
||||
if (Day && Day.length > 0) {
|
||||
if (Soundpath && Soundpath.length > 0) {
|
||||
if (Time && Time.length > 0) {
|
||||
if (Language && Language.length > 0) {
|
||||
if (BroadcastZones && BroadcastZones.length > 0) {
|
||||
// Prepare object
|
||||
const scheduleObj = {
|
||||
Description,
|
||||
Day,
|
||||
Time,
|
||||
Soundpath,
|
||||
Repeat,
|
||||
Enable,
|
||||
BroadcastZones,
|
||||
Language
|
||||
};
|
||||
|
||||
// Prepare object
|
||||
const scheduleObj = {
|
||||
Description,
|
||||
Day,
|
||||
Time,
|
||||
Soundpath,
|
||||
Repeat,
|
||||
Enable,
|
||||
BroadcastZones
|
||||
};
|
||||
fetchAPI(APIURL + "UpdateByIndex/" + sr.index, "PATCH", {}, scheduleObj, (okdata) => {
|
||||
alert("Success edit schedule: " + okdata.message);
|
||||
reloadTimerBank(APIURL);
|
||||
}, (errdata) => {
|
||||
alert("Error edit schedule: " + errdata.message);
|
||||
});
|
||||
$schedulemodal.modal('hide');
|
||||
} else alert("At least one Broadcast Zone is required");
|
||||
} else alert("At least one Language is required");
|
||||
} else alert("Time is invalid");
|
||||
} else alert("Message is not selected");
|
||||
} else alert("Day is invalid");
|
||||
} else alert("Description is empty");
|
||||
|
||||
fetchAPI(APIURL + "UpdateByIndex/" + sr.index, "PATCH", {}, scheduleObj, (okdata) => {
|
||||
alert("Success edit schedule: " + okdata.message);
|
||||
reloadTimerBank(APIURL);
|
||||
}, (errdata) => {
|
||||
alert("Error edit schedule: " + errdata.message);
|
||||
});
|
||||
|
||||
$schedulemodal.modal('hide');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user