Переглянути джерело

Fixed Timesheets andProject Dock

Frank van den Bos 2 роки тому
батько
коміт
f290d2cfd2

+ 2 - 0
prs.desktop/DockPanels/JobDock.xaml.cs

@@ -26,6 +26,8 @@ namespace PRSDesktop
             _jobs = new JobGrid();
             _jobs = new JobGrid();
             _jobs.SetValue(Grid.RowProperty, 1);
             _jobs.SetValue(Grid.RowProperty, 1);
             _jobs.Margin = new Thickness(2);
             _jobs.Margin = new Thickness(2);
+            _jobs.ColumnsTag = "JobDock";
+            _jobs.Refresh(true, false);
             grid.Children.Add(_jobs);  
             grid.Children.Add(_jobs);  
             
             
             var statustable = new Client<JobStatus>().Query(
             var statustable = new Client<JobStatus>().Query(

+ 1 - 1
prs.desktop/Grids/TimesheetGrid.cs

@@ -414,7 +414,7 @@ namespace PRSDesktop
         protected override void Reload(Filters<TimeSheet> criteria, Columns<TimeSheet> columns, ref SortOrder<TimeSheet> sort,
         protected override void Reload(Filters<TimeSheet> criteria, Columns<TimeSheet> columns, ref SortOrder<TimeSheet> sort,
             Action<CoreTable, Exception> action)
             Action<CoreTable, Exception> action)
         {
         {
-            var filter = new Filter<TimeSheet>(x => x.Processed).IsLessThanOrEqualTo(DateTime.MinValue.AddDays(1));
+            var filter = new Filter<TimeSheet>(x => x.Processed).IsEqualTo(DateTime.MinValue);
             if (!string.IsNullOrWhiteSpace(Search))
             if (!string.IsNullOrWhiteSpace(Search))
                 filter = filter.TextSearch(Search, x => x.EmployeeLink.Name, x => x.Address, x => x.Notes);
                 filter = filter.TextSearch(Search, x => x.EmployeeLink.Name, x => x.Address, x => x.Notes);
             criteria.Add(filter);
             criteria.Add(filter);

+ 3 - 3
prs.desktop/Panels/Jobs/JobPanel.xaml.cs

@@ -88,7 +88,7 @@ namespace PRSDesktop
         private JobFormGrid JobFormsPage;
         private JobFormGrid JobFormsPage;
         private InvoicePanel JobInvoicePage;
         private InvoicePanel JobInvoicePage;
         private JobSpreadsheetGrid JobSpreadsheetPage;
         private JobSpreadsheetGrid JobSpreadsheetPage;
-        private JobSummaryGrid JobSummaryPage;
+        private JobSummaryPanel JobSummaryPage;
         
         
         private DateTime lastselection = DateTime.MaxValue;
         private DateTime lastselection = DateTime.MaxValue;
        
        
@@ -164,7 +164,7 @@ namespace PRSDesktop
                 
                 
                 PageIndex.Spreadsheets => new Dictionary<string, object[]> { { typeof(JobSpreadsheet).EntityName(), JobSpreadsheetPage.SelectedRows } },
                 PageIndex.Spreadsheets => new Dictionary<string, object[]> { { typeof(JobSpreadsheet).EntityName(), JobSpreadsheetPage.SelectedRows } },
                 
                 
-                PageIndex.Summary => new Dictionary<string, object[]> { { typeof(JobMaterial).EntityName(), JobSummaryPage.SelectedRows } },
+                PageIndex.Summary => new Dictionary<string, object[]> { { typeof(JobMaterial).EntityName(), JobSummaryPage.Summary.SelectedRows } },
                 
                 
                 _ => new Dictionary<string,object[]> {{ typeof(Job).EntityName(), JobGrid.SelectedRows}}
                 _ => new Dictionary<string,object[]> {{ typeof(Job).EntityName(), JobGrid.SelectedRows}}
                 
                 
@@ -458,7 +458,7 @@ namespace PRSDesktop
                         RefreshGrid(Spreadsheets, ref JobSpreadsheetPage, jobid, row != null);
                         RefreshGrid(Spreadsheets, ref JobSpreadsheetPage, jobid, row != null);
                         break;
                         break;
                     case PageIndex.Summary : 
                     case PageIndex.Summary : 
-                        RefreshGrid(Summary, ref JobSummaryPage, jobid, row != null);
+                        RefreshPanel(Summary, ref JobSummaryPage, jobid, row != null);
                         break;
                         break;
                 }
                 }
             }
             }

