3.0.1.6 Addresses

This commit is contained in:
Andy Howard
2025-05-05 16:00:32 +01:00
parent 047f9db390
commit 527943b861
88 changed files with 3261 additions and 370 deletions
@@ -897,4 +897,49 @@
<data name="caption.requirement.create" xml:space="preserve">
<value>Create Requirement</value>
</data>
<data name="label.visit.last" xml:space="preserve">
<value>Last visit</value>
</data>
<data name="label.visit.next" xml:space="preserve">
<value>Next visit</value>
</data>
<data name="label.number.street" xml:space="preserve">
<value>Number and street</value>
</data>
<data name="label.addresses" xml:space="preserve">
<value>Addresses</value>
</data>
<data name="label.postcode" xml:space="preserve">
<value>Postcode</value>
</data>
<data name="label.postal.code" xml:space="preserve">
<value>Postal code</value>
</data>
<data name="label.ref" xml:space="preserve">
<value>Ref</value>
</data>
<data name="caption.address.create" xml:space="preserve">
<value>Create Address</value>
</data>
<data name="caption.address.update" xml:space="preserve">
<value>Update Address</value>
</data>
<data name="label.country" xml:space="preserve">
<value>Country</value>
</data>
<data name="label.city" xml:space="preserve">
<value>City</value>
</data>
<data name="label.province" xml:space="preserve">
<value>Province</value>
</data>
<data name="label.primary" xml:space="preserve">
<value>Primary</value>
</data>
<data name="label.set.primary" xml:space="preserve">
<value>Set primary</value>
</data>
<data name="label.prim." xml:space="preserve">
<value>Prim.</value>
</data>
</root>
@@ -240,15 +240,48 @@ namespace Sarand.BusinessMgr.Web.Portal.Components
/// List of Affiliate Types for filter dropdown.
/// <para>- Contact model cannot define this as contact list/dialog may be included in other views with their own model, eg. Association page.</para>
/// </summary>
public IEnumerable<SelectListItem> GetAffiliateTypeCodesForFilterDropdown()
public IEnumerable<SelectListItem> GetAffiliateTypeCodesForFilterDropdown(Sbm.AffiliateType typeExcluded)
{
IEnumerable<Sbm.AffiliateType> typesExcluded = new Sbm.AffiliateType[] { typeExcluded };
return GetAffiliateTypeCodesForFilterDropdown(typesExcluded);
}
/// <summary>
/// List of Affiliate Types for filter dropdown.
/// <para>- Contact model cannot define this as contact list/dialog may be included in other views with their own model, eg. Association page.</para>
/// </summary>
public IEnumerable<SelectListItem> GetAffiliateTypeCodesForFilterDropdown(IEnumerable<Sbm.AffiliateType> typesExcluded = null)
{
List<TypeCodeDesc> affiliateTypes = GetSystemCodes(Sbm.SystemCode.AffiliateType);
if (typesExcluded?.Any() ?? false)
affiliateTypes.RemoveAll(item => typesExcluded.Contains((Sbm.AffiliateType)item.Type));
if (!affiliateTypes.Any(item => item.Type == (int)Sbm.AffiliateType.AnyOrganisation))
affiliateTypes.Insert(0, new TypeCodeDesc((int)Sbm.AffiliateType.AnyOrganisation, ((short)Sbm.AffiliateType.AnyOrganisation).ToString(), Localiser["label.organisation"]));
affiliateTypes.Insert(0, Sbm.AffiliateType.Any, "", Localiser["label.any"]);
return new SelectList(affiliateTypes, "Code", "Desc");
}
/// <summary>
/// List of Address Types for filter dropdown.
/// <para>- Address model cannot define this as contact list/dialog may be included in other views with their own model, eg. Association page.</para>
/// </summary>
public IEnumerable<SelectListItem> GetAddressTypeCodesForFilterDropdown()
{
List<TypeCodeDesc> affiliateTypes = GetSystemCodes(Sbm.SystemCode.AddressType);
affiliateTypes.Insert(0, Sbm.AddressType.Any, "", Localiser["label.any"]);
return new SelectList(affiliateTypes, "Code", "Desc");
}
/// <summary>
/// List of Address Types for filter dropdown.
/// <para>- Address model cannot define this as contact list/dialog may be included in other views with their own model, eg. Association page.</para>
/// </summary>
public IEnumerable<SelectListItem> GetAddressTypeCodesForDropdown()
{
List<TypeCodeDesc> affiliateTypes = GetSystemCodes(Sbm.SystemCode.AddressType);
return new SelectList(affiliateTypes, "Code", "Desc");
}
/// <summary>
/// List of Association Types for filter dropdown.
/// <para>- Association model cannot define this as association list/dialog may be included in other views with their own model, eg. Commodity page.</para>
@@ -0,0 +1,578 @@
using Microsoft.AspNetCore.Mvc;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Web.Portal.Components;
using Sarand.BusinessMgr.Web.Portal.Models.Addresses;
using Sarand.BusinessMgr.Web.Portal.Models.Contacts;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.CodeTypes;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Dbas;
using Sarand.Net.Standard.Base.ReferenceData;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
{
//=======================================================================
// Portal Address Controller - Ajax actions.
//=======================================================================
partial class AddressController
{
//-------------------------------------------------------------------
// Item data.
private class AddressListData : AjaxResponse_Data.ItemData_Base
{
// Item properties with specific handling.
public String Caption { get; set; }
public bool? Primary { get; set; }
// Field values.
public AjaxResponse_Data.FieldValuesData Field { get; } = new AjaxResponse_Data.FieldValuesData();
}
private class AddressItemData : AddressListData
{
// Item properties with specific handling.
public String TypeCode { get; set; }
public String TypeDesc { get; set; }
}
private void PopulateAddressResponseListData(SbmModel_Portal model, SbmAddress address, AddressListData data)
{
data.Id = SysId.ToString(address.Id);
data.Caption = address.GetSummary();
if (address.IsPrimary) data.Primary = true;
}
private void PopulateAddressResponseItemData(SbmModel_Portal model, SbmAddress address, AddressItemData data)
{
PopulateAddressResponseListData(model, address, data as AddressListData);
// Address type - populate for list ('Type' property populated with desc) and form (Type Code & Desc).
data.TypeCode = Internals.AddressTypeCodes.GetCodeForType(address.AddressType);
data.TypeDesc = Internals.AddressTypeCodes.GetDescForType(address.AddressType);
data.Field.Value.Add($"{Model_Address.ItemField.Type}", data.TypeCode);
data.Field.Value.Add($"{Model_Address.ItemField.TypeDesc}", data.TypeDesc);
// Address properties.
data.Field.Value.Add($"{Model_Address.ItemField.RefExt}", address.RefExt);
data.Field.Value.Add($"{Model_Address.ItemField.Name}", address.Name);
data.Field.Value.Add($"{Model_Address.ItemField.DescBrief}", address.DescBrief);
data.Field.Value.Add($"{Model_Address.ItemField.Caption}", address.GetSummary());
data.Field.Value.Add($"{Model_Address.ItemField.Line1}", address.Line1);
data.Field.Value.Add($"{Model_Address.ItemField.Line2}", address.Line2);
data.Field.Value.Add($"{Model_Address.ItemField.Line3}", address.Line3);
data.Field.Value.Add($"{Model_Address.ItemField.City}", address.City);
data.Field.Value.Add($"{Model_Address.ItemField.Province}", address.Province);
data.Field.Value.Add($"{Model_Address.ItemField.Postcode}", address.Postcode);
data.Field.Value.Add($"{Model_Address.ItemField.Country}", address.Country);
data.Field.Value.Add($"{Model_Address.ItemField.RegionIdCity}", SysId.ToString(address.RegionIdCity));
data.Field.Value.Add($"{Model_Address.ItemField.RegionIdProvince}", SysId.ToString(address.RegionIdProvince));
data.Field.Value.Add($"{Model_Address.ItemField.RegionIdCountry}", SysId.ToString(address.RegionIdCountry));
data.Field.Value.Add($"{Model_Address.ItemField.Contact}", address.Contact);
data.Field.Value.Add($"{Model_Address.ItemField.Phone}", address.Phone);
data.Field.Value.Add($"{Model_Address.ItemField.Fax}", address.Fax);
data.Field.Value.Add($"{Model_Address.ItemField.Email}", address.Email);
// Codes.
data.Field.Value.Add($"{Model_Address.ItemField.AccountManager}", address.AccountManagerCode);
data.Field.Value.Add($"{Model_Address.ItemField.AccountHandler}", address.AccountHandlerCode);
data.Field.Value.Add($"{Model_Address.ItemField.ContactArea}", address.ContactAreaCode);
data.Field.Value.Add($"{Model_Address.ItemField.ContactHandler}", address.ContactHandlerCode);
data.Field.Value.Add($"{Model_Address.ItemField.DeliveryType}", address.DeliveryTypeCode);
data.Field.Value.Add($"{Model_Address.ItemField.DeliveryMethod}", address.DeliveryMethodCode);
data.Field.Value.Add($"{Model_Address.ItemField.DeliveryBookIn}", address.DeliveryBookInCode);
data.Field.Value.Add($"{Model_Address.ItemField.LastVisitOn}", model.FormatDateForForm(address.LastVisitOn));
data.Field.Value.Add($"{Model_Address.ItemField.NextVisitOn}", model.FormatDateForForm(address.NextVisitOn));
// Common properties.
data.StatusCode = address.StatusCode;
data.StatusDesc = address.StatusDesc;
data.Field.Value.Add($"{Model_Contact.ItemField.Status}", address.StatusDesc);
// Cleanse field values.
data.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value));
// Populate item list values that might be cleared during update after removing blank values to ensure that blank values are published.
data.Field.Value.Add($"{Model_Address.ItemField.Notes}", address.Notes);
data.Field.Value.Add($"{Model_Address.ItemField.UpdatedOn}", Localiser.FormatDate(address.UpdateStamp.On));
}
//-------------------------------------------------------------------
// Address configuration.
//-------------------------------------------------------------------
private class AjaxResponse_AddressConfig : AjaxResponse_Data
{
// Construction.
public AjaxResponse_AddressConfig(SbmModel_Portal model) : base(model) { }
// Configuration data - object copied directly to env.datain script.
public class ConfigData
{
// Configurations.
public Model_Address.ListConfigData CfgList { get; } = new Model_Address.ListConfigData();
public Model_Address.ItemConfigData CfgItemNew { get; } = new Model_Address.ItemConfigData();
// Reference data.
public List<ItemCodeDesc> AddressTypes { get; } = new List<ItemCodeDesc>();
public String AddressTypeDefault { get; set; }
public List<ItemCodeDesc> AccountManagerCodes { get; set; }
public List<ItemCodeDesc> AccountHandlerCodes { get; set; }
public List<ItemCodeDesc> ContactAreaCodes { get; set; }
public List<ItemCodeDesc> ContactHandlerCodes { get; set; }
public List<ItemCodeDesc> DeliveryTypeCodes { get; set; }
public List<ItemCodeDesc> DeliveryMethodCodes { get; set; }
public List<ItemCodeDesc> DeliveryBookInCodes { get; set; }
public List<ItemCodeDesc> Statuses { get; } = new List<ItemCodeDesc>();
public String DefaultStatusCode { get; set; }
}
public ConfigData Data { get; set; } = new ConfigData();
}
// Ajax request.
[HttpPost]
[Route("Address/Ajax/Config")]
[Route("Address/Ajax/GetConfig")]
public IActionResult Ajax_AddressConfig(Model_Address model)
{
AjaxResponse_AddressConfig responseData = new AjaxResponse_AddressConfig(model);
String messageTitle = Localiser["label.addresses"];
// Validate session and referrer.
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
if (!ValidReferer) return Forbid();
RefreshModel(model);
// Populate configuration data.
PopulateAddressConfig(model, responseData);
// Complete response.
responseData.Success = true;
return Json(responseData);
}
private void PopulateAddressConfig(Model_Address model, AjaxResponse_AddressConfig responseData)
{
// Configuration.
model.PopulateListConfig(responseData.Data.CfgList);
model.PopulateItemConfig(responseData.Data.CfgItemNew, null, Sbm.AddressType.Any);
// Address types.
List<TypeCodeDesc> addressTypes = GetSystemCodes(Sbm.SystemCode.AddressType);
foreach (TypeCodeDesc addressType in addressTypes.Where(addr => addr.Type > 0))
responseData.Data.AddressTypes.Add(new AjaxResponse_Data.ItemCodeDesc(addressType.Code, addressType.Desc));
responseData.Data.AddressTypeDefault = addressTypes.GetCodeForType(Sbm.AddressType.Office);
// Codes.
List<SaCode> accountManagerCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.AccountManager));
if (accountManagerCodes.Any())
responseData.Data.AccountManagerCodes = accountManagerCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
List<SaCode> accountHandlerCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.AccountHandler));
if (accountHandlerCodes.Any())
responseData.Data.AccountHandlerCodes = accountHandlerCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
List<SaCode> contactAreaCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.ContactArea));
if (contactAreaCodes.Any())
responseData.Data.ContactAreaCodes = contactAreaCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
List<SaCode> contactHandlerCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.ContactHandler));
if (contactHandlerCodes.Any())
responseData.Data.ContactHandlerCodes = contactHandlerCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
List<SaCode> deliveryTypeCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryType));
if (deliveryTypeCodes.Any())
responseData.Data.DeliveryTypeCodes = deliveryTypeCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
List<SaCode> deliveryMethodCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryMethod));
if (deliveryMethodCodes.Any())
responseData.Data.DeliveryMethodCodes = deliveryMethodCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
List<SaCode> deliveryBookInCodes = CodeTypeConsole.GetCodesForCodeType(SbmSystem.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryBookIn));
if (deliveryBookInCodes.Any())
responseData.Data.DeliveryBookInCodes = deliveryBookInCodes.Select(item => new AjaxResponse_Data.ItemCodeDesc(item.Code, item.Description)).ToList();
// Reference data - statuses.
foreach (SaStatus status in SbmAddress.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
responseData.Data.Statuses.Add(new AjaxResponse_Data.ItemCodeDesc(SacsSystem.GetStatusCode(status), Localiser.GetStatusCaption(status)));
responseData.Data.DefaultStatusCode = SacsSystem.GetStatusCode(SbmAddress.DefaultStatus);
}
//-------------------------------------------------------------------
// Address list.
//-------------------------------------------------------------------
private class AjaxResponse_AddressList : AjaxResponse_AddressConfig
{
// Construction.
public AjaxResponse_AddressList(SbmModel_Portal model) : base(model) { }
// View mode.
public class ModeData
{
public ushort? Search { get; set; }
public ushort? Maintain { get; set; }
public ushort? StockControl { get; set; }
public ushort? StockTake { get; set; }
}
public ModeData Mode { get; set; }
// Address list.
public List<AddressListData> Addresses { get; } = new List<AddressListData>();
}
// Ajax request.
[HttpPost]
[Route("Address/Ajax/List")]
[Route("Address/Ajax/GetList")]
public IActionResult Ajax_AddressList(Model_Address model)
{
AjaxResponse_AddressList responseData = new AjaxResponse_AddressList(model);
String messageTitle = Localiser["label.addresses"];
// Validate session and referrer.
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
if (!ValidReferer) return Forbid();
RefreshModel(model);
// Populate configuration data.
PopulateAddressConfig(model, responseData);
// View mode.
responseData.Mode = new AjaxResponse_AddressList.ModeData();
Model_Address.ViewMode viewMode = model.GetFilterMode();
if (viewMode == Model_Address.ViewMode.Maintain)
responseData.Mode.Maintain = 1;
else
responseData.Mode.Search = 1;
// Item filter.
SbmAddress.Params prmAddress = new SbmAddress.Params();
prmAddress.ItemId = model.GetFilterItemId();
prmAddress.Search = model.Filter.Search;
prmAddress.AddressType = model.GetFilterAddressType();
prmAddress.StatusCat = SbmAddress.StatusCat.NotDeleted;
prmAddress.SortColumns.Add(AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Type_Desc));
prmAddress.SortColumns.Add(AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Line1));
model.Paging.ItemTotal = (ulong)AccountMgr.GetAddressCount(prmAddress);
model.PopulatePagingTo(prmAddress.ResultsPaging);
// Item columns.
ColumnDfn colId = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Id);
ColumnDfn colType = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Type_Desc);
ColumnDfn colRefExt = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.RefExt);
ColumnDfn colName = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Name);
ColumnDfn colDescBrief = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.DescBrief);
ColumnDfn colCaption = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Caption);
ColumnDfn colPostcode = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Postcode);
ColumnDfn colContact = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Contact);
ColumnDfn colPhone = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Phone);
ColumnDfn colNotes = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Notes);
ColumnDfn colFlags = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Flags);
ColumnDfn colStatus = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.Status);
ColumnDfn colCreatedOn = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.CreateOn_Date);
ColumnDfn colUpdatedOn = AccountMgr.GetAddressColumnDfn(SbmAddress.Column.UpdateOn_Date);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colType, colRefExt, colName, colDescBrief,
colCaption, colPostcode, colContact, colPhone,
colNotes, colFlags, colStatus, colCreatedOn, colUpdatedOn
};
// Query items.
using (DbResultSet resultSet = AccountMgr.ExecuteAddressQuery(columns, prmAddress))
{
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
{
NamedValue.Map values = resultSet.GetRecordValues();
Sbm.AddressType addressType = (Sbm.AddressType)values.GetLong(colType.DataName);
ushort flags = (ushort)values.GetLong(colFlags.DataName);
AddressListData addressData = new AddressListData()
{
Id = values.GetString(colId.DataName),
Caption = values.GetString(colCaption.DataName),
StatusCode = values.GetString(colStatus.DataName),
};
if (SbmAddress.GetFlag(flags, SbmAddress.Flag_Primary)) addressData.Primary = true;
addressData.Field.Value.Add($"{Model_Address.ItemField.TypeDesc}", Internals.AddressTypeCodes.GetDescForType(addressType));
addressData.Field.Value.Add($"{Model_Address.ItemField.RefExt}", values.GetString(colRefExt.DataName));
addressData.Field.Value.Add($"{Model_Address.ItemField.Name}", values.GetString(colName.DataName));
addressData.Field.Value.Add($"{Model_Address.ItemField.DescBrief}", values.GetString(colDescBrief.DataName));
addressData.Field.Value.Add($"{Model_Address.ItemField.Caption}", AccountMgr.GetAddressDataValue(colCaption, values).ToString());
addressData.Field.Value.Add($"{Model_Address.ItemField.Postcode}", values.GetString(colPostcode.DataName));
addressData.Field.Value.Add($"{Model_Address.ItemField.Contact}", values.GetString(colContact.DataName));
addressData.Field.Value.Add($"{Model_Address.ItemField.Phone}", values.GetString(colPhone.DataName));
addressData.Field.Value.Add($"{Model_Address.ItemField.Notes}", AccountMgr.GetAddressDataValue(colNotes, values).ToString());
addressData.Field.Value.Add($"{Model_Address.ItemField.Status}", SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName)));
addressData.Field.Value.Add($"{Model_Address.ItemField.CreatedOn}", Localiser.FormatDate(values.GetDate(colCreatedOn.DataName)));
addressData.Field.Value.Add($"{Model_Address.ItemField.UpdatedOn}", Localiser.FormatDate(values.GetDate(colUpdatedOn.DataName)));
// Cleanse item values.
addressData.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value));
responseData.Addresses.Add(addressData);
}
}
// Refresh paging info.
if (model.Paging.IsPaged)
model.Paging.ItemCount = (ushort)responseData.Addresses.Count;
responseData.SetPaging(model);
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
// Get Address ajax request.
//-------------------------------------------------------------------
private class AjaxResponse_Address : AjaxResponse_Data
{
// Construction.
public AjaxResponse_Address(SbmModel_Portal model) : base(model) { }
// Configuration.
public Model_Address.ItemConfigData Config { get; } = new Model_Address.ItemConfigData();
// Address details.
public AddressItemData address { get; } = new AddressItemData();
}
//-------------------------------------------------------------------
[HttpPost]
[Route("Address/Ajax/Item")]
[Route("Address/Ajax/GetItem")]
public IActionResult Ajax_GetItem(Model_Address model)
{
String messageTitle = Localiser["label.address"];
AjaxResponse_Address responseData = new AjaxResponse_Address(model);
// Validate session and referrer.
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
if (!ValidReferer) return Forbid();
RefreshModel(model);
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
{
// Identify item.
SysId addressId = SysId.ToSysId(model.Address.Id);
if (!SysId.IsValid(addressId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
// Retrieve item.
SbmAddress address = AccountMgr.GetAddressById(addressId);
disposables.Add(address);
if (address == null)
{
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve address for Id: '{model.Address.Id}'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Construct response.
model.PopulateItemConfig(responseData.Config, address);
PopulateAddressResponseItemData(model, address, responseData.address);
responseData.Success = true;
}
return Json(responseData);
}
//-------------------------------------------------------------------
// Store Address ajax request.
//-------------------------------------------------------------------
[HttpPost]
[Route("Address/Ajax/Store")]
[Route("Address/Ajax/StoreItem")]
public IActionResult Ajax_StoreItem(Model_Address model)
{
String messageTitle = Localiser["label.address"];
AjaxResponse_Address responseData = new AjaxResponse_Address(model);
// Validate session and referrer.
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
if (!ValidReferer) return Forbid();
RefreshModel(model);
// Validate item properties.
model.ValidateAddressData(responseData);
if (responseData.HasControlErrors())
return Json(responseData);
// Validate item Id against 'Exists' flag.
SysId addressId = SysId.ToSysId(model.Address.Id);
bool addressExists = StringUtil.ToBool(model.Address.Exists);
if (addressExists && !SysId.IsValid(addressId))
{
SaLogger.Warn($"{SysUtil.Fn} Id not specified for existing Address.");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
if (!addressExists && SysId.IsValid(addressId))
{
SaLogger.Warn($"{SysUtil.Fn} Id specified for new Address: '{model.Address.Id}'");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
{
// Retrieve existing item.
SbmAddress address = AccountMgr.GetAddressById(addressId);
disposables.Add(address);
if (address == null && SysId.IsValid(addressId))
{
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve address for Id: '{model.Address.Id}'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Address item.
SbmItemId addressItemId = address?.GetItemId() ?? model.GetAddressItemId();
if (!ItemId.IsValid(addressItemId))
{
if (address != null)
{
SaLogger.Warn($"{SysUtil.Fn} Item not found for existing Address: '{model.Address.Id}'");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
else
{
SaLogger.Warn($"{SysUtil.Fn} Item not specified for new Address.");
return Json(responseData.SetGoHome(messageTitle, Localiser["msg.error.system"]));
}
}
// Create new item if required.
if (address == null)
{
address = AccountMgr.CreateAddress((Sbm.ItemType)addressItemId.Type, addressItemId.Id, model.GetAddressType());
disposables.Add(address);
}
// Populate item properties.
if (model.Address.Type != null)
address.AddressType = model.GetAddressType();
if (model.Address.RefExt != null)
address.RefExt = model.Address.RefExt;
if (model.Address.Name != null)
address.Name = model.Address.Name;
if (model.Address.DescBrief != null)
address.DescBrief = model.Address.DescBrief;
// Address.
if (model.Address.Line1 != null)
address.Line1 = model.Address.Line1;
if (model.Address.Line2 != null)
address.Line2 = model.Address.Line2;
if (model.Address.Line3 != null)
address.Line3 = model.Address.Line3;
if (model.Address.City != null)
address.City = model.Address.City;
if (model.Address.Province != null)
address.Province = model.Address.Province;
if (model.Address.Postcode != null)
address.Postcode = model.Address.Postcode;
if (model.Address.Country != null)
address.Country = model.Address.Country;
// Regions.
if (model.Address.RegionIdCity != null)
address.RegionIdCity = model.GetAddressRegionIdCity();
if (model.Address.RegionIdProvince != null)
address.RegionIdProvince = model.GetAddressRegionIdProvince();
if (model.Address.RegionIdCountry != null)
address.RegionIdCountry = model.GetAddressRegionIdCountry();
// Codes.
if (model.Address.AccountManager != null)
address.AccountManagerCode = model.Address.AccountManager;
if (model.Address.AccountHandler != null)
address.AccountHandlerCode = model.Address.AccountHandler;
if (model.Address.ContactArea != null)
address.ContactAreaCode = model.Address.ContactArea;
if (model.Address.ContactHandler != null)
address.ContactHandlerCode = model.Address.ContactHandler;
if (model.Address.DeliveryType != null)
address.DeliveryTypeCode = model.Address.DeliveryType;
if (model.Address.DeliveryMethod != null)
address.DeliveryMethodCode = model.Address.DeliveryMethod;
if (model.Address.DeliveryBookIn != null)
address.DeliveryBookInCode = model.Address.DeliveryBookIn;
// Contact Management dates.
if (model.Address.LastVisitOn != null)
address.LastVisitOn = model.GetAddressLastVisitOn();
if (model.Address.NextVisitOn != null)
address.NextVisitOn = model.GetAddressNextVisitOn();
// Common properties.
if (model.Address.Notes != null)
address.Notes = model.Address.Notes;
if (model.Address.StatusCode != null)
address.Status = model.GetAddressStatus();
// Store item.
if (!SysId.IsValid(address.Id))
{
if (!AccountMgr.InsertAddress(address, DbUpdateInfo))
{
SaLogger.Warn($"{SysUtil.Fn} Failed to insert address: {AccountMgr.ErrorStateMessage}");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"]));
}
responseData.SetNotification(messageTitle, Localiser["msg.item.created"]);
}
else
{
if (!AccountMgr.UpdateAddress(address, DbUpdateInfo))
{
SaLogger.Warn($"{SysUtil.Fn} Failed to update address [Id:{SysId.ToLong(address.Id)}]: {AccountMgr.ErrorStateMessage}");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"]));
}
responseData.SetNotification(messageTitle, Localiser["msg.item.updated"]);
}
if (address.IsPrimary) AccountMgr.VerifyAsPrimaryAddress(address, DbUpdateInfo);
// Construct response.
model.PopulateItemConfig(responseData.Config, address);
PopulateAddressResponseItemData(model, address, responseData.address);
responseData.Success = true;
}
return Json(responseData);
}
//-------------------------------------------------------------------
// Set Primary ajax request.
//-------------------------------------------------------------------
[HttpPost]
[Route("Address/Ajax/SetPrimary")]
public IActionResult Ajax_Setprimary(Model_Address model)
{
String messageTitle = Localiser["label.address"];
AjaxResponse_Address responseData = new AjaxResponse_Address(model);
// Validate session and referrer.
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
if (!ValidReferer) return Forbid();
RefreshModel(model);
// Record disposable items as they are created so all can be disposed when needed.
using (DisposableCollection<SacsHierarchyItem> disposables = new DisposableCollection<SacsHierarchyItem>())
{
// Identify item.
SysId addressId = SysId.ToSysId(model.Address.Id);
if (!SysId.IsValid(addressId))
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
// Retrieve item.
SbmAddress address = AccountMgr.GetAddressById(addressId);
disposables.Add(address);
if (address == null)
{
SaLogger.Warn($"{SysUtil.Fn} Failed to retrieve address for Id: '{model.Address.Id}'");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
}
// Set this address as primary and clear primary against othe addresses for the same item.
address.IsPrimary = true;
if (!AccountMgr.UpdateAddress(address, DbUpdateInfo))
{
SaLogger.Warn($"{SysUtil.Fn} Failed to update address [Id:{SysId.ToLong(address.Id)}]: {AccountMgr.ErrorStateMessage}");
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"]));
}
AccountMgr.VerifyAsPrimaryAddress(address, DbUpdateInfo);
responseData.SetNotification(messageTitle, Localiser["msg.item.updated"]);
// Construct response.
model.PopulateItemConfig(responseData.Config, address);
PopulateAddressResponseItemData(model, address, responseData.address);
responseData.Success = true;
}
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -0,0 +1,64 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Sarand.BusinessMgr.Net.Core.Web.App;
using Sarand.BusinessMgr.Net.Core.Web.Helpers;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Sarand.BusinessMgr.Web.Portal.Models.Addresses;
using Sarand.BusinessMgr.Web.Portal.Components;
namespace Sarand.BusinessMgr.Web.Portal.Controllers.Addresses
{
//=======================================================================
// Portal Address Controller.
//=======================================================================
public partial class AddressController : SbmController_Portal
{
//-------------------------------------------------------------------
// Data members.
//-------------------------------------------------------------------
// Construction.
public AddressController(SbmLocaliser localiser, ILogger<AddressController> logger) :
base(localiser, logger)
{
}
//-------------------------------------------------------------------
[HttpGet]
[Route("Address")]
[Route("Addresses")]
public IActionResult Index(Model_Address model)
{
if (!ValidUserSession)
AutoLoginUser();
// Redirect to sign-in if not signed-in.
if (!ValidUserSession)
{
ClearKeepLoggedInCookie();
return RedirectToAction("", "Security");
}
// Address page.
RefreshModel(model);
model.PopulateListConfig();
model.Paging.PageNo = 1;
model.Paging.PageLength = 20;
return View(model);
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -1,21 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Sarand.BusinessMgr.Net.Core.Web.App;
using Sarand.BusinessMgr.Net.Core.Web.Helpers;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Security;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Sarand.BusinessMgr.Web.Portal.Models.Commodities;
using Sarand.BusinessMgr.Web.Portal.Components;
using Sarand.BusinessMgr.Web.Portal.Models.Commodities;
namespace Sarand.BusinessMgr.Web.Portal.Controllers.Commodities
{
@@ -25,6 +25,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
// Association data.
private class AssociationListData : AjaxResponse_Data.ItemData_Base
{
public String TargetId { get; set; }
public String TargetName { get; set; }
public String TypeDesc { get; set; }
public String Code { get; set; }
@@ -38,12 +39,14 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
// Association properties.
public String OwnerId { get; set; }
public String OwnerName { get; set; }
public String TargetId { get; set; }
public String TypeCode { get; set; }
}
private void PopulateAssociationResponseListData(SbmAssociation association, SbmAffiliate affiliateTarget, AssociationListData data)
{
data.Id = SysId.ToString(association.Id);
data.TargetId = SysId.ToString(association.AffiliateIdTarget);
data.TargetName = affiliateTarget.GetDisplayName();
data.TypeDesc = Internals.AssociationTypeCodes.GetDescForType(association.AssociationType);
}
private void PopulateAssociationResponseItemData(SbmAssociation association, SbmAffiliate affiliateTarget, AssociationItemData data)
{
@@ -51,15 +54,13 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
PopulateAssociationResponseListData(association, affiliateTarget, data as AssociationListData);
// Association properties.
data.OwnerId = SysId.ToString(association.AffiliateIdOwner);
data.TargetId = SysId.ToString(association.AffiliateIdTarget);
data.TypeCode = Internals.AssociationTypeCodes.GetCodeForType(association.AssociationType);
data.TypeDesc = Internals.AssociationTypeCodes.GetDescForType(association.AssociationType);
// Owner - Check if current organisation.
if (association.AffiliateIdOwner.Equals(SessionData_Portal.Organisation.AffiliateId))
data.Field.Value.Add($"{Model_Association.ItemField.Owner}", SessionData_Portal.Organisation.DisplayName);
else
{
// REtrieve owner contact details.
// Retrieve owner contact details.
using (SbmAffiliate affiliateOwner = AccountMgr.GetAffiliateById(association.AffiliateIdOwner))
{
if (affiliateOwner != null)
@@ -83,6 +84,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
data.Field.Value.RemoveAll(item => StringUtil.IsBlank(item.Value));
// Populate item list values that might be cleared during update after removing blank values to ensure that blank values are published.
data.Field.Value.Add($"{Model_Association.ItemField.Code}", association.Code);
data.Field.Value.Add($"{Model_Association.ItemField.Address}", AccountMgr.GetItemAddressSummary(affiliateTarget.GetItemId()));
data.Field.Value.Add($"{Model_Association.ItemField.Notes}", association.Notes);
data.Field.Value.Add($"{Model_Contact.ItemField.UpdatedOn}", Localiser.FormatDate(association.UpdateStamp.On));
}
@@ -217,6 +219,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
// Item columns.
ColumnDfn colId = AccountMgr.GetAssociationColumnDfn(SbmAssociation.Column.Id);
ColumnDfn colTargetId = AccountMgr.GetAssociationColumnDfn(SbmAssociation.Column.AffIdTarget);
ColumnDfn colTargetName = AccountMgr.GetAssociationColumnDfn(SbmAssociation.Column.Target_Name);
ColumnDfn colAssociationType = AccountMgr.GetAssociationColumnDfn(SbmAssociation.Column.Type_Desc);
ColumnDfn colCode = AccountMgr.GetAssociationColumnDfn(SbmAssociation.Column.Code);
@@ -227,7 +230,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
ColumnDfn colUpdatedOn = AccountMgr.GetAssociationColumnDfn(SbmAssociation.Column.UpdateOn_Date);
List<ColumnDfn> columns = new List<ColumnDfn>()
{
colId, colTargetName, colAssociationType, colCode, colAddress,
colId, colTargetId, colTargetName, colAssociationType, colCode, colAddress,
colNotes, colStatus, colCreatedOn, colUpdatedOn
};
@@ -241,6 +244,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
AssociationListData associationData = new AssociationListData()
{
Id = values.GetString(colId.DataName),
TargetId = $"{values.GetLong(colTargetId.DataName)}",
TargetName = values.GetString(colTargetName.DataName),
StatusCode = values.GetString(colStatus.DataName),
};
associationData.Field.Value.Add($"{Model_Association.ItemField.Type}", Internals.AssociationTypeCodes.GetDescForType(associationType));
@@ -48,7 +48,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
data.Id = SysId.ToString(affiliate.Id);
if (affiliate.Id.Equals(model.GetAffiliateIdOwner())) data.IsOwner = true;
// Associations.
data.AssociationCount = AccountMgr.GetAffiliateTargetAssociationCount(affiliate.Id, Sbm.AssociationType.NotInternal);
long associationCount = AccountMgr.GetAffiliateTargetAssociationCount(affiliate.Id, Sbm.AssociationType.NotInternal);
if (associationCount > 0) data.AssociationCount = associationCount;
HashSet<Sbm.AssociationType> associationTypes = AccountMgr.GetAssociationTypesForTarget(affiliate.Id);
if (associationTypes.Contains(Sbm.AssociationType.Customer))
data.IsCust = true;
@@ -64,6 +65,8 @@ namespace Sarand.BusinessMgr.Web.Portal.Controllers.Contacts
data.TypeCode = Internals.AffiliateTypeCodes.GetCodeForType(affiliate.AffiliateType);
data.TypeDesc = Internals.AffiliateTypeCodes.GetDescForType(affiliate.AffiliateType);
data.Field.Value.Add($"{Model_Contact.ItemField.Type}", Internals.AffiliateTypeCodes.GetDescForType(affiliate.AffiliateType));
// Address.
data.Field.Value.Add($"{Model_Contact.ItemField.Address}", AccountMgr.GetItemAddressSummary(affiliate.GetItemId()));
// Ogranisation.
data.Field.Value.Add($"{Model_Contact.ItemField.Parent}", SysId.ToString(affiliate.AffiliateIdParent));
data.Field.Value.Add($"{Model_Contact.ItemField.Name}", affiliate.Name);
@@ -0,0 +1,459 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Bus;
using System;
using System.Collections.Generic;
using System.Drawing;
namespace Sarand.BusinessMgr.Web.Portal.Models.Addresses
{
//=======================================================================
// Address model - Configuration.
//=======================================================================
partial class Model_Address
{
//-------------------------------------------------------------------
// Address fields.
//-------------------------------------------------------------------
/// <summary>Prefix for field names.</summary>
public const String FieldNamePrefix = "Addr";
//-------------------------------------------------------------------
// Legacy Address dialog tabs and panels.
// - Address.
// - Tab 1:
// - ???.
// - Tab 2:
// - ???.
//-------------------------------------------------------------------
/// <summary>Item fields.</summary>
public enum ItemField
{
//---------------------------------------------------------------
// Address.
Pos,
Id,
Exists,
Item,
ItemType,
ItemId,
ItemCaption,
AddressIdRef,
AddressRef,
Type,
TypeDesc,
RefExt,
Name,
Caption,
DescBrief,
Primary,
// Address.
Line1,
Line2,
Line3,
City,
Province,
Postcode,
Country,
RegionIdCity,
RegionIdProvince,
RegionIdCountry,
// Contact.
Contact,
Phone,
Fax,
Email,
// Codes.
AccountManager,
AccountHandler,
ContactArea,
ContactHandler,
DeliveryType,
DeliveryMethod,
DeliveryBookIn,
// Visit dates.
LastVisitOn,
NextVisitOn,
// Common.
Notes,
Status,
CreatedOn,
UpdatedOn,
Actions,
}
/// <summary>
/// Identifier used by form fields to show control specific messages generated by model validation etc.
/// <para>- Both page and model should use this method to consistently generate the field name.</para>
/// </summary>
public static String GetFieldName(ItemField field)
{
return $"{FieldNamePrefix}{field}";
}
//-------------------------------------------------------------------
// List configuration.
public class ListConfigData
{
// Actions.
public class ActionData
{
public class AllowData
{
public bool? Create { get; set; }
public bool? Update { get; set; }
}
public AllowData Allow { get; } = new AllowData();
}
public ActionData Action { get; } = new ActionData();
// List columns.
public class ColumnData
{
// Column name prefix.
public String Prefix { get; } = Model_Address.FieldNamePrefix;
// Hide column.
public HashSet<string> Hide { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
// Column labels.
public Dictionary<String, String> Label { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
}
public ColumnData Column { get; } = new ColumnData();
}
public ListConfigData ListConfig { get; private set; }
//-------------------------------------------------------------------
/// <summary>
/// Populate Address list configuration data in this model - only required on initial page construction.
/// </summary>
public void PopulateListConfig()
{
ListConfig = new ListConfigData();
PopulateListConfig(ListConfig);
}
/// <summary>
/// Populate Address list configuration data.
/// </summary>
public void PopulateListConfig(ListConfigData config)
{
// View properties.
ViewMode viewMode = GetFilterMode();
bool modeIsMaintain = viewMode == ViewMode.Maintain;
bool modeIsSearch = viewMode == ViewMode.Search;
bool userCanCreateAddresses = SessionData_Portal.SecurityProfile.UserCanCreateItemType(Sbm.ItemType.Address);
bool userCanUpdateAddresses = SessionData_Portal.SecurityProfile.UserCanUpdateItemType(Sbm.ItemType.Address);
Sbm.AddressType addressType = GetFilterAddressType();
//---------------------------------------------------------------
// Actions.
if (userCanCreateAddresses)
config.Action.Allow.Create = true;
if (userCanUpdateAddresses)
config.Action.Allow.Update = true;
//---------------------------------------------------------------
// Address list columns.
// - Pos.
// - Item (if not selected).
// - Type (if not selected).
// - External reference.
// - Name
// - Description
// - Summary
// - Postcode
// - Contact
// - Phone
// - Last visit on (if column exists).
// - Next visit on (if column exists).
// - Notes
// - Create On, Id (debug only).
//---------------------------------------------------------------
// Position.
// Item.
if (!SbmItemId.IsValid(GetFilterItemId()))
{
// Item is shown.
}
else
config.Column.Hide.Add($"{ItemField.ItemCaption}");
// Address type.
if (addressType <= 0)
{
// Address type is shown.
}
else
config.Column.Hide.Add($"{ItemField.TypeDesc}");
// Id
if (!SbmSystem.DebugMode)
config.Column.Hide.Add($"{ItemField.Id}");
// Created.
if (!SbmSystem.DebugMode)
config.Column.Hide.Add($"{ItemField.CreatedOn}");
// Actions.
if (!modeIsMaintain)
config.Column.Hide.Add($"{ItemField.Actions}");
}
//-------------------------------------------------------------------
// Item configuration.
//-------------------------------------------------------------------
// Contact item configuration.
public class ItemConfigData
{
// Item type.
public bool? IsOrganisation { get; set; }
public bool? IsIndividual { get; set; }
public bool? IsGroup { get; set; }
// Decimals.
public class DecimalsData
{
public int? PackQty { get; set; } = 0;
}
public DecimalsData Decimals { get; } = new DecimalsData();
// Item fields.
public class FieldData
{
// Field name prefix.
public String Prefix { get; } = Model_Address.FieldNamePrefix;
// Hide field.
public HashSet<string> Hide { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
// Read-only field.
public HashSet<string> Readonly { get; } = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
// Field labels.
public Dictionary<String, String> Label { get; } = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
}
public FieldData Field { get; } = new FieldData();
}
//-------------------------------------------------------------------
/// <summary>
/// Populate item configuration for existing association.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, SbmAddress address)
{
PopulateItemConfig(config, address.GetItemId(), address.AddressType);
}
/// <summary>
/// Populate item configuration for new or existing association.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, SbmItemId addressItemId, Sbm.AddressType addressType)
{
// Item configuration.
bool itemKnown = SbmItemId.IsValid(addressItemId);
bool importedFromAccounts = Internals.AccountsConsole.ItemIsImportedFromAccounts(addressItemId);
bool managedByAccounts = Internals.AccountsConsole.IsItemTypeManagedByAccounts(Sbm.ItemType.Address);
bool showNotes = true;
//---------------------------------------------------------------
// Address.
// Id.
if (SbmSystem.DebugMode)
config.Field.Readonly.Add($"{ItemField.Id}");
else
config.Field.Hide.Add($"{ItemField.Id}");
// Item. Always Readonly.
config.Field.Readonly.Add($"{ItemField.Item}");
// Address type.
if (!managedByAccounts)
{
// Type is editable.
}
else config.Field.Readonly.Add($"{ItemField.Type}");
// Name.
if (!managedByAccounts)
{
// Name is editable.
}
else config.Field.Readonly.Add($"{ItemField.Name}");
// RefExt.
if (!managedByAccounts)
{
// RefExt is editable.
}
else config.Field.Readonly.Add($"{ItemField.RefExt}");
// Desc Brief.
if (!managedByAccounts)
{
// DescBrief is editable.
}
else config.Field.Readonly.Add($"{ItemField.DescBrief}");
//---------------------------------------------------------------
// Line1.
if (!managedByAccounts)
{
// Line1 is editable.
}
else config.Field.Readonly.Add($"{ItemField.Line1}");
// Line2.
if (!managedByAccounts)
{
// Line2 is editable.
}
else config.Field.Readonly.Add($"{ItemField.Line2}");
// Line3.
if (!managedByAccounts)
{
// Line3 is editable.
}
else config.Field.Readonly.Add($"{ItemField.Line3}");
// City.
if (!managedByAccounts)
{
// City is editable.
}
else config.Field.Readonly.Add($"{ItemField.City}");
// Province.
if (!managedByAccounts)
{
// Province is editable.
}
else config.Field.Readonly.Add($"{ItemField.Province}");
// Postcode.
if (!managedByAccounts)
{
// Postcode is editable.
}
else config.Field.Readonly.Add($"{ItemField.Postcode}");
// Country.
if (!managedByAccounts)
{
// Country is editable.
}
else config.Field.Readonly.Add($"{ItemField.Country}");
//---------------------------------------------------------------
// Contact.
if (!managedByAccounts)
{
// Contact is editable.
}
else config.Field.Readonly.Add($"{ItemField.Contact}");
// Phone.
if (!managedByAccounts)
{
// Phone is editable.
}
else config.Field.Readonly.Add($"{ItemField.Phone}");
// Fax.
if (!managedByAccounts)
{
// Fax is editable.
}
else config.Field.Readonly.Add($"{ItemField.Fax}");
// Email.
if (!managedByAccounts)
{
// Email is editable.
}
else config.Field.Readonly.Add($"{ItemField.Email}");
//---------------------------------------------------------------
// Codes.
// AccountManagerCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountManager)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_AccountManagerCode))
{
// AccountManagerCode is visible.
}
else config.Field.Hide.Add($"{ItemField.AccountManager}");
// AccountHandlerCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.AccountHandler)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_AccountHandlerCode))
{
// AccountHandlerCode is visible.
}
else config.Field.Hide.Add($"{ItemField.AccountHandler}");
// ContactAreaCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactArea)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_ContactAreaCode))
{
// ContactAreaCode is visible.
}
else config.Field.Hide.Add($"{ItemField.ContactArea}");
// ContactHandlerCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.ContactHandler)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_ContactHandlerCode))
{
// ContactHandlerCode is visible.
}
else config.Field.Hide.Add($"{ItemField.ContactHandler}");
// DeliveryTypeCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryType)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_DeliveryTypeCode))
{
// DeliveryTypeCode is visible.
}
else config.Field.Hide.Add($"{ItemField.DeliveryType}");
// DeliveryMethodCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryMethod)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_DeliveryMethodCode))
{
// DeliveryMethodCode is visible.
}
else config.Field.Hide.Add($"{ItemField.DeliveryMethod}");
// DeliveryBookInCode.
if (Internals.CodeTypeConsole.CodeTypeHasCodes(Internals.GetCodeTypeCode(Sbm.ApplCodeType.DeliveryBookIn)) && AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_DeliveryBookInCode))
{
// DeliveryBookInCode is visible.
}
else config.Field.Hide.Add($"{ItemField.DeliveryBookIn}");
// LastVisitOn.
if (AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_LastVisitOn))
{
// LastVisitOn is visible.
}
else config.Field.Hide.Add($"{ItemField.LastVisitOn}");
// NextVisitOn.
if (AccountMgr.ColumnExists(SbmDbDfn.ColumnIdx.Address_NextVisitOn))
{
// NextVisitOn is visible.
}
else config.Field.Hide.Add($"{ItemField.NextVisitOn}");
//---------------------------------------------------------------
// Common.
// Notes.
if (!showNotes)
config.Field.Hide.Add($"{ItemField.Notes}");
// Status.
if (managedByAccounts)
config.Field.Readonly.Add($"{ItemField.Status}");
}
//-------------------------------------------------------------------
}
}
@@ -0,0 +1,389 @@
using DocumentFormat.OpenXml.Office2016.Excel;
using NPOI.SS.Util;
using Sarand.BusinessMgr.Net.Core.Web.App;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Web.Portal.Components;
using Sarand.BusinessMgr.Web.Portal.Controllers.Addresses;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Bus;
using Sarand.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.ReferenceData;
using Sarand.Net.Standard.Base.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static Sarand.BusinessMgr.Net.Standard.Base.App.Sbm;
namespace Sarand.BusinessMgr.Web.Portal.Models.Addresses
{
//=======================================================================
// Address model.
//=======================================================================
/// <summary>
/// Address model - Filter, Form, validation and configuration.
/// </summary>
public partial class Model_Address : SbmModel_Portal
{
//-------------------------------------------------------------------
// Definitions.
public enum ViewMode
{
Search, Maintain
}
//-------------------------------------------------------------------
// Construction.
public Model_Address(SbmLocaliser localiser) :
base(localiser)
{
}
//-------------------------------------------------------------------
// Filter properties.
public class FilterData
{
public String Mode { get; set; }
public String ItemType { get; set; }
public String ItemId { get; set; }
public String AddressType { get; set; }
public String Search { get; set; }
}
public FilterData Filter { get; } = new FilterData();
public ViewMode GetFilterMode()
{
return EnumUtil.ParseEnum(Filter.Mode, ViewMode.Search);
}
public Sbm.ItemType GetFilterItemType()
{
Sbm.ItemType addressType = (Sbm.ItemType)Internals.ItemTypeCodes.GetTypeForCode(Filter.ItemType);
if (addressType == 0 && !StringUtil.IsBlank(Filter.ItemType) && StringUtil.IsNumeric(Filter.ItemType, true))
addressType = (Sbm.ItemType)StringUtil.ToInt(Filter.ItemType);
return addressType;
}
public SbmItemId GetFilterItemId()
{
return new SbmItemId(GetFilterItemType(), SysId.ToSysId(Filter.ItemId));
}
public Sbm.AddressType GetFilterAddressType()
{
Sbm.AddressType addressType = (Sbm.AddressType)Internals.AddressTypeCodes.GetTypeForCode(Filter.AddressType);
if (addressType == 0 && !StringUtil.IsBlank(Filter.AddressType) && StringUtil.IsNumeric(Filter.AddressType, true))
addressType = (Sbm.AddressType)StringUtil.ToInt(Filter.AddressType);
return addressType;
}
//-------------------------------------------------------------------
// Address properties.
public class AddressData
{
public String Id { get; set; }
public String Exists { get; set; }
public String Caption { get; set; }
public String ItemType { get; set; }
public String ItemId { get; set; }
public String ItemCaption { get; set; }
public String Type { get; set; }
public String AddressIdRef { get; set; }
public String RefExt { get; set; }
public String Name { get; set; }
public String DescBrief { get; set; }
public String Line1 { get; set; }
public String Line2 { get; set; }
public String Line3 { get; set; }
public String City { get; set; }
public String Province { get; set; }
public String Postcode { get; set; }
public String Country { get; set; }
public String RegionIdCity { get; set; }
public String RegionIdProvince { get; set; }
public String RegionIdCountry { get; set; }
public String Contact { get; set; }
public String Phone { get; set; }
public String Fax { get; set; }
public String Email { get; set; }
public String AccountManager { get; set; }
public String AccountHandler { get; set; }
public String ContactArea { get; set; }
public String ContactHandler { get; set; }
public String DeliveryType { get; set; }
public String DeliveryMethod { get; set; }
public String DeliveryBookIn { get; set; }
public String LastVisitOn { get; set; }
public String NextVisitOn { get; set; }
// Common properties.
public String Notes { get; set; }
public String StatusCode { get; set; }
}
public AddressData Address { get; } = new AddressData();
// Extract properties.
public Sbm.AddressType GetAddressType()
{
return (Sbm.AddressType)Internals.AddressTypeCodes.GetTypeForCode(Address.Type);
}
public Sbm.ItemType GetAddressItemType()
{
return (Sbm.ItemType)StringUtil.ToLong(Address.ItemType);
}
public SbmItemId GetAddressItemId()
{
return new SbmItemId(GetAddressItemType(), SysId.ToSysId(Address.ItemId));
}
public SysId GetAddressIdRef()
{
return SysId.ToSysId(Address.AddressIdRef);
}
// Regions.
public SysId GetAddressRegionIdCity()
{
return SysId.ToSysId(Address.RegionIdCity);
}
public SysId GetAddressRegionIdProvince()
{
return SysId.ToSysId(Address.RegionIdProvince);
}
public SysId GetAddressRegionIdCountry()
{
return SysId.ToSysId(Address.RegionIdCountry);
}
// Contact Management.
public DateTime GetAddressLastVisitOn()
{
return ParseDateFromForm(Address.LastVisitOn);
}
public DateTime GetAddressNextVisitOn()
{
return ParseDateFromForm(Address.NextVisitOn);
}
// Common properties.
public SaStatus GetAddressStatus()
{
return SacsSystem.GetStatusForCode(Address.StatusCode);
}
//-------------------------------------------------------------------
// Validation.
//-------------------------------------------------------------------
// Address validation.
public bool ValidateAddressData(Sacs.Web.Components.SaController.AjaxResponse_Data responseData)
{
// Item.
if (Address.ItemType != null || Address.ItemId != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Item);
SbmItemId itemIdAddress = GetAddressItemId();
if (!ItemId.IsValid(GetAddressItemId()))
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
}
// Address Type.
if (Address.Type != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Type);
if (Address.Type.IsEmpty() || GetAddressType() <= 0)
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
}
// Reference.
if (Address.RefExt != null)
{
String controlName = GetFieldName(Model_Address.ItemField.RefExt);
Address.RefExt = Address.RefExt.ToUpperInvariant();
responseData.SetControlValue(controlName, Address.RefExt);
if (!StringUtil.IsEmpty(Address.RefExt) && StringUtil.GetLength(Address.RefExt) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_RefExt))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_RefExt)]);
}
// Reference Address.
if (Address.AddressIdRef != null)
{
String controlName = GetFieldName(Model_Address.ItemField.AddressRef);
if (!SysId.IsValid(GetAddressIdRef()))
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
}
// Name.
if (Address.Name != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Name);
responseData.SetControlValue(controlName, Address.Name);
if (!Address.Name.IsEmpty() && StringUtil.GetLength(Address.Name) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Name))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Name)]);
}
// Description.
if (Address.DescBrief != null)
{
String controlName = GetFieldName(Model_Address.ItemField.DescBrief);
responseData.SetControlValue(controlName, Address.DescBrief);
if (!Address.DescBrief.IsEmpty() && StringUtil.GetLength(Address.DescBrief) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_DescBrief))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_DescBrief)]);
}
// Line 1.
if (Address.Line1 != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Line1);
responseData.SetControlValue(controlName, Address.Line1);
if (Address.Line1.IsBlank())
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
else if (!Address.Line1.IsEmpty() && StringUtil.GetLength(Address.Line1) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line1))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line1)]);
}
// Line 2.
if (Address.Line2 != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Line2);
responseData.SetControlValue(controlName, Address.Line2);
if (!Address.Line2.IsEmpty() && StringUtil.GetLength(Address.Line2) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line2))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line2)]);
}
// Line 3.
if (Address.Line3 != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Line3);
responseData.SetControlValue(controlName, Address.Line3);
if (!Address.Line3.IsEmpty() && StringUtil.GetLength(Address.Line3) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line3))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line3)]);
}
// City.
if (Address.City != null)
{
String controlName = GetFieldName(Model_Address.ItemField.City);
responseData.SetControlValue(controlName, Address.City);
if (!Address.City.IsEmpty() && StringUtil.GetLength(Address.City) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_City))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_City)]);
}
// City Region.
// Province.
if (Address.Province != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Province);
responseData.SetControlValue(controlName, Address.Province);
if (!Address.Province.IsEmpty() && StringUtil.GetLength(Address.Province) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Province))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Province)]);
}
// Province Region.
// Postcode.
if (Address.Postcode != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Postcode);
Address.Postcode = Address.Postcode.ToUpperInvariant();
responseData.SetControlValue(controlName, Address.Postcode);
if (!Address.Postcode.IsEmpty() && StringUtil.GetLength(Address.Postcode) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Postcode))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Postcode)]);
}
// Country.
if (Address.Country != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Country);
responseData.SetControlValue(controlName, Address.Country);
if (!Address.Country.IsEmpty() && StringUtil.GetLength(Address.Country) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Country))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Country)]);
}
// Country Region.
// Contact.
if (Address.Contact != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Contact);
responseData.SetControlValue(controlName, Address.Contact);
if (!Address.Contact.IsEmpty() && StringUtil.GetLength(Address.Contact) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Contact))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Contact)]);
}
// Phone.
if (Address.Phone != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Phone);
responseData.SetControlValue(controlName, Address.Phone);
if (!Address.Phone.IsEmpty() && StringUtil.GetLength(Address.Phone) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Phone))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Phone)]);
}
// Fax.
if (Address.Fax != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Fax);
responseData.SetControlValue(controlName, Address.Fax);
if (!Address.Fax.IsEmpty() && StringUtil.GetLength(Address.Fax) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Fax))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Fax)]);
}
// Email.
if (Address.Email != null)
{
String controlName = GetFieldName(Model_Address.ItemField.Email);
responseData.SetControlValue(controlName, Address.Email);
if (!Address.Email.IsEmpty() && StringUtil.GetLength(Address.Email) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Email))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Email)]);
}
// Last Visit On.
if (Address.LastVisitOn != null)
{
String controlName = GetFieldName(Model_Address.ItemField.LastVisitOn);
DateTime lastVisitOn = GetAddressLastVisitOn();
if (!StringUtil.IsBlank(Address.LastVisitOn))
{
if (!DateUtil.IsValid(GetAddressLastVisitOn()))
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
else if (GetAddressLastVisitOn().CompareTo(DateTime.Today) > 0)
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
}
}
// Next Visit On.
if (Address.NextVisitOn != null)
{
String controlName = GetFieldName(Model_Address.ItemField.NextVisitOn);
DateTime lastVisitOn = GetAddressNextVisitOn();
if (!StringUtil.IsBlank(Address.NextVisitOn))
{
if (!DateUtil.IsValid(GetAddressNextVisitOn()))
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
else if (DateUtil.IsValid(GetAddressLastVisitOn()) && GetAddressNextVisitOn().CompareTo(GetAddressLastVisitOn()) < 0)
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
}
}
// Address Notes.
if (Address.Notes != null)
{
String controlName = "AddressNotes";
responseData.SetControlValue(controlName, Address.Notes);
if (!Address.Notes.IsEmpty() && StringUtil.GetLength(Address.Notes) > GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Notes))
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Notes)]);
}
// Address status.
if (Address.StatusCode != null)
{
String controlName = "AddressStatusCode";
if (Address.StatusCode.IsEmpty())
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
else if (!SbmAddress.ValidStatuses.Contains(GetAddressStatus()))
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
}
return !responseData.HasControlErrors();
}
//-------------------------------------------------------------------
}
//=======================================================================
}
@@ -203,7 +203,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets
/// <summary>
/// Populate item configuration for new or existing vehicle.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId assetId, Sbm.AssetType assetType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId assetId, Sbm.AssetType assetType)
{
// Session configuration.
bool assetPurchaseAllowed = SessionConsole.GetOwnerOption_AllowOption(Sbm.OrgOption_AllowOption.Asset_Purchase);
@@ -236,7 +236,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets
// Purchase.
// Purchase net price.
if (!assetPurchaseAllowed||!userCanUpdateAssets)
if (!assetPurchaseAllowed || !userCanUpdateAssets)
config.Field.Readonly.Add($"{ItemField.PurchaseAmount}");
// Purchase tax code.
@@ -185,7 +185,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Assets
/// <summary>
/// Populate item configuration for new or existing vehicle.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId assetCategoryId, Sbm.AssetType assetType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId assetCategoryId, Sbm.AssetType assetType)
{
// Session configuration.
bool userCanCreateAssetCategories = SessionData_Portal.SecurityProfile.UserCanCreateItemType(Sbm.ItemType.AssetCategory);
@@ -413,7 +413,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Commodities
/// <summary>
/// Populate item configuration for new or existing association.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId commodityItemId, Sbm.CommodityType commodityType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId commodityItemId, Sbm.CommodityType commodityType)
{
// Item type.
bool isProduct = commodityType != Sbm.CommodityType.Service;
@@ -309,7 +309,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts
/// <summary>
/// Populate item configuration for new or existing association.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId associationItemId, SysId ownerId, Sbm.AssociationType associationType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId associationItemId, SysId ownerId, Sbm.AssociationType associationType)
{
bool ownerIsInternal = SessionData_Portal.Organisation.AffiliateId.Equals(ownerId);
bool isCustomer = SbmAssociation.IsCustomer(associationType);
@@ -234,7 +234,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Contacts
/// <summary>
/// Populate item configuration for new or existing association.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId affiliateItemId, Sbm.AffiliateType affiliateType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId affiliateItemId, Sbm.AffiliateType affiliateType)
{
// Item type.
bool isIndividual = SbmAffiliate.IsIndividual(affiliateType);
@@ -479,7 +479,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Requirements
/// <summary>
/// Populate item configuration for new or existing requirement.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId requirementItemId, Sbm.TransactionType transactionType, SbmTransaction.StatusCat transactionStatusCat, Sbm.RequirementType requirementType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId requirementItemId, Sbm.TransactionType transactionType, SbmTransaction.StatusCat transactionStatusCat, Sbm.RequirementType requirementType)
{
// Item type.
bool isSales = SbmTransaction.IsSalesType(transactionType);
@@ -603,7 +603,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Transactions
/// <summary>
/// Populate item configuration for new or existing transaction.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId transactionItemId, Sbm.TransactionType transactionType)
public void PopulateItemConfig(ItemConfigData config, SbmItemId transactionItemId, Sbm.TransactionType transactionType)
{
// Item type.
bool isSales = SbmTransaction.IsSalesType(transactionType);
@@ -193,7 +193,7 @@ namespace Sarand.BusinessMgr.Web.Portal.Models.Vehicles
/// <summary>
/// Populate item configuration for new or existing vehicle.
/// </summary>
public void PopulateItemConfig(ItemConfigData config, ItemId vehicleItemId)
public void PopulateItemConfig(ItemConfigData config, SbmItemId vehicleItemId)
{
// Session configuration.
bool userCanCreateVehicles = SessionData_Portal.SecurityProfile.UserCanCreateItemType(Sbm.ItemType.Vehicle);
@@ -0,0 +1,8 @@
@model SbmModel_Portal
@inject SbmLocaliser Localiser
@{
/* Address page. */
ViewData["Title"] = "Addresses";
}
<partial name="Panel-AddressMaintain.cshtml" />
@@ -0,0 +1,522 @@
@* View is decoupled from Address model as it may be included in other views, eg. Contacts. *@
@model SbmModel_Portal
@inject SbmLocaliser Localiser
@{
/* Address - Dialog panel */
// Ensure view is only included once in page.
if (!Model.RegisterView(Html.ViewContext)) return;
}
<script type="text/javascript">
sbm.dlg.title.createAddress = '@Localiser.GetJavascriptText("caption.address.create")';
sbm.dlg.title.updateAddress = '@Localiser.GetJavascriptText("caption.address.update")';
</script>
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAddressId", @class = "sbm-form" }))
{
@Html.Hidden("Address.Id", "", new { @id = "", @class = "AddressId" })
@Html.Hidden("Address.DataGroups", "", new { @id = "", @class = "AddressDataGroups" })
}
<div id="dlgAddress" class="sbm-dialog" title="">
@using (@Html.BeginForm(FormMethod.Post, new { @id = "frmAddress", @class = "sbm-form", @onSubmit = "return false;" }))
{
@Html.Hidden("Address.Id", "", new { @id = "", @class = "AddressId sbm-input" })
@Html.Hidden("Address.Exists", "", new { @id = "", @class = "AddressExists sbm-input" })
@Html.Hidden("Address.SupersededStatusConfirmed", "", new { @id = "", @class = "SupersededStatusConfirmed sbm-input" })
<div class="spacer2"></div>
@* Address Owner *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Item)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifAddressItem"><span>@Localiser["label.item"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.Hidden("Address.ItemType", "", new { @id = "", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.ItemType)} sbm-input sbm-auto-val" })
@Html.Hidden("Address.ItemId", "", new { @id = "", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.ItemId)} sbm-input sbm-auto-val" })
<input type="text" id="ifAddressItem" class = "@(Model_Address.GetFieldName(Model_Address.ItemField.ItemCaption)) sbm-input sbm-auto-val" readonly="readonly" />
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
@* Address Type *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Type)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressType"><span>@Localiser["label.type"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.Type", Model.GetEmptyListForSelect(), Localiser["label.select"], new { @id = "cbAddressType", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Type)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-6">
@* Address Reference External *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.RefExt)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressRefExt"><span>@Localiser["label.reference"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.RefExt", "", new { @id = "ifAddressRefExt", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.RefExt)} sbm-input upper sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_RefExt) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
@* Address Name *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Name)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifAddressName"><span>@Localiser["label.name"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Name", "", new { @id = "ifAddressName", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Name)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Name) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
@* Address Description *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.DescBrief)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifAddressDesc"><span>@Localiser["label.caption"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.DescBrief", "", new { @id = "ifAddressDesc", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.DescBrief)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_DescBrief) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
@* Address lines *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Line1)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifAddressLine1"><span>@Localiser["label.number.street"]</span><span class="required">&nbsp;*</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Line1", "", new { @id = "ifAddressLine1", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Line1)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line1) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Line2)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Line2", "", new { @id = "ifAddressLine2", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Line2)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line2) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Line3)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Line3", "", new { @id = "ifAddressLine3", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Line3)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Line3) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Address City *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.City)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressCity"><span>@Localiser["label.city"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.City", "", new { @id = "ifAddressCity", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.City)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_City) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Province *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Province)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressProvince"><span>@Localiser["label.province"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Province", "", new { @id = "ifAddressProvince", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Province)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Province) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Address Postcode *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Postcode)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressPostcode"><span>@Localiser["label.postcode"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Postcode", "", new { @id = "ifAddressPostcode", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Postcode)} sbm-input upper sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Postcode) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Country *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Country)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressCountry"><span>@Localiser["label.country"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Country", "", new { @id = "ifAddressCountry", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Country)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Country) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Address Contact *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Contact)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressContact"><span>@Localiser["label.contact"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Contact", "", new { @id = "ifAddressContact", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Contact)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Contact) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Phone *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Phone)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressPhone"><span>@Localiser["label.phone"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Phone", "", new { @id = "ifAddressPhone", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Phone)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Phone) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
@* Address Email *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Email)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifAddressEmail"><span>@Localiser["label.email"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.Email", "", new { @id = "ifAddressEmail", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Email)} sbm-input sbm-auto-val", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Email) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Address Account Manager *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.AccountManager)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressAccountManager"><span>@Localiser["label.account.manager"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.AccountManager", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressAccountManager", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.AccountManager)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Account Handler *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.AccountHandler)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressAccountHandler"><span>@Localiser["label.account.handler"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.AccountHandler", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressAccountHandler", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.AccountHandler)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Contact Area *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.ContactArea)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressContactArea"><span>@Localiser["label.contact.area"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.ContactArea", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressContactArea", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.ContactArea)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Contact Handler *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.ContactHandler)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressContactHandler"><span>@Localiser["label.contact.handler"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.ContactHandler", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressContactHandler", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.ContactHandler)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Delivery Type *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.DeliveryType)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressDeliveryType"><span>@Localiser["label.delivery.type"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.DeliveryType", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressDeliveryType", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.DeliveryType)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Delivery Method *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.DeliveryMethod)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressDeliveryMethod"><span>@Localiser["label.delivery.method"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.DeliveryMethod", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressDeliveryMethod", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.DeliveryMethod)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Delivery Book-In *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.DeliveryBookIn)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="cbAddressDeliveryBookIn"><span>@Localiser["label.delivery.book.in"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.DropDownList("Address.DeliveryBookIn", Model.GetEmptyListForSelect(), "", new { @id = "cbAddressDeliveryBookIn", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.DeliveryBookIn)} sbm-select sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
@* Address Last Visit On *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.LastVisitOn)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressLastVisitOn"><span>@Localiser["label.visit.last"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.LastVisitOn", "", new { @id = "ifAddressLastVisitOn", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.LastVisitOn)} sbm-input sbm-calendar upper sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
<div class="col-sm-6">
@* Address Next Visit On *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.NextVisitOn)">
<div class="row">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifAddressNextVisitOn"><span>@Localiser["label.visit.next"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextBox("Address.NextVisitOn", "", new { @id = "ifAddressNextVisitOn", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.NextVisitOn)} sbm-input sbm-calendar upper sbm-auto-val" })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
</div>
</div>
@* Address Notes *@
<div class="sbm-form-control @Model_Address.GetFieldName(Model_Address.ItemField.Notes)">
<div class="row">
<div class="col-sm-3">
<div class="sbm-label">
<label for="ifAddressNotes"><span>@Localiser["label.notes"]</span></label>
</div>
</div>
<div class="col-sm">
<div class="sbm-control">
@Html.TextArea("Address.Notes", "", new { @id = "ifAddressNotes", @class = $"{Model_Address.GetFieldName(Model_Address.ItemField.Notes)} sbm-textarea sbm-auto-val", @rows = "3", @maxlength = @Model.GetControlMaxLength(SbmDbDfn.ColumnIdx.Address_Notes) })
</div>
<div class="sbm-message"></div>
</div>
</div>
</div>
}
</div>
@@ -0,0 +1,82 @@
@* View is decoupled from Address model as it may be included in other views, eg. Contacts. *@
@model SbmModel_Portal
@inject SbmLocaliser Localiser
@{
/* Address - List panel */
/* NB Can potentially appear more than once on a page. */
}
<script type="text/javascript">
sbm.lbl.setPrimary= '@(Localiser.GetJavascriptText("label.set.primary"))';
</script>
@* Item list *@
<div class="sbm-panel-item-table sbm-flex">
<table class="sbm-item-list">
<thead>
<tr>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.TypeDesc) width5pc center">@Localiser["label.type"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.RefExt) width5pc">@Localiser["label.ref"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Name) width10pc d-none d-md-table-cell">@Localiser["label.name"]</th>
@*<th class="@Model_Address.GetFieldName(Model_Address.ItemField.DescBrief) width25pc d-none d-xl-table-cell">@Localiser["label.description"]</th>*@
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Caption) width25pc">@Localiser["label.address"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Postcode) width5pc center">@Localiser["label.postcode"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Contact) width5pc center d-none d-xl-table-cell">@Localiser["label.contact"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Phone) width5pc center">@Localiser["label.phone"]</th>
@*<th class="@Model_Address.GetFieldName(Model_Address.ItemField.LastVisitOn) width5pc center d-none d-xl-table-cell">@Localiser["label.visit.last"]</th>*@
@*<th class="@Model_Address.GetFieldName(Model_Address.ItemField.NextVisitOn) width5pc center d-none d-xl-table-cell">@Localiser["label.visit.next"]</th>*@
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Notes) width10pc d-none d-lg-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Primary) width2pc center">@Localiser["label.prim."]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Status) width5pc center">@Localiser["label.status"]</th>
<th class="@Model_Address.GetFieldName(Model_Address.ItemField.Actions) width2pc right"></th>
</tr>
<tr><td colspan="6"><div class="sbm-panel-messages"></div></td></tr>
</thead>
<tbody></tbody>
</table>
</div>
@* Element templates *@
<div class="sbm-panel-item-template">
@* List burger dropdown template - ul is ignored *@
<ul class="sbm-dropdown-menu AddressList">
<li class="sbm-dropdown-item sbm-action"><div class="sbm-label">XXX</div></li>
</ul>
@* Item row template - table is ignored. *@
<table>
<tr class="sbm-row-item Address">
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.TypeDesc) center nowrap"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.RefExt)" style="max-width:0;overflow-x:hidden;text-overflow:clip;white-space:nowrap;"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Name) d-none d-md-table-cell"></td>
@*<td class="@Model_Address.GetFieldName(Model_Address.ItemField.DescBrief) d-none d-xl-table-cell"></td>*@
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Caption)"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Postcode)"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Contact) d-none d-xl-table-cell"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Phone)"></td>
@*<td class="@Model_Address.GetFieldName(Model_Address.ItemField.LastVisitOn) d-none d-xl-table-cell"></td>*@
@*<td class="@Model_Address.GetFieldName(Model_Address.ItemField.NextVisitOn) d-none d-xl-table-cell"></td>*@
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Notes) d-none d-lg-table-cell"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Primary) center"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Status) center nowrap"></td>
<td class="@Model_Address.GetFieldName(Model_Address.ItemField.Actions) right">
<div class="right">
@* Burger menu *@
<ul class="nav navbar-nav navbar-light navbar-right sbm-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="sbm-ellipsis-dot"></span><span class="sbm-ellipsis-dot"></span><span class="sbm-ellipsis-dot"></span></a>
<ul class="dropdown-menu dropdown-menu-right sbm-dropdown-menu">@* Menu items will be inserted here. *@</ul>
</li>
</ul>
</div>
</td>
</tr>
</table>
@* Item burger dropdown template - ul is ignored *@
<ul class="sbm-dropdown-menu Address">
<li class="sbm-dropdown-item sbm-action"><div class="sbm-label">XXX</div></li>
</ul>
</div>
@@ -0,0 +1,69 @@
@* View is decoupled from Address model as it may be included in other views, eg. Contacts. *@
@model SbmModel_Portal
@inject SbmLocaliser Localiser
@{
/* Address - Maintain panel */
// Ensure view is only included once in page.
if (!Model.RegisterView(Html.ViewContext)) return;
Model.AdditionalFiles_JS.Add("js/sbm-addr.js");
}
<div class="sbm-panel Addresses fullheight">
<script type="text/javascript">
</script>
<div class="sbm-panel-data sbm-flex">
@* Filter form - wrap header to include paging controls. *@
@using (@Html.BeginForm(FormMethod.Post, new { @id = "", @class = "frmAddressFilter sbm-form", @onSubmit = "return false;" }))
{
@Html.Hidden("Filter.Mode", Model_Address.ViewMode.Maintain, new { @id = "" })
@* Header - Page caption, paging controls, actions. *@
<div class="sbm-panel-header">
<div class="row">
<div class="col"><partial name="~/Views/Common/ResultsPaging.cshtml" /></div>
<div class="fixed center"><div class="sbm-panel-caption">@Localiser["label.addresses"]</div></div>
<div class="col right">
@* Burger menu *@
<ul class="nav navbar-nav navbar-dark navbar-right sbm-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
<ul class="dropdown-menu dropdown-menu-right sbm-dropdown-menu">@* Menu items will be inserted here. *@</ul>
</li>
</ul>
</div>
</div>
</div>
@* Filter Panel *@
<div class="sbm-panel-filter">
<div class="row">
<div class="col-sm-4 row pb4">
@* Address Category *@
<div class="col-4 col-sm-4 sbm-label text-left text-sm-right">@Localiser["label.type"]</div>
<div class="col-7 col-sm-8">
@Html.DropDownList("Filter.AddressType", Model.GetAddressTypeCodesForFilterDropdown(), null, new { @id = "", @class = "FilterAddressType sbm-select" })
</div>
</div>
<div class="col-sm-4 row pb4">
@* Address filter - code, description etc *@
<div class="col-4 col-sm-4 sbm-label text-left text-sm-right">@Localiser["label.search"]</div>
<div class="col-7 col-sm-8">
@Html.TextBox("Filter.Search", "", new { @type = "search", @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" })
</div>
</div>
<div class="col-sm-4 row pb4">
</div>
</div>
</div>
}
<partial name="Panel-AddressList.cshtml" />
</div>
<partial name="Panel-AddressDialog.cshtml" />
</div>
@@ -0,0 +1,81 @@
@* View is decoupled from Address model as it may be included in other views, eg. Contacts. *@
@model SbmModel_Portal
@inject SbmLocaliser Localiser
@{
/* Address - Select panel */
// Ensure view is only included once in page.
if (!Model.RegisterView(Html.ViewContext)) return;
Model.AdditionalFiles_JS.Add("js/sbm-addr.js");
}
<script type="text/javascript">
sbm.lbl.item = '@(Localiser.GetJavascriptText("label.item"))';
</script>
<div id="dlgAddressSelect" class="sbm-dialog sbm-flex sbm-no-padding" title="@Localiser["label.addresses"]">
@using (@Html.BeginForm(FormMethod.Post, new { @id = "", @class = "frmAddressFilter sbm-form", @onSubmit = "return false;" }))
{
@Html.Hidden("Filter.Mode", Model_Address.ViewMode.Search, new { @id = "", @class = "FilterMode" })
@* Filter Panel *@
<div class="sbm-panel-filter">
<div class="row">
<div class="col-sm-4 row pb4 AddressFilterItem">
@* Address type *@
<div class="col-4 col-sm-4 sbm-label text-left text-sm-right">@Localiser["label.item"]</div>
<div class="col-8 col-sm-8">
@Html.Hidden("Filter.ItemType", "", new { @id = "", @class = "FilterItemType sbm-input" })
@Html.Hidden("Filter.ItemId", "", new { @id = "", @class = "FilterItemId sbm-input" })
<input type="text" id="" class="FilterItemCaption sbm-input" readonly="readonly" />
</div>
</div>
<div class="col-sm-4 row pb4">
@* Address type *@
<div class="col-4 col-sm-4 sbm-label text-left text-sm-right">@Localiser["label.type"]</div>
<div class="col-8 col-sm-8">
@Html.DropDownList("Filter.AddressType", Model.GetAddressTypeCodesForFilterDropdown(), Localiser["label.any"], new { @id = "", @class = "FilterAddressType sbm-select" })
</div>
</div>
<div class="col-sm-4 row pb4">
@* Address filter - name etc. *@
<div class="col-4 col-sm-4 sbm-label text-left text-sm-right">@Localiser["label.search"]</div>
<div class="col-8 col-sm-8">
@Html.TextBox("Filter.Search", "", new { @type = "search", @id = "", @class = "FilterSearch sbm-input", @maxlength = "32" })
</div>
</div>
</div>
</div>
}
@* Element templates *@
<div class="sbm-panel-item-template">
@* Select Address Dialog Titlebar content *@
<div class="sbm-panel-header">
<div class="row">
<div class="col"><partial name="~/Views/Common/ResultsPaging.cshtml" /></div>
<div class="fixed center"><div class="sbm-panel-caption">@Localiser["label.addresses"]</div></div>
<div class="col right">
@* Burger menu *@
<ul class="nav navbar-nav navbar-dark navbar-right sbm-burger">
<li class="dropdown-toggle caret-off">
<a href="#" class="dropdown" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="navbar-toggler-icon"></span></a>
<ul class="dropdown-menu dropdown-menu-right sbm-dropdown-menu">@* Menu items will be inserted here. *@</ul>
</li>
</ul>
</div>
</div>
</div>
@* Dialog burger dropdown template is defined in Address List panel. *@
</div>
@* Address List panel. *@
<partial name="Panel-AddressList.cshtml" />
</div>
@* Address Dialog. *@
<partial name="Panel-AddressDialog.cshtml" />
@@ -15,7 +15,7 @@
<th class="@Model_Asset.GetFieldName(Model_Asset.ItemField.Caption) width25pc">@Localiser["label.description"]</th>
<th class="@Model_Asset.GetFieldName(Model_Asset.ItemField.Notes) width25pc d-none d-md-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Asset.GetFieldName(Model_Asset.ItemField.Status) width10pc center">@Localiser["label.status"]</th>
<th class="@Model_Asset.GetFieldName(Model_Asset.ItemField.Actions) width5pc right" style="width:2%;"></th>
<th class="@Model_Asset.GetFieldName(Model_Asset.ItemField.Actions) width2pc right"></th>
</tr>
<tr><td colspan="6"><div class="sbm-panel-messages"></div></td></tr>
</thead>
@@ -6,6 +6,10 @@
/* NB Can potentially appear more than once on a page. */
}
<script type="text/javascript">
sbm.lbl.addresses = '@(Localiser.GetJavascriptText("label.addresses"))';
</script>
@* Item list *@
<div class="sbm-panel-item-table sbm-flex">
<table class="sbm-item-list">
@@ -67,7 +67,10 @@
<partial name="Panel-AssociationDialog.cshtml" />
</div>
@* Contact panels. *@
<partial name="~/Views/Contact/Panel-ContactSelect.cshtml" />
<partial name="~/Views/Contact/Panel-ContactDialog.cshtml" />
@* Address panels. *@
<partial name="~/Views/Address/Panel-AddressSelect.cshtml" />
<partial name="~/Views/Address/Panel-AddressDialog.cshtml" />
@@ -21,7 +21,7 @@
}
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Notes) width25pc d-none d-md-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Status) width5pc center">@Localiser["label.status"]</th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Actions) width5pc right" style="width:2%;"></th>
<th class="@Model_Commodity.GetFieldName(Model_Commodity.ItemField.Actions) width2pc right"></th>
</tr>
<tr><td colspan="6"><div class="sbm-panel-messages"></div></td></tr>
</thead>
@@ -47,13 +47,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Organisation Abbreviation *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.Abbreviation)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactAbbreviation"><span class="sbm-control-label">@Localiser["label.abbreviation"]</span></label>
</div>
@@ -108,13 +107,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Organisation Contact *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.Contact)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactContact"><span class="sbm-control-label">@Localiser["label.contact"]</span></label>
</div>
@@ -157,13 +155,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Individual Salutation *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.Salutation)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactSalutation"><span class="sbm-control-label">@Localiser["label.salutation"]</span></label>
</div>
@@ -201,13 +198,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Individual Initials *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.Initials)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactInitials"><span class="sbm-control-label">@Localiser["label.initials"]</span></label>
</div>
@@ -262,13 +258,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Organisation Alt Phone *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.PhoneAlt)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactPhoneAlt"><span class="sbm-control-label">@Localiser["label.phone.alt"]</span></label>
</div>
@@ -285,7 +280,7 @@
@* Individual Mobile Phone *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.PhoneMobile)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactPhoneMobile"><span class="sbm-control-label">@Localiser["label.phone.mobile"]</span></label>
</div>
@@ -323,13 +318,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Organisation Fax *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.PhoneFax)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactPhoneFax"><span class="sbm-control-label">@Localiser["label.phone.fax"]</span></label>
</div>
@@ -401,13 +395,12 @@
</div>
</div>
<div class="col-sm-1"></div>
<div class="col-sm">
@* Organisation VAT registration number *@
<div class="sbm-form-control @Model_Contact.GetFieldName(Model_Contact.ItemField.VatReg)">
<div class="row">
<div class="col-sm-5">
<div class="col-sm-6">
<div class="sbm-label">
<label for="ifContactVatReg"><span class="sbm-control-label">@Localiser["label.vat.reg"]</span></label>
</div>
@@ -7,6 +7,8 @@
}
<script type="text/javascript">
sbm.lbl.addresses = '@(Localiser.GetJavascriptText("label.addresses"))';
sbm.lbl.contact = '@(Localiser.GetJavascriptText("label.contact"))';
</script>
@* Item list *@
@@ -22,7 +24,7 @@
<th class="@Model_Contact.GetFieldName(Model_Contact.ItemField.Notes) width25pc d-none d-md-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Contact.GetFieldName(Model_Contact.ItemField.Associations) width10pc center">@Localiser["label.associations"]</th>
<th class="@Model_Contact.GetFieldName(Model_Contact.ItemField.Status) width5pc center">@Localiser["label.status"]</th>
<th class="@Model_Contact.GetFieldName(Model_Contact.ItemField.Actions) width5pc right" style="width:2%;"></th>
<th class="@Model_Contact.GetFieldName(Model_Contact.ItemField.Actions) width2pc right"></th>
</tr>
<tr><td colspan="6"><div class="sbm-panel-messages"></div></td></tr>
</thead>
@@ -73,3 +73,7 @@
@* Association panels. *@
<partial name="~/Views/Association/Panel-AssociationSelect.cshtml" />
<partial name="~/Views/Association/Panel-AssociationDialog.cshtml" />
@* Address panels. *@
<partial name="~/Views/Address/Panel-AddressSelect.cshtml" />
<partial name="~/Views/Address/Panel-AddressDialog.cshtml" />
@@ -25,7 +25,7 @@
@* Contact type *@
<div class="col-4 col-sm-4 sbm-label text-left text-sm-right">@Localiser["label.type"]</div>
<div class="col-8 col-sm-8">
@Html.DropDownList("Filter.ContactType", Model.GetAffiliateTypeCodesForFilterDropdown(), Localiser["label.any"], new { @id = "", @class = "FilterContactType sbm-select" })
@Html.DropDownList("Filter.ContactType", Model.GetAffiliateTypeCodesForFilterDropdown(Sbm.AffiliateType.ContactGroup), Localiser["label.any"], new { @id = "", @class = "FilterContactType sbm-select" })
</div>
</div>
<div class="col-sm-4 row pb4">
@@ -22,7 +22,7 @@
}
<th class="@Model_Requirement.GetFieldName(Model_Requirement.ItemField.Notes) width25pc d-none d-md-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Requirement.GetFieldName(Model_Requirement.ItemField.Status) width5pc center">@Localiser["label.status"]</th>
<th class="@Model_Requirement.GetFieldName(Model_Requirement.ItemField.Actions) width5pc right" style="width:2%;"></th>
<th class="@Model_Requirement.GetFieldName(Model_Requirement.ItemField.Actions) width2pc right"></th>
</tr>
<tr><td colspan="6"><div class="sbm-panel-messages"></div></td></tr>
</thead>
@@ -56,10 +56,12 @@
@* Scripts *@
<script type="text/javascript">
var sbm = sbm || { page: {}, mdl: {}, fn: {}, url: {}, links: {}, data: {}, form: {}, ajax: {}, msg: {}, lbl: {}, dlg: { title: {}, btn: {} }, $frm: {}, $dlg: {}, $pnl: {}, session: {}, kli: {} };
var sbm = sbm || { page: {}, mdl: {}, fn: {}, url: {}, links: {}, data: {}, itemType:{}, form: {}, ajax: {}, msg: {}, lbl: {}, dlg: { title: {}, btn: {} }, $frm: {}, $dlg: {}, $pnl: {}, session: {}, kli: {} };
sbm.url.base = '@Model.RedirectLocation.Base';
sbm.url.home = '@Model.RedirectLocation.Home';
sbm.url.sessionExpired = '@Model.RedirectLocation.Home_SessionExpired';
sbm.itemType.contact = @((int)Sbm.ItemType.Affiliate);
sbm.itemType.association = @((int)Sbm.ItemType.Association);
sbm.form.calendarDateFormat = '@(Model.CalendarDateFormat)';
sbm.lbl.refresh = '@(Localiser.GetJavascriptText("label.refresh"))';
sbm.lbl.create = '@(Localiser.GetJavascriptText("label.create"))';
@@ -29,7 +29,7 @@
}
<th class="@Model_Transaction.GetFieldName(Model_Transaction.ItemField.Notes) width15pc d-none d-lg-table-cell">@Localiser["label.notes"]</th>
<th class="@Model_Transaction.GetFieldName(Model_Transaction.ItemField.Status) width5pc center">@Localiser["label.status"]</th>
<th class="@Model_Transaction.GetFieldName(Model_Transaction.ItemField.Actions) width5pc right" style="width:2%;"></th>
<th class="@Model_Transaction.GetFieldName(Model_Transaction.ItemField.Actions) width2pc right"></th>
</tr>
<tr><td colspan="6"><div class="sbm-panel-messages"></div></td></tr>
</thead>
@@ -5,6 +5,7 @@
@using Sarand.BusinessMgr.Web.Portal.Models.Home
@using Sarand.BusinessMgr.Web.Portal.Models.Security
@using Sarand.BusinessMgr.Web.Portal.Models.Contacts
@using Sarand.BusinessMgr.Web.Portal.Models.Addresses
@using Sarand.BusinessMgr.Web.Portal.Models.Commodities
@using Sarand.BusinessMgr.Web.Portal.Models.Transactions
@using Sarand.BusinessMgr.Web.Portal.Models.Requirements
@@ -212,6 +212,16 @@ td.action
text-align: center;
}
.width1pc
{
width: 1%;
}
.width2pc
{
width: 2%;
}
.width5pc
{
width: 5%;
@@ -23,13 +23,71 @@
--color-Burgundy: #800020;
--color-BrightPurple: #bf40bf;
--color-DarkPink: #aa336a;
/* Pastels */
--color-Pastel-DarkYellow: #ffd400;
--color-Pastel-MidYellow: #ffea61;
--color-Pastel-LightYellow: #ffffb7;
--color-Pastel-DarkOrange: #ff9e4e;
--color-Pastel-MidOrange: #ffb577;
--color-Pastel-LightOrange: #ffd9aa;
--color-Pastel-DarkDeepOrange: #d65d26;
--color-Pastel-MidDeepOrange: #e07c4f;
--color-Pastel-LightDeepOrange: #e89c7b;
--color-Pastel-DarkPink: #ffd6f3;
--color-Pastel-MidPink: #ffdef5;
--color-Pastel-LightPink: #ffe6f7;
--color-Pastel-DarkRedPink: #ffb0b0;
--color-Pastel-MidRedPink: #ffd8d8;
--color-Pastel-LightRedPink: #ffeaea;
--color-Pastel-DarkStrawberry: #ff9c9c;
--color-Pastel-MidStrawberry: #ffcccc;
--color-Pastel-LightStrawberry: #fff0f0;
--color-Pastel-DarkRed: #ee6969;
--color-Pastel-MidRed: #fdaaaa;
--color-Pastel-LightRed: #fde0e0;
--color-Pastel-DarkBrown: #ccb79c;
--color-Pastel-MidBrown: #cebaa0;
--color-Pastel-LightBrown: #dfc7a7;
--color-Pastel-DarkGreen: #b8d8be;
--color-Pastel-MidGreen: #d2e7d6;
--color-Pastel-LightGreen: #e8f4ea;
--color-Pastel-DarkOliveGreen: #8eb15c;
--color-Pastel-MidOliveGreen: #b1cf86;
--color-Pastel-LightOliveGreen: #d2e6b5;
--color-Pastel-DarkMintOmbre: #aafbdc;
--color-Pastel-MidMintOmbre: #cffff2;
--color-Pastel-LightMintOmbre: #e6fff8;
--color-Pastel-DarkMintParty: #abd2b6;
--color-Pastel-MidMintParty: #c9e7d2;
--color-Pastel-LightMintParty: #dcf0e2;
--color-Pastel-DarkMintBlue: #b1d3c8;
--color-Pastel-MidMintBlue: #ace2d3;
--color-Pastel-LightMintBlue: #b1efe0;
--color-Pastel-DarkMintBleu: #6984a3;
--color-Pastel-MidMintBleu: #8aa4c5;
--color-Pastel-LightMintBleu: #abc4e7;
--color-Pastel-DarkPaleBlue: #92dff3;
--color-Pastel-MidPaleBlue: #b7e9f6;
--color-Pastel-LightPaleBlue: #dbf3fa;
--color-Pastel-DarkBlue: #d6deff;
--color-Pastel-MidBlue: #dee4ff;
--color-Pastel-LightBlue: #e6ebff;
--color-Pastel-DarkBlueOwo: #72d3fe;
--color-Pastel-MidBlueOwo: #98ddfc;
--color-Pastel-LightBlueOwo: #bbeaff;
--color-Pastel-DarkPurple: #e0d6ff;
--color-Pastel-MidPurple: #e6deff;
--color-Pastel-LightPurple: #ece6ff;
--color-Pastel-DarkDeepPurple: #ada2ff;
--color-Pastel-MidDeepPurple: #b7adff;
--color-Pastel-LightDeepPurple: #c5bef9;
}
/* Data panel */
:root
{
--color-panel-data: var(--color-OliveGreen);
--color-panel-data: var(--color-Pastel-DarkBlue);
}
.Contacts .sbm-panel-data
@@ -37,6 +95,11 @@
--color-panel-data: var(--color-KellyGreen);
}
.Addresses .sbm-panel-data
{
--color-panel-data: var(--color-OliveGreen);
}
.Associations .sbm-panel-data
{
--color-panel-data: var(--color-ForestGreen);
@@ -77,7 +140,7 @@
:root
{
--color-dialog: var(--color-OldGold);
--color-dialog: var(--color-Pastel-DarkBlue);
}
.ui-dialog.sbm-dark-blue
@@ -90,6 +153,11 @@
--color-dialog: var(--color-KellyGreen);
}
.ui-dialog.sbm-Address
{
--color-dialog: var(--color-OliveGreen);
}
.ui-dialog.sbm-Association
{
--color-dialog: var(--color-ForestGreen);
@@ -65,7 +65,7 @@
.sbm-form .sbm-form-control
{
margin: 0 0 16px 0;
margin: 0 0 12px 0;
}
.sbm-form .sbm-form-control .sbm-form-control
@@ -75,7 +75,8 @@
.sbm-form .sbm-form-control .sbm-label
{
margin: 2px 0 8px 0;
margin: 2px 12px 8px 0;
text-align: right;
}
.sbm-form .sbm-form-control .sbm-label,
@@ -0,0 +1,355 @@
/*
* Address page scripts.
*/
(function (win, doc, undef)
{
"use strict";
let ad = sbm.mdl.addresses = { env: {} };
//--------------------------------------------------------------
ad.refreshConfig = function (env, delay)
{
env.ajax.refreshConfig = env.ajax.refreshConfig || { url: sbm.url.base + 'Address/Ajax/Config', formSel: env.$frm.filter, callbackFn: function (response) { ad.doRefreshConfig(env, response); } };
sbm.doAjaxRequest(env.ajax.refreshConfig, delay || 50);
}
ad.doRefreshConfig = function (env, response)
{
//sbm.debug('doRefreshConfig', env, response);
if (!response.success) return;
Object.assign(env.data, response.data);
}
//--------------------------------------------------------------
ad.refreshResults = function (env, delay)
{
if (!ad.awaitingRefreshResponse)
{
env.$pnl.bgr.invisible();
env.$pnl.table.find('tbody tr').remove();
env.$pnl.msgs.hide().empty().append($('<div class="sbm-message">' + sbm.msg.dataQuerying + '</div>')).fadeIn(200);
}
env.ajax.refreshResults = env.ajax.refreshResults || { url: sbm.url.base + 'Address/Ajax/List', formSel: env.$frm.filter, callbackFn: function (response) { ad.doRefreshResults(env, response); } };
sbm.doAjaxRequest(env.ajax.refreshResults, delay || 50);
ad.awaitingRefreshResponse = true;
}
ad.doRefreshResults = function (env, response)
{
//sbm.debug('doRefreshResults', env, response);
delete ad.awaitingRefreshResponse;
env.$pnl.msgs.hide().empty();
let $table = $('table', env.$pnl.table).find('tbody tr').remove().end();
sbm.refreshPaging(response, env.$frm.filter, function () { ad.refreshResults(env); });
if (!response.success) return;
ad.doRefreshConfig(env, response);
env.mode = response.mode;
let cfgList = env.data.cfgList;
// Menu.
if (env.$pnl.bgr.length)
{
env.$pnl.bgr.invisible();
env.$pnl.mnu.empty();
env.$pnl.mnu.append(ad.getFilterMenuOption(env, sbm.lbl.refresh, function () { ad.refreshResults(env); }, 'sbm-refresh'));
if (cfgList.action.allow.create) env.$pnl.mnu.append(ad.getFilterMenuOption(env, sbm.lbl.create, function () { ad.createItem(env, env.data.cfgItemNew); }, 'sbm-add'));
env.$pnl.bgr.toggleVisibility(!!$('.sbm-dropdown-item', env.$pnl.mnu).length);
}
// Items.
let items = response.addresses || [];
if (!items.length)
return env.$pnl.msgs.append($('<div class="sbm-message">' + sbm.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let item of items)
$table.append(ad.populateItem(env, ad.getItemTemplate(env), item));
sbm.configureItemTable(cfgList, $table);
}
ad.populateItem = function (env, $item, item)
{
if (!item) return $item;
$item.prop('id', ad.getItemId(item));
let cfgList = env.data.cfgList;
if (cfgList) sbm.populateItemValues(cfgList, $item, item.field.value);
let prefix = cfgList.column.prefix;
$item.find('.AddrPrimary').empty().append(item.primary ? $('<img src="/img/action/accept16.png" />') : null);
$('.' + prefix + 'Status', $item).text(item.statusDesc).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase());
if (!env.mode.search)
{
// Actions.
var $bgr = $('.sbm-burger', $item).hide();
let $mnu = $('ul.sbm-dropdown-menu', $bgr).empty();
if (!item.deleted)
{
let fnUpd = function () { ad.updateItem(env, item.id) };
$mnu.append(ad.getItemMenuOption(env, sbm.lbl.edit, fnUpd, 'sbm-edit'));
$mnu.append(ad.getItemMenuOption(env, sbm.lbl.setPrimary, function () { ad.setPrimary(env, $item, item); }, 'sbm-process'));
$('.AddressCode,.AddressDesc', $item).off('click').on('click', fnUpd).addClass('sbm-action-text');
$item.off('dblclick').on('dblclick', fnUpd);
}
$bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length);
}
else
{
$item.off('click').on('click', function () { ad.selectItemRow(env, $item, item); });
$item.off('dblclick').on('dblclick', function () { ad.selectItem(env); });
}
return $item;
}
ad.getItemId = function (item)
{
return 'Cmd_' + (item || {}).id;
}
//--------------------------------------------------------------
ad.getFilterDropdownTemplate = function (env)
{
return $('.sbm-dropdown-menu.AddressList li.sbm-dropdown-item', env.$pnl.tmpl).clone();
}
ad.getItemTemplate = function (env)
{
return $('table tr.sbm-row-item.Address', env.$pnl.tmpl).clone();
}
ad.getItemDropdownTemplate = function (env)
{
return $('.sbm-dropdown-menu.Address li.sbm-dropdown-item', env.$pnl.tmpl).clone();
}
//--------------------------------------------------------------
ad.getFilterMenuOption = function (env, lbl, fn, cls)
{
return ad.getMenuOption(ad.getFilterDropdownTemplate(env), lbl, fn, cls);
}
ad.getItemMenuOption = function (env, lbl, fn, cls)
{
return ad.getMenuOption(ad.getItemDropdownTemplate(env), lbl, fn, cls);
}
ad.getMenuOption = function ($opt, lbl, fn, cls)
{
return $opt.find('div.sbm-label').text(lbl).end().on('click', fn).addClass(cls);
}
//--------------------------------------------------------------
ad.setPrimary = function (env, $item, item)
{
let $frm = env.$frm.itemId;
$('.AddressId', $frm).val(item.id);
let fn = function (env, response) { ad.refreshResults(env); };
env.ajax.setPrimary = env.ajax.setPrimary || { url: sbm.url.base + 'Address/Ajax/SetPrimary', formSel: $frm, callbackFn: function (response) { fn(env, response); } };
sbm.doAjaxRequest(env.ajax.setPrimary, 50);
}
//--------------------------------------------------------------
ad.createItem = function (env, cfg)
{
ad.clearItem(env, cfg);
let $frm = env.$frm.item;
$frm.find('.AddressType').val(env.data.addressTypeDefault);
$frm.find('.AddressStatus').val(env.data.defaultStatusCode);
ad.openItemDlg(env, cfg, sbm.dlg.title.createAddress);
}
ad.clearItem = function (env, cfg)
{
sbm.clearItemForm(env.$frm.item);
env.$ctrl.addrItemType.val(env.$ctrl.filterItemType.val());
env.$ctrl.addrItemId.val(env.$ctrl.filterItemId.val());
env.$ctrl.addrItemCaption.val(env.$ctrl.filterItemCaption.val());
sbm.populateSelectCodeDesc('#cbAddressType', env.data.addressTypes);
sbm.populateSelectCodeDesc('#cbAddressStatus', env.data.statuses);
}
ad.openItemDlg = function (env, cfg, title)
{
let $dlg = env.$dlg.item;
let $frm = env.$frm.item;
sbm.configureItemControls(cfg, $frm);
var btns = {};
btns[sbm.lbl.ok] = function () { ad.storeItem(env); };
btns[sbm.lbl.cancel] = function () { delete env.prmEdit; $(this).dialog('close'); };
$dlg.dialog('option', 'buttons', btns);
if (title) $dlg.dialog('option', 'title', title);
sbm.openDialog($dlg, 720, 640);
}
//--------------------------------------------------------------
ad.updateItem = function (env, id)
{
let $frm = env.$frm.itemId;
$('.AddressId', $frm).val(id);
env.ajax.updateItem = env.ajax.updateItem || { url: sbm.url.base + 'Address/Ajax/GetItem', formSel: $frm, callbackFn: function (response) { ad.onUpdateItem(env, response); } };
sbm.doAjaxRequest(env.ajax.updateItem, 50);
}
ad.onUpdateItem = function (env, response)
{
//sbm.debug('onUpdateItem', env, response);
if (!response.success) return;
let cfg = response.config || {};
ad.clearItem(env, cfg);
let item = response.address;
let $frm = env.$frm.item;
sbm.populateFormValues(cfg, $frm, item.field.value);
let $ctrls = $frm.find('.sbm-input,.sbm-textarea,.sbm-select');
$ctrls.filter('.AddressId').val(item.id);
$ctrls.filter('.AddressExists').val(1);
sbm.selectOrAdd($ctrls.filter('.AddressType'), item.typeCode, item.typeDesc);
$ctrls.filter('.AddressSalePackQty').off('blur').on('blur', function () { sbm.formatNumber($(this), cfg.decimals.packQty); }).trigger('blur');
sbm.selectOrAdd($ctrls.filter('.AddressStatus'), item.statusCode, item.field.value.Status);
ad.openItemDlg(env, cfg, sbm.dlg.title.updateAddress);
}
//--------------------------------------------------------------
ad.storeItem = function (env)
{
env.ajax.storeItem = env.ajax.storeItem || { url: sbm.url.base + 'Address/Ajax/StoreItem', formSel: env.$frm.item, callbackFn: function (response) { ad.onStoreItem(env, response); } };
sbm.doAjaxRequest(env.ajax.storeItem, 50);
}
ad.onStoreItem = function (env, response)
{
sbm.debug('onStoreItem', env, response);
sbm.refreshControlValues(response.controlValues);
if (!response.success) return;
env.$dlg.item.dialog('close');
var item = response.address;
if (env.prmEdit)
{
ad.onItemEdited(env, item);
}
else if (env.$pnl.table.length)
{
env.$pnl.msgs.hide().empty();
var $item = $('#' + ad.getItemId(item), env.$pnl.table);
if (!$item.length)
{
$item = ad.getItemTemplate(env);
$('table tbody', env.$pnl.table).prepend($item).show();
}
ad.populateItem(env, $item, item);
sbm.configureItemTable(env.data.cfgList, env.$pnl.table);
}
}
//--------------------------------------------------------------
/* Params: item{type,id,caption}, type, search, fnSuccess. */
sbm.fn.maintainAddresses = function (prm)
{
let env = ad.env.select;
env.prmMaintain = prm = { mode: 'Maintain', ...prm };
ad.listAddresses(env, prm);
}
sbm.fn.selectAddress = function (prm)
{
let env = ad.env.select;
env.prmSelect = prm = { mode: 'Search', ...prm };
ad.listAddresses(env, prm);
}
ad.listAddresses = function (env, prm)
{
//sbm.debug('listAddresses', prm);
if (!env.$pnl.items.length) return;
env.$ctrl.filterMode.val(prm.mode || 'Search');
env.$frm.filter.find('.AddressFilterItem .sbm-label').text(prm.item.label || sbm.lbl.item);
env.$ctrl.filterItemType.val(prm.item.type || '');
env.$ctrl.filterItemId.val(prm.item.id || '');
env.$ctrl.filterItemCaption.val(prm.item.caption || '');
env.$ctrl.filterAddressType.val(prm.type || '');
env.$ctrl.filterSearch.val(prm.search || '');
env.$pnl.table.find('tbody tr').remove();
let btns = {};
if (env.prmMaintain)
btns = { [sbm.lbl.close]: function () { if (env.prmMaintain.fnSuccess) { env.prmMaintain.fnSuccess(); } delete env.prmMaintain; $(this).dialog('close'); } };
else if (env.prmSelect)
btns = { [sbm.lbl.ok]: function () { ad.selectItem(env); }, [sbm.lbl.cancel]: function () { delete env.prmSelect; $(this).dialog('close'); } };
else return;
sbm.openDialog(env.$dlg.select.dialog('option', 'buttons', btns), 1000, 800);
setTimeout(function () { ad.refreshResults(env); }, 250);
}
ad.selectItemRow = function (env, $item, item)
{
//sbm.debug('selectItemRow', env, $item, item);
env.$pnl.table.find('tr').removeClass('sbm-sel');
$item.addClass('sbm-sel');
env.prmSelect.item = item;
}
ad.selectItem = function (env)
{
//sbm.debug('selectItem', env, env.prmSelect.item);
env.$dlg.select.dialog('close');
env.prmSelect.fnSuccess(env.prmSelect.item);
delete env.prmMaintain, env.prmSelect;
}
/* Params: id, fnSuccess. */
sbm.fn.editAddress = function (prm)
{
//sbm.debug('editAddress', prm);
let env = ad.env.select;
env.prmEdit = prm;
//sbm.debug(env, prm);
ad.updateItem(env, prm.id);
}
ad.onItemEdited = function (env, item)
{
//sbm.debug('ad.onItemEdited', env, item);
env.prmEdit.fnSuccess(item);
delete env.prmEdit;
}
//--------------------------------------------------------------
ad.initEnv = function ($pnlItems)
{
let env = { mode: { search: 1 }, data: {}, ajax: {}, $pnl: {}, $frm: {}, $ctrl: {}, $dlg: {} };
let $items = env.$pnl.items = $($pnlItems);
if (!$items.length) return env;
env.$pnl.hdr = $items.find('.sbm-panel-header');
env.$pnl.bgr = env.$pnl.hdr.find('.sbm-burger').invisible();
env.$pnl.mnu = env.$pnl.bgr.find('ul.sbm-dropdown-menu');
env.$pnl.table = $items.find('.sbm-panel-item-table');
env.$pnl.msgs = env.$pnl.table.find('.sbm-panel-messages');
env.$pnl.tmpl = $items.find('.sbm-panel-item-template');
env.$frm.filter = $items.find('.frmAddressFilter');
env.$frm.filter.on('input', '.FilterSearch', function () { ad.refreshResults(env, 250); }).on('change', '.FilterAddressType,.FilterStatusCat', function () { ad.refreshResults(env, 50); });
env.$ctrl.filterMode = env.$frm.filter.find('.FilterMode');
env.$ctrl.filterItemType = env.$frm.filter.find('.FilterItemType');
env.$ctrl.filterItemId = env.$frm.filter.find('.FilterItemId');
env.$ctrl.filterItemCaption = env.$frm.filter.find('.FilterItemCaption');
env.$ctrl.filterAddressType = env.$frm.filter.find('.FilterAddressType');
env.$ctrl.filterSearch = env.$frm.filter.find('.FilterSearch');
env.$frm.itemId = $('#frmAddressId');
var opt = sbm.dlgOpts();
opt.dialogClass += " sbm-Address";
env.$dlg.item = $('#dlgAddress').dialog(opt);
env.$frm.item = env.$dlg.item.find('#frmAddress').off('input').on('input', '.sbm-input, .sbm-textarea', function () { sbm.clearControlError(this); }).off('change').on('change', '.sbm-select', function () { sbm.clearControlError(this); });
env.$frm.item.off('blur').on('blur', '.sbm-input.sbm-format-integer', function () { sbm.formatInteger($(this)); }).off('blur').on('blur', '.sbm-input.sbm-format-currency', function () { sbm.formatCurrency($(this)); });
sbm.initCalendars(env.$frm.item.find('.sbm-input.sbm-calendar'), {});
env.$ctrl.addrItemType = env.$frm.item.find('.AddrItemType');
env.$ctrl.addrItemId = env.$frm.item.find('.AddrItemId');
env.$ctrl.addrItemCaption = env.$frm.item.find('.AddrItemCaption');
let $dlgSelect = $('#dlgAddressSelect');
if ($dlgSelect.length)
{
var opt = sbm.dlgOpts();
opt.dialogClass += " sbm-Address";
env.$dlg.select = $dlgSelect.dialog(opt);
env.$dlg.select.parent().find('.ui-dialog-titlebar').empty().append(env.$pnl.tmpl.find('.sbm-panel-header').remove());
}
return env;
}
//--------------------------------------------------------------
$(function ()
{
ad.env.maint = ad.initEnv('.sbm-panel.Addresses');
if (ad.env.maint.$pnl.items.length)
{
$('body').on('keydown', function (e) { let env = ad.env.maint; if (e.which == 45/*Insert*/ && env.data.cfgList.action.allow.create) ad.createItem(env, env.data.cfgItemNew); });
setTimeout(function () { ad.refreshResults(ad.env.maint); }, 250);
}
ad.env.select = ad.initEnv('#dlgAddressSelect');
if (ad.env.select.$pnl.items.length) setTimeout(function () { ad.refreshConfig(ad.env.select); }, 250);
});
//--------------------------------------------------------------
}(window, window.document));
/* The End */
@@ -6,7 +6,7 @@
(function (win, doc, undef)
{
"use strict";
let ac = sbm.AssetCats = { env: {} };
let ac = sbm.assetCats = { env: {} };
//--------------------------------------------------------------
ac.refreshConfig = function (env, delay)
@@ -6,7 +6,7 @@
(function (win, doc, undef)
{
"use strict";
let as = sbm.Assets = { env: {} };
let as = sbm.assets = { env: {} };
//--------------------------------------------------------------
as.refreshConfig = function (env, delay)
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let as = sbm.mdl.Associations = { env: {} };
let as = sbm.mdl.assocs = { env: {} };
//--------------------------------------------------------------
as.refreshConfig = function (env, delay)
@@ -80,6 +80,7 @@
{
let fnUpd = function () { as.updateItem(env, item.id) };
$mnu.append(as.getItemMenuOption(env, sbm.lbl.edit, fnUpd, 'sbm-edit'));
$mnu.append(as.getItemMenuOption(env, sbm.lbl.addresses, function () { as.maintainAddresses(env, $item, item); }, 'sbm-mail'));
$('.' + prefix + 'Target', $item).off('click').on('click', fnUpd).addClass('sbm-action-text');
$item.off('dblclick').on('dblclick', fnUpd);
}
@@ -125,6 +126,25 @@
return $opt.find('div.sbm-label').text(lbl).end().on('click', fn).addClass(cls);
}
//--------------------------------------------------------------
as.maintainAddresses = function (env, $item, item)
{
sbm.fn.maintainAddresses({ item: { label: item.field.value.Type, type: sbm.itemType.contact, id: item.targetId, caption: item.targetName }, fnSuccess: function () { as.refreshItem(env, $item, item); } });
}
as.refreshItem = function (env, $item, item)
{
let $frm = env.$frm.itemId;
$('.AssociationId', $frm).val(item.id);
let fn = function (env, response)
{
if (!response.success) return;
as.populateItem(env, $item, response.association);
sbm.configureItemTable(env.data.cfgList, env.$pnl.table);
}
sbm.doAjaxRequest(env.ajax.refreshItem = env.ajax.refreshItem || { url: sbm.url.base + 'Association/Ajax/GetItem', formSel: $frm, callbackFn: function (response) { fn(env, response); } }, 50);
}
//--------------------------------------------------------------
as.createItem = function (env, cfg, title, target)
{
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let co = sbm.mdl.Commodities = { env: {} };
let co = sbm.mdl.commodities = { env: {} };
//--------------------------------------------------------------
co.refreshConfig = function (env, delay)
@@ -6,7 +6,7 @@
(function (win, doc, undef)
{
"use strict";
let ct = sbm.CodeTypes = { env: {} };
let ct = sbm.codeTypes = { env: {} };
//--------------------------------------------------------------
ct.refreshResults = function (env, delay)
@@ -6,7 +6,7 @@
(function (win, doc, undef)
{
"use strict";
let cd = sbm.Codes = { env: {} };
let cd = sbm.codes = { env: {} };
//--------------------------------------------------------------
cd.refreshResults = function (env, delay)
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let co = sbm.mdl.Contacts = { env: {} };
let co = sbm.mdl.contacts = { env: {} };
//--------------------------------------------------------------
co.refreshConfig = function (env, delay)
@@ -81,8 +81,9 @@
let fnUpd = function () { co.updateItem(env, item.id) };
$mnu.append(co.getItemMenuOption(env, sbm.lbl.edit, fnUpd, 'sbm-edit'));
$item.off('dblclick').on('dblclick', fnUpd).find('.' + prefix + 'Name').off('click').on('click', fnUpd).addClass('sbm-action-text');
if (!item.isOwner && !item.isCust) $mnu.append(co.getItemMenuOption(env, sbm.lbl.createCust, function () { co.createCustomer(env, item.id, item.name); }, 'sbm-add'));
if (!item.isOwner && !item.isSupp) $mnu.append(co.getItemMenuOption(env, sbm.lbl.createSupp, function () { co.createSupplier(env, item.id, item.name); }, 'sbm-add'));
if (!item.isOwner && !item.isCust) $mnu.append(co.getItemMenuOption(env, sbm.lbl.createCust, function () { co.createCustomer(env, $item, item); }, 'sbm-add'));
if (!item.isOwner && !item.isSupp) $mnu.append(co.getItemMenuOption(env, sbm.lbl.createSupp, function () { co.createSupplier(env, $item, item); }, 'sbm-add'));
$mnu.append(co.getItemMenuOption(env, sbm.lbl.addresses, function () { co.maintainAddresses(env, $item, item); }, 'sbm-mail'));
}
$bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length);
}
@@ -126,6 +127,39 @@
return $opt.find('div.sbm-label').text(lbl).end().on('click', fn).addClass(cls);
}
//--------------------------------------------------------------
co.createCustomer = function (env, $item, item)
{
co.createAssociation(env, $item, item, 'CUS');
}
co.createSupplier = function (env, $item, item)
{
co.createAssociation(env, $item, item, 'SUP');
}
co.createAssociation = function (env, $item, item, type)
{
sbm.fn.createAssociation({ type: type, target: { id: item.id, name: item.name }, fnSuccess: function () { co.refreshItem(env, $item, item); } });
}
//--------------------------------------------------------------
co.maintainAddresses = function (env, $item, item)
{
sbm.fn.maintainAddresses({ item: { label: sbm.lbl.contact, type: sbm.itemType.contact, id: item.id, caption: item.name }, fnSuccess: function () { co.refreshItem(env, $item, item); } });
}
co.refreshItem = function (env, $item, item)
{
let $frm = env.$frm.itemId;
$('.ContactId', $frm).val(item.id);
let fn = function (env, response)
{
if (!response.success) return;
co.populateItem(env, $item, response.contact);
sbm.configureItemTable(env.data.cfgList, env.$pnl.table);
}
sbm.doAjaxRequest(env.ajax.refreshItem = env.ajax.refreshItem || { url: sbm.url.base + 'Contact/Ajax/GetItem', formSel: $frm, callbackFn: function (response) { fn(env, response); } }, 50);
}
//--------------------------------------------------------------
co.createItem = function (env, cfg, title)
{
@@ -167,7 +201,7 @@
}
co.onUpdateItem = function (env, response)
{
//sbm.debug('onUpdateItem', env, response);
sbm.debug('onUpdateItem', env, response);
if (!response.success) return;
let cfg = response.config || {};
co.clearItem(env, cfg);
@@ -183,27 +217,6 @@
co.openItemDlg(env, cfg, sbm.dlg.title.updateContact);
}
//--------------------------------------------------------------
co.createCustomer = function (env, id, name)
{
co.createAssociation(env, 'CUS', id, name);
}
co.createSupplier = function (env, id, name)
{
co.createAssociation(env, 'SUP', id, name);
}
co.createAssociation = function (env, type, id, name)
{
sbm.fn.createAssociation({ type: type, target: { id: id, name: name }, fnSuccess: function (item) { co.onCreateAssociation(env, item); } });
}
co.onCreateAssociation = function (env, item)
{
//sbm.debug('onCreateAssociation', env, item);
let $frm = env.$frm.itemId;
$('.ContactId', $frm).val(item.id);
sbm.doAjaxRequest(env.ajax.refreshItem = env.ajax.refreshItem || { url: sbm.url.base + 'Contact/Ajax/GetItem', formSel: $frm, callbackFn: function (response) { co.onStoreItem(env, response); } }, 50);
}
//--------------------------------------------------------------
co.storeItem = function (env)
{
@@ -325,7 +338,6 @@
co.env.maint = co.initEnv('.sbm-panel.Contacts');
if (co.env.maint.$pnl.items.length) setTimeout(function () { co.refreshResults(co.env.maint); }, 250);
co.env.select = co.initEnv('#dlgContactSelect');
co.env.select.$frm.filter.find('.FilterContactType option[value="GRP"]').remove();
if (co.env.select.$pnl.items.length) setTimeout(function () { co.refreshConfig(co.env.select); }, 250);
});
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let re = sbm.mdl.Reqnts = { env: {} };
let re = sbm.mdl.reqnts = { env: {} };
//--------------------------------------------------------------
re.refreshConfig = function (env, delay)
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let sc = sbm.mdl.Security = { env: {} };
let sc = sbm.mdl.security = { env: {} };
//--------------------------------------------------------------
sc.doSignin = function ()
@@ -5,7 +5,7 @@
(function (win, doc, undef)
{
"use strict";
let tr = sbm.mdl.Transactions = { env: {} };
let tr = sbm.mdl.trans = { env: {} };
//--------------------------------------------------------------
tr.refreshConfig = function (env, delay)
@@ -6,7 +6,7 @@
(function (win, doc, undef)
{
"use strict";
let vc = sbm.VehicleClass = { data: {}, ajax: {} };
let vc = sbm.vehicleClass = { data: {}, ajax: {} };
let $pnl = vc.$pnl = {}, $frm = vc.$frm = {}, $dlg = vc.$dlg = {};
//--------------------------------------------------------------