Parcourir la source

Merge remote-tracking branch 'origin/nick' into frank

Frank van den Bos il y a 2 ans
Parent
commit
57b3bde1d9

+ 39 - 21
prs.classes/Entities/Assignment/Assignment.cs

@@ -5,17 +5,17 @@ using InABox.Core;
 namespace Comal.Classes
 {
     //public class DeliveryAssignments : CoreAggregate<Assignment, Delivery, Guid>
-//{
-//    public override Expression<Func<Delivery, Guid>> Aggregate => Delivery => Delivery.ID;
-//    //public Expression<Func<Delivery, Guid>> Link => x => x.Assignment.ID;
-//    public override AggregateCalculation Calculation => AggregateCalculation.Count;
-
-//    public override Dictionary<Expression<Func<Delivery, object>>, Expression<Func<Assignment, object>>> Links =>
-//        new Dictionary<Expression<Func<Delivery, object>>, Expression<Func<Assignment, object>>>
-//        {
-//            { Delivery => Delivery.Assignment.ID, x => x.ID }
-//        };
-//}
+    //{
+    //    public override Expression<Func<Delivery, Guid>> Aggregate => Delivery => Delivery.ID;
+    //    //public Expression<Func<Delivery, Guid>> Link => x => x.Assignment.ID;
+    //    public override AggregateCalculation Calculation => AggregateCalculation.Count;
+
+    //    public override Dictionary<Expression<Func<Delivery, object>>, Expression<Func<Assignment, object>>> Links =>
+    //        new Dictionary<Expression<Func<Delivery, object>>, Expression<Func<Assignment, object>>>
+    //        {
+    //            { Delivery => Delivery.Assignment.ID, x => x.ID }
+    //        };
+    //}
 
     /// <summary>
     ///     An assignment represents an anticipated booking for an employee, much like a diary entry
@@ -47,20 +47,20 @@ namespace Comal.Classes
         [MemoEditor]
         [EditorSequence(5)]
         public string Description { get; set; }
-        
+
         [EditorSequence(6)]
         public AssignmentActivityLink ActivityLink { get; set; }
-        
+
         [EditorSequence(7)]
         [EntityRelationship(DeleteAction.SetNull)]
         public KanbanLink Task { get; set; }
-        
+
         [EditorSequence(8)]
         public JobLink JobLink { get; set; }
-        
+
         [EditorSequence(9)]
         public JobITPLink ITP { get; set; }
-        
+
         [NullEditor]
         [Obsolete("Replaced with Actual.Start", true)]
         public TimeSpan Start { get; set; }
@@ -68,11 +68,11 @@ namespace Comal.Classes
         [NullEditor]
         [Obsolete("Replaced with Actual.Duration", true)]
         public TimeSpan Duration { get; set; }
-        
+
         [NullEditor]
         [Obsolete("Replaced with Actual.Finish", true)]
         public TimeSpan Finish { get; set; }
-        
+
         [EditorSequence(10)]
         [CoreTimeEditor]
         public CoreTime Booked { get; set; }
@@ -80,7 +80,7 @@ namespace Comal.Classes
         [EditorSequence(11)]
         [CoreTimeEditor]
         public CoreTime Actual { get; set; }
-        
+
         [TimestampEditor]
         [EditorSequence(12)]
         public DateTime Completed { get; set; }
@@ -95,7 +95,7 @@ namespace Comal.Classes
 
         [NullEditor]
         public DeliveryLink Delivery { get; set; }
-        
+
         [NullEditor]
         [EntityRelationship(DeleteAction.SetNull)]
         public InvoiceLink Invoice { get; set; }
@@ -109,7 +109,7 @@ namespace Comal.Classes
         {
             return null;
         }
-        
+
 
         protected override void Init()
         {
@@ -125,5 +125,23 @@ namespace Comal.Classes
             Booked = new CoreTime();
             Actual = new CoreTime();
         }
+
+        public DateTime EffectiveStart()
+        {
+            if (Actual.Start.Ticks != 0)
+                return Date.Add(Actual.Start);
+            else
+                return Date.Add(Booked.Start);
+        }
+
+        public DateTime EffectiveFinish()
+        {
+            if (Actual.Finish.Ticks != 0)
+                return Date.Add(Actual.Finish);
+            else if (Actual.Start.Ticks != 0)
+                return Date.Add(Actual.Start).Add(Booked.Duration);
+            else
+                return Date.Add(Booked.Finish);
+        }
     }
 }

