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..c59f1adf 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 +746,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 00000000..f4409788 Binary files /dev/null and b/ServiceHost/wwwroot/AssetsClient/images/sms-icon.png differ