359 lines
17 KiB
C#
359 lines
17 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using AyaNova.Biz;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class QuoteDataList : DataListProcessingBase, IDataListInternalCriteria
|
|
{
|
|
public QuoteDataList()
|
|
{
|
|
DefaultListAType = AyaType.Quote;
|
|
SQLFrom = "from aquote "
|
|
+ "left join aquotestatus on (aquote.laststatusid = aquotestatus.id) "
|
|
+ "left join acustomer on (aquote.customerid=acustomer.id) "
|
|
+ "left join aheadoffice on (acustomer.headofficeid=aheadoffice.id) "
|
|
+ "left join aproject on (aquote.projectid=aproject.id) "
|
|
+ "left join acontract on (aquote.contractid=acontract.id)";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListAType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
DefaultColumns = new List<string>() { "QuoteSerialNumber", "Customer", "QuoteStatus", "Project" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "QuoteSerialNumber", "-" } };
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteSerialNumber",
|
|
FieldKey = "QuoteSerialNumber",
|
|
AType = (int)AyaType.Quote,
|
|
UiFieldDataType = (int)UiFieldDataType.Integer,
|
|
SqlIdColumnName = "aquote.id",
|
|
SqlValueColumnName = "aquote.serial",
|
|
IsRowId = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "Customer",
|
|
TKey = "Customer",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.Customer,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "HeadOffice",
|
|
FieldKey = "quoteheadoffice",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.HeadOffice,
|
|
SqlIdColumnName = "aheadoffice.id",
|
|
SqlValueColumnName = "aheadoffice.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteStatus",
|
|
FieldKey = "QuoteStatus",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.QuoteStatus,
|
|
SqlIdColumnName = "aquote.laststatusid",
|
|
SqlColorColumnName = "aquotestatus.color",
|
|
SqlValueColumnName = "aquotestatus.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteSummary",
|
|
FieldKey = "quotenotes",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.notes"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Tags",
|
|
FieldKey = "quotetags",
|
|
UiFieldDataType = (int)UiFieldDataType.Tags,
|
|
SqlValueColumnName = "aquote.tags"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "Project",
|
|
TKey = "Project",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.Project,
|
|
SqlIdColumnName = "aproject.id",
|
|
SqlValueColumnName = "aproject.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "Contract",
|
|
FieldKey = "Contract",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
AType = (int)AyaType.Contract,
|
|
SqlIdColumnName = "acontract.id",
|
|
SqlValueColumnName = "acontract.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteInternalReferenceNumber",
|
|
FieldKey = "QuoteInternalReferenceNumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.internalreferencenumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteCustomerReferenceNumber",
|
|
FieldKey = "QuoteCustomerReferenceNumber",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.customerreferencenumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteCustomerContactName",
|
|
FieldKey = "QuoteCustomerContactName",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.customercontactname"
|
|
});
|
|
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "QuoteServiceDate",
|
|
// FieldKey = "QuoteServiceDate",
|
|
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
// SqlValueColumnName = "aquote.servicedate"
|
|
// });
|
|
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "QuoteCloseByDate",
|
|
// FieldKey = "QuoteCloseByDate",
|
|
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
// SqlValueColumnName = "aquote.completebydate"
|
|
// });
|
|
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "QuoteInvoiceNumber",
|
|
// FieldKey = "QuoteInvoiceNumber",
|
|
// UiFieldDataType = (int)UiFieldDataType.Text,
|
|
// SqlValueColumnName = "aquote.invoicenumber"
|
|
// });
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "QuoteOnsite",
|
|
FieldKey = "QuoteOnsite",
|
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
|
SqlValueColumnName = "aquote.onsite"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressPostalDeliveryAddress",
|
|
FieldKey = "quotepostaddress",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.postaddress"
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressPostalCity",
|
|
FieldKey = "quotepostcity",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.postcity"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressPostalStateProv",
|
|
FieldKey = "quotepostregion",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.postregion"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressPostalCountry",
|
|
FieldKey = "quotepostcountry",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.postcountry"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressPostalPostal",
|
|
FieldKey = "quotepostcode",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.postcode"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressDeliveryAddress",
|
|
FieldKey = "quoteaddress",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.address"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressCity",
|
|
FieldKey = "quotecity",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.city"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressStateProv",
|
|
FieldKey = "quoteregion",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.region"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressCountry",
|
|
FieldKey = "quotecountry",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlValueColumnName = "aquote.country"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressLatitude",
|
|
FieldKey = "quotelatitude",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "aquote.latitude"
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
TKey = "AddressLongitude",
|
|
FieldKey = "quotelongitude",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "aquote.longitude"
|
|
});
|
|
|
|
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "QuoteCloseByDate",
|
|
// FieldKey = "QuoteCloseByDate",
|
|
// UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
// SqlValueColumnName = "aquote.closebydate"
|
|
// });
|
|
|
|
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "QuoteAge",
|
|
// FieldKey = "QuoteAge",
|
|
// UiFieldDataType = (int)UiFieldDataType.TimeSpan,
|
|
// SqlValueColumnName = "expwoage"
|
|
// });
|
|
|
|
// FieldDefinitions.Add(new DataListFieldDefinition
|
|
// {
|
|
// TKey = "TimeToCompletion",
|
|
// FieldKey = "TimeToCompletion",
|
|
// UiFieldDataType = (int)UiFieldDataType.TimeSpan,
|
|
// SqlValueColumnName = "durationtocompleted"
|
|
// });
|
|
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom1", FieldKey = "quotecustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom2", FieldKey = "quotecustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom3", FieldKey = "quotecustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom4", FieldKey = "quotecustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom5", FieldKey = "quotecustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom6", FieldKey = "quotecustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom7", FieldKey = "quotecustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom8", FieldKey = "quotecustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom9", FieldKey = "quotecustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom10", FieldKey = "quotecustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom11", FieldKey = "quotecustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom12", FieldKey = "quotecustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom13", FieldKey = "quotecustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom14", FieldKey = "quotecustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom15", FieldKey = "quotecustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
FieldDefinitions.Add(new DataListFieldDefinition { TKey = "QuoteCustom16", FieldKey = "quotecustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aquote.customfields" });
|
|
|
|
|
|
//META COLUMNS
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metacustomer",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "acustomer.id",
|
|
SqlValueColumnName = "acustomer.id",
|
|
IsMeta = true
|
|
});
|
|
|
|
FieldDefinitions.Add(new DataListFieldDefinition
|
|
{
|
|
FieldKey = "metaproject",
|
|
UiFieldDataType = (int)UiFieldDataType.InternalId,
|
|
SqlIdColumnName = "aproject.id",
|
|
SqlValueColumnName = "aproject.id",
|
|
IsMeta = true
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<DataListFilterOption> DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria)
|
|
{
|
|
List<DataListFilterOption> ret = new List<DataListFilterOption>();
|
|
|
|
//ClientCriteria format for this list is "OBJECTID,AYATYPE"
|
|
var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray();
|
|
if (crit.Length > 1)
|
|
{
|
|
//will be filtered from different types, show all quotes from Customer, Project and nothing else at this time (others but for sub lists like quoteitemunits etc)
|
|
int nType = 0;
|
|
if (!int.TryParse(crit[1], out nType)) return ret;
|
|
AyaType forType = (AyaType)nType;
|
|
if (forType != AyaType.Customer && forType != AyaType.Project) return ret;//only supports customer and project for now
|
|
|
|
long lId = 0;
|
|
if (!long.TryParse(crit[0], out lId)) return ret;
|
|
if (lId == 0) return ret;
|
|
|
|
//Have valid type, have an id, so filter away
|
|
switch (forType)
|
|
{
|
|
case AyaType.Customer:
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
break;
|
|
case AyaType.Project:
|
|
{
|
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaproject" };
|
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
|
ret.Add(FilterOption);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
}//eoc
|
|
}//eons |