+ 1 - 1
prs.classes/SecurityDescriptors/Project_Descriptors.cs

@@ -42,7 +42,7 @@ namespace Comal.Classes
     {
     }
 
-    [Caption("View Web General Documents from App")]
+    [Caption("Open Mobile Native PDF Viewer")]
     public class CanOpenMobileNativePDFViewer : DisabledSecurityDescriptor<ProjectManagementLicense, JobDocumentSetMileStone>
     {
     }

+ 1 - 1
prs.mobile/comal.timesheets.Android/Properties/AndroidManifest.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="440300" android:versionName="4.40.3" package="au.com.frogsoftware.timesheets.comal_timesheets" android:installLocation="auto">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="440400" android:versionName="4.40.4" package="au.com.frogsoftware.timesheets.comal_timesheets" android:installLocation="auto">
 	<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" />
 	<uses-permission android:name="android.permission.INTERNET" />
 	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

+ 2 - 1
prs.mobile/comal.timesheets.Android/Resources/Resource.designer.cs

@@ -2,6 +2,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -14,7 +15,7 @@ namespace comal.timesheets.Droid
 {
 	
 	
-	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.0.0.73")]
+	[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "13.2.0.93")]
 	public partial class Resource
 	{
 		

+ 2 - 2
prs.mobile/comal.timesheets.iOS/Info.plist

@@ -9,9 +9,9 @@
 	<key>CFBundleName</key>
 	<string>TimeBench</string>
 	<key>CFBundleShortVersionString</key>
-	<string>4.40.3</string>
+	<string>4.40.4</string>
 	<key>CFBundleVersion</key>
-	<string>4.40.3</string>
+	<string>4.40.4</string>
 	<key>NSBluetoothAlwaysUsageDescription</key>
 	<string>Bluetooth access is needed to locate equipment items</string>
 	<key>NSBluetoothPeripheralUsageDescription</key>

+ 3 - 3
prs.mobile/comal.timesheets/Assignments/AssignmentColumn.xaml.cs

@@ -80,11 +80,11 @@ namespace comal.timesheets.iOS.Assignments
                     var assignment = new Assignment()
                     {
                         Date = e.Datetime.Date,
-                        Start = e.Datetime.TimeOfDay,
-                        Finish = e.Datetime.TimeOfDay.Add(new TimeSpan(1, 0, 0)),
-                        Duration = new TimeSpan(1, 0, 0),
                         Title = "New Assignment"
                     };
+                    assignment.Booked.Start = e.Datetime.TimeOfDay;
+                    assignment.Booked.Finish = e.Datetime.TimeOfDay.Add(new TimeSpan(1, 0, 0));
+                    assignment.Booked.Duration = new TimeSpan(1, 0, 0);
                     assignment.EmployeeLink.ID = App.Data.Employee.ID;
                     var editor = new AssignmentEdit(assignment);
                     Navigation.PushAsync(editor);

+ 6 - 9
prs.mobile/comal.timesheets/Assignments/AssignmentList.xaml.cs

@@ -303,17 +303,16 @@ namespace comal.timesheets
         }
 
         private void CreateAssignment(DateTime date, ScheduleResource resource)
