diff --git a/ApiControllers/eva_create_evaluation_detail_review05Controllers.cs b/ApiControllers/eva_create_evaluation_detail_review05Controllers.cs new file mode 100644 index 0000000..5428b4f --- /dev/null +++ b/ApiControllers/eva_create_evaluation_detail_review05Controllers.cs @@ -0,0 +1,361 @@ +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/eva_create_evaluation_detail_review05")] + public class eva_create_evaluation_detail_review05Controller : BaseController + { + #region Private Variables + private ILogger _logger; + private Ieva_create_evaluation_detail_review05Service _repository; + private IConfiguration Configuration { get; set; } + #endregion + + #region Properties + + #endregion + + /// + /// Default constructure for dependency injection + /// + /// + /// + /// + public eva_create_evaluation_detail_review05Controller(ILogger logger, Ieva_create_evaluation_detail_review05Service repository, IConfiguration configuration) + { + _logger = logger; + _repository = repository; + Configuration = configuration; + } + + /// + /// Get specific item by id + /// + /// + /// + /// Return Get specific item by id + /// Returns the item + /// Error Occurred + [HttpGet("{id}")] + [ProducesResponseType(typeof(eva_create_evaluation_detail_review05WithSelectionViewModel), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Get(int id) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.GetWithSelection(id); + + return Ok(result); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult Get.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get Blank Item + /// + /// + /// + /// Return a blank item + /// Returns the item + /// Error Occurred + [HttpGet("GetBlankItem")] + [ProducesResponseType(typeof(eva_create_evaluation_detail_review05WithSelectionViewModel), 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}"); + } + } + + /// + /// Get list items by create_evaluation_id + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("")] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetList(int? create_evaluation_id) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + return Ok(_repository.GetListBycreate_evaluation_id(create_evaluation_id)); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetList.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + /// + /// Get list items by search + /// + /// + /// + /// Return list of items by specifced keyword + /// Returns the item + /// Error Occurred + [HttpGet("GetListBySearch")] + [ProducesResponseType(typeof(List), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult GetListBySearch(eva_create_evaluation_detail_review05SearchModel model) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + return Ok(_repository.GetListBySearch(model)); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception in IActionResult GetListBySearch.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + + /// + /// Create new item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPost("")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Insert([FromBody] eva_create_evaluation_detail_review05InputModel model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.Insert(model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"เพิ่มข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while insert.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Update item + /// + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("{id}")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Update(int id, [FromBody] eva_create_evaluation_detail_review05InputModel model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + var result = _repository.Update(id, model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"แก้ไขข้อมูล เรียบร้อย"; + message.data = result; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while update {id.ToString()}.", ex); + return StatusCode(500, $"{id.ToString()}. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Delete item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpDelete("{id}")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult Delete(int id) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + _repository.Delete(id); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"ลบข้อมูล เรียบร้อย"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while delete {id.ToString()}.", ex); + return StatusCode(500, $"{id.ToString()}. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Update multiple item + /// + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("UpdateMultiple")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult UpdateMultiple([FromBody] List model) + { + if (ModelState.IsValid) + { + try + { + if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + string rowCount = _repository.UpdateMultiple(model, true); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = "ปรับปรุงข้อมูลเรียบร้อย จำนวน "+rowCount+" รายการ"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while UpdateMultiple.", ex); + return StatusCode(500, $"{ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + /// + /// Refresh AutoField of all items + /// + /// + /// + /// Response Result Message + /// Response Result Message + /// If the model is invalid + /// Error Occurred + [HttpPut("RefreshAutoField")] + [ProducesResponseType(typeof(CommonResponseMessage), 200)] + [ProducesResponseType(400)] + [ProducesResponseType(500)] + //[ValidateAntiForgeryToken] + public IActionResult RefreshAutoField() + { + if (ModelState.IsValid) + { + try + { + //if (!MyHelper.checkAuth(Configuration, HttpContext)) return Unauthorized(); + _repository.RefreshAutoFieldOfAllData(); + var message = new CommonResponseMessage(); + message.code = "200"; + message.message = $"ปรับปรุง Auto Field ของทุก record เรียบร้อย"; + message.data = null; + return Ok(message); + } + catch (Exception ex) + { + _logger.LogCritical($"Exception while RefreshAutoField.", ex); + return StatusCode(500, $"มีปัญหาระหว่างการปรับปรุง Auto Field. {ex.Message}"); + } + } + + return BadRequest(ModelState); + } + + + + } +} diff --git a/EXCEL/eva_create_evaluation_detail@eva_create_evaluation_detail_review05.xlsx b/EXCEL/eva_create_evaluation_detail@eva_create_evaluation_detail_review05.xlsx new file mode 100644 index 0000000..c2edf5c Binary files /dev/null and b/EXCEL/eva_create_evaluation_detail@eva_create_evaluation_detail_review05.xlsx differ 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 a2f27d1..8763068 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 @@ -197,7 +197,8 @@ 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, m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id, path, - special_person), + special_person, + m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id), role_desc = getRoleName(emp_id, m_eva_create_evaluation_detail_process.chief, m_eva_create_evaluation_detail_process.chief, @@ -205,7 +206,8 @@ 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, m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id, path, - special_person), + special_person, + m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id), remark_hrm_work_record = fk_external_employee.remark_hrm_work_record + GetWorkTimeText(fk_external_employee.packing_date, end_date), @@ -475,6 +477,7 @@ namespace TodoAPI2.Models status_supervisor1A = m_eva_create_evaluation_detail_process.status_supervisor1A, status_supervisor2A = m_eva_create_evaluation_detail_process.status_supervisor2A, + status_supervisor3A = m_eva_create_evaluation_detail_process.status_supervisor3A, role_code = getRoleCodeSearch(emp_id, m_eva_create_evaluation_detail_process.chief, m_eva_create_evaluation_detail_process.chief, @@ -482,7 +485,8 @@ 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, m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id, m_eva_create_evaluation_detail_process.status_chief, - special_person + special_person, + m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id ), role_desc = getRoleName(emp_id, m_eva_create_evaluation_detail_process.chief, @@ -491,13 +495,16 @@ 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, m_eva_create_evaluation_detail_process.supervisor2_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor2_id : fk_eva_create_evaluationResult10.supervisor2_id, path, - special_person), + special_person, + m_eva_create_evaluation_detail_process.supervisor3_id.HasValue ? m_eva_create_evaluation_detail_process.supervisor3_id : fk_eva_create_evaluationResult10.supervisor3_id + ), status_self_click_date = m_eva_create_evaluation_detail_process.status_self_click_date, status_chief_click_date = m_eva_create_evaluation_detail_process.status_chief_click_date, status_supervisor_click_date = m_eva_create_evaluation_detail_process.status_supervisor_click_date, status_supervisor1A_click_date = m_eva_create_evaluation_detail_process.status_supervisor1A_click_date, status_supervisor2A_click_date = m_eva_create_evaluation_detail_process.status_supervisor2A_click_date, + status_supervisor3A_click_date = m_eva_create_evaluation_detail_process.status_supervisor3A_click_date, plan_round_year = checkNull(fk_planResult.theTime)+"/"+checkNull(fk_planResult.fiscal_year), @@ -519,7 +526,7 @@ namespace TodoAPI2.Models return ""; } - private string getRoleCode(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string path, object special_person) + private string getRoleCode(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string path, object special_person, int? supervisor3A) { if ((emp_id == chief || emp_id == supervisor1) && chief == supervisor2 && path == "d2") return "2"; else if (emp_id == chief) return "1"; @@ -527,11 +534,12 @@ namespace TodoAPI2.Models else if (emp_id == supervisor2) return "2"; else if (emp_id == supervisor1A) return "3"; else if (emp_id == supervisor2A) return "4"; + else if (emp_id == supervisor3A) return "5"; if (((int?[])special_person).Contains(emp_id)) return "99"; return ""; } - private string getRoleCodeSearch(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string status_chief, object special_person) + private string getRoleCodeSearch(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string status_chief, object special_person, int? supervisor3A) { if ((emp_id == chief || emp_id == supervisor1) && chief == supervisor2 && status_chief=="Y") return "2"; else if (emp_id == chief) return "1"; @@ -539,11 +547,12 @@ namespace TodoAPI2.Models else if (emp_id == supervisor2) return "2"; else if (emp_id == supervisor1A) return "3"; else if (emp_id == supervisor2A) return "4"; + else if (emp_id == supervisor3A) return "5"; if (((int?[])special_person).Contains(emp_id)) return "99"; return ""; } - private string getRoleName(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string path, object special_person) + private string getRoleName(int? emp_id, int? chief, int? supervisor1, int? supervisor2, int? supervisor1A, int? supervisor2A, string path, object special_person, int? supervisor3A) { if ((emp_id == chief || emp_id == supervisor1) && chief == supervisor2 && path == "d2") return "ผู้ประเมินสูงสุด"; else if (emp_id == chief) return "ผู้ประเมิน"; @@ -551,6 +560,7 @@ namespace TodoAPI2.Models else if (emp_id == supervisor2) return "ผู้ประเมินสูงสุด"; else if (emp_id == supervisor1A) return "ผู้บังคับบัญชาเหนือขึ้นไป"; else if (emp_id == supervisor2A) return "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด)"; + else if (emp_id == supervisor3A) return "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง (พิเศษ)"; if (((int?[])special_person).Contains(emp_id)) return "ผู้ตรวจสอบ"; return ""; } diff --git a/Models/eva_create_evaluation_detail_review04/eva_create_evaluation_detail_review04Service.cs b/Models/eva_create_evaluation_detail_review04/eva_create_evaluation_detail_review04Service.cs index 94d8e7c..fce4ed7 100644 --- a/Models/eva_create_evaluation_detail_review04/eva_create_evaluation_detail_review04Service.cs +++ b/Models/eva_create_evaluation_detail_review04/eva_create_evaluation_detail_review04Service.cs @@ -20,14 +20,14 @@ namespace TodoAPI2.Models public class eva_create_evaluation_detail_review04Service : Ieva_create_evaluation_detail_review04Service { private IBaseRepository2 _repository; - private IMyDatabase db; - private Iexternal_linkageService ext; + private IMyDatabase db; + private Iexternal_linkageService ext; public eva_create_evaluation_detail_review04Service(IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext) { _repository = repository; - db = mydb; - ext = inext; + db = mydb; + ext = inext; } #region Private Functions @@ -47,7 +47,7 @@ namespace TodoAPI2.Models { return Mapper.Map>(entities); } - + #endregion #region Public Functions @@ -79,12 +79,12 @@ namespace TodoAPI2.Models public List GetListBycreate_evaluation_id(int? create_evaluation_id) { - var model = new eva_create_evaluation_detail_review04SearchModel(); + var model = new eva_create_evaluation_detail_review04SearchModel(); model.create_evaluation_id = create_evaluation_id; return GetListBySearch(model); } - public List GetListBySearch(eva_create_evaluation_detail_review04SearchModel model) + public List GetListBySearch(eva_create_evaluation_detail_review04SearchModel model) { var data = ( from m_eva_create_evaluation_detail_review04 in _repository.Context.eva_create_evaluation_detail @@ -94,7 +94,7 @@ namespace TodoAPI2.Models from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty() - where 1==1 + where 1 == 1 //&& (m_eva_create_evaluation_detail_review04.id == model.id || !model.id.HasValue) && (m_eva_create_evaluation_detail_review04.create_evaluation_id == model.create_evaluation_id || !model.create_evaluation_id.HasValue) @@ -129,10 +129,10 @@ namespace TodoAPI2.Models int? newkey = 0; var x = (from i in _repository.Context.eva_create_evaluation_detail - orderby i.id descending - select i).Take(1).ToList(); + orderby i.id descending + select i).Take(1).ToList(); - if(x.Count > 0) + if (x.Count > 0) { newkey = x[0].id + 1; } @@ -148,7 +148,7 @@ namespace TodoAPI2.Models var inserted = _repository.Insert(entity); - + return Get(inserted.id); } @@ -168,23 +168,23 @@ namespace TodoAPI2.Models return Get(updated.id); } else - throw new NotificationException("No data to update"); + throw new NotificationException("No data to update"); } - public string UpdateMultiple(List model) + public string UpdateMultiple(List model) { - foreach(var i in model) + foreach (var i in model) { if (i.active_mode == "1" && i.id.HasValue) // update - { + { var existingEntity = _repository.Get(i.id.Value); if (existingEntity != null) { - existingEntity.create_evaluation_id = i.create_evaluation_id; - existingEntity.supervisor2A = i.supervisor2A; - existingEntity.supervisor2A_result = i.supervisor2A_result; - existingEntity.supervisor2A_remark = i.supervisor2A_remark; - existingEntity.supervisor2A_date = i.supervisor2A_date; + existingEntity.create_evaluation_id = i.create_evaluation_id; + existingEntity.supervisor2A = i.supervisor2A; + existingEntity.supervisor2A_result = i.supervisor2A_result; + existingEntity.supervisor2A_remark = i.supervisor2A_remark; + existingEntity.supervisor2A_date = i.supervisor2A_date; _repository.UpdateWithoutCommit(i.id.Value, existingEntity); @@ -197,15 +197,15 @@ namespace TodoAPI2.Models _repository.InsertWithoutCommit(entity); } else if (i.active_mode == "0" && i.id.HasValue) // remove - { + { _repository.DeleteWithoutCommit(i.id.Value); } else if (i.active_mode == "0" && !i.id.HasValue) { // nothing to do - } + } } - _repository.Context.SaveChanges(); + _repository.Context.SaveChanges(); return model.Count().ToString(); } diff --git a/Models/eva_create_evaluation_detail_review05/Ieva_create_evaluation_detail_review05Service.cs b/Models/eva_create_evaluation_detail_review05/Ieva_create_evaluation_detail_review05Service.cs new file mode 100644 index 0000000..2132d25 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/Ieva_create_evaluation_detail_review05Service.cs @@ -0,0 +1,32 @@ +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 Ieva_create_evaluation_detail_review05Service : IBaseService2 + { + new eva_create_evaluation_detail_review05ViewModel Insert(eva_create_evaluation_detail_review05InputModel model, bool is_force_save); + new eva_create_evaluation_detail_review05ViewModel Update(int id, eva_create_evaluation_detail_review05InputModel model, bool is_force_save); + List GetListBycreate_evaluation_id(int? create_evaluation_id); + List GetListBySearch(eva_create_evaluation_detail_review05SearchModel model); + + string UpdateMultiple(List model, bool is_force_save); + eva_create_evaluation_detail_review05WithSelectionViewModel GetWithSelection(int id); + eva_create_evaluation_detail_review05WithSelectionViewModel GetBlankItem(); + + void RefreshAutoFieldOfAllData(); + eva_create_evaluation_detailEntity GetEntity(int id); + DataContext GetContext(); + + + + } +} + diff --git a/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05InputModel.cs b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05InputModel.cs new file mode 100644 index 0000000..10bfdb9 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05InputModel.cs @@ -0,0 +1,32 @@ +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 eva_create_evaluation_detail_review05InputModel + { + + public int? id { get; set; } + + public int? create_evaluation_id { get; set; } + + public int? supervisor3A { get; set; } + + public string supervisor3A_result { get; set; } + + public string supervisor3A_remark { get; set; } + + public DateTime? supervisor3A_date { get; set; } + + public string active_mode { get; set; } + } +} + diff --git a/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05ReportRequestModel.cs b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05ReportRequestModel.cs new file mode 100644 index 0000000..b09f758 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05ReportRequestModel.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 eva_create_evaluation_detail_review05ReportRequestModel : eva_create_evaluation_detail_review05SearchModel + { + public string filetype { get; set; } + + public string contentType { get { return MyHelper.GetContentType(filetype); } } + } +} + diff --git a/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05SearchModel.cs b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05SearchModel.cs new file mode 100644 index 0000000..eb7b0b8 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05SearchModel.cs @@ -0,0 +1,23 @@ +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 eva_create_evaluation_detail_review05SearchModel + { + + public int id { get; set; } + + public int? create_evaluation_id { get; set; } + + } +} + diff --git a/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05Service.cs b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05Service.cs new file mode 100644 index 0000000..b3793b8 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05Service.cs @@ -0,0 +1,307 @@ +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 eva_create_evaluation_detail_review05Service : Ieva_create_evaluation_detail_review05Service + { + private IBaseRepository2 _repository; + private IMyDatabase db; + private Iexternal_linkageService ext; + + public eva_create_evaluation_detail_review05Service(IBaseRepository2 repository, IMyDatabase mydb, Iexternal_linkageService inext) + { + _repository = repository; + db = mydb; + ext = inext; + } + + #region Private Functions + private eva_create_evaluation_detailEntity GetEntity(eva_create_evaluation_detail_review05InputModel model) + { + return Mapper.Map(model); + } + private List GetEntityList(List models) + { + return Mapper.Map>(models); + } + private eva_create_evaluation_detail_review05ViewModel GetDto(eva_create_evaluation_detailEntity entity) + { + return Mapper.Map(entity); + } + private List GetDtoList(List entities) + { + return Mapper.Map>(entities); + } + + #endregion + + #region Public Functions + #region Query Functions + + public eva_create_evaluation_detail_review05ViewModel Get(int id) + { + var entity = _repository.Get(id); + + return GetDto(entity); + } + + public eva_create_evaluation_detailEntity GetEntity(int id) + { + var entity = _repository.Get(id); + + return entity; + } + + public DataContext GetContext() + { + return _repository.Context; + } + + public eva_create_evaluation_detail_review05WithSelectionViewModel GetWithSelection(int id) + { + var entity = _repository.Get(id); + var i = Mapper.Map(entity); + i.item_supervisor3A_result = (from x in ext.GetAgreeDisagree() select x).ToList(); + + + return i; + } + public eva_create_evaluation_detail_review05WithSelectionViewModel GetBlankItem() + { + var i = new eva_create_evaluation_detail_review05WithSelectionViewModel(); + i.item_supervisor3A_result = (from x in ext.GetAgreeDisagree() select x).ToList(); + + + return i; + } + + public List GetListBycreate_evaluation_id(int? create_evaluation_id) + { + var model = new eva_create_evaluation_detail_review05SearchModel(); + model.create_evaluation_id = create_evaluation_id; + return GetListBySearch(model); + } + + public List GetListBySearch(eva_create_evaluation_detail_review05SearchModel model) + { + var data = ( + from m_eva_create_evaluation_detail_review05 in _repository.Context.eva_create_evaluation_detail + + join fk_external_linkage3 in ext.GetAgreeDisagree() on m_eva_create_evaluation_detail_review05.supervisor3A_result equals fk_external_linkage3.external_code + into external_linkageResult3 + from fk_external_linkageResult3 in external_linkageResult3.DefaultIfEmpty() + + + where + 1 == 1 + && (!model.create_evaluation_id.HasValue || m_eva_create_evaluation_detail_review05.create_evaluation_id == model.create_evaluation_id) + + + orderby m_eva_create_evaluation_detail_review05.created descending + select new eva_create_evaluation_detail_review05ViewModel() + { + id = m_eva_create_evaluation_detail_review05.id, + create_evaluation_id = m_eva_create_evaluation_detail_review05.create_evaluation_id, + supervisor3A = m_eva_create_evaluation_detail_review05.supervisor3A, + supervisor3A_result = m_eva_create_evaluation_detail_review05.supervisor3A_result, + supervisor3A_remark = m_eva_create_evaluation_detail_review05.supervisor3A_remark, + supervisor3A_date = m_eva_create_evaluation_detail_review05.supervisor3A_date, + + supervisor3A_result_external_linkage_external_name = fk_external_linkageResult3.external_name, + + isActive = m_eva_create_evaluation_detail_review05.isActive, + Created = m_eva_create_evaluation_detail_review05.created, + Updated = m_eva_create_evaluation_detail_review05.updated + } + ).Take(1000).ToList(); + + return data; + } + + #endregion + + #region Manipulation Functions + + + public int GetNewPrimaryKey() + { + int? newkey = 0; + + var x = (from i in _repository.Context.eva_create_evaluation_detail + orderby i.id descending + select i).Take(1).ToList(); + + if (x.Count > 0) + { + newkey = x[0].id + 1; + } + + return newkey.Value; + } + + + public eva_create_evaluation_detail_review05ViewModel Insert(eva_create_evaluation_detail_review05InputModel model, bool is_force_save) + { + var entity = GetEntity(model); + entity.id = GetNewPrimaryKey(); + + + //entity.SetAutoField(_repository.Context); + + if (is_force_save) + { + var inserted = _repository.Insert(entity); + //entity.DoAfterInsertUpdate(_repository.Context); + return Get(inserted.id); + } + else + { + _repository.InsertWithoutCommit(entity); + //entity.DoAfterInsertUpdate(_repository.Context); + return Mapper.Map(entity); + } + } + + public eva_create_evaluation_detail_review05ViewModel Update(int id, eva_create_evaluation_detail_review05InputModel model, bool is_force_save) + { + var existingEntity = _repository.Get(id); + if (existingEntity != null) + { + existingEntity.create_evaluation_id = model.create_evaluation_id; + existingEntity.supervisor3A = model.supervisor3A; + existingEntity.supervisor3A_result = model.supervisor3A_result; + existingEntity.supervisor3A_remark = model.supervisor3A_remark; + existingEntity.supervisor3A_date = model.supervisor3A_date; + + //existingEntity.SetAutoField(_repository.Context); + + if (is_force_save) + { + var updated = _repository.Update(id, existingEntity); + //existingEntity.DoAfterInsertUpdate(_repository.Context); + return Get(updated.id); + } + else + { + _repository.UpdateWithoutCommit(id, existingEntity); + //existingEntity.DoAfterInsertUpdate(_repository.Context); + return Mapper.Map(existingEntity); + } + } + else + throw new NotificationException("No data to update"); + } + + public string UpdateMultiple(List model, bool is_force_save) + { + foreach (var i in model) + { + if (i.active_mode == "1" && i.id.HasValue) // update + { + var existingEntity = _repository.Get(i.id.Value); + if (existingEntity != null) + { + existingEntity.create_evaluation_id = i.create_evaluation_id; + existingEntity.supervisor3A = i.supervisor3A; + existingEntity.supervisor3A_result = i.supervisor3A_result; + existingEntity.supervisor3A_remark = i.supervisor3A_remark; + existingEntity.supervisor3A_date = i.supervisor3A_date; + + //existingEntity.SetAutoField(_repository.Context); + _repository.UpdateWithoutCommit(i.id.Value, existingEntity); + } + } + else if (i.active_mode == "1" && !i.id.HasValue) // add + { + var entity = GetEntity(i); + entity.id = GetNewPrimaryKey(); + //entity.SetAutoField(_repository.Context); + _repository.InsertWithoutCommit(entity); + } + else if (i.active_mode == "0" && i.id.HasValue) // remove + { + _repository.DeleteWithoutCommit(i.id.Value); + } + else if (i.active_mode == "0" && !i.id.HasValue) + { + // nothing to do + } + } + if (is_force_save) + { + _repository.Context.SaveChanges(); + } + + return model.Count().ToString(); + } + + public eva_create_evaluation_detail_review05ViewModel SetAsActive(int id) + { + var updated = _repository.SetAsActive(id); + + return Get(updated.id); + } + public eva_create_evaluation_detail_review05ViewModel SetAsInactive(int id) + { + var updated = _repository.SetAsInActive(id); + + return Get(updated.id); + } + public void Delete(int id) + { + _repository.Delete(id); + + return; + } + + public void RefreshAutoFieldOfAllData() + { + //var all_items = from i in _repository.Context.eva_create_evaluation_detail + // select i; + //foreach (var item in all_items) + //{ + // item.SetAutoField(_repository.Context); + //} + //_repository.Context.SaveChanges(); + } + + private Dictionary GetLookupForLog() + { + var i = new Dictionary(); + + + i.Add("create_evaluation_id", "แบบประเมิน"); + i.Add("supervisor3A", "ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด)"); + i.Add("supervisor3A_result", "ผลการประเมิน"); + i.Add("supervisor3A_result_external_linkage_external_name", "ผลการประเมิน"); + i.Add("supervisor3A_remark", "ความเห็นผู้ประเมินสูงสุด"); + i.Add("supervisor3A_date", "วันที่ประเมิน"); + i.Add("txt_supervisor3A_date", "วันที่ประเมิน"); + + return i; + } + + #endregion + + #region Match Item + + #endregion + + #endregion + } +} \ No newline at end of file diff --git a/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05ViewModel.cs b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05ViewModel.cs new file mode 100644 index 0000000..4c48c81 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05ViewModel.cs @@ -0,0 +1,32 @@ +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 eva_create_evaluation_detail_review05ViewModel : BaseViewModel2 + { + + public int? create_evaluation_id { get; set; } + + public int? supervisor3A { get; set; } + + public string supervisor3A_result { get; set; } + + public string supervisor3A_remark { get; set; } + + public DateTime? supervisor3A_date { get; set; } + + public string txt_supervisor3A_date { get { return MyHelper.GetDateStringForReport(this.supervisor3A_date); } } + + public string supervisor3A_result_external_linkage_external_name { get; set; } + + } +} \ No newline at end of file diff --git a/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05WithSelectionViewModel.cs b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05WithSelectionViewModel.cs new file mode 100644 index 0000000..66a9747 --- /dev/null +++ b/Models/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05WithSelectionViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace TodoAPI2.Models +{ + public class eva_create_evaluation_detail_review05WithSelectionViewModel: eva_create_evaluation_detail_review05ViewModel + { + public List item_supervisor3A_result { get; set; } + + } +} \ No newline at end of file diff --git a/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs b/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs index 26fdbc2..89f18ed 100644 --- a/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs +++ b/Models/eva_create_evaluation_detail_status/eva_create_evaluation_detail_statusService.cs @@ -350,6 +350,24 @@ namespace TodoAPI2.Models noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d2?id=" + existingEntity.id.ToString(); add_history(DateTime.Now, "แบบประเมินถูกตีกลับ โดย ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด)", model.employee_id, existingEntity.id, 2); } + else if (model.status_mode == "next5") + { + existingEntity.status_supervisor3A_click_date = DateTime.Now; + + noti_to_employee_id2 = owner_eva_employee_id; + noti_message2 = "แบบประเมินของ {0} ได้รับการประเมินเรียบร้อยแล้ว"; + noti_url2 = "/eva/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (พิเศษ) อนุมัติแบบประเมินแล้ว", model.employee_id, existingEntity.id, 2); + } + else if (model.status_mode == "back5") + { + existingEntity.status_supervisor3A_click_date = DateTime.Now; + existingEntity.status_supervisor2A_click_date = null; + noti_to_employee_id = current_eva.supervisor2_id; + noti_message = "แบบประเมินของ {0} ถูกตีกลับ"; + noti_url = "/eva/eva_create_evaluation_detail_agreementView/eva_create_evaluation_detail_agreement_d2?id=" + existingEntity.id.ToString(); + add_history(DateTime.Now, "แบบประเมินถูกตีกลับ โดย ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (พิเศษ)", model.employee_id, existingEntity.id, 2); + } if (need_noti) { diff --git a/Startup.cs b/Startup.cs index 1f47a9f..52a3ccf 100644 --- a/Startup.cs +++ b/Startup.cs @@ -271,6 +271,8 @@ namespace Test01 services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddScoped(); @@ -542,6 +544,10 @@ namespace Test01 cfg.CreateMap(); cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); cfg.CreateMap(); cfg.CreateMap(); diff --git a/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml b/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml index c99e51d..7b76146 100644 --- a/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml +++ b/Views/eva_create_evaluation_detail_processView/eva_create_evaluation_detail_process_d2.cshtml @@ -589,7 +589,7 @@
- + @@ -599,6 +599,57 @@ +
+ +
+
ความเห็น ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (พิเศษ)
+
+
+ +
+
+ + + + +
+
+ + +
+ +
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+
+ + + + + + + +
+
+ +
+ @section FooterPlaceHolder{ @@ -610,6 +661,7 @@ + @@ -623,6 +675,7 @@ eva_create_evaluation_detail_review02_SetEditForm(id); eva_create_evaluation_detail_review03_SetEditForm(id); eva_create_evaluation_detail_review04_SetEditForm(id); + eva_create_evaluation_detail_review05_SetEditForm(id); eva_create_evaluation_detail_status_SetEditForm(id); eva_idp_plan_InitiateDataTable(id); @@ -638,6 +691,7 @@ SetupValidationRemark("eva_create_evaluation_detail_review02"); SetupValidationRemark("eva_create_evaluation_detail_review03"); SetupValidationRemark("eva_create_evaluation_detail_review04"); + SetupValidationRemark("eva_create_evaluation_detail_review05"); SetupValidationRemark("eva_idp_plan"); }); @@ -680,6 +734,17 @@ } } + function Oneva_create_evaluation_detail_review05_supervisor3A_resultChanged(a) { + if ($(a).val() == "Y") { + $("#eva_create_evaluation_detail_review05_supervisor3A_remark").attr("iRequire", "false"); + $("#eva_create_evaluation_detail_review05_supervisor3A_remark").css('border-color', ''); + $("#review05x").hide(); + } else { + $("#eva_create_evaluation_detail_review05_supervisor3A_remark").attr("iRequire", "true"); + $("#review05x").show(); + } + } + function searchVacation_GetFromForm() { var searchVacationObject = new Object(); searchVacationObject.start_date = formatDateForGetParameter(getDate($("#date_from").val())); @@ -751,6 +816,14 @@ }, 2000); } + function savereview05() { + saveAll(); + setTimeout(function () { + eva_create_evaluation_detail_review05_PutUpdate(true); + endLoad(); + }, 2000); + } + function saveStatus(s) { if (s === "next2" || s === "back2") { if (!ValidateForm('eva_create_evaluation_detail_review02', eva_create_evaluation_detail_review02_customValidation)) { @@ -785,6 +858,17 @@ eva_create_evaluation_detail_status_PutUpdate(s); }, 2000); } + else if (s === "next5") { + if (!ValidateForm('eva_create_evaluation_detail_review05', eva_create_evaluation_detail_review05_customValidation)) { + return; + } + startLoad(); + saveAll(); + eva_create_evaluation_detail_review05_PutUpdate(false); + setTimeout(function () { + eva_create_evaluation_detail_status_PutUpdate(s); + }, 2000); + } } function saveAll() { diff --git a/tb320eva.xml b/tb320eva.xml index 6d592d5..b7f7826 100644 --- a/tb320eva.xml +++ b/tb320eva.xml @@ -1756,6 +1756,114 @@ If the model is invalid Error Occurred + + + Default constructure for dependency injection + + + + + + + + Get specific item by id + + + + Return Get specific item by id + Returns the item + Error Occurred + + + + Get Blank Item + + + + Return a blank item + Returns the item + Error Occurred + + + + Get list items by create_evaluation_id + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + + + + Get list items by search + + + + Return list of items by specifced keyword + Returns the item + Error Occurred + + + + Create new item + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Update item + + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Delete item + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Update multiple item + + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + + + + Refresh AutoField of all items + + + + Response Result Message + Response Result Message + If the model is invalid + Error Occurred + Default constructure for dependency injection diff --git a/wwwroot/js/eva_create_evaluation_detail_process/eva_create_evaluation_detail_process_d2.js b/wwwroot/js/eva_create_evaluation_detail_process/eva_create_evaluation_detail_process_d2.js index f054b9a..bc5fb61 100644 --- a/wwwroot/js/eva_create_evaluation_detail_process/eva_create_evaluation_detail_process_d2.js +++ b/wwwroot/js/eva_create_evaluation_detail_process/eva_create_evaluation_detail_process_d2.js @@ -217,6 +217,13 @@ function setPageByRoleAndStatus(role_code, status_self, status_chief, status_sup $("#btnd02").hide(); $("#btnd03").hide(); + $("#eva_create_evaluation_detail_review05_supervisor3A_result").attr("disabled", true); + //$("#eva_create_evaluation_detail_review05_supervisor3A_date").attr("disabled", true); + $("#eva_create_evaluation_detail_review05_supervisor3A_remark").attr("disabled", true); + $("#btne01").hide(); + $("#btne02").hide(); + $("#btne03").hide(); + setViewOfComment(status_supervisor, status_supervisor1A, status_supervisor2A); if (role_code === "2") { // ความเห็น ความเห็นผู้ประเมินสูงสุด @@ -300,6 +307,34 @@ function setPageByRoleAndStatus(role_code, status_self, status_chief, status_sup $(".myeditor").attr("disabled", true); } } + + else if (role_code === "5") { // ความเห็น ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (พิเศษ) + + $("#eva_create_evaluation_detail_review05_supervisor3A_result").show(); + + if (status_supervisor1A === "Y" && status_supervisor === "Y" && status_chief === "Y" && status_self === "Y") { + $("#eva_create_evaluation_detail_review05_supervisor3A_result").attr("disabled", false); + //$("#eva_create_evaluation_detail_review05_supervisor3A_date").attr("disabled", false); + $("#eva_create_evaluation_detail_review05_supervisor3A_remark").attr("disabled", false); + $("#btne01").show(); + $("#btne02").show(); + //$("#btne03").show(); + $(".myeditor").attr("disabled", false); + } else { + $("#thestatus3A").text("(ผู้รับการประเมิน หรือ ผู้ประเมิน หรือ ผู้ประเมินสูงสุด หรือ ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง หรือ ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (สูงสุด) ยังไม่ส่งแบบประเมิน คุณจึงไม่สามารถให้ความเห็นได้)"); + } + if (status_supervisor3A === "Y") { + $("#eva_create_evaluation_detail_review05_supervisor3A_result").attr("disabled", true); + //$("#eva_create_evaluation_detail_review05_supervisor3A_date").attr("disabled", true); + $("#eva_create_evaluation_detail_review05_supervisor3A_remark").attr("disabled", true); + $("#btne01").hide(); + $("#btne02").hide(); + $("#btne03").hide(); + $("#thestatus3A").text("(ผู้บังคับบัญชาการเหนือขึ้นไปอีกชั้นหนึ่ง (พิเศษ) ส่งแบบประเมินแล้ว)"); + $(".myeditor").attr("disabled", true); + } + } + else if (role_code === "99") { // ผู้ตรวจสอบ diff --git a/wwwroot/js/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05_d.js b/wwwroot/js/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05_d.js new file mode 100644 index 0000000..09d0f5b --- /dev/null +++ b/wwwroot/js/eva_create_evaluation_detail_review05/eva_create_evaluation_detail_review05_d.js @@ -0,0 +1,106 @@ +var eva_create_evaluation_detail_review05_editMode = "CREATE"; +var eva_create_evaluation_detail_review05_API = "/api/eva_create_evaluation_detail_review05/"; + +//================= Form Data Customizaiton ========================================= + +function eva_create_evaluation_detail_review05_FeedDataToForm(data) { +$("#eva_create_evaluation_detail_review05_id").val(data.id); +$("#eva_create_evaluation_detail_review05_create_evaluation_id").val(data.create_evaluation_id); +$("#eva_create_evaluation_detail_review05_supervisor3A").val(data.supervisor3A); +DropDownClearFormAndFeedWithData($("#eva_create_evaluation_detail_review05_supervisor3A_result"), data, "id", "external_name", "item_supervisor3A_result", data.supervisor3A_result); +$("#eva_create_evaluation_detail_review05_supervisor3A_remark").val(data.supervisor3A_remark); +$("#eva_create_evaluation_detail_review05_supervisor3A_date").val(formatDate(data.supervisor3A_date)); + +} + +function eva_create_evaluation_detail_review05_GetFromForm() { + var eva_create_evaluation_detail_review05Object = new Object(); +eva_create_evaluation_detail_review05Object.id = $("#eva_create_evaluation_detail_review05_id").val(); +eva_create_evaluation_detail_review05Object.create_evaluation_id = $("#eva_create_evaluation_detail_review05_create_evaluation_id").val(); +eva_create_evaluation_detail_review05Object.supervisor3A = $("#eva_create_evaluation_detail_review05_supervisor3A").val(); +eva_create_evaluation_detail_review05Object.supervisor3A_result = $("#eva_create_evaluation_detail_review05_supervisor3A_result").val(); +eva_create_evaluation_detail_review05Object.supervisor3A_remark = $("#eva_create_evaluation_detail_review05_supervisor3A_remark").val(); +eva_create_evaluation_detail_review05Object.supervisor3A_date = getDate($("#eva_create_evaluation_detail_review05_supervisor3A_date").val()); + + + return eva_create_evaluation_detail_review05Object; +} + +function eva_create_evaluation_detail_review05_InitialForm() { + var successFunc = function (result) { + eva_create_evaluation_detail_review05_FeedDataToForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + eva_create_evaluation_detail_review05_API + "GetBlankItem", successFunc, AlertDanger); +} + +//================= Form Mode Setup and Flow ========================================= + +function eva_create_evaluation_detail_review05_SetEditForm(a) { + var successFunc = function (result) { + eva_create_evaluation_detail_review05_editMode = "UPDATE"; + eva_create_evaluation_detail_review05_FeedDataToForm(result); + endLoad(); + }; + startLoad(); + AjaxGetRequest(apisite + eva_create_evaluation_detail_review05_API + a, successFunc, AlertDanger); +} + +function eva_create_evaluation_detail_review05_SetCreateForm() { + eva_create_evaluation_detail_review05_editMode = "CREATE"; + eva_create_evaluation_detail_review05_InitialForm(); +} + +//================= Update and Delete ========================================= + +var eva_create_evaluation_detail_review05_customValidation = function (group) { + return ""; +}; + +function eva_create_evaluation_detail_review05_PutUpdate() { + if (!ValidateForm('eva_create_evaluation_detail_review05', eva_create_evaluation_detail_review05_customValidation)) + { + return; + } + var data = eva_create_evaluation_detail_review05_GetFromForm(); + + //Update Mode + if (eva_create_evaluation_detail_review05_editMode === "UPDATE") { + var successFunc1 = function (result) { + AlertSuccess(result.code+" "+result.message); + endLoad(); + }; + startLoad(); + AjaxPutRequest(apisite + eva_create_evaluation_detail_review05_API + data.id, data, successFunc1, AlertDanger); + } + // Create mode + else { + var successFunc2 = function (result) { + AlertSuccess(result.code+" "+result.message); + endLoad(); + }; + startLoad(); + AjaxPostRequest(apisite + eva_create_evaluation_detail_review05_API, data, successFunc2, AlertDanger); + } +} + +function eva_create_evaluation_detail_review05_GoDelete(a) { + if (confirm('คุณต้องการลบ ' + a + ' ใช่หรือไม่?')) { + var successFunc = function (result) { + AlertSuccess(result.code+" "+result.message); + eva_create_evaluation_detail_review05_RefreshTable(); + endLoad(); + }; + startLoad(); + AjaxDeleteRequest(apisite + eva_create_evaluation_detail_review05_API + a, null, successFunc, AlertDanger); + } +} + +//================= File Upload ========================================= + + + +//================= Multi-Selection Function ========================================= + +