+ 7 - 13
prs.desktop/Panels/Jobs/JobSummaryGrid.cs

@@ -18,7 +18,7 @@ namespace PRSDesktop
 
 
         private bool _stylecolumnVisible;
         private bool _stylecolumnVisible;
 
 
-        private bool _includeReserves;
+        public bool IncludeReserves { get; set; }
         
         
         public JobSummaryGrid() : base()
         public JobSummaryGrid() : base()
         {
         {
@@ -54,17 +54,11 @@ namespace PRSDesktop
             ActionColumns.Add(new DynamicImageManagerColumn<JobMaterial>(this, x => x.Product.Image, false)
             ActionColumns.Add(new DynamicImageManagerColumn<JobMaterial>(this, x => x.Product.Image, false)
                 { Position = DynamicActionColumnPosition.Start });
                 { Position = DynamicActionColumnPosition.Start });
             
             
-            AddButton("Include Reserves", null, ToggleIncludeReserves);
+            
 
 
             OnCellDoubleClick += JobSummaryGrid_OnCellDoubleClick;
             OnCellDoubleClick += JobSummaryGrid_OnCellDoubleClick;
         }
         }
-
-        private bool ToggleIncludeReserves(Button sender, CoreRow[] arg2)
-        {
-            _includeReserves = !_includeReserves;
-            UpdateButton(sender, null, _includeReserves ? "Free Stock Only" : "Include Reserves");
-            return true;
-        }
+        
         
         
         protected override void GenerateColumns(DynamicGridColumns columns)
         protected override void GenerateColumns(DynamicGridColumns columns)
         {
         {
@@ -237,7 +231,7 @@ namespace PRSDesktop
                     null,
                     null,
                     new Filter<StockHolding>(x=>x.Units).IsNotEqualTo(0.0F)
                     new Filter<StockHolding>(x=>x.Units).IsNotEqualTo(0.0F)
                         .And(
                         .And(
-                            _includeReserves 
+                            IncludeReserves 
                                 ?  new Filter<StockHolding>(x=>x.Job.ID).IsNotEqualTo(ParentID) 
                                 ?  new Filter<StockHolding>(x=>x.Job.ID).IsNotEqualTo(ParentID) 
                                 : new Filter<StockHolding>(x=>x.Job.JobStatus.Active).IsEqualTo(false)
                                 : new Filter<StockHolding>(x=>x.Job.JobStatus.Active).IsEqualTo(false)
                             ),
                             ),
@@ -256,7 +250,7 @@ namespace PRSDesktop
                     unitsize,
                     unitsize,
                     null,
                     null,
                     
                     
-                    _includeReserves 
+                    IncludeReserves 
                         ?  new Filter<PurchaseOrderItem>(x=>x.Job.ID).IsNotEqualTo(ParentID)
                         ?  new Filter<PurchaseOrderItem>(x=>x.Job.ID).IsNotEqualTo(ParentID)
                         : new Filter<PurchaseOrderItem>(x=>x.Job.JobStatus.Active).IsEqualTo(false),
                         : new Filter<PurchaseOrderItem>(x=>x.Job.JobStatus.Active).IsEqualTo(false),
                     null
                     null
@@ -354,7 +348,7 @@ namespace PRSDesktop
                     new Filter<StockHolding>(x => x.Product.ID).InList(pids)
                     new Filter<StockHolding>(x => x.Product.ID).InList(pids)
                         .And(x=>x.Units).IsNotEqualTo(0.0F)
                         .And(x=>x.Units).IsNotEqualTo(0.0F)
                         .And(
                         .And(
-                            _includeReserves
+                            IncludeReserves
                                 ? new Filter<StockHolding>(x => x.Job.ID).IsNotEqualTo(ParentID)
                                 ? new Filter<StockHolding>(x => x.Job.ID).IsNotEqualTo(ParentID)
                                 : new Filter<StockHolding>(x => x.Job.JobStatus.Active).IsEqualTo(false)
                                 : new Filter<StockHolding>(x => x.Job.JobStatus.Active).IsEqualTo(false)
                         ),
                         ),
@@ -369,7 +363,7 @@ namespace PRSDesktop
                     new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
                     new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(DateTime.MinValue)
                         .And(x => x.Product.ID).InList(pids)
                         .And(x => x.Product.ID).InList(pids)
                         .And(
                         .And(
-                            _includeReserves
+                            IncludeReserves
                                 ? new Filter<PurchaseOrderItem>(x => x.Job.ID).IsNotEqualTo(ParentID)
                                 ? new Filter<PurchaseOrderItem>(x => x.Job.ID).IsNotEqualTo(ParentID)
                                 : new Filter<PurchaseOrderItem>(x => x.Job.JobStatus.Active).IsEqualTo(false)
                                 : new Filter<PurchaseOrderItem>(x => x.Job.JobStatus.Active).IsEqualTo(false)
                         ),
                         ),

+ 44 - 0
prs.desktop/Panels/Jobs/JobSummaryPanel.xaml

@@ -0,0 +1,44 @@
+<UserControl x:Class="PRSDesktop.JobSummaryPanel"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+             xmlns:local="clr-namespace:PRSDesktop"
+             mc:Ignorable="d"
+             d:DesignHeight="300" d:DesignWidth="300">
+    <UserControl.Resources>
+        <Style x:Key="TextAlignLeft" TargetType="CheckBox">
+            <Style.Resources>
+                <Style TargetType="Path">
+                    <Setter Property="FlowDirection" Value="LeftToRight" />
+                </Style>
+                <Style TargetType="TextBlock">
+                    <Setter Property="FlowDirection" Value="LeftToRight" />
+                </Style>
+            </Style.Resources>
+
+            <Setter Property="FlowDirection" Value="RightToLeft" />
+        </Style>
+    </UserControl.Resources>
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <Border Grid.Row="0" CornerRadius="5,5,0,0" BorderBrush="Gray" BorderThickness="0.75" Padding="5,2" Background="WhiteSmoke" >
+            <DockPanel>
+                <CheckBox 
+                    x:Name="ReservedStock" 
+                    Content="Include Other Reserves" 
+                    IsThreeState="False" 
+                    IsChecked="False" 
+                    DockPanel.Dock="Right" 
+                    VerticalContentAlignment="Center" 
+                    Style="{StaticResource TextAlignLeft}"
+                    Checked="ReservedStock_OnChecked" Unchecked="ReservedStock_OnChecked"/>
+                <Label Content="" DockPanel.Dock="Left"/>
+            </DockPanel>
+        </Border>
+        <local:JobSummaryGrid x:Name="Summary" Grid.Row="1" Margin="0,2,0,0" />
+    </Grid>
+</UserControl>

+ 72 - 0
prs.desktop/Panels/Jobs/JobSummaryPanel.xaml.cs

@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using Comal.Classes;
+using InABox.Core;
+
+namespace PRSDesktop
+{
+    public partial class JobSummaryPanel : UserControl, IJobControl, IPanel<JobMaterial>
+    {
+        public JobSummaryPanel()
+        {
+            InitializeComponent();
+        }
+
+        public Guid ParentID
+        {
+            get => Summary.ParentID;
+            set => Summary.ParentID = value;
+        }
+        
+        public JobPanelSettings Settings { get; set; }
+
+        public bool IsReady { get; set; }
+
+        public event DataModelUpdateEvent OnUpdateDataModel;
+
+        public void CreateToolbarButtons(IPanelHost host)
+        {
+        }
+
+        public string SectionName => "Job Summary";
+
+        public DataModel DataModel(Selection selection)
+        {
+            // This won't work - it needs to incldue all the fields, because AutoTables like this don't have an ID :-(
+            var ids = Summary.ExtractValues(x => x.ID, selection).ToArray();
+            return new AutoDataModel<JobMaterial>(new Filter<JobMaterial>(x => x.ID).InList(ids));
+        }
+
+        public void Heartbeat(TimeSpan time)
+        {
+        }
+
+        public void Refresh()
+        {
+            Summary.Refresh(false, true);
+        }
+
+        public Dictionary<string, object[]> Selected()
+        {
+            return new Dictionary<string, object[]>();
+        }
+
+        public void Setup()
+        {
+            Summary.Refresh(true, false);
+        }
+
+        public void Shutdown()
+        {
+        }
+        
+        private void ReservedStock_OnChecked(object sender, RoutedEventArgs e)
+        {
+            Summary.IncludeReserves = ReservedStock.IsChecked == true;
+            Summary.Refresh(false, true);
+        }
+    }
+}