|
@@ -4,6 +4,7 @@ using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
using Comal.Classes;
|
|
|
using InABox.Core;
|
|
|
using InABox.DynamicGrid;
|
|
@@ -14,23 +15,54 @@ namespace PRSDesktop;
|
|
|
|
|
|
public class StockLocationGrid : DynamicDataGrid<StockLocation>
|
|
|
{
|
|
|
- private bool bShowAll;
|
|
|
- public Button ShowAllBtn;
|
|
|
public Button StockTakeBtn;
|
|
|
|
|
|
+ private BitmapImage _stocktakeheader = PRSDesktop.Resources.schedule_enabled.AsBitmapImage();
|
|
|
+ private BitmapImage _stocktakedisabled = PRSDesktop.Resources.schedule_disabled.AsBitmapImage();
|
|
|
+ private BitmapImage _stocktakeinprogress = PRSDesktop.Resources.locked.AsBitmapImage();
|
|
|
+ private BitmapImage _stocktakenotyetdue = PRSDesktop.Resources.tick.AsBitmapImage();
|
|
|
+ private BitmapImage _stocktakeoverdue = PRSDesktop.Resources.warning.AsBitmapImage();
|
|
|
+
|
|
|
protected override void Init()
|
|
|
{
|
|
|
base.Init();
|
|
|
- ShowAllBtn = AddButton("Show All", PRSDesktop.Resources.parcel.AsBitmapImage(Color.White), ToggleHiddenJobs);
|
|
|
|
|
|
+
|
|
|
+ HiddenColumns.Add(x => x.Job.ID);
|
|
|
+ HiddenColumns.Add(x => x.StocktakeFrequency);
|
|
|
+ HiddenColumns.Add(x => x.StocktakeStatus);
|
|
|
+ HiddenColumns.Add(x => x.NextStocktake);
|
|
|
+
|
|
|
+ ActionColumns.Add(new DynamicImageColumn(StockTakeStatusImage) { ToolTip = StockTakeStatusToolTip, Position = DynamicActionColumnPosition.Start });
|
|
|
+
|
|
|
if (Security.CanEdit<StockMovement>())
|
|
|
StockTakeBtn = AddButton("Stock Take", PRSDesktop.Resources.rack.AsBitmapImage(Color.White), DoStockTake);
|
|
|
- HiddenColumns.Add(x => x.Job.ID);
|
|
|
-
|
|
|
- //HiddenColumns.Add(x => x.Movements);
|
|
|
|
|
|
OnCustomiseEditor += CustomiseEditor;
|
|
|
}
|
|
|
+
|
|
|
+ private FrameworkElement? StockTakeStatusToolTip(DynamicActionColumn column, CoreRow? row)
|
|
|
+ {
|
|
|
+ return row == null
|
|
|
+ ? column.TextToolTip("Indicates the Stocktake status of this location")
|
|
|
+ : row.Get<StockLocation, StockTakeStatus>(x => x.StocktakeStatus) == StockTakeStatus.InProgress
|
|
|
+ ? column.TextToolTip("Stocktake in progress")
|
|
|
+ : column.TextToolTip($"Stocktake due on {row.Get<StockLocation, DateTime>(x => x.NextStocktake).Date:dd MMM yy}");
|
|
|
+ }
|
|
|
+
|
|
|
+ private BitmapImage? StockTakeStatusImage(CoreRow? row)
|
|
|
+ {
|
|
|
+ return row == null
|
|
|
+ ? _stocktakeheader
|
|
|
+ : row.Get<StockLocation, StockTakeStatus>(x => x.StocktakeStatus) == StockTakeStatus.InProgress
|
|
|
+ ? _stocktakeinprogress
|
|
|
+ : row.Get<StockLocation, StockTakeFrequency>(x => x.StocktakeFrequency) == StockTakeFrequency.Never
|
|
|
+ ? _stocktakedisabled
|
|
|
+ : row.Get<StockLocation, DateTime>(x => x.NextStocktake).Date > DateTime.Today
|
|
|
+ ? _stocktakenotyetdue
|
|
|
+ : _stocktakeoverdue;
|
|
|
+ }
|
|
|
+
|
|
|
protected override void DoReconfigure(FluentList<DynamicGridOption> options)
|
|
|
{
|
|
|
base.DoReconfigure(options);
|
|
@@ -55,21 +87,8 @@ public class StockLocationGrid : DynamicDataGrid<StockLocation>
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- private bool ToggleHiddenJobs(Button sender, CoreRow[] rows)
|
|
|
- {
|
|
|
- bShowAll = !bShowAll;
|
|
|
- UpdateButton(sender, PRSDesktop.Resources.parcel.AsBitmapImage(Color.White), bShowAll ? "Active Only" : "Show All");
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- protected override void Reload(Filters<StockLocation> criteria, Columns<StockLocation> columns, ref SortOrder<StockLocation>? sort, Action<CoreTable?, Exception?> action)
|
|
|
- {
|
|
|
- if (!bShowAll)
|
|
|
- criteria.Add(new Filter<StockLocation>(x => x.Active).IsEqualTo(true));
|
|
|
- base.Reload(criteria, columns, ref sort, action);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
protected override void DoValidate(StockLocation[] items, List<string> errors)
|
|
|
{
|