admin/warehouse landing page

This commit is contained in:
Frede Hundewadt 2023-01-02 16:43:58 +01:00
parent a5c5ed6883
commit e520a03666
7 changed files with 182 additions and 133 deletions

View file

@ -18,38 +18,68 @@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
<div class="card m-3" style="width: 400px">
<div class="row">
<div class="col-lg-4 col-md-12 col-md-4 mb-4">
<div class="card">
<div class="card-header">Danmark</div>
<div class="card-body">
<h4 class="card-title">
Danmark
</h4>
<p class="card-text">
Kunder, Prisliste
</p>
<a class="btn btn-lg btn-primary d-block" href="/office/country/dk"> Danmark ....</a>
<div class="list-group list-group-flush">
<AuthorizeView Roles="Admin">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/dk">
<i class="bi-activity"></i> Sælgere
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/dk">
<i class="bi-phone"></i> Tlf.Ordre
</a>
<a class="list-group-item list-group-item-action list-group-item-info" href="/office/catalog/dk">
<i class="bi-file-spreadsheet"></i> Priser
</a>
</div>
</div>
</div>
</div>
</div>
<div class="card m-3" style="width: 400px">
<div class="col-lg-4 col-md-12 col-md-4 mb-4">
<div class="card">
<div class="card-header">Norge</div>
<div class="card-body">
<h4 class="card-title">
Norge
</h4>
<p class="card-text">
Kunder, Prisliste
</p>
<a class="btn btn-lg btn-primary d-block" href="/office/country/no"> Norge ....</a>
<div class="list-group">
<AuthorizeView Roles="Admin">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/no">
<i class="bi-activity"></i> Sælgere
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/no">
<i class="bi-phone"></i> Tlf.Ordre
</a>
<a class="list-group-item list-group-item-action list-group-item-info" href="/office/catalog/no">
<i class="bi-file-spreadsheet"></i> Priser
</a>
</div>
</div>
</div>
</div>
</div>
<div class="card m-3" style="width: 400px">
<div class="col-lg-4 col-md-12 col-md-4 mb-4">
<div class="card">
<div class="card-header">Sverige</div>
<div class="card-body">
<h4 class="card-title">
Sverige
</h4>
<p class="card-text">
Kunder, Prisliste
</p>
<a class="btn btn-lg btn-primary d-block" href="/office/country/s"> Sverige ....</a>
<div class="list-group">
<AuthorizeView Roles="Admin">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/se">
<i class="bi-activity"></i> Sælgere
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/se">
<i class="bi-phone"></i> Tlf.Ordre
</a>
<a class="list-group-item list-group-item-action list-group-item-info" href="/office/catalog/se">
<i class="bi-file-spreadsheet"></i> Priser
</a>
</div>
</div>
</div>
</div>
</div>

View file

