From ccef30e5881f2c454aa3e4aaf0aae5ed5e012ee0 Mon Sep 17 00:00:00 2001 From: nakorn Date: Fri, 6 May 2022 07:54:55 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=AA=E0=B8=A3=E0=B9=87=E0=B8=88?= =?UTF-8?q?=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=AD=E0=B8=99=E0=B8=B8=E0=B8=A1?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=20=E0=B8=9B=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=20=E0=B9=81=E0=B8=A5=E0=B8=B0=20=E0=B9=82?= =?UTF-8?q?=E0=B8=84=E0=B8=A7=E0=B8=95=E0=B9=89=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ieva_adjust_postponement_quotaService.cs | 2 + .../eva_adjust_postponement_quotaService.cs | 46 +++++++++++++++++++ ...ostponement_quotaWithSelectionViewModel.cs | 4 +- ...djust_postponement_update_statusService.cs | 9 +++- ...adjust_quota_update_final_statusService.cs | 15 +++++- .../eva_adjust_quota_update_statusService.cs | 24 +++++++++- ...create_evaluation_detail_processService.cs | 3 ++ .../eva_adjust_postponement_normal_d.cshtml | 4 +- .../eva_adjust_postponement_quota_d.cshtml | 13 +++++- appsettings.Development.json | 4 +- ...st_postponement_detail_normal_02_inline.js | 3 +- .../eva_adjust_postponement_quota_d.js | 9 ++++ .../eva_adjust_postponement_update_status.js | 16 ++++++- .../eva_adjust_quota_update_final_status.js | 10 ++-- .../eva_adjust_quota_update_status.js | 3 +- 15 files changed, 146 insertions(+), 19 deletions(-) diff --git a/Models/eva_adjust_postponement_quota/Ieva_adjust_postponement_quotaService.cs b/Models/eva_adjust_postponement_quota/Ieva_adjust_postponement_quotaService.cs index 8798aa7..b1df143 100644 --- a/Models/eva_adjust_postponement_quota/Ieva_adjust_postponement_quotaService.cs +++ b/Models/eva_adjust_postponement_quota/Ieva_adjust_postponement_quotaService.cs @@ -23,6 +23,8 @@ namespace TodoAPI2.Models rep_eva_savemessageReportRequestModel setModelFor_rep_eva_savemessageReport(rep_eva_savemessageReportRequestModel model); DataContext GetContext(); + void updateAllpostponement(int id); + } } diff --git a/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaService.cs b/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaService.cs index 584c1e2..fc76e9f 100644 --- a/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaService.cs +++ b/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaService.cs @@ -70,6 +70,39 @@ namespace TodoAPI2.Models return GetDto(entity); } + + private string isStringNull(string a, string b) + { + if (!string.IsNullOrEmpty(a)) return a; + else return b; + } + + private T isNull(T a, T b) + { + if (a != null) return a; + else return b; + } + + public void updateAllpostponement(int id) + { + var entity = _repository.Get(id); + + var postponement = from x in _repository.Context.eva_adjust_postponement + where x.fiscal_year == entity.fiscal_year + && x.theRound == entity.theRound + && x.id != entity.id + select x; + + foreach(var i in postponement) + { + //i.postponement_status = entity.postponement_status; + i.quota_status = entity.quota_status; + i.quota_final_status = entity.quota_final_status; + } + + _repository.Context.SaveChanges(); + } + public eva_adjust_postponement_quotaWithSelectionViewModel GetWithSelection(int id) { var entity = _repository.Get(id); @@ -84,6 +117,19 @@ namespace TodoAPI2.Models select new external_linkageViewModel { external_id = x.theRound, external_name = x.theRound.ToString() } ).Distinct().OrderByDescending(x => x.external_id).ToList(); + var postponement = from x in _repository.Context.eva_adjust_postponement + join e in emp.GetAllEmployee() on isNull(x.managed_by, x.postponement_status_by) equals e.id + join v in ext.GetAgreeDisagree4() on isStringNull(x.postponement_status, "W") equals v.external_code + join c in _repository.Context.eva_create_evaluation on x.create_evaluation_id equals c.id + join d in _repository.Context.eva_evaluation_group on c.evaluation_group_id equals d.id + where x.fiscal_year == entity.fiscal_year + && x.theRound == entity.theRound + && x.id != entity.id + select d.thegroup + " โดย " + e.fullname + " " + v.external_name; + + + i.approve_status = postponement.ToList(); + return i; } public eva_adjust_postponement_quotaWithSelectionViewModel GetBlankItem() diff --git a/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaWithSelectionViewModel.cs b/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaWithSelectionViewModel.cs index 97c4e84..948f0e9 100644 --- a/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaWithSelectionViewModel.cs +++ b/Models/eva_adjust_postponement_quota/eva_adjust_postponement_quotaWithSelectionViewModel.cs @@ -10,5 +10,7 @@ namespace TodoAPI2.Models public List item_managed_by { get; set; } public List item_fiscal_year_search { get; set; } public List item_theRound_search { get; set; } + public List approve_status { get; set; } } -} \ No newline at end of file +} + diff --git a/Models/eva_adjust_postponement_update_status/eva_adjust_postponement_update_statusService.cs b/Models/eva_adjust_postponement_update_status/eva_adjust_postponement_update_statusService.cs index 67cfa59..f1df649 100644 --- a/Models/eva_adjust_postponement_update_status/eva_adjust_postponement_update_statusService.cs +++ b/Models/eva_adjust_postponement_update_status/eva_adjust_postponement_update_statusService.cs @@ -23,18 +23,20 @@ namespace TodoAPI2.Models private IMyDatabase db; private Iexternal_linkageService ext; private Iexternal_employeeService emp; - + private Ieva_adjust_postponement_quotaService quotaStatus; public eva_adjust_postponement_update_statusService( IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext, - Iexternal_employeeService inemp + Iexternal_employeeService inemp, + Ieva_adjust_postponement_quotaService inquotaStatus ) { _repository = repository; db = mydb; ext = inext; emp = inemp; + quotaStatus = inquotaStatus; } #region Private Functions @@ -183,6 +185,9 @@ namespace TodoAPI2.Models existingEntity.postponement_status_note = model.postponement_status_note; var updated = _repository.Update(id, existingEntity); + + //quotaStatus.updateAllpostponement(id); + return Get(updated.id); } else diff --git a/Models/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_statusService.cs b/Models/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_statusService.cs index 62325f9..e9d2968 100644 --- a/Models/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_statusService.cs +++ b/Models/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_statusService.cs @@ -23,15 +23,18 @@ namespace TodoAPI2.Models private IMyDatabase db; private Iexternal_linkageService ext; private Iexternal_employeeService emp; + private Ieva_adjust_postponement_quotaService quotaStatus; public eva_adjust_quota_update_final_statusService(IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext, - Iexternal_employeeService inemp) + Iexternal_employeeService inemp, + Ieva_adjust_postponement_quotaService inquotaStatus) { _repository = repository; db = mydb; ext = inext; emp = inemp; + quotaStatus = inquotaStatus; } #region Private Functions @@ -164,13 +167,18 @@ namespace TodoAPI2.Models return newkey.Value; } - public eva_adjust_quota_update_final_statusViewModel Update(int id, eva_adjust_quota_update_final_statusInputModel model, bool is_force_save, int? updateby) { var existingEntity = _repository.Get(id); + if (existingEntity != null) { + if(model.quota_final_status == "Y" && existingEntity.quota_status != "Y") + { + throw new Exception("ผู้อนุมัติวงเงินที่กันไว้ คนแรก, ยังไม่ได้อนุมัติ วงเงินที่กันไว้"); + } + existingEntity.quota_final_status = model.quota_final_status; existingEntity.quota_final_status_date = DateTime.Now; existingEntity.quota_final_status_by = updateby; @@ -183,6 +191,9 @@ namespace TodoAPI2.Models } var updated = _repository.Update(id, existingEntity); + + quotaStatus.updateAllpostponement(id); + return Get(updated.id); } else diff --git a/Models/eva_adjust_quota_update_status/eva_adjust_quota_update_statusService.cs b/Models/eva_adjust_quota_update_status/eva_adjust_quota_update_statusService.cs index 6741fec..f53625b 100644 --- a/Models/eva_adjust_quota_update_status/eva_adjust_quota_update_statusService.cs +++ b/Models/eva_adjust_quota_update_status/eva_adjust_quota_update_statusService.cs @@ -23,16 +23,19 @@ namespace TodoAPI2.Models private IMyDatabase db; private Iexternal_linkageService ext; private Iexternal_employeeService emp; + private Ieva_adjust_postponement_quotaService quotaStatus; public eva_adjust_quota_update_statusService(IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext, - Iexternal_employeeService inemp) + Iexternal_employeeService inemp, + Ieva_adjust_postponement_quotaService inquotaStatus) { _repository = repository; db = mydb; ext = inext; emp = inemp; + quotaStatus = inquotaStatus; } #region Private Functions @@ -165,12 +168,26 @@ namespace TodoAPI2.Models return newkey.Value; } - public eva_adjust_quota_update_statusViewModel Update(int id, eva_adjust_quota_update_statusInputModel model, bool is_force_save, int? updateby) { var existingEntity = _repository.Get(id); + if (existingEntity != null) { + if (model.quota_status == "Y") + { + var postponement = from x in _repository.Context.eva_adjust_postponement + where x.fiscal_year == existingEntity.fiscal_year + && x.theRound == existingEntity.theRound + && x.id != existingEntity.id + && x.postponement_status != "Y" + select x; + if (postponement.Count() > 0) + { + throw new Exception("ยังมีบางหน่วยงาน ยังไม่ได้อนุมัติ ปรับเลื่อนค่าตอบแทน"); + } + } + existingEntity.quota_status = model.quota_status; existingEntity.quota_status_date = DateTime.Now; existingEntity.quota_status_by = updateby; @@ -184,6 +201,9 @@ namespace TodoAPI2.Models } var updated = _repository.Update(id, existingEntity); + + quotaStatus.updateAllpostponement(id); + return Get(updated.id); } else diff --git a/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs b/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs index 253660e..86ded1b 100644 --- a/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs +++ b/Models/eva_create_evaluation_detail_process/eva_create_evaluation_detail_processService.cs @@ -454,6 +454,9 @@ namespace TodoAPI2.Models || ((m_eva_create_evaluation_detail_process.supervisor1_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor1_id : fk_eva_create_evaluationResult10.supervisor1_id).HasValue && emp_id == (m_eva_create_evaluation_detail_process.supervisor1_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor1_id : fk_eva_create_evaluationResult10.supervisor1_id)) || ((m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id).HasValue && emp_id == (m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id)) || ((int?[])special_person).Contains(emp_id) + + || ((m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id).HasValue && emp_id == (m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id)) + ) && (!model.employee_id.HasValue || m_eva_create_evaluation_detail_process.employee_id == model.employee_id) diff --git a/Views/eva_adjust_postponement_normalView/eva_adjust_postponement_normal_d.cshtml b/Views/eva_adjust_postponement_normalView/eva_adjust_postponement_normal_d.cshtml index e94eead..07860a3 100644 --- a/Views/eva_adjust_postponement_normalView/eva_adjust_postponement_normal_d.cshtml +++ b/Views/eva_adjust_postponement_normalView/eva_adjust_postponement_normal_d.cshtml @@ -141,7 +141,7 @@ - + @@ -153,7 +153,7 @@
- + diff --git a/Views/eva_adjust_postponement_quotaView/eva_adjust_postponement_quota_d.cshtml b/Views/eva_adjust_postponement_quotaView/eva_adjust_postponement_quota_d.cshtml index fed70ec..7e6812b 100644 --- a/Views/eva_adjust_postponement_quotaView/eva_adjust_postponement_quota_d.cshtml +++ b/Views/eva_adjust_postponement_quotaView/eva_adjust_postponement_quota_d.cshtml @@ -226,11 +226,17 @@
รายชื่อบุคลลากร
+
+
+

สถานะ ปรับเลื่อนค่าตอบแทน

+ +
+
- + @@ -293,6 +299,11 @@ } else { eva_adjust_postponement_quota_SetCreateForm(); } + + $("#eva_adjust_quota_update_status_quota_status_submit_to").select2({ + dropdownParent: $('#eva_adjust_quota_update_statusModel') + }); + SetupValidationRemark("eva_adjust_postponement_quota"); SetupValidationRemark("eva_adjust_postponement_detail_quota"); SetupValidationRemark("eva_adjust_quota_update_status"); diff --git a/appsettings.Development.json b/appsettings.Development.json index 992bc18..2b7e1ee 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -1,7 +1,7 @@ { "connectionStrings": { - "mainDBConnectionString": "Server=192.168.1.34;Port=32432;Database=tb320_hr_site2_eva2;User ID=postgres;Password=ZdPr0jects;", - "externalDBConnectionString": "Server=192.168.1.34;Port=32432;Database=tb320_hr_site2_eva2;User ID=postgres;Password=ZdPr0jects;" + "mainDBConnectionString": "Server=192.168.1.34;Port=32432;Database=tb320_hr_site2;User ID=postgres;Password=ZdPr0jects;", + "externalDBConnectionString": "Server=192.168.1.34;Port=32432;Database=tb320_hr_site2;User ID=postgres;Password=ZdPr0jects;" //"mainDBConnectionString": "Server=192.168.2.233;Port=5432;Database=tb320_hr_site2;User ID=postgres;Password=project0*;", //"externalDBConnectionString": "Server=192.168.2.233;Port=5432;Database=tb320_hr_site2;User ID=postgres;Password=project0*;" }, diff --git a/wwwroot/js/eva_adjust_postponement_detail_normal_02/eva_adjust_postponement_detail_normal_02_inline.js b/wwwroot/js/eva_adjust_postponement_detail_normal_02/eva_adjust_postponement_detail_normal_02_inline.js index cc8560d..0438301 100644 --- a/wwwroot/js/eva_adjust_postponement_detail_normal_02/eva_adjust_postponement_detail_normal_02_inline.js +++ b/wwwroot/js/eva_adjust_postponement_detail_normal_02/eva_adjust_postponement_detail_normal_02_inline.js @@ -163,7 +163,7 @@ function eva_adjust_postponement_detail_normal_02_Get(a, blankItem) { tag += '

'; tag += '

'; - tag += ''; + tag += ''; tag += ''; tag += '

'; @@ -225,6 +225,7 @@ function eva_adjust_postponement_detail_normal_02_Get(a, blankItem) { }); //eva_adjust_postponement_detail_normal_02_Summary(); Oneva_adjust_postponement_detail_normal_02_promoted_percentageChanged(true); + checkEnableForm(); endLoad(); }; startLoad(); diff --git a/wwwroot/js/eva_adjust_postponement_quota/eva_adjust_postponement_quota_d.js b/wwwroot/js/eva_adjust_postponement_quota/eva_adjust_postponement_quota_d.js index c76fda6..0ac47a6 100644 --- a/wwwroot/js/eva_adjust_postponement_quota/eva_adjust_postponement_quota_d.js +++ b/wwwroot/js/eva_adjust_postponement_quota/eva_adjust_postponement_quota_d.js @@ -23,6 +23,15 @@ function eva_adjust_postponement_quota_FeedDataToForm(data) { //console.log(data); + var previousstatus = ""; + + $.each(data.approve_status, function (index, value) { + //console.log(index + ": " + value); + previousstatus += "

  • " + value + "
  • " + }); + + $("#previousstatus").html("
      "+previousstatus+"
    "); + quota_status_submit_to = data.quota_status_submit_to; managed_by = data.managed_by; diff --git a/wwwroot/js/eva_adjust_postponement_update_status/eva_adjust_postponement_update_status.js b/wwwroot/js/eva_adjust_postponement_update_status/eva_adjust_postponement_update_status.js index 7f31721..3e9f0e0 100644 --- a/wwwroot/js/eva_adjust_postponement_update_status/eva_adjust_postponement_update_status.js +++ b/wwwroot/js/eva_adjust_postponement_update_status/eva_adjust_postponement_update_status.js @@ -17,9 +17,19 @@ function eva_adjust_postponement_update_status_FeedDataToSearchForm(data) { //================= Form Data Customizaiton ========================================= +function checkEnableForm() { + if ($("#eva_adjust_postponement_update_status_postponement_status").val() === "Y") { + $(".edittext").attr("disabled", true); + $("#savebtn").hide(); + } else { + $(".edittext").attr("disabled", false); + $("#savebtn").show(); + } +} + function eva_adjust_postponement_update_status_FeedDataToForm(data) { $("#eva_adjust_postponement_update_status_id").val(data.id); - DropDownClearFormAndFeedWithData($("#eva_adjust_postponement_update_status_postponement_status"), data, "id", "external_name", "item_postponement_status", data.postponement_status); + DropDownClearFormAndFeedWithData($("#eva_adjust_postponement_update_status_postponement_status"), data, "external_code", "external_name", "item_postponement_status", data.postponement_status); $("#eva_adjust_postponement_update_status_postponement_status_date").val(formatDate(data.postponement_status_date)); DropDownClearFormAndFeedWithData($("#eva_adjust_postponement_update_status_postponement_status_by"), data, "id", "fullname", "item_postponement_status_by", data.postponement_status_by); $("#eva_adjust_postponement_update_status_postponement_status_note").val(data.postponement_status_note); @@ -31,6 +41,7 @@ function eva_adjust_postponement_update_status_FeedDataToForm(data) { //console.log(data); + checkEnableForm(); } function eva_adjust_postponement_update_status_GetFromForm() { @@ -127,7 +138,8 @@ function eva_adjust_postponement_update_status_PutUpdate() { //eva_adjust_postponement_update_status_RefreshTable(); eva_adjust_postponement_update_status_SetEditForm(getUrlParameter('id'), false); - + window.location.reload(); + console.log("window.location.reload()"); endLoad(); }; startLoad(); diff --git a/wwwroot/js/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_status.js b/wwwroot/js/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_status.js index 3f95e54..cdf6e08 100644 --- a/wwwroot/js/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_status.js +++ b/wwwroot/js/eva_adjust_quota_update_final_status/eva_adjust_quota_update_final_status.js @@ -28,7 +28,8 @@ function eva_adjust_quota_update_final_status_FeedDataToForm(data) { var statusfinalText = $("#eva_adjust_quota_update_final_status_quota_final_status option:selected").text(); if ($("#eva_adjust_quota_update_final_status_quota_final_status_by option:selected").text() !== "") statusfinalText += " โดย " + $("#eva_adjust_quota_update_final_status_quota_final_status_by option:selected").text(); - $("#statusfinalapprove").text(statusfinalText); + + if (statusfinalText !== "กรุณาเลือก โดย กรุณาเลือก") $("#statusfinalapprove").text(statusfinalText); } function eva_adjust_quota_update_final_status_GetFromForm() { @@ -122,11 +123,14 @@ function showHideForm() { //console.log("CON 2"); } - $(".thesubmit").hide(); + //$(".thesubmit").hide(); $(".thesubmit2").hide(); if (parseInt(getCookie("emp_id")) === quota_status_submit_to) $(".thesubmit2").show(); - if (parseInt(getCookie("emp_id")) === managed_by) $(".thesubmit").show(); + //if (parseInt(getCookie("emp_id")) === managed_by) $(".thesubmit").show(); + + //console.log(managed_by); + //console.log(getCookie("emp_id")); if ($("#eva_adjust_quota_update_status_quota_status").val() !== "Y") { diff --git a/wwwroot/js/eva_adjust_quota_update_status/eva_adjust_quota_update_status.js b/wwwroot/js/eva_adjust_quota_update_status/eva_adjust_quota_update_status.js index d73f06b..b9e9a9c 100644 --- a/wwwroot/js/eva_adjust_quota_update_status/eva_adjust_quota_update_status.js +++ b/wwwroot/js/eva_adjust_quota_update_status/eva_adjust_quota_update_status.js @@ -28,7 +28,8 @@ function eva_adjust_quota_update_status_FeedDataToForm(data) { var statusText = $("#eva_adjust_quota_update_status_quota_status option:selected").text(); if ($("#eva_adjust_quota_update_status_quota_status_by option:selected").text() !== "") statusText += " โดย " + $("#eva_adjust_quota_update_status_quota_status_by option:selected").text(); - $("#statusapprove").text(statusText); + + if (statusText != "กรุณาเลือก โดย กรุณาเลือก") $("#statusapprove").text(statusText); }