From c026e4145b165175dc8b7d6d916dc7c0adfbb13e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 11 Nov 2020 00:35:09 +0000 Subject: [PATCH] --- server/AyaNova/DataList/CustomerDataList.cs | 153 ++++++++++++++++++ server/AyaNova/biz/AyaFormFieldDefinitions.cs | 2 +- server/AyaNova/models/Customer.cs | 11 +- server/AyaNova/util/AySchema.cs | 3 +- 4 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 server/AyaNova/DataList/CustomerDataList.cs diff --git a/server/AyaNova/DataList/CustomerDataList.cs b/server/AyaNova/DataList/CustomerDataList.cs new file mode 100644 index 00000000..0ca88b09 --- /dev/null +++ b/server/AyaNova/DataList/CustomerDataList.cs @@ -0,0 +1,153 @@ +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"; + 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 = "customeraccountnumber"; + dlistView.Add(cm); + + cm = new JObject(); + cm.fld = "active"; + dlistView.Add(cm); + + + DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); + + + + // DefaultDataListView = @" + // { + // [{key:""COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}] + + // ""full"":[""widgetname"",""widgetserial"",""widgetdollaramount"",""widgetusertype"",""widgetstartdate"",""widgetactive"",""username""], + + // } + // "; + + //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely + FieldDefinitions = new List(); + //DEPRECATED: FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Customer, SqlIdColumnName = "awidget.id", IsFilterable = false, IsSortable = false, }); + + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerName", + FieldKey = "widgetname", + AyaObjectType = (int)AyaType.Customer, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "awidget.id", + SqlValueColumnName = "awidget.name", + IsRowId = true + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerSerial", + FieldKey = "widgetserial", + UiFieldDataType = (int)UiFieldDataType.Integer, + SqlValueColumnName = "awidget.serial" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerDollarAmount", + FieldKey = "widgetdollaramount", + UiFieldDataType = (int)UiFieldDataType.Currency, + SqlValueColumnName = "awidget.dollaramount" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerCount", + FieldKey = "widgetcount", + UiFieldDataType = (int)UiFieldDataType.Integer, + SqlValueColumnName = "awidget.count" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "UserType", + FieldKey = "widgetusertype", + UiFieldDataType = (int)UiFieldDataType.Enum, + EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(UserType).ToString()), + SqlValueColumnName = "awidget.usertype" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerStartDate", + FieldKey = "widgetstartdate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "awidget.startdate" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerEndDate", + FieldKey = "widgetenddate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "awidget.enddate" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "CustomerNotes", + FieldKey = "widgetnotes", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "awidget.notes" + }); + + //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 = "Active", + FieldKey = "widgetactive", + UiFieldDataType = (int)UiFieldDataType.Bool, + SqlValueColumnName = "awidget.active" + }); + FieldDefinitions.Add(new AyaDataListFieldDefinition + { + TKey = "Tags", + FieldKey = "widgettags", + UiFieldDataType = (int)UiFieldDataType.Tags, + SqlValueColumnName = "awidget.tags" + }); + + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom1", FieldKey = "widgetcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom2", FieldKey = "widgetcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom3", FieldKey = "widgetcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom4", FieldKey = "widgetcustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom5", FieldKey = "widgetcustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom6", FieldKey = "widgetcustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom7", FieldKey = "widgetcustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom8", FieldKey = "widgetcustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom9", FieldKey = "widgetcustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom10", FieldKey = "widgetcustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom11", FieldKey = "widgetcustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom12", FieldKey = "widgetcustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom13", FieldKey = "widgetcustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom14", FieldKey = "widgetcustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom15", FieldKey = "widgetcustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom16", FieldKey = "widgetcustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" }); + } + }//eoc +}//eons \ No newline at end of file diff --git a/server/AyaNova/biz/AyaFormFieldDefinitions.cs b/server/AyaNova/biz/AyaFormFieldDefinitions.cs index ac669e93..80ea1dbb 100644 --- a/server/AyaNova/biz/AyaFormFieldDefinitions.cs +++ b/server/AyaNova/biz/AyaFormFieldDefinitions.cs @@ -122,7 +122,7 @@ namespace AyaNova.Biz #region Customer { List l = new List(); - l.Add(new AyaFormFieldDefinition { TKey = "Name", FieldKey = "Name", Hideable = false }); + l.Add(new AyaFormFieldDefinition { TKey = "CustomerName", FieldKey = "Name", Hideable = false }); l.Add(new AyaFormFieldDefinition { TKey = "CustomerNotes", FieldKey = "Notes" }); l.Add(new AyaFormFieldDefinition { TKey = "Active", FieldKey = "Active", Hideable = false }); l.Add(new AyaFormFieldDefinition { TKey = "Tags", FieldKey = "Tags" }); diff --git a/server/AyaNova/models/Customer.cs b/server/AyaNova/models/Customer.cs index cfcfef82..a8dc681c 100644 --- a/server/AyaNova/models/Customer.cs +++ b/server/AyaNova/models/Customer.cs @@ -35,10 +35,15 @@ namespace AyaNova.Models public long? ContractID { get; set; } public DateTime? ContractExpires { get; set; } public long? DefaultServiceTemplateID { get; set; } + [Phone] public string Phone1 { get; set; } + [Phone] public string Phone2 { get; set; } + [Phone] public string Phone3 { get; set; } + [Phone] public string Phone4 { get; set; } + [Phone] public string Phone5 { get; set; } [EmailAddress] public string EmailAddress { get; set; } @@ -55,10 +60,10 @@ namespace AyaNova.Models public string City { get; set; } public string Region { get; set; } public string Country { get; set; } - public decimal Latitude { get; set; } - public decimal Longitude { get; set; } + public decimal? Latitude { get; set; } + public decimal? Longitude { get; set; } + - public Customer() { Tags = new List(); diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 3d4e6bc6..f6d7265b 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -485,7 +485,8 @@ $BODY$; await ExecQueryAsync("CREATE TABLE acustomer (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool, " + "notes text, wiki text, customfields text, tags varchar(255) ARRAY, " + "webaddress text, popupnotes text, billheadoffice bool, technotes text, accountnumber text, usesbanking bool, contractexpires timestamp null, " + - "phone1 text, phone2 text, phone3 text, phone4 text, phone5 text, emailaddress text)"); + "phone1 text, phone2 text, phone3 text, phone4 text, phone5 text, emailaddress text, " + + "postaddress text, postcity text, postregion text, postcountry text, postcode text, address text, city text, region text, country text, latitude decimal(8,6), longitude decimal(9,6))"); await ExecQueryAsync("CREATE UNIQUE INDEX acustomer_name_id_idx ON acustomer (id, name);"); await ExecQueryAsync("CREATE INDEX acustomer_tags ON acustomer using GIN(tags)");