diff --git a/Controllers/HrRegister.Controller.cs b/Controllers/HrRegister.Controller.cs index 6848e76..ad52a0d 100644 --- a/Controllers/HrRegister.Controller.cs +++ b/Controllers/HrRegister.Controller.cs @@ -183,6 +183,322 @@ namespace rmutr_report.Controllers break; } + return Ok(); + } + [HttpPost, Route("reports/hr_position_academic/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetHr2Report([FromRoute] string type, [FromBody] hr_position_manage _hr) + { + foreach (var hr in _hr.data) + { + if (hr.position_academic_salary != null) + { + string NumberText = hr.position_academic_salary.ToString(); + var str = + NumberText.Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str.Length == 4) + { + for (int i = 1; i <= str.Length - 1; i += 4) + { + hr.money1 = str.Insert(i, ","); + } + } + else if (str.Length == 5) + { + for (int i = 2; i <= str.Length - 1; i += 5) + { + hr.money1 = str.Insert(i, ","); + } + } + else + { + hr.money1 = str; + } + + var total1 = _hr.data.Select(t => t.position_academic_salary).Sum(h => h.Value); + var str3 = + total1.ToString().Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str3.Length == 4) + { + for (int i = 1; i <= str3.Length - 1; i += 4) + { + _hr.total1 = str3.Insert(i, ","); + } + } + else if (str3.Length == 5) + { + for (int i = 2; i <= str3.Length - 1; i += 5) + { + _hr.total1 = str3.Insert(i, ","); + } + } + else + { + _hr.total1 = str3; + } + + if (hr.position_academic_salary == null) + { + _hr.total1 = null; + } + } + + if (hr.compensation != null) + { + string NumberText2 = hr.compensation.ToString(); + var str2 = + NumberText2.Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str2.Length == 4) + { + for (int i = 1; i <= str2.Length - 1; i += 4) + { + hr.money2 = str2.Insert(i, ","); + } + } + else if (str2.Length == 5) + { + for (int i = 2; i <= str2.Length - 1; i += 5) + { + hr.money2 = str2.Insert(i, ","); + } + } + else + { + hr.money2 = str2; + } + + var total2 = _hr.data.Select(t => t.compensation).Sum(h => h.Value); + var str4 = + total2.ToString().Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str4.Length == 4) + { + for (int i = 1; i <= str4.Length - 1; i += 4) + { + _hr.total2 = str4.Insert(i, ","); + } + } + else if (str4.Length == 5) + { + for (int i = 2; i <= str4.Length - 1; i += 5) + { + _hr.total2 = str4.Insert(i, ","); + } + } + else + { + _hr.total2 = str4; + } + } + + if (hr.compensation == null) + { + _hr.total2 = null; + } + } + + var hr1 = new List() {_hr}; + + Report report = new Report(); + report.Load(_setting.report_path + "hr_position_academic.frx"); + report.RegisterData(hr1, "hr_position_manage"); + report.Prepare(); + + MemoryStream stream = new MemoryStream(); + switch (type) + { + case "pdf": + PDFExport pdf = new PDFExport(); + report.Export(pdf, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/pdf"); + break; + case "xls": + case "xlsx": + Excel2007Export excel = new Excel2007Export(); + report.Export(excel, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/vnd.ms-excel"); + break; + case "mht": + MHTExport mht = new MHTExport(); + report.Export(mht, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "multipart/related"); + break; + case "csv": + CSVExport csv = new CSVExport(); + report.Export(csv, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "text/csv"); + break; + } + + return Ok(); + } + [HttpPost, Route("reports/hr_position_profession/{type}")] + [ApiExplorerSettings(GroupName = "reports")] + public IActionResult GetHr3Report([FromRoute] string type, [FromBody] hr_position_manage _hr) + { + foreach (var hr in _hr.data) + { + if (hr.position_profession_salary != null) + { + string NumberText = hr.position_profession_salary.ToString(); + var str = + NumberText.Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str.Length == 4) + { + for (int i = 1; i <= str.Length - 1; i += 4) + { + hr.money1 = str.Insert(i, ","); + } + } + else if (str.Length == 5) + { + for (int i = 2; i <= str.Length - 1; i += 5) + { + hr.money1 = str.Insert(i, ","); + } + } + else + { + hr.money1 = str; + } + + var total1 = _hr.data.Select(t => t.position_profession_salary).Sum(h => h.Value); + var str3 = + total1.ToString().Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str3.Length == 4) + { + for (int i = 1; i <= str3.Length - 1; i += 4) + { + _hr.total1 = str3.Insert(i, ","); + } + } + else if (str3.Length == 5) + { + for (int i = 2; i <= str3.Length - 1; i += 5) + { + _hr.total1 = str3.Insert(i, ","); + } + } + else + { + _hr.total1 = str3; + } + + if (hr.position_profession_salary == null) + { + _hr.total1 = null; + } + } + + if (hr.compensation != null) + { + string NumberText2 = hr.compensation.ToString(); + var str2 = + NumberText2.Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str2.Length == 4) + { + for (int i = 1; i <= str2.Length - 1; i += 4) + { + hr.money2 = str2.Insert(i, ","); + } + } + else if (str2.Length == 5) + { + for (int i = 2; i <= str2.Length - 1; i += 5) + { + hr.money2 = str2.Insert(i, ","); + } + } + else + { + hr.money2 = str2; + } + + var total2 = _hr.data.Select(t => t.compensation).Sum(h => h.Value); + var str4 = + total2.ToString().Replace('0', '๐').Replace('1', '๑').Replace('2', '๒').Replace('3', '๓') + .Replace('4', '๔').Replace('5', '๕').Replace('6', '๖').Replace('7', '๗').Replace('8', '๘') + .Replace('9', '๙'); + if (str4.Length == 4) + { + for (int i = 1; i <= str4.Length - 1; i += 4) + { + _hr.total2 = str4.Insert(i, ","); + } + } + else if (str4.Length == 5) + { + for (int i = 2; i <= str4.Length - 1; i += 5) + { + _hr.total2 = str4.Insert(i, ","); + } + } + else + { + _hr.total2 = str4; + } + } + + if (hr.compensation == null) + { + _hr.total2 = null; + } + } + + var hr1 = new List() {_hr}; + + Report report = new Report(); + report.Load(_setting.report_path + "hr_position_profession.frx"); + report.RegisterData(hr1, "hr_position_manage"); + report.Prepare(); + + MemoryStream stream = new MemoryStream(); + switch (type) + { + case "pdf": + PDFExport pdf = new PDFExport(); + report.Export(pdf, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/pdf"); + break; + case "xls": + case "xlsx": + Excel2007Export excel = new Excel2007Export(); + report.Export(excel, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "application/vnd.ms-excel"); + break; + case "mht": + MHTExport mht = new MHTExport(); + report.Export(mht, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "multipart/related"); + break; + case "csv": + CSVExport csv = new CSVExport(); + report.Export(csv, stream); + stream.Seek(0, SeekOrigin.Begin); + return File(stream, "text/csv"); + break; + } + return Ok(); } } diff --git a/Models/Hrregister/hr_position_manage.cs b/Models/Hrregister/hr_position_manage.cs index c9ec45e..6ba782c 100644 --- a/Models/Hrregister/hr_position_manage.cs +++ b/Models/Hrregister/hr_position_manage.cs @@ -6,23 +6,32 @@ namespace rmutr_report.Models.Hrregister { public string academic_year_name_th { get; set; } public string position_manage_type { get; set; } + public string position_academic_type { get; set; } + public string position_academic_profession { get; set; } public string status { get; set; } + public string agency_name_th { get; set; } public List data { get; set; } public string total1 { get; set; } public string total2 { get; set; } - + public int? professor { get; set; } + public int? associate_rofessor { get; set; } + public int? assistant_professor { get; set; } } public class hr_position_manage_detail { public string position_manage_name { get; set; } public decimal? position_manage_salary { get; set; } + public decimal? position_academic_salary { get; set; } + public decimal? position_profession_salary { get; set; } public decimal? compensation { get; set; } public string position_id { get; set; } public string display_name_th { get; set; } public string agency_name_th { get; set; } public string date_office { get; set; } public string date_term_of_ffice { get; set; } + public string appointment_date { get; set; } + public string retire_date { get; set; } public string directive { get; set; } public string money1 { get; set; } public string money2 { get; set; } diff --git a/wwwroot/reports/hr_position_academic.frx b/wwwroot/reports/hr_position_academic.frx new file mode 100644 index 0000000..5142256 --- /dev/null +++ b/wwwroot/reports/hr_position_academic.frx @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/reports/hr_position_manage.frx b/wwwroot/reports/hr_position_manage.frx index 177cc02..8b129ae 100644 --- a/wwwroot/reports/hr_position_manage.frx +++ b/wwwroot/reports/hr_position_manage.frx @@ -3,18 +3,18 @@ - - + + - + - + diff --git a/wwwroot/reports/hr_position_profession.frx b/wwwroot/reports/hr_position_profession.frx new file mode 100644 index 0000000..b246f7d --- /dev/null +++ b/wwwroot/reports/hr_position_profession.frx @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +