|  | @@ -46,6 +46,9 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          [NullEditor]
 | 
	
		
			
				|  |  |          public Type FormType { get; set; }
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        [NullEditor]
 | 
	
		
			
				|  |  | +        public DateTime Processed { get; set; }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
	
		
			
				|  | @@ -91,10 +94,11 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              _mappings = new CoreFieldMap<IDigitalFormInstance, DigitalFormDockModel>()
 | 
	
		
			
				|  |  |                  .Add(x => x.ID, x => x.ID)
 | 
	
		
			
				|  |  |                  .Add(x => x.Form.ID, x => x.FormID)
 | 
	
		
			
				|  |  | -                .Add(x=>x.Number, x=>x.Number)
 | 
	
		
			
				|  |  | +                .Add(x => x.Number, x => x.Number)
 | 
	
		
			
				|  |  |                  .Add(x => x.Form.Description, x => x.FormName)
 | 
	
		
			
				|  |  |                  .Add(x => x.FormCompleted, x => x.Completed)
 | 
	
		
			
				|  |  | -                .Add(x => x.FormCompletedBy.UserID, x => x.CompletedBy);
 | 
	
		
			
				|  |  | +                .Add(x => x.FormCompletedBy.UserID, x => x.CompletedBy)
 | 
	
		
			
				|  |  | +                .Add(x => x.FormProcessed, x => x.Processed);
 | 
	
		
			
				|  |  |              
 | 
	
		
			
				|  |  |              _query = new MultiQuery();
 | 
	
		
			
				|  |  |              
 | 
	
	
		
			
				|  | @@ -122,6 +126,17 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              options.EndUpdate();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        protected override DynamicGridStyle GetRowStyle(CoreRow row, DynamicGridStyle style)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var result = base.GetRowStyle(row, style);
 | 
	
		
			
				|  |  | +            if (!row.Get<DigitalFormDockModel, DateTime>(x => x.Processed).IsEmpty())
 | 
	
		
			
				|  |  | +                result = new DynamicGridRowStyle(result)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    Background = new SolidColorBrush(Colors.LightGray),
 | 
	
		
			
				|  |  | +                };
 | 
	
		
			
				|  |  | +            return result;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          private bool TypeFilter(CoreRow row, string[] filter)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              string typename = row.Get<DigitalFormDockModel, Type>(x => x.FormType).EntityName().Split('.').Last().SplitCamelCase();
 | 
	
	
		
			
				|  | @@ -149,28 +164,82 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              var modules = new Client<CustomModule>().Query(
 | 
	
		
			
				|  |  |                  new Filter<CustomModule>(x => x.DataModel).IsEqualTo(model.Name)
 | 
	
		
			
				|  |  |                      .And(x => x.Section).IsEqualTo(formID.ToString())
 | 
	
		
			
				|  |  | +                    .And(x => x.Visible).IsEqualTo(true)
 | 
	
		
			
				|  |  |                  ).Rows.Select(x => x.ToObject<CustomModule>());
 | 
	
		
			
				|  |  |              foreach(var module in modules)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                column.AddItem(module.Name, PRSDesktop.Resources.edit, row =>
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    try
 | 
	
		
			
				|  |  | +                column.AddItem(
 | 
	
		
			
				|  |  | +                    module.Name, 
 | 
	
		
			
				|  |  | +                    PRSDesktop.Resources.edit, 
 | 
	
		
			
				|  |  | +                    row =>
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  | -                        if(ScriptDocument.RunCustomModule(model, new Dictionary<string, object[]>(), module.Script))
 | 
	
		
			
				|  |  | +                        try
 | 
	
		
			
				|  |  |                          {
 | 
	
		
			
				|  |  | -                            Refresh(true, true);
 | 
	
		
			
				|  |  | +                            if(ScriptDocument.RunCustomModule(model, new Dictionary<string, object[]>(), module.Script))
 | 
	
		
			
				|  |  | +                            {
 | 
	
		
			
				|  |  | +                                Refresh(false, true);
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    catch(CompileException c)
 | 
	
		
			
				|  |  | +                        catch(CompileException c)
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            MessageBox.Show(c.Message);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        catch(Exception e)
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            MessageBox.Show(CoreUtils.FormatException(e));
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    },
 | 
	
		
			
				|  |  | +                    null,
 | 
	
		
			
				|  |  | +                    row.Get<DigitalFormDockModel, DateTime>(x => x.Processed).IsEmpty()
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            if (modules.Any())
 | 
	
		
			
				|  |  | +                column.AddSeparator();
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            if (row.Get<DigitalFormDockModel, DateTime>(x => x.Processed).IsEmpty())
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                column.AddItem(
 | 
	
		
			
				|  |  | +                    "Mark As Processed",
 | 
	
		
			
				|  |  | +                    PRSDesktop.Resources.lock_sml,
 | 
	
		
			
				|  |  | +                    (row) =>
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  | -                        MessageBox.Show(c.Message);
 | 
	
		
			
				|  |  | +                        var form = Activator.CreateInstance(formType) as IDigitalFormInstance;
 | 
	
		
			
				|  |  | +                        form.ID = row.Get<DigitalFormDockModel, Guid>(x => x.ID);
 | 
	
		
			
				|  |  | +                        form.FormProcessed = row.Get<DigitalFormDockModel, DateTime>(x => x.Processed);
 | 
	
		
			
				|  |  | +                        form.CommitChanges();
 | 
	
		
			
				|  |  | +                        form.FormProcessed = DateTime.Now;
 | 
	
		
			
				|  |  | +                        using (new WaitCursor())
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            ClientFactory.CreateClient(formType).Save(form, "Marked As Processed");
 | 
	
		
			
				|  |  | +                            Refresh(false, true);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                    catch(Exception e)
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                column.AddItem(
 | 
	
		
			
				|  |  | +                    "Clear Processed Flag",
 | 
	
		
			
				|  |  | +                    PRSDesktop.Resources.lock_sml,
 | 
	
		
			
				|  |  | +                    (row) =>
 | 
	
		
			
				|  |  |                      {
 | 
	
		
			
				|  |  | -                        MessageBox.Show(CoreUtils.FormatException(e));
 | 
	
		
			
				|  |  | +                        var form = Activator.CreateInstance(formType) as IDigitalFormInstance;
 | 
	
		
			
				|  |  | +                        form.ID = row.Get<DigitalFormDockModel, Guid>(x => x.ID);
 | 
	
		
			
				|  |  | +                        form.FormProcessed = row.Get<DigitalFormDockModel, DateTime>(x => x.Processed);
 | 
	
		
			
				|  |  | +                        form.CommitChanges();
 | 
	
		
			
				|  |  | +                        form.FormProcessed = DateTime.MinValue;
 | 
	
		
			
				|  |  | +                        using (new WaitCursor())
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            ClientFactory.CreateClient(formType).Save(form, "Processed Flag Cleared");
 | 
	
		
			
				|  |  | +                            Refresh(false, true);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                });
 | 
	
		
			
				|  |  | +                );
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (Security.IsAllowed<CanCustomiseModules>())
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  column.AddSeparator();
 | 
	
	
		
			
				|  | @@ -207,8 +276,8 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |              foreach (var type in _types.Where(x => !ExcludedTypes.Contains(x)))
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                var filter = Filter.Create<IDigitalFormInstance>(type, x => x.FormCompleted)
 | 
	
		
			
				|  |  | -                    .IsGreaterThanOrEqualTo(StartDate);
 | 
	
		
			
				|  |  | +                var filter = Filter.Create<IDigitalFormInstance>(type, x => x.FormCompleted).IsGreaterThanOrEqualTo(StartDate)
 | 
	
		
			
				|  |  | +                    .And<IDigitalFormInstance>(x=>x.FormCancelled).IsEqualTo(DateTime.MinValue);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  var cols = Columns.Create<IDigitalFormInstance>(type)
 | 
	
		
			
				|  |  |                      .Add<IDigitalFormInstance>(c => c.ID)
 | 
	
	
		
			
				|  | @@ -216,7 +285,8 @@ namespace PRSDesktop
 | 
	
		
			
				|  |  |                      .Add<IDigitalFormInstance>(c => c.Number)
 | 
	
		
			
				|  |  |                      .Add<IDigitalFormInstance>(c => c.Form.Description)
 | 
	
		
			
				|  |  |                      .Add<IDigitalFormInstance>(c => c.FormCompleted)
 | 
	
		
			
				|  |  | -                    .Add<IDigitalFormInstance>(c => c.FormCompletedBy.UserID);
 | 
	
		
			
				|  |  | +                    .Add<IDigitalFormInstance>(c => c.FormCompletedBy.UserID)
 | 
	
		
			
				|  |  | +                    .Add<IDigitalFormInstance>(c => c.FormProcessed);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  var sorts = SortOrder.Create<IDigitalFormInstance>(type, x => x.FormCompleted, SortDirection.Descending);
 | 
	
		
			
				|  |  |  
 |