| 
					
				 | 
			
			
				@@ -69,6 +69,7 @@ using ValidationResult = InABox.Clients.ValidationResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Diagnostics.CodeAnalysis; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using System.Runtime.InteropServices; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 using FastReport.Export.Email; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+using InABox.Wpf; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -491,8 +492,11 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AddSetupSeparator(tab); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AddSetupAction(tab, "Custom Modules", ManageModules, PRSDesktop.Resources.script).SetSecurityToken<CanCustomiseModules>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             AddSetupAction(tab, "Reports", ManageReports, PRSDesktop.Resources.printer).SetSecurityToken<CanDesignReports>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AddSetupAction(tab, "Email Templates", ManageEmailTemplates, PRSDesktop.Resources.email).SetSecurityToken<CanDesignReports>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void ConfigureMainScreen() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1791,10 +1795,51 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         #region Email 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void DoEmailReport(DataModel model, byte[] data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        {            
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CheckTemplates(model, data);            
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void CheckTemplates(DataModel model, byte[] data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             string attachmentName = DetermineName(model); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            EmailUtils.CreateEMLFile(attachmentName, data, App.EmployeeEmail, "Emailing report for " + attachmentName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //this section is meant to be for parsing templates into emails - not working yet! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //var templates = new Client<DataModelTemplate>().Query(new Filter<DataModelTemplate>(x => x.Model).IsEqualTo(model.Name)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //if (templates.Rows.Any()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //    var context = new ContextMenu(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //    foreach (var row in templates.Rows) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        var menu = new MenuItem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            Header = row.Get<DataModelTemplate, string>(x => x.Name), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            Tag = row 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        menu.Click += (o, args) => 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            var chosenrow = ((MenuItem)o).Tag as CoreRow;                        
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //                var data = chosenrow.Get<DataModelTemplate, string>(x => x.Template); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //                var to = chosenrow.Get<DataModelTemplate, string>(x => x.To); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //                var body = DataModelUtils.ParseTemplate(model, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            catch (Exception err) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //                MessageBox.Show("Unable to Parse Template!\n\n" + err.Message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //        context.Items.Add(menu); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //    context.IsOpen = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //{               
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                EmailUtils.CreateEMLFile(attachmentName, data, App.EmployeeEmail, "Emailing report for " + attachmentName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //}                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private string DetermineName(DataModel model) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1814,11 +1859,11 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 else if (table.Rows.Count > 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     foreach (CoreRow row in table.Rows) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    {                      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         title = title + row.Get<PurchaseOrder, string>(x => x.PONumber) + ", "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     title = title.Substring(0, title.Length - 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }                 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return title; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -3764,6 +3809,23 @@ namespace PRSDesktop 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ReloadReports(section, model); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private void ManageEmailTemplates() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (CurrentTab is null || CurrentPanel is null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var section = CurrentPanel.SectionName; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var model = CurrentPanel.DataModel(Selection.None); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (model == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                MessageBox.Show("No DataModel for " + CurrentTab.Header); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            var window = new EmailTemplateManagerWindow(model); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            window.ShowDialog(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void ManageReportsMenu_Click(object sender, RoutedEventArgs e) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ManageReports(); 
			 |