using System.Collections.Generic;
using System;

namespace Sockeye.Biz
{
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    // This contains all the **OPTIONAL** fields that can be customized by user to be required or hide
    // on all object edit forms   
    // it is used for both validation and driving the UI 
    // it does *NOT* need to contain every field on the form, just user customizable ones
    // and should not have mandatory fields since they are not customizable by end user 

    //See the DataList folder / namespace for LIST related similar class

    public static class FormFieldOptionalCustomizableReference
    {
        private static Dictionary<string, List<FormField>> _formFields;
        private static List<string> _formFieldKeys = null;

        public static List<string> FormFieldKeys
        {
            get
            {
                if (_formFieldKeys == null)
                {
                    _formFieldKeys = new List<string>();
                    var values = Enum.GetValues(typeof(SockType));
                    foreach (SockType t in values)
                    {
                        if (t.HasAttribute(typeof(CoreBizObjectAttribute)))
                        {
                            _formFieldKeys.Add(t.ToString());
                        }
                    }
                    //No type / not corebiz form keys:
                    _formFieldKeys.Add("Contact");

                }
                return _formFieldKeys;
            }
        }


        public static bool IsValidFormFieldKey(string key)
        {
            return FormFieldKeys.Contains(key);
        }

        public static List<FormField> FormFieldReferenceList(string key)
        {
            //Initialize the static list here on first retrieval
            if (_formFields == null)
            {
                _formFields = new Dictionary<string, List<FormField>>();
                /*  *****************************  WARNING: Be careful here, if a standard field is hideable and also it's DB SCHEMA is  set to NON NULLABLE then the CLIENT end needs to set a default
                    *****************************  Otherwise the hidden field can't be set and the object can't be saved EVER        
                */

                #region USER_KEY
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber" });
                    l.Add(new FormField { TKey = "LastLogin", FieldKey = "LastLogin" });
                    l.Add(new FormField { TKey = "UserNotes", FieldKey = "Notes" });
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
                    _formFields.Add(SockType.User.ToString(), l);
                }
                #endregion

                #region CONTACT_KEY
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber" });
                    l.Add(new FormField { TKey = "LastLogin", FieldKey = "LastLogin" });
                    l.Add(new FormField { TKey = "UserNotes", FieldKey = "Notes" });
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
                    _formFields.Add("Contact", l);
                }
                #endregion


