diff --git a/ApiControllers/rep_summary_a01Controllers.cs b/ApiControllers/rep_summary_a01Controllers.cs new file mode 100644 index 0000000..ce802be --- /dev/null +++ b/ApiControllers/rep_summary_a01Controllers.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.Extensions.Logging; +using TTSW.Controllers; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; +using System.Data; +using Microsoft.Extensions.Configuration; +using System.IO; +using System.Net; + +namespace TodoAPI2.Controllers +{ + //[Authorize] + [Produces("application/json")] + [Route("api/rep_summary_a01")] + public class rep_summary_a01Controller : BaseController + { + #region Private Variables + private ILogger _logger; + private Irep_summary_a01Service _repository; + private IConfiguration Configuration { get; set; } + #endregion + + #region Properties + + #endregion + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public rep_summary_a01Controller(ILogger logger, Irep_summary_a01Service repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + + /// + /// Get Blank Item + /// + /// + /// + /// Return a blank item + /// Returns the item + /// Error Occurred + [HttpGet("GetBlankItem")] + [ProducesResponseType(typeof(rep_summary_a01WithSelectionViewModel), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetBlankItem() + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.GetBlankItem(); + + return Ok(result); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetBlankItem.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + + + /// + /// Download Report + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("rep_summary_a01_report")] + [ProducesResponseType(typeof(FileStreamResult), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult rep_summary_a01_report(rep_summary_a01ReportRequestModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var httpclient = new WebClient(); + string mainurl = MyHelper.GetConfig(Configuration, "JasperReportServer:MainURL"); + string reportsite = MyHelper.GetConfig(Configuration, "JasperReportServer:reportsite"); + string username = MyHelper.GetConfig(Configuration, "JasperReportServer:username"); + string password = MyHelper.GetConfig(Configuration, "JasperReportServer:password"); + + string url = $"{mainurl}{reportsite}/rep_summary_a01.{model.filetype}?{MyHelper.GetParameterForJasperReport(model)}&j_username={username}&j_password={password}"; + + if (model.filetype == "xlsx") + { + url += "&ignorePagination=true"; + } + + var data = httpclient.DownloadData(url); + var stream = new MemoryStream(data); + + return File(stream, model.contentType); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while GetReport.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + + } +} diff --git a/EXCEL/eva_level_score@rep_summary_a01.xlsx b/EXCEL/eva_level_score@rep_summary_a01.xlsx new file mode 100644 index 0000000..ef6158e Binary files /dev/null and b/EXCEL/eva_level_score@rep_summary_a01.xlsx differ diff --git a/Models/rep_eva01/rep_eva01Service.cs b/Models/rep_eva01/rep_eva01Service.cs index 898cd10..041da28 100644 --- a/Models/rep_eva01/rep_eva01Service.cs +++ b/Models/rep_eva01/rep_eva01Service.cs @@ -60,7 +60,6 @@ namespace TodoAPI2.Models i.item_org_id = (from x in ext.GetSortingDep() select x).ToList(); i.item_round_id = (from x in ext.GetEvaRound() orderby x.external_code descending select x).ToList(); - return i; } public rep_eva01WithSelectionViewModel GetBlankItem() @@ -69,7 +68,6 @@ namespace TodoAPI2.Models i.item_org_id = (from x in ext.GetSortingDep() select x).ToList(); i.item_round_id = (from x in ext.GetEvaRound() orderby x.external_code descending select x).ToList(); - return i; } @@ -82,4 +80,5 @@ namespace TodoAPI2.Models #endregion } -} \ No newline at end of file +} + diff --git a/Models/rep_summary_a01/Irep_summary_a01Service.cs b/Models/rep_summary_a01/Irep_summary_a01Service.cs new file mode 100644 index 0000000..5eb6560 --- /dev/null +++ b/Models/rep_summary_a01/Irep_summary_a01Service.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; + +namespace TodoAPI2.Models +{ + public interface Irep_summary_a01Service + { + + rep_summary_a01WithSelectionViewModel GetWithSelection(Guid id); + rep_summary_a01WithSelectionViewModel GetBlankItem(); + + + } +} + diff --git a/Models/rep_summary_a01/rep_summary_a01InputModel.cs b/Models/rep_summary_a01/rep_summary_a01InputModel.cs new file mode 100644 index 0000000..2d1bd45 --- /dev/null +++ b/Models/rep_summary_a01/rep_summary_a01InputModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_summary_a01InputModel + { + + public Guid? id { get; set; } + + public int? org_id { get; set; } + + public int? round_id { get; set; } + + public int? employee_id { get; set; } + + public string active_mode { get; set; } + } +} + diff --git a/Models/rep_summary_a01/rep_summary_a01ReportRequestModel.cs b/Models/rep_summary_a01/rep_summary_a01ReportRequestModel.cs new file mode 100644 index 0000000..bd6407e --- /dev/null +++ b/Models/rep_summary_a01/rep_summary_a01ReportRequestModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_summary_a01ReportRequestModel : rep_summary_a01SearchModel + { + public string filetype { get; set; } + + public string contentType { get { return MyHelper.GetContentType(filetype); } } + } +} + diff --git a/Models/rep_summary_a01/rep_summary_a01SearchModel.cs b/Models/rep_summary_a01/rep_summary_a01SearchModel.cs new file mode 100644 index 0000000..16a98ea --- /dev/null +++ b/Models/rep_summary_a01/rep_summary_a01SearchModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_summary_a01SearchModel + { + + public Guid id { get; set; } + + public int? org_id { get; set; } + + public int? round_id { get; set; } + + public int? employee_id { get; set; } + + } +} + diff --git a/Models/rep_summary_a01/rep_summary_a01Service.cs b/Models/rep_summary_a01/rep_summary_a01Service.cs new file mode 100644 index 0000000..12877a4 --- /dev/null +++ b/Models/rep_summary_a01/rep_summary_a01Service.cs @@ -0,0 +1,56 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; +using TodoAPI2.Models; +using System.IO; +using System.Web; +using System.Net; +using TTSW.Configure; +using Microsoft.Extensions.Options; +using System.Data; + +namespace TodoAPI2.Models +{ + public class rep_summary_a01Service : Irep_summary_a01Service + { + private IBaseRepository _repository; + private IMyDatabase db; + private Iexternal_linkageService ext; + private Iexternal_employeeService emp; + + public rep_summary_a01Service(IBaseRepository repository, IMyDatabase mydb, Iexternal_linkageService inext, Iexternal_employeeService inemp) + { + _repository = repository; + db = mydb; + ext = inext; + emp = inemp; + } + + public rep_summary_a01WithSelectionViewModel GetWithSelection(Guid id) + { + var entity = _repository.Get(id); + var i = Mapper.Map(entity); + i.item_org_id = (from x in ext.GetSortingDep() select x).ToList(); + i.item_round_id = (from x in ext.GetEvaRound() orderby x.external_code descending select x).ToList(); + i.item_employee_id = (from x in emp.GetListByemployee_type(null, null) orderby x.fullname select x).ToList(); + + return i; + } + public rep_summary_a01WithSelectionViewModel GetBlankItem() + { + var i = new rep_summary_a01WithSelectionViewModel(); + i.item_org_id = (from x in ext.GetSortingDep() select x).ToList(); + i.item_round_id = (from x in ext.GetEvaRound() orderby x.external_code descending select x).ToList(); + i.item_employee_id = (from x in emp.GetListByemployee_type(null, null) orderby x.fullname select x).ToList(); + + return i; + } + } +} + diff --git a/Models/rep_summary_a01/rep_summary_a01ViewModel.cs b/Models/rep_summary_a01/rep_summary_a01ViewModel.cs new file mode 100644 index 0000000..751496b --- /dev/null +++ b/Models/rep_summary_a01/rep_summary_a01ViewModel.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Threading.Tasks; +using TTSW.EF; +using TTSW.Utils; +using TTSW.Constant; +using TTSW.Common; + +namespace TodoAPI2.Models +{ + public class rep_summary_a01ViewModel : BaseViewModel2 + { + + public int? org_id { get; set; } + + public int? round_id { get; set; } + + public int? employee_id { get; set; } + + public string org_id_external_linkage_external_name { get; set; } + public string round_id_external_linkage_external_name { get; set; } + public string employee_id_external_linkage_external_name { get; set; } + + } +} \ No newline at end of file diff --git a/Models/rep_summary_a01/rep_summary_a01WithSelectionViewModel.cs b/Models/rep_summary_a01/rep_summary_a01WithSelectionViewModel.cs new file mode 100644 index 0000000..59a4897 --- /dev/null +++ b/Models/rep_summary_a01/rep_summary_a01WithSelectionViewModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace TodoAPI2.Models +{ + public class rep_summary_a01WithSelectionViewModel: rep_summary_a01ViewModel + { + public List item_org_id { get; set; } + public List item_round_id { get; set; } + public List item_employee_id { get; set; } + + } +} \ No newline at end of file diff --git a/Startup.cs b/Startup.cs index e89fc55..2f9a66b 100644 --- a/Startup.cs +++ b/Startup.cs @@ -335,6 +335,8 @@ namespace Test01 services.AddScoped, BaseRepository2>(); services.AddScoped(); + services.AddScoped(); + #endregion services.TryAddSingleton(); @@ -630,6 +632,10 @@ namespace Test01 cfg.CreateMap(); cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + }); #endregion diff --git a/ViewControllers/rep_summary_a01ViewControllers.cs b/ViewControllers/rep_summary_a01ViewControllers.cs new file mode 100644 index 0000000..cb63f6a --- /dev/null +++ b/ViewControllers/rep_summary_a01ViewControllers.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using TodoAPI2.Models; +using STAFF_API.Models; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; +using TodoAPI2.Controllers; + +namespace TodoAPI2.Controllers +{ + public class rep_summary_a01ViewController : Controller + { + private ILogger _logger; + private Irep_summary_a01Service _repository; + private IConfiguration Configuration { get; set; } + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public rep_summary_a01ViewController(ILogger logger, Irep_summary_a01Service repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + // public IActionResult rep_summary_a01() + // { + //if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + // return View(); + // } + + // public IActionResult rep_summary_a01_d() + // { + //if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + // return View(); + // } + + public IActionResult rep_summary_a01_report() + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + return View(); + } + + //public IActionResult rep_summary_a01_inline() + //{ + // if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); // Or UnauthorizedView + // return View(); + //} + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + public IActionResult Error() + { + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + } + } +} + + diff --git a/Views/home/index2.cshtml b/Views/home/index2.cshtml index 7a2fd7e..e3f9190 100644 --- a/Views/home/index2.cshtml +++ b/Views/home/index2.cshtml @@ -82,6 +82,9 @@ + diff --git a/Views/rep_summary_a01View/rep_summary_a01_report.cshtml b/Views/rep_summary_a01View/rep_summary_a01_report.cshtml new file mode 100644 index 0000000..22c75df --- /dev/null +++ b/Views/rep_summary_a01View/rep_summary_a01_report.cshtml @@ -0,0 +1,68 @@ +@using Microsoft.Extensions.Configuration +@inject IConfiguration Configuration +@{ + ViewData["Title"] = "rep_summary_a01"; +} + +
+
+
+ @Configuration["SiteInformation:modulename"] +
+
+
+ +
+
+ +
+
สรุปการประเมินผลการปฏิบัติงานของพนักงานเนติบัณฑิตยสภา
+
+
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+
+
+ + +
+
+
+
+
+ + +@section FooterPlaceHolder{ + + +} + diff --git a/tb320eva.csproj b/tb320eva.csproj index f557aa5..ae7bdae 100644 --- a/tb320eva.csproj +++ b/tb320eva.csproj @@ -78,6 +78,7 @@ + @@ -101,6 +102,10 @@ + + + + diff --git a/tb320eva.xml b/tb320eva.xml index 498212c..6dbd0ec 100644 --- a/tb320eva.xml +++ b/tb320eva.xml @@ -5047,6 +5047,34 @@ Returns the item Error Occurred + + + Default constructure for dependency injection + + + + + + + + Get Blank Item + + + + Return a blank item + Returns the item + Error Occurred + + + + Download Report + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + Default constructure for dependency injection @@ -5688,6 +5716,14 @@ + + + Default constructure for dependency injection + + + + + Default constructure for dependency injection diff --git a/wwwroot/js/rep_summary_a01/rep_summary_a01.js b/wwwroot/js/rep_summary_a01/rep_summary_a01.js new file mode 100644 index 0000000..931fc2d --- /dev/null +++ b/wwwroot/js/rep_summary_a01/rep_summary_a01.js @@ -0,0 +1,228 @@ +var rep_summary_a01_editMode = "CREATE"; +var rep_summary_a01_API = "/api/rep_summary_a01/"; + +//================= Search Customizaiton ========================================= + +function rep_summary_a01_GetSearchParameter() { + var rep_summary_a01SearchObject = new Object(); +rep_summary_a01SearchObject.org_id = $("#s_rep_summary_a01_org_id").val(); +rep_summary_a01SearchObject.round_id = $("#s_rep_summary_a01_round_id").val(); +rep_summary_a01SearchObject.employee_id = $("#s_rep_summary_a01_employee_id").val(); + + return rep_summary_a01SearchObject; +} + +function rep_summary_a01_FeedDataToSearchForm(data) { +DropDownClearFormAndFeedWithData($("#s_rep_summary_a01_org_id"), data, "id", "external_name", "item_org_id", data.org_id); +DropDownClearFormAndFeedWithData($("#s_rep_summary_a01_round_id"), data, "id", "external_name", "item_round_id", data.round_id); +DropDownClearFormAndFeedWithData($("#s_rep_summary_a01_employee_id"), data, "id", "external_name", "item_employee_id", data.employee_id); + +} + +//================= Form Data Customizaiton ========================================= + +function rep_summary_a01_FeedDataToForm(data) { +$("#rep_summary_a01_id").val(data.id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_org_id"), data, "id", "external_name", "item_org_id", data.org_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_round_id"), data, "id", "external_name", "item_round_id", data.round_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_employee_id"), data, "id", "external_name", "item_employee_id", data.employee_id); + +} + +function rep_summary_a01_GetFromForm() { + var rep_summary_a01Object = new Object(); +rep_summary_a01Object.id = $("#rep_summary_a01_id").val(); +rep_summary_a01Object.org_id = $("#rep_summary_a01_org_id").val(); +rep_summary_a01Object.round_id = $("#rep_summary_a01_round_id").val(); +rep_summary_a01Object.employee_id = $("#rep_summary_a01_employee_id").val(); + + + return rep_summary_a01Object; +} + +function rep_summary_a01_InitialForm(s) { + var successFunc = function (result) { + rep_summary_a01_FeedDataToForm(result); + rep_summary_a01_FeedDataToSearchForm(result); + if (s) { + // Incase model popup + $("#rep_summary_a01Model").modal("show"); + } + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_summary_a01_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Form Mode Setup and Flow ========================================= + +function rep_summary_a01_GoCreate() { + // Incase model popup + rep_summary_a01_SetCreateForm(true); + + // Incase open new page + //window_open(appsite + "/rep_summary_a01View/rep_summary_a01_d"); +} + +function rep_summary_a01_GoEdit(a) { + // Incase model popup + rep_summary_a01_SetEditForm(a); + + // Incase open new page + //window_open(appsite + "/rep_summary_a01View/rep_summary_a01_d?id=" + a); +} + +function rep_summary_a01_SetEditForm(a) { + var successFunc = function (result) { + rep_summary_a01_editMode = "UPDATE"; + rep_summary_a01_FeedDataToForm(result); + $("#rep_summary_a01Model").modal("show"); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_summary_a01_API + a, successFunc, AlertDanger); +} + +function rep_summary_a01_SetCreateForm(s) { + rep_summary_a01_editMode = "CREATE"; + rep_summary_a01_InitialForm(s); +} + +function rep_summary_a01_RefreshTable() { + // Incase model popup + rep_summary_a01_DoSearch(); + + // Incase open new page + //window.parent.rep_summary_a01_DoSearch(); +} + +//================= Update and Delete ========================================= + +var rep_summary_a01_customValidation = function (group) { + return ""; +}; + +function rep_summary_a01_PutUpdate() { + if (!ValidateForm('rep_summary_a01', rep_summary_a01_customValidation)) + { + return; + } + + var data = rep_summary_a01_GetFromForm(); + + //Update Mode + if (rep_summary_a01_editMode === "UPDATE") { + var successFunc1 = function (result) { + $("#rep_summary_a01Model").modal("hide"); + AlertSuccess(result.code+" "+result.message); + rep_summary_a01_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxPutRequest(apisite + rep_summary_a01_API + data.id, data, successFunc1, AlertDanger); + } + // Create mode + else { + var successFunc2 = function (result) { + $("#rep_summary_a01Model").modal("hide"); + AlertSuccess(result.code+" "+result.message); + rep_summary_a01_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxPostRequest(apisite + rep_summary_a01_API, data, successFunc2, AlertDanger); + } +} + +function rep_summary_a01_GoDelete(a) { + if (confirm('คุณต้องการลบข้อมูล ใช่หรือไม่?')) { + var successFunc = function (result) { + $("#rep_summary_a01Model").modal("hide"); + AlertSuccess(result.code+" "+result.message); + rep_summary_a01_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxDeleteRequest(apisite + rep_summary_a01_API + a, null, successFunc, AlertDanger); + } +} + +//================= Data Table ========================================= + +var rep_summary_a01TableV; + +var rep_summary_a01_setupTable = function (result) { + tmp = '"'; + rep_summary_a01TableV = $('#rep_summary_a01Table').DataTable({ + "processing": true, + "serverSide": false, + "data": result, + //"select": { + // "style": 'multi' + //}, + "columns": [ + //{ "data": "" }, + { "data": "id" }, + { "data": "id" }, + { "data": "org_id_external_linkage_external_name" }, + { "data": "round_id_external_linkage_external_name" }, + { "data": "employee_id_external_linkage_external_name" }, + ], + "columnDefs": [ + { + "targets": 0, //1, + "data": "id", + "render": function (data, type, row, meta) { + return " "; + } + }, + //{ + // 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_summary_a01_InitiateDataTable() { + startLoad(); + var p = $.param(rep_summary_a01_GetSearchParameter()); + AjaxGetRequest(apisite + "/api/rep_summary_a01/GetListBySearch?"+p, rep_summary_a01_setupTable, AlertDanger); +} + +function rep_summary_a01_DoSearch() { + var p = $.param(rep_summary_a01_GetSearchParameter()); + var rep_summary_a01_reload = function (result) { + rep_summary_a01TableV.destroy(); + rep_summary_a01_setupTable(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + "/api/rep_summary_a01/GetListBySearch?"+p, rep_summary_a01_reload, AlertDanger); +} + +function rep_summary_a01_GetSelect(f) { + var rep_summary_a01_selectitem = []; + $.each(rep_summary_a01TableV.rows('.selected').data(), function (key, value) { + rep_summary_a01_selectitem.push(value[f]); + }); + alert(rep_summary_a01_selectitem); +} + +//================= File Upload ========================================= + + + +//================= Multi-Selection Function ========================================= + + + diff --git a/wwwroot/js/rep_summary_a01/rep_summary_a01_d.js b/wwwroot/js/rep_summary_a01/rep_summary_a01_d.js new file mode 100644 index 0000000..284cb34 --- /dev/null +++ b/wwwroot/js/rep_summary_a01/rep_summary_a01_d.js @@ -0,0 +1,102 @@ +var rep_summary_a01_editMode = "CREATE"; +var rep_summary_a01_API = "/api/rep_summary_a01/"; + +//================= Form Data Customizaiton ========================================= + +function rep_summary_a01_FeedDataToForm(data) { +$("#rep_summary_a01_id").val(data.id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_org_id"), data, "id", "external_name", "item_org_id", data.org_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_round_id"), data, "id", "external_name", "item_round_id", data.round_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_employee_id"), data, "id", "external_name", "item_employee_id", data.employee_id); + +} + +function rep_summary_a01_GetFromForm() { + var rep_summary_a01Object = new Object(); +rep_summary_a01Object.id = $("#rep_summary_a01_id").val(); +rep_summary_a01Object.org_id = $("#rep_summary_a01_org_id").val(); +rep_summary_a01Object.round_id = $("#rep_summary_a01_round_id").val(); +rep_summary_a01Object.employee_id = $("#rep_summary_a01_employee_id").val(); + + + return rep_summary_a01Object; +} + +function rep_summary_a01_InitialForm() { + var successFunc = function (result) { + rep_summary_a01_FeedDataToForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_summary_a01_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Form Mode Setup and Flow ========================================= + +function rep_summary_a01_SetEditForm(a) { + var successFunc = function (result) { + rep_summary_a01_editMode = "UPDATE"; + rep_summary_a01_FeedDataToForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_summary_a01_API + a, successFunc, AlertDanger); +} + +function rep_summary_a01_SetCreateForm() { + rep_summary_a01_editMode = "CREATE"; + rep_summary_a01_InitialForm(); +} + +//================= Update and Delete ========================================= + +var rep_summary_a01_customValidation = function (group) { + return ""; +}; + +function rep_summary_a01_PutUpdate() { + if (!ValidateForm('rep_summary_a01', rep_summary_a01_customValidation)) + { + return; + } + var data = rep_summary_a01_GetFromForm(); + + //Update Mode + if (rep_summary_a01_editMode === "UPDATE") { + var successFunc1 = function (result) { + AlertSuccess(result.code+" "+result.message); + endLoad(); + }; + startLoad(); + AjaxPutRequest(apisite + rep_summary_a01_API + data.id, data, successFunc1, AlertDanger); + } + // Create mode + else { + var successFunc2 = function (result) { + AlertSuccess(result.code+" "+result.message); + endLoad(); + }; + startLoad(); + AjaxPostRequest(apisite + rep_summary_a01_API, data, successFunc2, AlertDanger); + } +} + +function rep_summary_a01_GoDelete(a) { + if (confirm('คุณต้องการลบ ' + a + ' ใช่หรือไม่?')) { + var successFunc = function (result) { + AlertSuccess(result.code+" "+result.message); + rep_summary_a01_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxDeleteRequest(apisite + rep_summary_a01_API + a, null, successFunc, AlertDanger); + } +} + +//================= File Upload ========================================= + + + +//================= Multi-Selection Function ========================================= + + diff --git a/wwwroot/js/rep_summary_a01/rep_summary_a01_inline.js b/wwwroot/js/rep_summary_a01/rep_summary_a01_inline.js new file mode 100644 index 0000000..605b1b8 --- /dev/null +++ b/wwwroot/js/rep_summary_a01/rep_summary_a01_inline.js @@ -0,0 +1,140 @@ +function rep_summary_a01_ClearForm(i, blankItem) { + var data = blankItem; +$("#rep_summary_a01_id_" + i).val(""); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_org_id_" + i), blankItem, "id", "external_name", "item_org_id", data.org_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_round_id_" + i), blankItem, "id", "external_name", "item_round_id", data.round_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_employee_id_" + i), blankItem, "id", "external_name", "item_employee_id", data.employee_id); + +} + +function rep_summary_a01_FeedDataToForm(data, i, blankItem) { +$("#rep_summary_a01_id_" + i).val(data.id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_org_id_" + i), blankItem, "id", "external_name", "item_org_id", data.org_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_round_id_" + i), blankItem, "id", "external_name", "item_round_id", data.round_id); +DropDownClearFormAndFeedWithData($("#rep_summary_a01_employee_id_" + i), blankItem, "id", "external_name", "item_employee_id", data.employee_id); + +} + +function rep_summary_a01_GetFromForm(obj, i) { + var rep_summary_a01Object = new Object(); +rep_summary_a01Object.id = obj.find("#rep_summary_a01_id_" + i).val(); +rep_summary_a01Object.org_id = obj.find("#rep_summary_a01_org_id_" + i).val(); +rep_summary_a01Object.round_id = obj.find("#rep_summary_a01_round_id_" + i).val(); +rep_summary_a01Object.employee_id = obj.find("#rep_summary_a01_employee_id_" + i).val(); + + rep_summary_a01Object.active_mode = obj.find("#isActive_" + i + "_rep_summary_a01").val(); + return rep_summary_a01Object; +} + +function rep_summary_a01_GetAllData() { + //Insert rep_summary_a01 List + var rep_summary_a01 = []; + $('#rep_summary_a01Body tr').each(function () { + var i = $(this).find("#rowCount").text(); + var eachrep_summary_a01 = rep_summary_a01_GetFromForm($(this), i); + rep_summary_a01.push(eachrep_summary_a01); + }); + return rep_summary_a01; +} + +function rep_summary_a01_Save(id) { + //Insert rep_summary_a01 List + var rep_summary_a01 = rep_summary_a01_GetAllData(); + + var successFunc = function (result) { + AlertSuccess("ปรับปรุงข้อมูลเรียบร้อยแล้ว"); + endLoad(); + }; + startLoad(); + AjaxPutRequest(apisite + '/api/rep_summary_a01/UpdateMultiple', rep_summary_a01, successFunc, AlertDanger); +} + +function rep_summary_a01_Get(id, blankItem) { + + $('#rep_summary_a01Body').empty(); + + var successFunc = function (response) { + //console.log(response); + $.each(response, function (i, data) { + var tag = ''; + tag += ''; + tag += ''; + tag += ''; + tag += ''; + + tag += ''; + tag += ''; + $('#rep_summary_a01Body').append($(tag)); + rep_summary_a01_FeedDataToForm(data, (i + 1), blankItem); + }); + rep_summary_a01_Summary(); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + "/api/rep_summary_a01", successFunc, AlertDanger); + //AjaxGetRequest(apisite + '/api/rep_summary_a01/GetListByorg_id/' + a, successFunc, AlertDanger); + //AjaxGetRequest(apisite + '/api/rep_summary_a01/GetListByround_id/' + a, successFunc, AlertDanger); + //AjaxGetRequest(apisite + '/api/rep_summary_a01/GetListByemployee_id/' + a, successFunc, AlertDanger); + +} + +function rep_summary_a01_Add() { + var successFunc = function (result) { + var i = $("#rep_summary_a01Body tr").length; + var tag = ''; + tag += ''; + tag += ''; + tag += ''; + tag += ''; + + tag += ''; + tag += ''; + + $('#rep_summary_a01Body').append($(tag)); + rep_summary_a01_ClearForm(i + 1, result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + "/api/rep_summary_a01/" + "GetBlankItem", successFunc, AlertDanger); +} + +function rep_summary_a01_Removerep_summary_a01(e) { + if (confirm('กรุณากดตกลง เพื่อยืนยันการลบ?')) { + $(e).closest('tr').find("input,select,textarea").attr('disabled', true); + $(e).closest('tr').find("input,select,textarea").css({ opacity: '0.5' }); + $(e).hide(); + $(e).closest('tr').find("#restoreBtn").show(); + $(e).closest('tr').find("input").first().val("0"); + console.log($(e).closest('tr').find("input").first().val()); + rep_summary_a01_Summary(); + } +} + +function rep_summary_a01_Restorerep_summary_a01(e) { + if (confirm('กรุณากดตกลง เพื่อยืนยันการกู้คืน?')) { + $(e).closest('tr').find("input,select,textarea").attr('disabled', false); + $(e).closest('tr').find("input,select,textarea").css({ opacity: '1' }); + $(e).hide(); + $(e).closest('tr').find("#removeBtn").show(); + $(e).closest('tr').find("input").first().val("1"); + console.log($(e).closest('tr').find("input").first().val()); + rep_summary_a01_Summary(); + } +} + +function rep_summary_a01_Summary() { + var sum = 0; + $(".input_score").each(function () { + sum += +$(this).val(); + }); + $("#score_label").text("ผลรวม: " + sum); +} + +function rep_summary_a01_InitialForm(id) { + var successFunc = function (result) { + rep_summary_a01_Get(id, result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + "/api/rep_summary_a01/" + "GetBlankItem", successFunc, AlertDanger); +} diff --git a/wwwroot/js/rep_summary_a01/rep_summary_a01_report.js b/wwwroot/js/rep_summary_a01/rep_summary_a01_report.js new file mode 100644 index 0000000..1db6e5d --- /dev/null +++ b/wwwroot/js/rep_summary_a01/rep_summary_a01_report.js @@ -0,0 +1,62 @@ +var rep_summary_a01_API = "/api/rep_summary_a01/"; + +//================= Search Customizaiton ========================================= + +function rep_summary_a01_GetSearchParameter(fileType) { + var rep_summary_a01SearchObject = new Object(); + rep_summary_a01SearchObject.org_id = $("#s_rep_summary_a01_org_id").val(); + rep_summary_a01SearchObject.round_id = $("#s_rep_summary_a01_round_id").val(); + rep_summary_a01SearchObject.employee_id = $("#s_rep_summary_a01_employee_id").val(); + + + rep_summary_a01SearchObject.fileType = fileType; + + console.log(rep_summary_a01SearchObject); + + return rep_summary_a01SearchObject; +} + +function rep_summary_a01_FeedDataToSearchForm(data) { + DropDownClearFormAndFeedWithData($("#s_rep_summary_a01_org_id"), data, "id", "external_name", "item_org_id", data.org_id); + DropDownClearFormAndFeedWithData($("#s_rep_summary_a01_round_id"), data, "id", "external_name", "item_round_id", data.round_id); + DropDownClearFormAndFeedWithData($("#s_rep_summary_a01_employee_id"), data, "id", "fullname", "item_employee_id", data.employee_id); + +} + +//================= Form Data Customizaiton ========================================= + +function rep_summary_a01_InitialForm(s) { + var successFunc = function (result) { + rep_summary_a01_FeedDataToSearchForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + rep_summary_a01_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Data Table ========================================= + +var s_rep_summary_a01_customValidation = function (group) { + return ""; +}; + + +function rep_summary_a01_DoSearch(fileType) { + if (!ValidateForm('s_rep_summary_a01', s_rep_summary_a01_customValidation)) { + return; + } + + var p = $.param(rep_summary_a01_GetSearchParameter(fileType)); + + var report_url = apisite + "/api/rep_summary_a01/rep_summary_a01_report?" + p; + + if (fileType === "pdf") { + $("#report_result").attr("src", report_url); + $("#report_result").show(); + //window.open(report_url); + } else { + $("#report_result").hide(); + window.open(report_url); + } +} +