-        {
-            
+        {           
             var assignment = new Assignment()
             {
                 Date = date.Date,
-                Start = new TimeSpan(date.TimeOfDay.Hours, 0, 0),
-                Finish = date.TimeOfDay.Add(new TimeSpan(1, 0, 0)),
-                Duration = new TimeSpan(1, 0, 0),
                 Title = "New Assignment",
             };
-            
+            assignment.Booked.Start = new TimeSpan(date.TimeOfDay.Hours, 0, 0);
+            assignment.Booked.Finish = date.TimeOfDay.Add(new TimeSpan(1, 0, 0));
+            assignment.Booked.Duration = new TimeSpan(1, 0, 0);
+
             assignment.EmployeeLink.ID = (resource is ScheduleResource sr)
                 ? (Guid)sr.Id
                 : App.Data.Employee.ID;
@@ -345,9 +344,7 @@ namespace comal.timesheets
             }            
             
             var editor = new AssignmentEdit(assignment);
-            Navigation.PushAsync(editor);
-
-            
+            Navigation.PushAsync(editor);            
         }
         
         private async Task DeleteAssignment(Guid id)

+ 30 - 9
prs.mobile/comal.timesheets/Assignments/DataModels/AssignmentEditDataModel.cs

@@ -71,9 +71,12 @@ namespace comal.timesheets
             .Add(x => x.Title)
             .Add(x => x.Description)
             .Add(x => x.Date)
-            .Add(x => x.Start)
-            .Add(x => x.Duration)
-            .Add(x => x.Finish)
+            .Add(x => x.Actual.Start)
+            .Add(x => x.Actual.Duration)
+            .Add(x => x.Actual.Finish)
+            .Add(x => x.Booked.Start)
+            .Add(x => x.Booked.Duration)
+            .Add(x => x.Booked.Finish)
             .Add(c => c.JobLink.ID)
             .Add(c => c.JobLink.JobNumber)
             .Add(c => c.JobLink.Name)
@@ -190,20 +193,38 @@ namespace comal.timesheets
 
         public TimeSpan Start
         {
-            get => GetValue(c => c.Start);
-            set => UpdateValue(c => c.Start, value);
+            get 
+            {
+                var start = GetValue(c => c.Actual.Start);
+                if (start == TimeSpan.Zero)
+                    start = GetValue(c => c.Booked.Start);
+                return start;
+            }
+            set => UpdateValue(c => c.Actual.Start, value);
         }
 
         public TimeSpan Duration
         {
-            get => GetValue(c => c.Duration);
-            set => UpdateValue(c => c.Duration, value);
+            get
+            {
+                var duration = GetValue(c => c.Actual.Duration);
+                if (duration == TimeSpan.Zero)
+                    duration = GetValue(c => c.Booked.Duration);
+                return duration;
+            }
+            set => UpdateValue(c => c.Actual.Duration, value);
         }
         
         public TimeSpan Finish 
         {
-            get => GetValue(c => c.Finish);
-            set => UpdateValue(c => c.Finish, value);
+            get
+            {
+                var finish = GetValue(c => c.Actual.Finish);
+                if (finish == TimeSpan.Zero)
+                    finish = GetValue(c => c.Booked.Finish);
+                return finish;
+            }
+            set => UpdateValue(c => c.Actual.Finish, value);
         }
         
         public Guid JobID 

+ 51 - 34
prs.mobile/comal.timesheets/Assignments/DataModels/AssignmentListDataModel.cs