                #region Customer
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "CustomerAccountNumber", FieldKey = "AccountNumber" });
                    l.Add(new FormField { TKey = "WebAddress", FieldKey = "WebAddress" });
                    l.Add(new FormField { TKey = "CustomerEmail", FieldKey = "EmailAddress" });
                    l.Add(new FormField { TKey = "CustomerPhone1", FieldKey = "Phone1" });
                    l.Add(new FormField { TKey = "CustomerPhone2", FieldKey = "Phone2" });
                    l.Add(new FormField { TKey = "CustomerPhone3", FieldKey = "Phone3" });
                    l.Add(new FormField { TKey = "CustomerPhone4", FieldKey = "Phone4" });
                    l.Add(new FormField { TKey = "CustomerPhone5", FieldKey = "Phone5" });
                    l.Add(new FormField { TKey = "CustomerBillHeadOffice", FieldKey = "BillHeadOffice" });
                    l.Add(new FormField { TKey = "HeadOffice", FieldKey = "HeadOfficeId" });
                    l.Add(new FormField { TKey = "Contract", FieldKey = "ContractId" });
                    l.Add(new FormField { TKey = "ContractExpires", FieldKey = "ContractExpires" });
                    //l.Add(new FormField { TKey = "UsesBanking", FieldKey = "UsesBanking" });
                    l.Add(new FormField { TKey = "CustomerNotes", FieldKey = "Notes" });
                    l.Add(new FormField { TKey = "CustomerTechNotes", FieldKey = "TechNotes" });
                    l.Add(new FormField { TKey = "AlertNotes", FieldKey = "AlertNotes" });
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "AddressDeliveryAddress", FieldKey = "Address" });
                    l.Add(new FormField { TKey = "AddressCity", FieldKey = "City" });
                    l.Add(new FormField { TKey = "AddressStateProv", FieldKey = "Region" });
                    l.Add(new FormField { TKey = "AddressCountry", FieldKey = "Country" });
                    l.Add(new FormField { TKey = "AddressPostal", FieldKey = "AddressPostal" });
                    l.Add(new FormField { TKey = "AddressLatitude", FieldKey = "Latitude" });
                    l.Add(new FormField { TKey = "AddressLongitude", FieldKey = "Longitude" });
                    l.Add(new FormField { TKey = "AddressPostalDeliveryAddress", FieldKey = "PostAddress" });
                    l.Add(new FormField { TKey = "AddressPostalCity", FieldKey = "PostCity" });
                    l.Add(new FormField { TKey = "AddressPostalStateProv", FieldKey = "PostRegion" });
                    l.Add(new FormField { TKey = "AddressPostalCountry", FieldKey = "PostCountry" });
                    l.Add(new FormField { TKey = "AddressPostalPostal", FieldKey = "PostCode" });

                    l.Add(new FormField { TKey = "CustomerCustom1", FieldKey = "CustomerCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom2", FieldKey = "CustomerCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom3", FieldKey = "CustomerCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom4", FieldKey = "CustomerCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom5", FieldKey = "CustomerCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom6", FieldKey = "CustomerCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom7", FieldKey = "CustomerCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom8", FieldKey = "CustomerCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom9", FieldKey = "CustomerCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom10", FieldKey = "CustomerCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom11", FieldKey = "CustomerCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom12", FieldKey = "CustomerCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom13", FieldKey = "CustomerCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom14", FieldKey = "CustomerCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom15", FieldKey = "CustomerCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "CustomerCustom16", FieldKey = "CustomerCustom16", IsCustomField = true });
                    _formFields.Add(SockType.Customer.ToString(), l);
                }
                #endregion

                #region HeadOffice
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "HeadOfficeAccountNumber", FieldKey = "AccountNumber" });
                    l.Add(new FormField { TKey = "WebAddress", FieldKey = "WebAddress" });
                    l.Add(new FormField { TKey = "HeadOfficeEmail", FieldKey = "EmailAddress" });
                    l.Add(new FormField { TKey = "HeadOfficePhone1", FieldKey = "Phone1" });
                    l.Add(new FormField { TKey = "HeadOfficePhone2", FieldKey = "Phone2" });
                    l.Add(new FormField { TKey = "HeadOfficePhone3", FieldKey = "Phone3" });
                    l.Add(new FormField { TKey = "HeadOfficePhone4", FieldKey = "Phone4" });
                    l.Add(new FormField { TKey = "HeadOfficePhone5", FieldKey = "Phone5" });
                    l.Add(new FormField { TKey = "Contract", FieldKey = "ContractId" });
                    l.Add(new FormField { TKey = "ContractExpires", FieldKey = "ContractExpires" });
                    //l.Add(new FormField { TKey = "UsesBanking", FieldKey = "UsesBanking" });
                    l.Add(new FormField { TKey = "HeadOfficeNotes", FieldKey = "Notes" });
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "AddressDeliveryAddress", FieldKey = "Address" });
                    l.Add(new FormField { TKey = "AddressCity", FieldKey = "City" });
                    l.Add(new FormField { TKey = "AddressStateProv", FieldKey = "Region" });
                    l.Add(new FormField { TKey = "AddressCountry", FieldKey = "Country" });
                    l.Add(new FormField { TKey = "AddressPostal", FieldKey = "AddressPostal" });
                    l.Add(new FormField { TKey = "AddressLatitude", FieldKey = "Latitude" });
                    l.Add(new FormField { TKey = "AddressLongitude", FieldKey = "Longitude" });
                    l.Add(new FormField { TKey = "AddressPostalDeliveryAddress", FieldKey = "PostAddress" });
                    l.Add(new FormField { TKey = "AddressPostalCity", FieldKey = "PostCity" });
                    l.Add(new FormField { TKey = "AddressPostalStateProv", FieldKey = "PostRegion" });
                    l.Add(new FormField { TKey = "AddressPostalCountry", FieldKey = "PostCountry" });
                    l.Add(new FormField { TKey = "AddressPostalPostal", FieldKey = "PostCode" });

                    l.Add(new FormField { TKey = "HeadOfficeCustom1", FieldKey = "HeadOfficeCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom2", FieldKey = "HeadOfficeCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom3", FieldKey = "HeadOfficeCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom4", FieldKey = "HeadOfficeCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom5", FieldKey = "HeadOfficeCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom6", FieldKey = "HeadOfficeCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom7", FieldKey = "HeadOfficeCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom8", FieldKey = "HeadOfficeCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom9", FieldKey = "HeadOfficeCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom10", FieldKey = "HeadOfficeCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom11", FieldKey = "HeadOfficeCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom12", FieldKey = "HeadOfficeCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom13", FieldKey = "HeadOfficeCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom14", FieldKey = "HeadOfficeCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom15", FieldKey = "HeadOfficeCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "HeadOfficeCustom16", FieldKey = "HeadOfficeCustom16", IsCustomField = true });
                    _formFields.Add(SockType.HeadOffice.ToString(), l);
                }
                #endregion



                #region Memo
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });

                    l.Add(new FormField { TKey = "MemoCustom1", FieldKey = "MemoCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom2", FieldKey = "MemoCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom3", FieldKey = "MemoCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom4", FieldKey = "MemoCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom5", FieldKey = "MemoCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom6", FieldKey = "MemoCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom7", FieldKey = "MemoCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom8", FieldKey = "MemoCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom9", FieldKey = "MemoCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom10", FieldKey = "MemoCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom11", FieldKey = "MemoCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom12", FieldKey = "MemoCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom13", FieldKey = "MemoCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom14", FieldKey = "MemoCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom15", FieldKey = "MemoCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "MemoCustom16", FieldKey = "MemoCustom16", IsCustomField = true });
                    _formFields.Add(SockType.Memo.ToString(), l);
                }
                #endregion

                #region Reminder
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "ReminderColor", FieldKey = "Color" });

                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "ReminderCustom1", FieldKey = "ReminderCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom2", FieldKey = "ReminderCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom3", FieldKey = "ReminderCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom4", FieldKey = "ReminderCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom5", FieldKey = "ReminderCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom6", FieldKey = "ReminderCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom7", FieldKey = "ReminderCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom8", FieldKey = "ReminderCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom9", FieldKey = "ReminderCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom10", FieldKey = "ReminderCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom11", FieldKey = "ReminderCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom12", FieldKey = "ReminderCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom13", FieldKey = "ReminderCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom14", FieldKey = "ReminderCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom15", FieldKey = "ReminderCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReminderCustom16", FieldKey = "ReminderCustom16", IsCustomField = true });
                    _formFields.Add(SockType.Reminder.ToString(), l);
                }
                #endregion

                #region Review
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "ReviewCustom1", FieldKey = "ReviewCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom2", FieldKey = "ReviewCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom3", FieldKey = "ReviewCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom4", FieldKey = "ReviewCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom5", FieldKey = "ReviewCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom6", FieldKey = "ReviewCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom7", FieldKey = "ReviewCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom8", FieldKey = "ReviewCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom9", FieldKey = "ReviewCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom10", FieldKey = "ReviewCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom11", FieldKey = "ReviewCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom12", FieldKey = "ReviewCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom13", FieldKey = "ReviewCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom14", FieldKey = "ReviewCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom15", FieldKey = "ReviewCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "ReviewCustom16", FieldKey = "ReviewCustom16", IsCustomField = true });
                    _formFields.Add(SockType.Review.ToString(), l);
                }
                #endregion

                #region Vendor
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "VendorAccountNumber", FieldKey = "AccountNumber" });
                    l.Add(new FormField { TKey = "WebAddress", FieldKey = "WebAddress" });
                    l.Add(new FormField { TKey = "HeadOfficeEmail", FieldKey = "EmailAddress" });
                    l.Add(new FormField { TKey = "HeadOfficePhone1", FieldKey = "Phone1" });
                    l.Add(new FormField { TKey = "HeadOfficePhone2", FieldKey = "Phone2" });
                    l.Add(new FormField { TKey = "HeadOfficePhone3", FieldKey = "Phone3" });
                    l.Add(new FormField { TKey = "HeadOfficePhone4", FieldKey = "Phone4" });
                    l.Add(new FormField { TKey = "HeadOfficePhone5", FieldKey = "Phone5" });
                    l.Add(new FormField { TKey = "VendorContact", FieldKey = "Contact" });
                    l.Add(new FormField { TKey = "VendorNotes", FieldKey = "Notes" });
                    l.Add(new FormField { TKey = "VendorContactNotes", FieldKey = "ContactNotes" });
                    l.Add(new FormField { TKey = "AlertNotes", FieldKey = "AlertNotes" });
                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki", Requireable = false });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });
                    l.Add(new FormField { TKey = "AddressDeliveryAddress", FieldKey = "Address" });
                    l.Add(new FormField { TKey = "AddressCity", FieldKey = "City" });
                    l.Add(new FormField { TKey = "AddressStateProv", FieldKey = "Region" });
                    l.Add(new FormField { TKey = "AddressCountry", FieldKey = "Country" });
                    l.Add(new FormField { TKey = "AddressPostal", FieldKey = "AddressPostal" });
                    l.Add(new FormField { TKey = "AddressLatitude", FieldKey = "Latitude" });
                    l.Add(new FormField { TKey = "AddressLongitude", FieldKey = "Longitude" });
                    l.Add(new FormField { TKey = "AddressPostalDeliveryAddress", FieldKey = "PostAddress" });
                    l.Add(new FormField { TKey = "AddressPostalCity", FieldKey = "PostCity" });
                    l.Add(new FormField { TKey = "AddressPostalStateProv", FieldKey = "PostRegion" });
                    l.Add(new FormField { TKey = "AddressPostalCountry", FieldKey = "PostCountry" });
                    l.Add(new FormField { TKey = "AddressPostalPostal", FieldKey = "PostCode" });

                    l.Add(new FormField { TKey = "VendorCustom1", FieldKey = "VendorCustom1", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom2", FieldKey = "VendorCustom2", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom3", FieldKey = "VendorCustom3", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom4", FieldKey = "VendorCustom4", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom5", FieldKey = "VendorCustom5", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom6", FieldKey = "VendorCustom6", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom7", FieldKey = "VendorCustom7", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom8", FieldKey = "VendorCustom8", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom9", FieldKey = "VendorCustom9", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom10", FieldKey = "VendorCustom10", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom11", FieldKey = "VendorCustom11", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom12", FieldKey = "VendorCustom12", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom13", FieldKey = "VendorCustom13", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom14", FieldKey = "VendorCustom14", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom15", FieldKey = "VendorCustom15", IsCustomField = true });
                    l.Add(new FormField { TKey = "VendorCustom16", FieldKey = "VendorCustom16", IsCustomField = true });
                    _formFields.Add(SockType.Vendor.ToString(), l);
                }
                #endregion

                #region Product
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "ProductLicenseInterval", FieldKey = "ProductLicenseInterval" });
                    l.Add(new FormField { TKey = "ProductMaintInterval", FieldKey = "ProductMaintInterval" });
                    l.Add(new FormField { TKey = "ProductVendorCode", FieldKey = "ProductVendorCode" });
                    l.Add(new FormField { TKey = "ProductOurCode", FieldKey = "ProductOurCode" });

                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });


                    _formFields.Add(SockType.Product.ToString(), l);
                }
                #endregion

                #region Purchase
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "PurchaseExpireDate", FieldKey = "PurchaseExpireDate" });
                    l.Add(new FormField { TKey = "PurchaseCancelDate", FieldKey = "PurchaseCancelDate" });
                    l.Add(new FormField { TKey = "PurchaseCouponCode", FieldKey = "PurchaseCouponCode" });
                    l.Add(new FormField { TKey = "PurchaseNotes", FieldKey = "PurchaseNotes" });
                    l.Add(new FormField { TKey = "PurchaseVendorNotificationId", FieldKey = "PurchaseVendorNotificationId" });
                    l.Add(new FormField { TKey = "PurchaseProcessed", FieldKey = "PurchaseProcessed" });

                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });


                    _formFields.Add(SockType.Purchase.ToString(), l);
                }
                #endregion

               
                #region SubscriptionServer
                {
                    List<FormField> l = new List<FormField>();
                    l.Add(new FormField { TKey = "SubServerNotes", FieldKey = "SubServerNotes" });
                    l.Add(new FormField { TKey = "SubServerLastUpdated", FieldKey = "SubServerLastUpdated" });
                    l.Add(new FormField { TKey = "SubServerTrialContact", FieldKey = "SubServerTrialContact" });
                    l.Add(new FormField { TKey = "SubServerOperatingSystem", FieldKey = "SubServerOperatingSystem" });
                    l.Add(new FormField { TKey = "SubServerTrialCompany", FieldKey = "SubServerTrialCompany" });
                    l.Add(new FormField { TKey = "SubServerTrialEmail", FieldKey = "SubServerTrialEmail" });
                    l.Add(new FormField { TKey = "SubServerCustomerDomain", FieldKey = "SubServerCustomerDomain" });

                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });


                    _formFields.Add(SockType.SubscriptionServer.ToString(), l);
                }
                #endregion

                #region GZCase
                {
                    List<FormField> l = new List<FormField>();


                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });
                    l.Add(new FormField { TKey = "Wiki", FieldKey = "Wiki" });
                    l.Add(new FormField { TKey = "Attachments", FieldKey = "Attachments", Requireable = false });


                    _formFields.Add(SockType.GZCase.ToString(), l);
                }
                #endregion

                #region TrialLicenseRequest
                {
                    List<FormField> l = new List<FormField>();


                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });


                    _formFields.Add(SockType.TrialLicenseRequest.ToString(), l);
                }
                #endregion

                #region License
                {
                    List<FormField> l = new List<FormField>();


                    l.Add(new FormField { TKey = "Tags", FieldKey = "Tags" });


                    _formFields.Add(SockType.License.ToString(), l);
                }
                #endregion

                //******************************************************
            }

            if (!_formFields.ContainsKey(key))
                throw new System.ArgumentOutOfRangeException($"FormFieldReferenceList: {key} is not valid");
            return _formFields[key];

        }

        public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName)
        {
            var i = System.Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace(
                        lTCustomFieldName,  // Our input
                        "[^0-9]", // Select everything that is not in the range of 0-9
                        ""        // Replace that with an empty string.
                    ));

            return $"c{i}";
        }

    }//eoc ObjectFields

    public class FormField
    {
        private string tKey;

        //CLIENT / SERVER Unique identifier used at BOTH client and server
        //MUST MATCH MODEL PROPERTY NAME EXACTLY UNLESS ModelProperty is set OR REQUIRED FIELD VALIDATION WON"T WORK
        //The model name is used for validation and the fieldKey sometimes is not the model name in big forms with repeating model names in which case
        //the fieldkey will be unique and the ModelProperty will be set instead
        public string FieldKey { get; set; }

        //This exists to handle scenario of repeated identical model property multiple times on workorder quote pm forms
        //e.g. need to use a unique fieldkey but it can't match the model property becuase then
        //it would need to be "Tags" but there is already a "Tags" on the workorder header and in units
        //so here we can specify an exact property tag to check.  RequiredfieldsValidator will use this instead when set to issue errors
        public string ModelProperty { get; set; } = null;

        //CLIENT Use only for display in customization form, translation key to show translated name on UI customize form
        public string TKey
        {
            get => tKey;
            set
            {
                tKey = value;
                if (this.FieldKey == null)//save having to type out fieldkey when it's identical to tkey
                {
                    this.FieldKey = value;
                }
            }
        }

        //CLIENT Use only for display in customization form to disambiguate things like
        //Tags in main workorder and Tags in Workorder Item and Tags in Unit (all on same form)
        public string TKeySection { get; set; } = null;

        //CLIENT form customization
        public bool Hideable { get; set; }
        //CLIENT form customization
        public bool Requireable { get; set; }


        //CLIENT / SERVER - client display server validation purposes
        public bool IsCustomField { get; set; }


        public FormField()
        {
            //most common defaults           
            Hideable = true;
            Requireable = true;
            IsCustomField = false;
        }
    }//eoc


}//ens
