Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion PrintSendProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using PX.Data.BQL.Fluent;
using PX.Objects.CA;

using System;
using System.Collections.Generic;

namespace SendEmailPrintReport
Expand All @@ -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<processingAction> { }
Expand All @@ -44,6 +45,14 @@ public PrintSendProcess()
RecordsView.Cache.AllowDelete = false;

}
protected virtual void _(Events.RowSelecting<CADepositWithSelected> e)
{
if (e.Row != null && FilterView.Current?.ProcessingAction == "R"
&& e.Row.Status == CADocStatus.Released)
{
e.Cancel = true;
}
}
protected virtual void _(Events.RowSelected<PrintSendProcessFilter> e)
{
if (e.Row != null)
Expand All @@ -56,6 +65,10 @@ protected virtual void _(Events.RowSelected<PrintSendProcessFilter> e)
{
RecordsView.SetProcessDelegate(EmailRecords);
}
else if (e.Row.ProcessingAction == "R")
{
RecordsView.SetProcessDelegate(ReleaseRecords);
}
}
}

Expand Down Expand Up @@ -97,5 +110,28 @@ public static void EmailRecords(List<CADepositWithSelected> list)
PXProcessing.SetProcessed();
}
}
public static void ReleaseRecords(List<CADepositWithSelected> list)
{
var graph = PXGraph.CreateInstance<CADepositEntry>();
foreach (var recordToRelease in list)
{
PXProcessing.SetCurrentItem(recordToRelease);
try
{
graph.Clear();
graph.Document.Current = graph.Document.Search<CADeposit.refNbr>(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);
}
}
}
}
}