Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.191.223.30
Current Path : /var/www/html/oums/js/ |
| Current File : /var/www/html/oums/js/task_reminder.js |
function load_page() {
load_page_data(
window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
);
cncl_data();
}
function cncl_data() {
$("#page-container-body").load("task_reminder_grid.php", function () {
$("#btn_addn").show();
$("#btn_save").hide();
$("#btn_cncl").hide();
load_grid_data(20, 1);
});
}
function load_grid_data(page_limt, page_numb) {
$.ajax({
type: "POST",
url: "src/task_reminder.php",
data: {
load_data: "grid_data",
page_limt: page_limt,
page_numb: page_numb,
task_stat: document.getElementById("seltaskstat").value,
task_asby: document.getElementById("seltaskasby").value,
task_asto: document.getElementById("seltaskasto").value,
task_find: document.getElementById("txttaskfind").value,
},
cache: false,
success: function (data) {
$("#page-container-grid").html(data);
},
error: function (data) {
$("#page-container-grid").html("Error: " + data);
},
});
}
function load_page_limt(page_limt) {
load_grid_data(page_limt, 1);
}
function clrs_data() {
$("#btn_addn").hide();
$("#btn_save").show();
$("#btn_cncl").show();
$(function () {
$("#txttaskdate").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtstrtdate").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtlastdate").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtcompdate").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtremndat1").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtremndat2").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtremndat3").datepicker({ dateFormat: "dd/mm/yy" });
});
}
function addn_data() {
$("#page-container-body").load("task_reminder_form.php", function () {
clrs_data();
document.getElementById("lblpagemode").innerHTML = "Add";
document.getElementById("txtpagemode").value = "add";
document.getElementById("txttaskdate").value = get_today_date();
document.getElementById("txtstrtdate").value = get_today_date();
document.getElementById("txtlastdate").value = get_today_date();
document.getElementById("txttaskname").focus();
document.getElementById("txttaskstat").disabled = true;
document.getElementById("txtcompdate").disabled = true;
document.getElementById("txttaskasby").disabled = true;
document.getElementById("txttaskasto").disabled = false;
$.when($.ajax(load_empl_list())).then(function () {
$("#txttaskasby").val(document.getElementById("empl_id").value);
$("#txttaskasto").val(document.getElementById("empl_id").value);
});
});
}
function edit_data(prim_data) {
$("#page-container-body").load("task_reminder_form.php", function () {
clrs_data();
document.getElementById("lblpagemode").innerHTML = "Edit";
document.getElementById("txtpagemode").value = "edit";
document.getElementById("txttaskname").focus();
document.getElementById("txttaskasby").disabled = true;
document.getElementById("txttaskasto").disabled = false;
$.ajax({
type: "POST",
url: "src/task_reminder.php",
data: {
load_data: "disp_data",
task_code: prim_data,
},
cache: false,
success: function (data) {
var data = JSON.parse(data);
document.getElementById("txttaskcode").value = data.ftaskcode;
document.getElementById("txttaskdate").value = get_format_date(
data.ftaskdate
);
document.getElementById("txttaskname").value = data.ftaskname;
document.getElementById("txttaskdetl").value = data.ftaskdetl;
document.getElementById("txttaskasto").value = data.femplasto;
document.getElementById("txtstrtdate").value = get_format_date(
data.fstrtdate
);
document.getElementById("txtlastdate").value = get_format_date(
data.flastdate
);
document.getElementById("txttaskstat").value = data.ftaskstat;
document.getElementById("txtcompdate").value = get_format_date(
data.fcompdate
);
document.getElementById("txtremndat1").value = get_format_date(
data.fremndat1
);
document.getElementById("txtremndat2").value = get_format_date(
data.fremndat2
);
document.getElementById("txtremndat3").value = get_format_date(
data.fremndat3
);
document.getElementById("txttaskremk").value = data.ftaskremk;
// if (data.femplasto == document.getElementById("empl_id").value) {
// alert("same");
// }
set_task_comp_date(data.ftaskstat);
$.when($.ajax(load_empl_list())).then(function () {
$("#txttaskasby").val(data.ftaskasby);
$("#txttaskasto").val(data.ftaskasto);
});
},
error: function (data) {
$("#page-container-form").html("Error: " + data);
},
});
});
}
function dele_data(prim_data) {
var r = confirm("Delete Record?");
if (r == true) {
$.ajax({
type: "POST",
url: "src/task_reminder.php",
data: {
load_data: "dele_data",
dele_code: prim_data,
},
success: function (data) {
load_grid_data(20, 1);
},
});
}
}
function load_empl_list() {
$.ajax({
type: "POST",
url: "src/task_reminder.php",
data: {
load_data: "empl_list",
},
cache: false,
success: function (data) {
$("#txttaskasby").html(data);
$("#txttaskasto").html(data);
},
error: function (data) {
$("#txttaskasto").html("Error: " + data);
},
});
}
function save_data() {
if (document.getElementById("txttaskasby").value == "") {
alert("Please select task assigner!");
txttaskasby.focus();
return false;
}
if (document.getElementById("txttaskname").value == "") {
alert("Please enter task title!");
txttaskname.focus();
return false;
}
if (document.getElementById("txttaskdetl").value == "") {
alert("Please enter task description!");
txttaskdetl.focus();
return false;
}
if (document.getElementById("txttaskasto").value == 0) {
alert("Please select task assinee!");
txttaskasto.focus();
return false;
}
if (document.getElementById("txttaskstat").value == "COMPLETED") {
if (
document.getElementById("txtcompdate").value == "" ||
document.getElementById("txtcompdate").value == "00/00/0000"
) {
alert("Please enter completed date!");
txtcompdate.focus();
return false;
}
}
$.ajax({
type: "POST",
url: "src/task_reminder.php",
dataType: "json",
data: {
load_data: "save_data",
page_mode: document.getElementById("txtpagemode").value,
task_code: document.getElementById("txttaskcode").value,
task_date: document.getElementById("txttaskdate").value,
task_name: document.getElementById("txttaskname").value,
task_detl: document.getElementById("txttaskdetl").value,
task_stat: document.getElementById("txttaskstat").value,
task_asby: document.getElementById("txttaskasby").value,
task_asto: document.getElementById("txttaskasto").value,
strt_date: document.getElementById("txtstrtdate").value,
last_date: document.getElementById("txtlastdate").value,
comp_date: document.getElementById("txtcompdate").value,
remn_dat1: document.getElementById("txtremndat1").value,
remn_dat2: document.getElementById("txtremndat2").value,
remn_dat3: document.getElementById("txtremndat3").value,
task_remk: document.getElementById("txttaskremk").value,
},
cache: false,
beforeSend: function () {
show_process();
},
success: function (data) {
hide_process();
alert(data.mesg);
cncl_data();
},
error: function (data) {
$("#page-container-form").html("Error:" + data);
hide_process();
},
});
}
function set_task_comp_date(task_stat) {
if (task_stat == "COMPLETED") {
document.getElementById("txtcompdate").disabled = false;
document.getElementById("txtcompdate").value = get_today_date();
} else {
document.getElementById("txtcompdate").disabled = true;
document.getElementById("txtcompdate").value = "00/00/0000";
}
}
|