@model Nop.Plugin.Misc.FruitBankPlugin.Models.CustomerCreditWidgetModel @inject Nop.Services.Common.IGenericAttributeService genericAttributeService @inject Nop.Core.IWorkContext workContext @{ var remaining = Model.RemainingCredit; var statusClass = !Model.HasCreditLimit ? "text-muted" : remaining <= 0 ? "text-danger" : remaining < Model.CreditLimit * 0.2m ? "text-warning" : "text-success"; // Per-admin collapse state, persisted like the core nopCommerce cards var admin = await workContext.GetCurrentCustomerAsync(); const string hideAttributesCardName = "FruitBank.CustomerAttributesCard.Hide"; var hideAttributesCard = await genericAttributeService.GetAttributeAsync(admin, hideAttributesCardName); const string hideCreditCardName = "FruitBank.CustomerCreditCard.Hide"; var hideCreditCard = await genericAttributeService.GetAttributeAsync(admin, hideCreditCardName); } @* FruitBank customer-top section: injected into the CustomerDetailsBlock widget zone (which renders at the BOTTOM of the customer page) and relocated to the top of #customer-cards by the script below. Future non-credit elements go inside this same wrapper so the single relocation keeps them all together at the top. *@
@* ── Customer attributes (generic attributes block) ───────────────────────── *@

@T("Plugins.Misc.FruitBankPlugin.CustomerAttributes.Title")

@* No name attribute: this must NOT post with the core Customer Edit form; it is saved via AJAX on change to CustomerAttributesController.SetEkaer. *@
@if (Model.SiteCount > 0) { @Model.SiteCount @T("Plugins.Misc.FruitBankPlugin.CustomerSites.CountWord") if (!string.IsNullOrWhiteSpace(Model.DefaultSiteDisplay)) { (@T("Plugins.Misc.FruitBankPlugin.CustomerSites.DefaultLabel"): @Model.DefaultSiteDisplay) } } else { @T("Plugins.Misc.FruitBankPlugin.CustomerSites.None") }
@* ── Customer credit ──────────────────────────────────────────────────────── *@

@T("Plugins.Misc.FruitBankPlugin.CustomerCredit.PageTitle")

@(Model.HasCreditLimit ? Model.CreditLimit.ToString("N0") + " Ft" : T("Plugins.Misc.FruitBankPlugin.CustomerCredit.Unlimited").Text)
@Model.OutstandingBalance.ToString("N0") Ft
@if (!Model.HasCreditLimit) { @T("Plugins.Misc.FruitBankPlugin.CustomerCredit.Unlimited") } else { @(remaining!.Value.ToString("N0")) Ft }
@if (!string.IsNullOrWhiteSpace(Model.Comment)) {
@Model.Comment
}
@* ── Sites edit modal ───────────────────────────────────────────────────────── *@