@@ -13,57 +13,75 @@ namespace comal.timesheets
     public class AssignmentListDataModel : ListDataModel<Assignment, AssignmentListDataModelItem>
     {
         public override Columns<Assignment> Columns => new Columns<Assignment>(x => x.ID)
-            .Add(x=>x.Number)
-            .Add(x=>x.Title)
-            .Add(x=>x.Description)
-            .Add(x=>x.Date)
-            .Add(x=>x.Start)
-            .Add(x=>x.Finish)
-            .Add(x=>x.ActivityLink.Color)
-            .Add(x=>x.EmployeeLink.ID)
-            .Add(x=>x.JobLink.ID)
-            .Add(x=>x.JobLink.JobNumber)
-            .Add(x=>x.JobLink.Name)
-            .Add(x=>x.Task.ID)
-            .Add(x=>x.Task.Number)
-            .Add(x=>x.Task.Title)
-            .Add(x=>x.Completed);
-        
-        
-        
+            .Add(x => x.Number)
+            .Add(x => x.Title)
+            .Add(x => x.Description)
+            .Add(x => x.Date)
+            .Add(x => x.Actual.Start)
+            .Add(x => x.Actual.Finish)
+            .Add(x => x.Booked.Start)
+            .Add(x => x.Booked.Finish)
+            .Add(x => x.ActivityLink.Color)
+            .Add(x => x.EmployeeLink.ID)
+            .Add(x => x.JobLink.ID)
+            .Add(x => x.JobLink.JobNumber)
+            .Add(x => x.JobLink.Name)
+            .Add(x => x.Task.ID)
+            .Add(x => x.Task.Number)
+            .Add(x => x.Task.Title)
+            .Add(x => x.Completed);
     }
-    
+
     public class AssignmentListDataModelItem : CoreDataModelItem
     {
-        
+
         public Guid Id => Row.Get<Assignment, Guid>(c => c.ID);
 
         public int Number => Row.Get<Assignment, int>(c => c.Number);
-        
+
         public Guid EmployeeId => Row.Get<Assignment, Guid>(c => c.EmployeeLink.ID);
-        
+
         public Guid JobID => Row.Get<Assignment, Guid>(c => c.JobLink.ID);
         public string JobNumber => Row.Get<Assignment, String>(c => c.JobLink.JobNumber);
         public string JobName => Row.Get<Assignment, String>(c => c.JobLink.Name);
-        
+
         public Guid TaskID => Row.Get<Assignment, Guid>(c => c.Task.ID);
         public int TaskNumber => Row.Get<Assignment, int>(c => c.Task.Number);
         public string TaskName => Row.Get<Assignment, String>(c => c.Task.Title);
-        
+
         public String Subject => string.Format("{0}{1} {2}",
-            Row.Get<Assignment, int>(c => c.Number), 
-            Row.Get<Assignment,Guid>(c=>c.JobLink.ID) != Guid.Empty
+            Row.Get<Assignment, int>(c => c.Number),
+            Row.Get<Assignment, Guid>(c => c.JobLink.ID) != Guid.Empty
                 ? $"({Row.Get<Assignment, String>(c => c.JobLink.JobNumber)})"
                 : "",
             Row.Get<Assignment, String>(c => c.Title));
-        
+
         public string Notes => Row.Get<Assignment, String>(c => c.Description);
-        
-        public DateTime StartTime =>
-            Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Start));
 
-        public DateTime EndTime =>
-            Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Finish));
+        public DateTime StartTime
+        {
+            get
+            {
+                var startspan = Row.Get<Assignment, TimeSpan>(c => c.Actual.Start);
+                if (startspan.TotalMinutes != 0)
+                    return Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Actual.Start));
+                else
+                    return Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Booked.Start));
+            }
+        }
+
+
+        public DateTime EndTime
+        {
+            get
+            {
+                var finishspan = Row.Get<Assignment, TimeSpan>(c => c.Actual.Finish);
+                if (finishspan.TotalMinutes != 0)
+                    return Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Actual.Finish));
+                else
+                    return Row.Get<Assignment, DateTime>(c => c.Date).Add(Row.Get<Assignment, TimeSpan>(c => c.Booked.Finish));
+            }
+        }
 
         public bool Completed => !Row.Get<Assignment, DateTime>(c => c.Completed).IsEmpty();
 
@@ -72,7 +90,7 @@ namespace comal.timesheets
             get
             {
                 var color = Row.Get<Assignment, String>(c => c.ActivityLink.Color);
-                return !String.IsNullOrWhiteSpace(color) 
+                return !String.IsNullOrWhiteSpace(color)
                     ? Color.FromHex(color)
                     : Color.Silver;
             }
