using System.Collections.Generic; using Newtonsoft.Json.Linq; using AyaNova.Biz; namespace AyaNova.DataList { internal class CustomerDataList : AyaDataList { public CustomerDataList() { DefaultListObjectType = AyaType.Customer; SQLFrom = "from acustomer left outer join aheadoffice on (acustomer.headofficeid=aheadoffice.id) left outer join acontract on (acustomer.contractid=acontract.id)"; var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ //Default ListView dynamic dlistView = new JArray(); dynamic cm = new JObject(); cm.fld = "customername"; dlistView.Add(cm); cm = new JObject(); cm.fld = "customerphone1"; dlistView.Add(cm); cm = new JObject(); cm.fld = "customeremail"; dlistView.Add(cm); DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely FieldDefinitions = new List(); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerName", FieldKey = "customername", AyaObjectType = (int)AyaType.Customer, UiFieldDataType = (int)UiFieldDataType.Text, SqlIdColumnName = "acustomer.id", SqlValueColumnName = "acustomer.name", IsRowId = true }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerNotes", FieldKey = "customernotes", UiFieldDataType = (int)UiFieldDataType.Text, SqlValueColumnName = "acustomer.notes" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "Active", FieldKey = "customeractive", UiFieldDataType = (int)UiFieldDataType.Bool, SqlValueColumnName = "acustomer.active" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "Tags", FieldKey = "customertags", UiFieldDataType = (int)UiFieldDataType.Tags, SqlValueColumnName = "acustomer.tags" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "WebAddress", FieldKey = "customerwebaddress", UiFieldDataType = (int)UiFieldDataType.HTTP, SqlValueColumnName = "acustomer.webaddress" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerPopUpNotes", FieldKey = "customerpopupnotes", UiFieldDataType = (int)UiFieldDataType.Text, SqlValueColumnName = "acustomer.popupnotes" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerBillHeadOffice", FieldKey = "customerbillheadoffice", UiFieldDataType = (int)UiFieldDataType.Bool, SqlValueColumnName = "acustomer.billheadoffice" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerTechNotes", FieldKey = "customertechnotes", UiFieldDataType = (int)UiFieldDataType.Text, SqlValueColumnName = "acustomer.technotes" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerAccountNumber", FieldKey = "customeraccountnumber", UiFieldDataType = (int)UiFieldDataType.Text, SqlValueColumnName = "acustomer.accountnumber" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UsesBanking", FieldKey = "usesbanking", UiFieldDataType = (int)UiFieldDataType.Bool, SqlValueColumnName = "acustomer.usesbanking" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerStartDate", FieldKey = "customerstartdate", UiFieldDataType = (int)UiFieldDataType.DateTime, SqlValueColumnName = "acustomer.startdate" }); //------- FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerSerial", FieldKey = "customerserial", UiFieldDataType = (int)UiFieldDataType.Integer, SqlValueColumnName = "acustomer.serial" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerDollarAmount", FieldKey = "customerdollaramount", UiFieldDataType = (int)UiFieldDataType.Currency, SqlValueColumnName = "acustomer.dollaramount" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCount", FieldKey = "customercount", UiFieldDataType = (int)UiFieldDataType.Integer, SqlValueColumnName = "acustomer.count" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "UserType", FieldKey = "customerusertype", UiFieldDataType = (int)UiFieldDataType.Enum, EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(UserType).ToString()), SqlValueColumnName = "acustomer.usertype" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "Contract", FieldKey = "Contract", UiFieldDataType = (int)UiFieldDataType.Text, AyaObjectType = (int)AyaType.Contract, SqlIdColumnName = "acontract.id", SqlValueColumnName = "acontract.name" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "ContractExpires", FieldKey = "contractexpires", UiFieldDataType = (int)UiFieldDataType.DateTime, SqlValueColumnName = "acustomer.contractexpires" }); //FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "User", FieldKey = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User }); FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "username", TKey = "User", UiFieldDataType = (int)UiFieldDataType.Text, AyaObjectType = (int)AyaType.User, SqlIdColumnName = "auser.id", SqlValueColumnName = "auser.name" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom1", FieldKey = "customercustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom2", FieldKey = "customercustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom3", FieldKey = "customercustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom4", FieldKey = "customercustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom5", FieldKey = "customercustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom6", FieldKey = "customercustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom7", FieldKey = "customercustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom8", FieldKey = "customercustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom9", FieldKey = "customercustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom10", FieldKey = "customercustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom11", FieldKey = "customercustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom12", FieldKey = "customercustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom13", FieldKey = "customercustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom14", FieldKey = "customercustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom15", FieldKey = "customercustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom16", FieldKey = "customercustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); } }//eoc }//eons