From 64f6c4b1afbeb4143d52bab48c774cdcb732903e Mon Sep 17 00:00:00 2001 From: nakorn Date: Wed, 29 Sep 2021 17:05:12 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9A=E0=B8=B1?= =?UTF-8?q?=E0=B8=81=20=E0=B9=84=E0=B8=9F=E0=B8=A5=E0=B9=8C=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/js/rep_eva01/rep_eva01_report.js | 94 ++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 wwwroot/js/rep_eva01/rep_eva01_report.js diff --git a/wwwroot/js/rep_eva01/rep_eva01_report.js b/wwwroot/js/rep_eva01/rep_eva01_report.js new file mode 100644 index 0000000..7f351e2 --- /dev/null +++ b/wwwroot/js/rep_eva01/rep_eva01_report.js @@ -0,0 +1,94 @@ +var rep_eva01_API = "/api/rep_eva01/"; + +function array_to_string_comma(a) { + var x = ""; + $.each(a, function (index, value) { + if (x !== "") x += ","; + x += value; + }); + return x; +} + +//================= Search Customizaiton ========================================= + +function rep_eva01_GetSearchParameter(fileType) { + var rep_eva01SearchObject = new Object(); + rep_eva01SearchObject.org_id = $("#s_rep_eva01_org_id").val(); + rep_eva01SearchObject.round_id = $("#s_rep_eva01_round_id").val(); + rep_eva01SearchObject.round_text = $("#s_rep_eva01_round_id option:selected").text(); + + rep_eva01SearchObject.fileType = fileType; + + console.log(rep_eva01SearchObject); + + return rep_eva01SearchObject; +} + +function rep_eva01_FeedDataToSearchForm(data) { + DropDownClearFormAndFeedWithDataOrg($("#s_rep_eva01_org_id"), data, "id", "external_name", "item_org_id", data.org_id); + DropDownClearFormAndFeedWithData($("#s_rep_eva01_round_id"), data, "id", "external_name", "item_round_id", data.id_guid); +} + +function DropDownClearFormAndFeedWithDataOrg(d, result, x, y, z, i) { + $(d).html(''); + $(d).append($("") + .attr("value", "") + .text("กรุณาเลือก")); + $(d).append($("") + .attr("value", "-1") + .text("เนติบัณฑิตยสภา ในพระบรมราชูปถัมภ์")); + if (z !== "") { + $.each(result[z], function (key, value) { + $(d).append($("") + .attr("value", value[x]) + .text(value[y])); + }); + } else { + $.each(result, function (key, value) { + $(d).append($("") + .attr("value", value[x]) + .text(value[y])); + }); + } + $(d).val(i); +} + +//================= Form Data Customizaiton ========================================= + +function rep_eva01_InitialForm(s) { + var successFunc = function (result) { + rep_eva01_FeedDataToSearchForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_eva01_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Data Table ========================================= + +var s_rep_eva01_customValidation = function (group) { + return ""; +}; + + +function rep_eva01_DoSearch(fileType) { + if (!ValidateForm('s_rep_eva01', s_rep_eva01_customValidation)) { + return; + } + + var p = $.param(rep_eva01_GetSearchParameter(fileType)); + + var report_url = apisite + "/api/rep_eva01/rep_eva01_report?" + p; + + console.log(report_url); + + if (fileType === "pdf") { + $("#report_result").attr("src", report_url); + $("#report_result").show(); + //window.open(report_url); + } else { + $("#report_result").hide(); + window.open(report_url); + } +} +