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.119.112.208
Current Path : /var/www/html/oums/js/ |
| Current File : /var/www/html/oums/js/staff_move.js |
function load_page() {
load_page_data(
window.location.href.substr(window.location.href.lastIndexOf("/") + 1)
);
cncl_data();
}
function cncl_data() {
$("#btn_addn").show();
$("#btn_save").hide();
$("#btn_cncl").hide();
$("#page-container-main").show();
$("#page-container-grid").show();
$("#page-container-form").hide();
load_grid_data(20, 1);
}
function clrs_data() {
$("#btn_addn").hide();
$("#btn_save").show();
$("#btn_cncl").show();
$("#page-container-main").hide();
$("#page-container-grid").hide();
$("#page-container-form").show();
$(function () {
$("#txtstrtdate").datepicker({ dateFormat: "dd/mm/yy" });
});
$(function () {
$("#txtdestdate").datepicker({ dateFormat: "dd/mm/yy" });
});
//$("#txtdeptcode").html('');
$("#txtemplcode").html("");
$("#txtstrttown").html("");
$("#txtdesttown").html("");
// load_dept_data();
load_town_list();
document.getElementById("txtstrtdate").value = "";
document.getElementById("txtdestdate").value = "";
document.getElementById("txtstrttown").selectedIndex = 0;
document.getElementById("txtdesttown").selectedIndex = 0;
document.getElementById("txtmovetype").selectedIndex = 0;
document.getElementById("txtmovestat").selectedIndex = 0;
document.getElementById("txtmoveremk").value = "";
}
function load_grid_data(page_limt, page_numb) {
$.ajax({
type: "POST",
url: "src/staff_move.php",
data: {
load_data: "grid_data",
page_limt: page_limt,
page_numb: page_numb,
dept_code: document.getElementById("seldeptcode").value,
empl_code: document.getElementById("selemplcode").value,
move_type: document.getElementById("selmovetype").value,
move_find: document.getElementById("txtmovefind").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 addn_data() {
clrs_data();
document.getElementById("lblpagemode").innerHTML = "Add";
document.getElementById("txtpagemode").value = "add";
document.getElementById("txtdeptcode").focus();
document.getElementById("txtstrtdate").value = get_today_date();
}
function edit_data(disp_code) {
clrs_data();
document.getElementById("lblpagemode").innerHTML = "Edit";
document.getElementById("txtpagemode").value = "edit";
document.getElementById("txtdeptcode").focus();
$.ajax({
type: "POST",
url: "src/staff_move.php",
data: {
load_data: "disp_data",
disp_code: disp_code,
},
cache: false,
success: function (data) {
var data = JSON.parse(data);
document.getElementById("txtmovecode").value = data.fmovecode;
document.getElementById("txtstrtdate").value = get_format_date(
data.fstrtdate
);
document.getElementById("txtdeptcode").value = data.fdeptcode;
load_empl_data(data.femplcode);
document.getElementById("txtstrttown").value = data.fstrttown;
document.getElementById("txtdesttown").value = data.fdesttown;
document.getElementById("txtmovetype").value = data.fmovetype;
document.getElementById("txtmoveremk").value = data.fmoveremk;
document.getElementById("txtmovestat").value = data.fmovestat;
},
error: function (data) {
$("#page-container-form").html("Error: " + data);
},
});
}
function dele_data(dele_code) {
var r = confirm("Delete Record?");
if (r == true) {
$.ajax({
type: "POST",
url: "src/staff_move.php",
data: {
load_data: "dele_data",
dele_code: dele_code,
},
success: function (data) {
load_grid_data(20, 1);
},
});
}
}
function load_dept_data() {
$.ajax({
type: "POST",
url: "src/staff_move.php",
data: {
load_data: "dept_data",
},
cache: false,
success: function (data) {
$("#txtdeptcode").html(data);
load_empl_data(document.getElementById("txtdeptcode").value);
},
});
}
function load_empl_data(empl_code) {
$.ajax({
type: "POST",
url: "src/staff_move.php",
data: {
load_data: "empl_data",
dept_code: document.getElementById("txtdeptcode").value,
},
cache: false,
success: function (data) {
$("#txtemplcode").html(data);
if (empl_code == 0) {
document.getElementById("txtemplcode").selectedIndex = 0;
} else {
document.getElementById("txtemplcode").value = empl_code;
}
},
});
}
function load_town_list() {
$.ajax({
type: "POST",
url: "src/staff_move.php",
data: {
load_data: "town_list",
},
cache: false,
success: function (data) {
$("#txtstrttown").html(data);
$("#txtdesttown").html(data);
},
});
}
function save_data() {
if (document.getElementById("txtdeptcode").value == "") {
alert("Please select client!");
txtdeptcode.focus();
return false;
}
if (document.getElementById("txtemplcode").value == "") {
alert("Please select employee!");
txtemplcode.focus();
return false;
}
if (document.getElementById("txtstrttown").value == "") {
alert("Please select starting place!");
txtstrttown.focus();
return false;
}
if (document.getElementById("txtdesttown").value == "") {
alert("Please select destination!");
txtdesttown.focus();
return false;
}
if (document.getElementById("txtmovetype").value == "") {
alert("Please select purpose of movement!");
txtmovetype.focus();
return false;
}
if (document.getElementById("txtmovestat").value == "") {
alert("Please select status!");
txtmovestat.focus();
return false;
}
$.ajax({
type: "POST",
url: "src/staff_move.php",
dataType: "json",
data: {
load_data: "save_data",
page_mode: document.getElementById("txtpagemode").value,
move_code: document.getElementById("txtmovecode").value,
dept_code: document.getElementById("txtdeptcode").value,
empl_code: document.getElementById("txtemplcode").value,
move_date: document.getElementById("txtstrtdate").value,
strt_town: document.getElementById("txtstrttown").value,
dest_town: document.getElementById("txtdesttown").value,
move_type: document.getElementById("txtmovetype").value,
move_stat: document.getElementById("txtmovestat").value,
move_remk: document.getElementById("txtmoveremk").value,
},
cache: false,
success: function (data) {
alert(data.mesg);
cncl_data();
load_grid_data(20, 1);
},
error: function (data) {
$("#page-container-form").html("Error: " + data);
},
});
}
|