diff --git a/PrintSendProcess.cs b/PrintSendProcess.cs index 5b3dc47..8357eb1 100644 --- a/PrintSendProcess.cs +++ b/PrintSendProcess.cs @@ -2,6 +2,7 @@ using PX.Data.BQL.Fluent; using PX.Objects.CA; +using System; using System.Collections.Generic; namespace SendEmailPrintReport @@ -21,7 +22,7 @@ public class PrintSendProcessFilter : PXBqlTable, IBqlTable #region ProcessingAction [PXString] [PXDefault("P")] - [PXStringList(new string[] { "P", "E" }, new string[] { "Print", "Email" })] + [PXStringList(new string[] { "P", "E", "R" }, new string[] { "Print", "Email", "Release" })] [PXUIField(DisplayName = "Action")] public virtual string ProcessingAction { get; set; } public abstract class processingAction : PX.Data.BQL.BqlString.Field { } @@ -44,6 +45,14 @@ public PrintSendProcess() RecordsView.Cache.AllowDelete = false; } + protected virtual void _(Events.RowSelecting e) + { + if (e.Row != null && FilterView.Current?.ProcessingAction == "R" + && e.Row.Status == CADocStatus.Released) + { + e.Cancel = true; + } + } protected virtual void _(Events.RowSelected e) { if (e.Row != null) @@ -56,6 +65,10 @@ protected virtual void _(Events.RowSelected e) { RecordsView.SetProcessDelegate(EmailRecords); } + else if (e.Row.ProcessingAction == "R") + { + RecordsView.SetProcessDelegate(ReleaseRecords); + } } } @@ -97,5 +110,28 @@ public static void EmailRecords(List list) PXProcessing.SetProcessed(); } } + public static void ReleaseRecords(List list) + { + var graph = PXGraph.CreateInstance(); + foreach (var recordToRelease in list) + { + PXProcessing.SetCurrentItem(recordToRelease); + try + { + graph.Clear(); + graph.Document.Current = graph.Document.Search(recordToRelease.RefNbr, recordToRelease.DocType); + if (graph.Document.Current == null) + { + throw new PXException("Deposit {0} of type {1} was not found.", recordToRelease.RefNbr, recordToRelease.DocType); + } + graph.release.Press(); + PXProcessing.SetProcessed(); + } + catch (Exception e) + { + PXProcessing.SetError(e); + } + } + } } } \ No newline at end of file