@ -109,7 +109,7 @@ public class AdvisorCatalogRepository : IAdvisorCatalogRepository
["selectGroup"] = pagingParameters.SelectGroup == "0" ? "" : pagingParameters.SelectGroup,
};
var response = await _client
.GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/{countryCode}/page", queryString));
.GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/page", queryString));
if (!response.IsSuccessStatusCode)
{
@ -150,7 +150,7 @@ public class AdvisorCatalogRepository : IAdvisorCatalogRepository
/// <returns></returns>
public async Task<SalesItemView> GetSalesItemSku(string countryCode, string sku)
{
var salesItem = await _client.GetFromJsonAsync<SalesItemView>($"{_apiConfig.Catalog}/{countryCode}/sku/{sku}");
var salesItem = await _client.GetFromJsonAsync<SalesItemView>($"{_apiConfig.Catalog}/sku/{countryCode}/{sku}");
return salesItem ?? new SalesItemView();
}

View file

@ -26,10 +26,10 @@
</div>
</div>
@if (!string.IsNullOrWhiteSpace(Company.Blocked))
@if (!string.IsNullOrWhiteSpace(_company.Blocked))
{
<div class="alert alert-danger">
<h4>Ring til kontoret. Denne konto er spærret med kode '@Company.Blocked'</h4>
<h4>Ring til kontoret. Denne konto er spærret med kode '@_company.Blocked'</h4>
</div>
}
<div class="row bg-light border-1 border-dark rounded-3 p-3">
@ -67,7 +67,7 @@ else
<div class="col-md-4">
<InputSelect id="statusType" class="form-select bg-primary text-bg-primary" @bind-Value="@Activity.ActivityStatusEnum">
<option value="noSale">Ingen salg</option>
@if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && Company.HasFolded == 0)
@if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && _company.HasFolded == 0)
{
@if (DraftProvider.Draft.DraftType == "order")
{
@ -314,7 +314,7 @@ else
</EditForm>
<div class="row mt-5 mb-2">
<div class="col-sm-6">
<a class="btn btn-warning" href="/customers/@Company.CompanyId">Kundekort <i class="bi-arrow-left"></i></a>
<a class="btn btn-warning" href="/customers/@_company.CompanyId">Kundekort <i class="bi-arrow-left"></i></a>
</div>
<div class="col-sm-4 text-end">
<button type="button" class="btn btn-warning" @onclick="CallConfirmProductCheckModel" disabled="@(PoFormInvalid || Working)">Opret besøg <i class="bi-plus"></i></button>

View file

@ -49,12 +49,12 @@ public partial class AdvisorCreateActivityPage : IDisposable
[Inject] public IAdvisorReportRepository AdvisorReportRepo { get; set; }
[Inject] public ICustomerHistoryRepository HistoryRepo { get; set; }
// variables
private readonly JsonSerializerOptions? _options = new() {PropertyNameCaseInsensitive = true};
private readonly JsonSerializerOptions _options = new() {PropertyNameCaseInsensitive = true};
private SalesItemView SelectedItem { get; set; } = new();
private UserPref UserPrefs { get; set; } = new();
private ActivityDto Activity { get; set; } = new();
private CompanyDto Company = new();
private EditContext ActivityContext { get; set; }
private CompanyDto _company = new();
private EditContext? ActivityContext { get; set; }
private bool PoFormInvalid { get; set; } = true;
private bool ShowItem { get; set; }
private string Quantity { get; set; } = "1";
@ -62,20 +62,18 @@ public partial class AdvisorCreateActivityPage : IDisposable
private string Discount { get; set; } = "0";
private bool Sas { get; set; }
private bool InvalidActivityType { get; set; } = true;
private bool InvalidStatusType { get; set; } = true;
private bool InvalidActivity { get; set; } = true;
private bool InvalidCanvas { get; set; } = true;
private bool NoHistory { get; set; } = true;
private bool ReportClosed { get; set; }
private bool Working { get; set; } = true;
private UserInfoView ThisUserInfo { get; set; } = new();
private DateTime SelectedDate { get; set; }
private string OldPhone { get; set; } = "";
private string PromptDateConfirm { get; set; }
private string PromptDateConfirm { get; set; } = "";
// MODAL DIALOGS
private PriceListModal PriceListModal { get; set; }
private ProductHistoryModal HistoryModal { get; set; }
private ProductPriceHistoryModal PriceHistoryModal { get; set; }
private PriceListModal PriceListModal { get; set; } = new();
private ProductHistoryModal HistoryModal { get; set; } = new();
private ProductPriceHistoryModal PriceHistoryModal { get; set; } = new();
private ConfirmWorkDateModal ConfirmWorkDateModal { get; set; } = new();
private ConfirmProductCheckModal ConfirmProductCheckModal { get; set; } = new();
private List<ProductInventoryView> CheckList { get; set; } = new();
@ -97,42 +95,42 @@ public partial class AdvisorCreateActivityPage : IDisposable
// User Info
ThisUserInfo = await Storage.GetItemAsync<UserInfoView>("_xu");
// Fetch Customer from http
Company = await CompanyRepo.GetCompanyById(CompanyId);
if (Company.HasFolded == 1)
_company = await CompanyRepo.GetCompanyById(CompanyId);
if (_company.HasFolded == 1)
// Company has shutdown activities
Activity.OrderMessage = "BEMÆRK: CVR nummer er ophørt.";
// variable to validate if customer needs phone number update
OldPhone = Company.Phone;
if (string.IsNullOrWhiteSpace(Company.Phone)
&& !string.IsNullOrWhiteSpace(Company.Account)
&& Company.Account != "NY" && Company.Account.Length > 7)
OldPhone = _company.Phone;
if (string.IsNullOrWhiteSpace(_company.Phone)
&& !string.IsNullOrWhiteSpace(_company.Account)
&& _company.Account != "NY" && _company.Account.Length > 7)
{
Company.Phone = Company.Account[..8];
_company.Phone = _company.Account[..8];
}
// Populate base activity information
Activity.BcId = Company.BcId;
Activity.BcId = _company.BcId;
Activity.ActivityStatusEnum = "noSale";
Activity.VisitTypeEnum = Company.Account is "" or "NY" ? "new" : "recall";
Activity.CompanyId = Company.CompanyId;
Activity.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall";
Activity.CompanyId = _company.CompanyId;
Activity.SalesRepId = ThisUserInfo.Id;
Activity.SalesRep = ThisUserInfo.Advisor;
Activity.CountryCode = ThisUserInfo.CountryCode;
Activity.Account = Company.Account;
Activity.VatNumber = Company.VatNumber;
Activity.Email = Company.Email;
Activity.Phone = Company.Phone;
Activity.Mobile = Company.Mobile;
Activity.Name = Company.Name;
Activity.Address1 = Company.Address1;
Activity.Address2 = Company.Address2;
Activity.ZipCode = Company.ZipCode;
Activity.City = Company.City;
Activity.DlvName = Company.Name;
Activity.DlvAddress1 = Company.Address1;
Activity.DlvAddress2 = Company.Address2;
Activity.DlvZipCode = Company.ZipCode;
Activity.DlvCity = Company.City;
Activity.Account = _company.Account;
Activity.VatNumber = _company.VatNumber;
Activity.Email = _company.Email;
Activity.Phone = _company.Phone;
Activity.Mobile = _company.Mobile;
Activity.Name = _company.Name;
Activity.Address1 = _company.Address1;
Activity.Address2 = _company.Address2;
Activity.ZipCode = _company.ZipCode;
Activity.City = _company.City;
Activity.DlvName = _company.Name;
Activity.DlvAddress1 = _company.Address1;
Activity.DlvAddress2 = _company.Address2;
Activity.DlvZipCode = _company.ZipCode;
Activity.DlvCity = _company.City;
// Initialize date variable
SelectedDate = string.IsNullOrWhiteSpace(UserPrefs.WorkDate) ? DateTime.Now : DateTime.Parse(UserPrefs.WorkDate);
// raise flag if report is closed
@ -159,8 +157,8 @@ public partial class AdvisorCreateActivityPage : IDisposable
private async Task CallConfirmProductCheckModel()
{
// check if new account
if (string.IsNullOrWhiteSpace(Company.Account)
|| Company.Account.ToLower() == "ny"
if (string.IsNullOrWhiteSpace(_company.Account)
|| _company.Account.ToLower() == "ny"
|| Activity.ActivityStatusEnum.ToLower() == "quote")
{
// proceed to create activity - as there is no product check to be done
@ -170,37 +168,39 @@ public partial class AdvisorCreateActivityPage : IDisposable
// check if product has been checked
// fetch products from storage
var storage = await Storage.GetItemAsStringAsync($"{CompanyId}-products");
var pStorage = await Storage.GetItemAsStringAsync($"{CompanyId}-products");
Logger.LogDebug("pStorage => {}", pStorage);
// fetch pDate from storage
var pDate = await Storage.GetItemAsStringAsync($"{CompanyId}-pDate");
var pDate = await Storage.GetItemAsync<string>($"{CompanyId}-pDate");
Logger.LogDebug("pDate => {}", pDate);
// check if product data is valid and updated today
if (string.IsNullOrWhiteSpace(storage) || DateTime.Parse(pDate.Replace("\"", "")) < DateTime.Now)
if (string.IsNullOrWhiteSpace(pStorage) || pDate.Replace("\"", "") != $"{DateTime.Now:yyyy-MM-dd}")
{
Working = true;
// pop a message
Toast.ShowError("Produkt gennemgang mangler. Vent mens produkt oversigt indlæses. Gå ikke væk fra siden!", "Produkt check ...");
// product inventory has not been updated
// send rpc call to sync ERP to CRM
Toast.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ...");
var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, Company.HistorySync);
var ts = await HistoryRepo.ErpInvoiceToCrmRpc(CompanyId, _company.HistorySync);
while (string.IsNullOrWhiteSpace(ts))
{
await Task.Delay(1000);
}
await Task.Delay(500);
// save pDate
await Storage.SetItemAsync($"{CompanyId}-pDate", ts);
// request products from backend
Toast.ShowInfo("Vent mens produkt oversigt hentes", "CRM produkt liste");
CheckList = await HistoryRepo.FetchInventory(CompanyId);
if(CheckList.Any())
CheckList = CheckList.OrderBy(x => x.Description).ToList();
await Storage.SetItemAsync($"{CompanyId}-products", CheckList);
Working = false;
}
else
{
// deserialize storage data
CheckList = JsonSerializer.Deserialize<List<ProductInventoryView>>(storage);
CheckList = JsonSerializer.Deserialize<List<ProductInventoryView>>(pStorage);
if(CheckList.Any())
CheckList = CheckList.OrderBy(x => x.Description).ToList();
}
@ -210,14 +210,14 @@ public partial class AdvisorCreateActivityPage : IDisposable
}
private async Task ConfirmProductCheckCallback()
{
ConfirmProductCheckModal.Hide();
await CreateActivity();
foreach (var item in CheckList)
{
item.Check = false;
}
await Storage.SetItemAsync($"{CompanyId}-products", CheckList);
ConfirmProductCheckModal.Hide();
}
/// <summary>
@ -308,7 +308,7 @@ public partial class AdvisorCreateActivityPage : IDisposable
Toast.ShowError("Ved bestilling skal der være en eller flere linjer i kladden.");
return;
// phone number is required if first time customer
case "order" when Company.Account is "NY" or "" && string.IsNullOrWhiteSpace(Activity.Phone):
case "order" when _company.Account is "NY" or "" && string.IsNullOrWhiteSpace(Activity.Phone):
Toast.ShowError("Ved bestilling til ny kunde skal telefon nummer angives.");
return;
// verify email address is a valid address
@ -324,8 +324,8 @@ public partial class AdvisorCreateActivityPage : IDisposable
// check if phone number need to be updated
if (OldPhone != Activity.Phone)
{
Company.Phone = Activity.Phone;
await CompanyRepo.UpdateErpData(Company.CompanyId, Company);
_company.Phone = Activity.Phone;
await CompanyRepo.UpdateErpData(_company.CompanyId, _company);
}
// begin assembling activity
Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}";

View file

@ -74,7 +74,7 @@
@activity.OfficeNote
</div>
<div class="col">
ikke fuldt implementeret
@activity.CrmNote
</div>
</div>
</div>

View file

@ -17,41 +17,70 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Warehouse")]
@page "/office/country/{CountryCode}"
@page "/office/country"
<div class="row">
<div class="col-lg-4 col-md-12 col-md-4 mb-4">
<div class="card">
<div class="card-header">Danmark</div>
<div class="card-body">
<div class="list-group list-group-flush">
<AuthorizeView Roles="Admin">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/dk">
<i class="bi-activity"></i> Sælgere
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/dk">
<i class="bi-phone"></i> Tlf.Ordre
</a>
<a class="list-group-item list-group-item-action list-group-item-info" href="/office/catalog/dk">
<i class="bi-file-spreadsheet"></i> Priser
</a>
</div>
</div>
</div>
</div>
<AuthorizeView Roles="Admin,Office">
<div class="card m-3" style="width: 400px">
<div class="col-lg-4 col-md-12 col-md-4 mb-4">
<div class="card">
<div class="card-header">Norge</div>
<div class="card-body">
<h4 class="card-title">
@CountryCode.ToUpper() Sælgere
</h4>
<p class="card-text">
Sælger kundeliste, Rapporter, Stamdata
</p>
<a class="btn btn-lg btn-primary d-block" href="/office/users/advisors/@CountryCode"> Sælgere</a>
<div class="list-group">
<AuthorizeView Roles="Admin">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/no">
<i class="bi-activity"></i> Sælgere
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/no">
<i class="bi-phone"></i> Tlf.Ordre
</a>
<a class="list-group-item list-group-item-action list-group-item-info" href="/office/catalog/no">
<i class="bi-file-spreadsheet"></i> Priser
</a>
</div>
</div>
</AuthorizeView>
<div class="card m-3" style="width: 400px">
</div>
</div>
<div class="col-lg-4 col-md-12 col-md-4 mb-4">
<div class="card">
<div class="card-header">Sverige</div>
<div class="card-body">
<h4 class="card-title">
@CountryCode.ToUpper() Kunder
</h4>
<p class="card-text">
Filtrer og søg kunder
</p>
<a class="btn btn-lg btn-primary d-block" href="/office/customers/@CountryCode"> Kundeliste</a>
</div>
</div>
<div class="card m-3" style="width: 400px">
<div class="card-body">
<h4 class="card-title">
@CountryCode.ToUpper() Priskatalog
</h4>
<p class="card-text">
Produkter og priser
</p>
<a class="btn btn-lg btn-primary d-block" href="/office/catalog/@CountryCode"> Priskatalog</a>
<div class="list-group">
<AuthorizeView Roles="Admin">
<a class="list-group-item list-group-item-action list-group-item-warning" href="/office/users/advisors/se">
<i class="bi-activity"></i> Sælgere
</a>
</AuthorizeView>
<a class="list-group-item list-group-item-action list-group-item-success" href="/office/customers/se">
<i class="bi-phone"></i> Tlf.Ordre
</a>
<a class="list-group-item list-group-item-action list-group-item-info" href="/office/catalog/se">
<i class="bi-file-spreadsheet"></i> Priser
</a>
</div>
</div>
</div>
</div>
</div>

View file

@ -46,18 +46,8 @@
<AuthorizeView Roles="Admin,Warehouse">
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/country/dk">
<i class="bi-people pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Danmark
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/country/no">
<i class="bi-file-spreadsheet pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Norge
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/office/country/se">
<i class="bi-file-spreadsheet pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Sverige
<NavLink class="nav-link ps-2" href="/office/country">
<i class="bi-people pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Sælgere
</NavLink>
</div>
<div class="nav-item px-3">