@@ -82,7 +100,6 @@ namespace comal.timesheets
         public Color TextColor => Color.Black;
 
         public ObservableCollection<object> ResourceIds => new ObservableCollection<object>() { Row.Get<Assignment, Guid>(c => c.EmployeeLink.ID) };
-
     }
 
 }

+ 2 - 2
prs.mobile/comal.timesheets/CustomControls/Pages/PDFList.xaml.cs

@@ -12,7 +12,7 @@ using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using XF.Material.Forms.UI.Dialogs;
 using Document = InABox.Core.Document;
-
+using PRSSecurity = InABox.Core.Security;
 
 namespace comal.timesheets
 {
@@ -225,7 +225,7 @@ namespace comal.timesheets
             shell.FileName = shell.FileName.ToLower();
             if (shell.FileName.EndsWith("pdf"))
             {
-                if (Device.RuntimePlatform.Equals(Device.Android) && Security.IsAllowed<CanOpenMobileNativePDFViewer>())
+                if (Device.RuntimePlatform.Equals(Device.Android) && PRSSecurity.IsAllowed<CanOpenMobileNativePDFViewer>())
                     OpenNativeViewer(shell);
                 else
                 {

+ 2 - 1
prs.mobile/comal.timesheets/CustomControls/Pages/PDFViewer.xaml.cs

@@ -11,6 +11,7 @@ using Xamarin.Essentials;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using XF.Material.Forms.UI.Dialogs;
+using PRSSecurity = InABox.Core.Security;
 
 namespace comal.timesheets
 {
@@ -80,7 +81,7 @@ namespace comal.timesheets
                         if (doc.FileName.EndsWith("pdf") || doc.FileName.EndsWith("pdf") || doc.FileName.EndsWith("pdf"))
                         {
                             byte[] data = table2.Rows.First().Get<Document, byte[]>(x => x.Data);
-                            if (Device.RuntimePlatform.Equals(Device.Android) && Security.IsAllowed<CanOpenMobileNativePDFViewer>())
+                            if (Device.RuntimePlatform.Equals(Device.Android) && PRSSecurity.IsAllowed<CanOpenMobileNativePDFViewer>())
                                 OpenNativeViewer(doc.FileName, data);
                             else
                                 ShowPDF(data);

+ 3 - 3
prs.mobile/comal.timesheets/Data Classes/NotifyChanges.cs

@@ -17,9 +17,9 @@ namespace comal.timesheets
             string latestChanges = "";
             List<string> changes = new List<string>
                 {
-                "- Bug fixes to Stock Control functions",
-                "- Bug fix open digital form from Task not working",
-                "- View delivery from Notifications"
+                "- Update to assignments (use actual/booked)",
+                "- Improve digital form viewing from tasks",
+                "- Improve PDF viewer for Androids"
                 };
             foreach (string s in changes)
             {

+ 2 - 1
prs.mobile/comal.timesheets/Site/JobDocViewer.xaml.cs

@@ -18,6 +18,7 @@ using Xamarin.Essentials;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using XF.Material.Forms.UI.Dialogs;
+using PRSSecurity = InABox.Core.Security;
 
 namespace comal.timesheets
 {
@@ -397,7 +398,7 @@ namespace comal.timesheets
         void List_Tapped(object sender, EventArgs e)
         {
             var shell = listView.SelectedItem as JobDocSetFileShell;
-            if (Device.RuntimePlatform.Equals(Device.Android) && Security.IsAllowed<CanOpenMobileNativePDFViewer>())
+            if (Device.RuntimePlatform.Equals(Device.Android) && PRSSecurity.IsAllowed<CanOpenMobileNativePDFViewer>())
                 OpenNativeViewer(shell.DocLinkID);
             else
             {