//SITEINSTRUCTION PAGE JS
if (page == "siteinstructionform.html") {
function PopulateDateDropDownSI() {
var si_menu = '';
//Date Menu From Json List
// Ajax Paramenters
var settings = {
"url": APP_URL + "datelistSISJ",
"method": "GET",
"dataType": "json",
"headers": {
"Authorization": auth
}
};
$.ajax(settings).done(function (response, status, xhr) {
si_menu += '
';
$.each(response._embedded, function (idx, resd) {
si_menu += '' + resd.day_name + '';
});
$("#si_menu").html(si_menu);
}).fail(function (jqXHR, exception) {
var msg = "";
msg = jqXHR.responseJSON["detail"];
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["title"];
}
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["phrase"];
}
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["status"];
}
alert(msg);
});
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.querySelectorAll('.needs-validation')
// Loop over them and prevent submission
Array.prototype.slice.call(forms)
.forEach(function (form) {
form.addEventListener('submit', function (event) {
if (!form.checkValidity()) {
event.preventDefault()
event.stopPropagation()
} else {
event.preventDefault();
event.stopPropagation();
var keywords = $("#txt_keywords").val().replace(' ', "+");;
// Ajax Paramenters
var settings = {
"async": true,
"crossDomain": true,
"url": APP_URL + "siteinstruction?search="+keywords,
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": auth
},
};
var SrchJobs = "",
TotalJobs_Cnt = 0,
SrchJobs_Cnt = 0;
// Ajax Submit
$.ajax(settings).done(function (response, status, xhr) {
if (status == "success" && xhr.status == "200") {
$(".lbl_srch").html(response["h2"]);
$.each(response._embedded, function (idx, res) {
$.each(res._links, function (idx, link) {
SrchJobs_Cnt = SrchJobs_Cnt + 1;
SrchJobs += '' +
'' +
'' + res.job_no + ' ' + cleanString(res.job_name) +
'
' +
'' + res.job_no + '' +
'' +
'' +
'';
});
});
TotalJobs_Cnt = SrchJobs_Cnt;
$(".lbl_TotalJobs_Cnt").html(TotalJobs_Cnt);
$(".lbl_SrchJobs_Cnt").html(SrchJobs_Cnt);
$("#SrchJobs .list-group").html(SrchJobs);
$('.text-addclamp').each(function (index, element) {
$clamp(element, {
clamp: 3,
useNativeClamp: false
});
});
$(form).trigger("reset");
$("#accordion1").addClass("d-none");
$("#serchDiv form").addClass("d-none");
$("#serchRes").removeClass("d-none");
} else {
alert("An error occurred: Please contact administrator");
}
}).fail(function (jqXHR, exception) {
var msg = "";
msg = jqXHR.responseJSON["detail"];
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["title"];
}
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["phrase"];
}
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["status"];
}
alert(msg);
location.reload();
});
}
form.classList.add('was-validated');
}, false)
})
}
PopulateDateDropDownSI();
function LoadSI(LoadURL) {
// Ajax Paramenters
var settings = {
"url": LoadURL,
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": auth
},
};
var PastJobs = "",
MyJobs = "",
OthersJobs = "",
TotalJobs_Cnt = 0,
PastJobs_Cnt = 0,
MyJobs_Cnt = 0,
OthersJobs_Cnt = 0;
// Ajax Submit
$.ajax(settings).done(function (response) {
$(".lbl_h1").html(response['h1']);
$.each(response._embedded['my_jobs'], function (idx, res) {
$(".lbl_h2").html(res['whichday']);
$.each(res['jobs'], function (idx, jobs) {
$.each(jobs._links, function (idx, link) {
MyJobs_Cnt = MyJobs_Cnt + 1;
MyJobs += '' +
'' +
'' + jobs.job_no + ' ' +
cleanString(jobs.job_description) +
'
' +
'' + jobs.job_no + ' ' + jobs.emp_inits + '' +
'' +
'' +
'';
});
});
});
$.each(response._embedded['other_jobs'], function (idx, res) {
$.each(res['jobs'], function (idx, jobs) {
$.each(jobs._links, function (idx, link) {
OthersJobs_Cnt = OthersJobs_Cnt + 1;
OthersJobs += '' +
'' +
'' + jobs.job_no + ' ' +
cleanString(jobs.job_description) +
'
' +
'' + jobs.job_no + ' ' + jobs.emp_inits + '' +
'' +
'' +
'';
});
});
});
$.each(response._embedded['yesterday_jobs'], function (idx, res) {
$.each(res['jobs'], function (idx, jobs) {
$.each(jobs._links, function (idx, link) {
PastJobs_Cnt = PastJobs_Cnt + 1;
PastJobs += '' +
'' +
'' + jobs.job_no + ' ' +
cleanString(jobs.job_description) +
'
' +
'' + jobs.job_no + ' ' + jobs.emp_inits + '' +
'' +
'' +
'';
});
});
});
if (PastJobs_Cnt > 0) {
$('.Yjob').removeClass('d-none');
} else {
$('.Yjob').addClass('d-none');
}
TotalJobs_Cnt = MyJobs_Cnt + OthersJobs_Cnt + PastJobs_Cnt;
$(".lbl_TotalJobs_Cnt").html(TotalJobs_Cnt);
$(".lbl_MyJobs_Cnt").html(MyJobs_Cnt);
$(".lbl_PastJobs_Cnt").html(PastJobs_Cnt);
$(".lbl_OthersJobs_Cnt").html(OthersJobs_Cnt);
$("#PastJobs .list-group").html(PastJobs);
$("#MyJobs .list-group").html(MyJobs);
$("#OtherJobs .list-group").html(OthersJobs);
$('.text-addclamp').each(function (index, element) {
$clamp(element, {
clamp: 3,
useNativeClamp: false
});
});
}).fail(function (jqXHR, exception) {
var msg = "";
msg = jqXHR.responseJSON["detail"];
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["title"];
}
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["phrase"];
}
if (msg == "" || msg == null || msg == "undefined") {
msg = jqXHR.responseJSON["status"];
}
alert(msg);
alert(msg);
});
}
var CallURL = localStorage.getItem("si_href");
LoadSI(CallURL);
//Date Change Clock On
$(document).on("click", ".si_date", function () {
var cDymcURL = $(this).attr("data-date");
LoadSI(cDymcURL);
});
//Open Job Details
$(document).on("click", ".btnOpenListSI", function () {
var DataURL = $(this).attr("data-URL");
localStorage.setItem("si_job_href", DataURL);
location.href = "job_details.html";
});
}
//SITEINSTRUCTION SEARCH JS
$(document).on("click", "#btnSearchSI", function () {
$("#accordion1").addClass("d-none");
$("#serchRes").addClass("d-none");
$("#serchDiv form").removeClass("d-none");
});