From aeb65dc152c92010002a33ac0dc1a7613af71cb8 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Sun, 20 Apr 2025 20:43:45 +0330 Subject: [PATCH] add sms report for admin --- 0_Framework/Application/Sms/ISmsService.cs | 7 + 0_Framework/Application/Sms/SmsService.cs | 15 + ServiceHost/Areas/Admin/Pages/Index.cshtml | 351 +++++++++++++----- ServiceHost/Areas/Admin/Pages/Index.cshtml.cs | 18 +- .../AssetsAdmin/page/Index/js/Index.js | 25 ++ .../wwwroot/AssetsClient/images/sms-icon.png | Bin 0 -> 1629 bytes 6 files changed, 311 insertions(+), 105 deletions(-) create mode 100644 ServiceHost/wwwroot/AssetsClient/images/sms-icon.png diff --git a/0_Framework/Application/Sms/ISmsService.cs b/0_Framework/Application/Sms/ISmsService.cs index d16ef5f2..36a38030 100644 --- a/0_Framework/Application/Sms/ISmsService.cs +++ b/0_Framework/Application/Sms/ISmsService.cs @@ -22,4 +22,11 @@ public interface ISmsService string DeliveryStatus(byte? dv); string DeliveryColorStatus(byte? dv); string UnixTimeStampToDateTime(int? unixTimeStamp); + + #region Mahan + + Task GetCreditAmount(); + + #endregion + } \ No newline at end of file diff --git a/0_Framework/Application/Sms/SmsService.cs b/0_Framework/Application/Sms/SmsService.cs index 4db0caa7..5c155b37 100644 --- a/0_Framework/Application/Sms/SmsService.cs +++ b/0_Framework/Application/Sms/SmsService.cs @@ -17,10 +17,14 @@ namespace _0_Framework.Application.Sms; public class SmsService : ISmsService { private readonly IConfiguration _configuration; + public SmsIr SmsIr { get; set; } + public SmsService(IConfiguration configuration) { _configuration = configuration; + SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa"); + } public void Send(string number, string message) @@ -311,4 +315,15 @@ public class SmsService : ISmsService //var tokenService = new Token(); //return tokenService.GetToken("x-api-key", "Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa"); } + + #region Mahan + + public async Task GetCreditAmount() + { + var credit = await SmsIr.GetCreditAsync(); + return (double)credit.Data; + } + + + #endregion } diff --git a/ServiceHost/Areas/Admin/Pages/Index.cshtml b/ServiceHost/Areas/Admin/Pages/Index.cshtml index 73372ae5..16bcbdc4 100644 --- a/ServiceHost/Areas/Admin/Pages/Index.cshtml +++ b/ServiceHost/Areas/Admin/Pages/Index.cshtml @@ -11,8 +11,151 @@ // // string adminVersion = _0_Framework.Application.Version.AdminVersion; + + + + + + + - }
@@ -52,49 +195,75 @@
-
-
- + } *@ + @*backups*@ @*
@@ -578,5 +731,5 @@ var ajaxDataReport = `@Url.Page("./Index", "ReportDataAjax")`; var boolPermissionForReports = @(authHelper.GetPermissions().Any(x => x == 306) ? "true" : "false"); *@ - + } \ No newline at end of file diff --git a/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs b/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs index ca781bdc..57538022 100644 --- a/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs +++ b/ServiceHost/Areas/Admin/Pages/Index.cshtml.cs @@ -21,6 +21,7 @@ using CompanyManagment.App.Contracts.Workshop; using CompanyManagment.App.Contracts.YearlySalary; using CompanyManagment.Application; using Microsoft.Extensions.Configuration.UserSecrets; +using _0_Framework.Application.Sms; namespace ServiceHost.Areas.Admin.Pages { @@ -36,6 +37,8 @@ namespace ServiceHost.Areas.Admin.Pages private readonly IWebHostEnvironment _webHostEnvironment; private readonly IConfiguration _configuration; private readonly IAuthHelper _authHelper; + private readonly ISmsService _smsService; + public string today; public string month; @@ -45,8 +48,9 @@ namespace ServiceHost.Areas.Admin.Pages public string FolderPath; public int TaskCount; public int TicketCount; + public int SmsRemaining; - public IndexModel(IWebHostEnvironment webHostEnvironment, IConfiguration configuration, IAuthHelper authHelper, IReportApplication reportApplication, IYearlySalaryApplication yearlySalaryApplication, IWorkshopApplication workshopApplication, IAccountApplication accountApplication, ITaskApplication taskApplication, ITicketApplication ticketApplication) + public IndexModel(IWebHostEnvironment webHostEnvironment, IConfiguration configuration, IAuthHelper authHelper, IReportApplication reportApplication, IYearlySalaryApplication yearlySalaryApplication, IWorkshopApplication workshopApplication, IAccountApplication accountApplication, ITaskApplication taskApplication, ITicketApplication ticketApplication, ISmsService smsService) { _webHostEnvironment = webHostEnvironment; _configuration = configuration; @@ -57,6 +61,7 @@ namespace ServiceHost.Areas.Admin.Pages _accountApplication = accountApplication; _taskApplication = taskApplication; _ticketApplication = ticketApplication; + _smsService = smsService; } public async Task OnGet() @@ -77,12 +82,13 @@ namespace ServiceHost.Areas.Admin.Pages TaskCount = await _taskApplication.RequestedAndOverdueTasksCount(userId); TicketCount = _ticketApplication.GetAdminTicketsCount(); + SmsRemaining = (int)await _smsService.GetCreditAmount(); - //foreach (string fileEntry in fileEntries) - //{ - // Console.WriteLine(Path.GetFileName(fileEntry)); - //} - } + //foreach (string fileEntry in fileEntries) + //{ + // Console.WriteLine(Path.GetFileName(fileEntry)); + //} + } public async Task OnGetReportDataAjax() { diff --git a/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js b/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js index 5ff967a7..138ce2e1 100644 --- a/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js +++ b/ServiceHost/wwwroot/AssetsAdmin/page/Index/js/Index.js @@ -5,11 +5,36 @@ loadingDiv.show(); }); + updateAmountColor(); //if (boolPermissionForReports) { // ReportAjaxData(); //} }); +function updateAmountColor() { + const amountDiv = document.querySelector("#amountSms"); + const smsDiv = document.getElementById('smsDiv'); + if (!amountDiv) return; + + const rawText = amountDiv.textContent.replace(/[, ]/g, '').replace('ریال', ''); + const amount = parseInt(rawText); + + + if (amount < 1000) { + amountDiv.classList.remove("card-amount-success"); + amountDiv.classList.add("card-amount-warn"); + smsDiv.classList.remove("gwb-card-blue"); + smsDiv.classList.add("gwb-card-red"); + } else { + amountDiv.classList.remove("card-amount-warn"); + amountDiv.classList.remove("gbt-card-red"); + amountDiv.classList.add("card-amount-success"); + smsDiv.classList.add("gwb-card-blue"); + smsDiv.classList.remove("gwb-card-red"); + + } +} + //function ReportAjaxData() { // $.ajax({ // async: false, diff --git a/ServiceHost/wwwroot/AssetsClient/images/sms-icon.png b/ServiceHost/wwwroot/AssetsClient/images/sms-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f44097882ee8daa42a78d86bd80f74bd2e36aea1 GIT binary patch literal 1629 zcmV-j2BP_iP)|xJ-&%Eb--{1Rt&-*;T=lOk~=lQ+IqX778 zX+tS`;?ok3htyO>o5!t%ug@ht<)Ds#)A9FIX0z9f%s`z33gfTi8SN(MY7?RZyClmv z+VhR)aXt5iJPP>nl#%YUbvTgdgD+_p5zFgdOA>E1{-=Pyh4Q3j3*V3E#wxPt?{y~G zPGaoKUn#vZSWNT_Z|J6Z`K7;9-{dGjMMla%Jt#ToMl~kdf#+|ao`jFrab-#tY%({F z(QX(ePk4iQ&s(0qp5r>GMae|EX%Uw2rxJ+<+z~^V7%~Mm@1ocdwgR!`AZ{!y{aG~Z zQ)~!Zfi{mo!bKP`9$uLYN6%3#ut^-&_?^}qXgLIq=LmjRC0V4ca*)o@yrC>~2e$=b zD`0qkE{t1nb9=cmQ2zmFSO*%_*1ope*SS}GT_LjRY>^Z=m!#2t4UPrrK4nY8!w)(u zJ>LoLu0oMfBn1p}R>R;=AnST)_uW?whR4Ahy`5s=qR0vurYwhd=fIUzLPlI0m^D(? z2s0N5N`VvSp=Nb;F2H%W?Sq$PiQRt_GFml;U#5u?!{EfAZZV$kFhW#$Hvc{?8%c>7 zuy8bVX{L!B0t;>33*#3N7J_!6ri0<&2^b-t9VXwcUWmyPFTsw(Qu+*JUV}?lUHY-} z5Ny|W@p9h&WyM@)<%(4*a%&Wru>yupb;lJHg?qJw{v9>)GJoY*f`(Z$LCP)P2$Pn; zk<d%I<;p^aMms$N(sH&`+iN``OYO1c z#XeP)#4A2@Z2^zhgRj=Z#Kq1cPd*A8CleAvVxeUkwZ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