217 lines
6.3 KiB
JavaScript
217 lines
6.3 KiB
JavaScript
var rep_eva03_editMode = "CREATE";
|
|
var rep_eva03_API = "/api/rep_eva03/";
|
|
|
|
//================= Search Customizaiton =========================================
|
|
|
|
function rep_eva03_GetSearchParameter() {
|
|
var rep_eva03SearchObject = new Object();
|
|
rep_eva03SearchObject.position_type_id = $("#s_rep_eva03_position_type_id").val();
|
|
|
|
return rep_eva03SearchObject;
|
|
}
|
|
|
|
function rep_eva03_FeedDataToSearchForm(data) {
|
|
DropDownClearFormAndFeedWithData($("#s_rep_eva03_position_type_id"), data, "id", "external_name", "item_position_type_id", data.position_type_id);
|
|
|
|
}
|
|
|
|
//================= Form Data Customizaiton =========================================
|
|
|
|
function rep_eva03_FeedDataToForm(data) {
|
|
$("#rep_eva03_id").val(data.id);
|
|
DropDownClearFormAndFeedWithData($("#rep_eva03_position_type_id"), data, "id", "external_name", "item_position_type_id", data.position_type_id);
|
|
|
|
}
|
|
|
|
function rep_eva03_GetFromForm() {
|
|
var rep_eva03Object = new Object();
|
|
rep_eva03Object.id = $("#rep_eva03_id").val();
|
|
rep_eva03Object.position_type_id = $("#rep_eva03_position_type_id").val();
|
|
|
|
|
|
return rep_eva03Object;
|
|
}
|
|
|
|
function rep_eva03_InitialForm(s) {
|
|
var successFunc = function (result) {
|
|
rep_eva03_FeedDataToForm(result);
|
|
rep_eva03_FeedDataToSearchForm(result);
|
|
if (s) {
|
|
// Incase model popup
|
|
$("#rep_eva03Model").modal("show");
|
|
}
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxGetRequest(apisite + rep_eva03_API + "GetBlankItem", successFunc, AlertDanger);
|
|
}
|
|
|
|
//================= Form Mode Setup and Flow =========================================
|
|
|
|
function rep_eva03_GoCreate() {
|
|
// Incase model popup
|
|
rep_eva03_SetCreateForm(true);
|
|
|
|
// Incase open new page
|
|
//window_open(appsite + "/rep_eva03View/rep_eva03_d");
|
|
}
|
|
|
|
function rep_eva03_GoEdit(a) {
|
|
// Incase model popup
|
|
rep_eva03_SetEditForm(a);
|
|
|
|
// Incase open new page
|
|
//window_open(appsite + "/rep_eva03View/rep_eva03_d?id=" + a);
|
|
}
|
|
|
|
function rep_eva03_SetEditForm(a) {
|
|
var successFunc = function (result) {
|
|
rep_eva03_editMode = "UPDATE";
|
|
rep_eva03_FeedDataToForm(result);
|
|
$("#rep_eva03Model").modal("show");
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxGetRequest(apisite + rep_eva03_API + a, successFunc, AlertDanger);
|
|
}
|
|
|
|
function rep_eva03_SetCreateForm(s) {
|
|
rep_eva03_editMode = "CREATE";
|
|
rep_eva03_InitialForm(s);
|
|
}
|
|
|
|
function rep_eva03_RefreshTable() {
|
|
// Incase model popup
|
|
rep_eva03_DoSearch();
|
|
|
|
// Incase open new page
|
|
//window.parent.rep_eva03_DoSearch();
|
|
}
|
|
|
|
//================= Update and Delete =========================================
|
|
|
|
var rep_eva03_customValidation = function (group) {
|
|
return "";
|
|
};
|
|
|
|
function rep_eva03_PutUpdate() {
|
|
if (!ValidateForm('rep_eva03', rep_eva03_customValidation))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var data = rep_eva03_GetFromForm();
|
|
|
|
//Update Mode
|
|
if (rep_eva03_editMode === "UPDATE") {
|
|
var successFunc1 = function (result) {
|
|
$("#rep_eva03Model").modal("hide");
|
|
AlertSuccess(result.code+" "+result.message);
|
|
rep_eva03_RefreshTable();
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxPutRequest(apisite + rep_eva03_API + data.id, data, successFunc1, AlertDanger);
|
|
}
|
|
// Create mode
|
|
else {
|
|
var successFunc2 = function (result) {
|
|
$("#rep_eva03Model").modal("hide");
|
|
AlertSuccess(result.code+" "+result.message);
|
|
rep_eva03_RefreshTable();
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxPostRequest(apisite + rep_eva03_API, data, successFunc2, AlertDanger);
|
|
}
|
|
}
|
|
|
|
function rep_eva03_GoDelete(a) {
|
|
if (confirm('คุณต้องการลบข้อมูล ใช่หรือไม่?')) {
|
|
var successFunc = function (result) {
|
|
$("#rep_eva03Model").modal("hide");
|
|
AlertSuccess(result.code+" "+result.message);
|
|
rep_eva03_RefreshTable();
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxDeleteRequest(apisite + rep_eva03_API + a, null, successFunc, AlertDanger);
|
|
}
|
|
}
|
|
|
|
//================= Data Table =========================================
|
|
|
|
var rep_eva03TableV;
|
|
|
|
var rep_eva03_setupTable = function (result) {
|
|
tmp = '"';
|
|
rep_eva03TableV = $('#rep_eva03Table').DataTable({
|
|
"processing": true,
|
|
"serverSide": false,
|
|
"data": result,
|
|
"select": {
|
|
"style": 'multi'
|
|
},
|
|
"columns": [
|
|
{ "data": "" },
|
|
{ "data": "id" },
|
|
{ "data": "id" },
|
|
{ "data": "position_type_id_external_linkage_external_name" },
|
|
],
|
|
"columnDefs": [
|
|
{
|
|
"targets": 1,
|
|
"data": "id",
|
|
"render": function (data, type, row, meta) {
|
|
return "<button type='button' class='btn btn-warning btn-sm' onclick='javascript:rep_eva03_GoEdit(" + tmp + data + tmp + ")'><i class='fa fa-pencil'></i></button> <button type='button' class='btn btn-danger btn-sm' onclick='javascript:rep_eva03_GoDelete(" + tmp + data + tmp + ")'><i class='fa fa-trash-o '></i></button> ";
|
|
}
|
|
},
|
|
{
|
|
targets: 0,
|
|
data: "",
|
|
defaultContent: '',
|
|
orderable: false,
|
|
className: 'select-checkbox'
|
|
}],
|
|
"language": {
|
|
"url": appsite + "/DataTables-1.10.16/thai.json"
|
|
},
|
|
"paging": true,
|
|
"searching": false
|
|
});
|
|
endLoad();
|
|
};
|
|
|
|
function rep_eva03_InitiateDataTable() {
|
|
startLoad();
|
|
AjaxGetRequest(apisite + "/api/rep_eva03/GetListBySearch", rep_eva03_setupTable, AlertDanger);
|
|
}
|
|
|
|
function rep_eva03_DoSearch() {
|
|
var p = $.param(rep_eva03_GetSearchParameter());
|
|
var rep_eva03_reload = function (result) {
|
|
rep_eva03TableV.destroy();
|
|
rep_eva03_setupTable(result);
|
|
endLoad();
|
|
};
|
|
startLoad();
|
|
AjaxGetRequest(apisite + "/api/rep_eva03/GetListBySearch?"+p, rep_eva03_reload, AlertDanger);
|
|
}
|
|
|
|
function rep_eva03_GetSelect(f) {
|
|
var rep_eva03_selectitem = [];
|
|
$.each(rep_eva03TableV.rows('.selected').data(), function (key, value) {
|
|
rep_eva03_selectitem.push(value[f]);
|
|
});
|
|
alert(rep_eva03_selectitem);
|
|
}
|
|
|
|
//================= File Upload =========================================
|
|
|
|
|
|
|
|
//================= Multi-Selection Function =========================================
|
|
|
|
|
|
|