/// <summary>
/// The <c>SalesBaileeController</c> class is the helper class for the associated SRS Report.
/// </summary>
class SalesBaileeController extends SrsPrintMgmtController
{
PrintCopyOriginal printCopyOriginal;
SalesInvoiceJournalPrint salesInvoiceJournalPrint;
RecordSortedList journalList;
CustInvoiceJour custInvoiceJour;
SalesBaileeContract salesBaileeContract;
/// <summary>
/// Initializes an instance of the print management report run object.
/// </summary>
/// <remarks>
/// This method provides the necessary construction of the <c>PrintMgmtReprotRun</c> class. Customizing
/// this class may cause problems with future upgrades to the software.
/// </remarks>
protected void initPrintMgmtReportRun()
{
printMgmtReportRun = PrintMgmtReportRun::construct(
PrintMgmtHierarchyType::Sales,
PrintMgmtNodeType::SalesTable,
PrintMgmtDocumentType::SalesOrderBailee);
printMgmtReportRun.parmReportRunController(this);
if (salesInvoiceJournalPrint)
{
printMgmtReportRun.parmDefaultCopyPrintJobSettings(new SRSPrintDestinationSettings(salesInvoiceJournalPrint.parmPrinterSettingsFormLetterCopy()));
printMgmtReportRun.parmDefaultOriginalPrintJobSettings(new SRSPrintDestinationSettings(salesInvoiceJournalPrint.parmPrinterSettingsFormLetter()));
printMgmtReportRun.parmForcePrintJobSettings(!salesInvoiceJournalPrint.parmUsePrintManagement());
}
else if (printCopyOriginal == PrintCopyOriginal::OriginalPrint)
{
//forcePrintJobSettings is reversal to usePrintManagement
printMgmtReportRun.parmForcePrintJobSettings(false);
}
}
/// <summary>
/// Loads the instances of the <c>PrintMgmtPrintSettingDetail</c> class that are used to print the
/// report.
/// </summary>
/// <param name="_jourTable">
/// The journal table to print.
/// </param>
/// <param name="_transTable">
/// The table to which the print management information has been related.
/// </param>
/// <param name="_languageId">
/// The language ID that should be used to retrieve the footer text.
/// </param>
/// <param name="_documentKeyValue">
/// A human readable value that uniquely identifies the document to be printed.
/// </param>
/// <remarks>
/// Start by calling the <c>loadPrintSettings</c> method to load print settings for the current
/// instance of the <c>FormLetterReport</c> class. Next, call the <c>moveNextPrintSetting</c> method to
/// iterate over the print settings that have been found. The <c>getCurrentPrintSetting</c> method will
/// then return the current instance of the <c>PrintMgmtPrintSettingDetail</c> class that can be used
/// to retrieve printer settings for the current copy of the report.
/// </remarks>
public void loadPrintSettings(Common _jourTable, Common _transTable, str _languageId, str _documentKeyValue = '')
{
boolean isValidReference(Common _referencedTableBuffer)
{
PrintMgmtNodeInstance nodeInstance = new PrintMgmtNodeInstance();
nodeInstance.parmNodeDefinition(PrintMgmtNode::construct(PrintMgmtNodeType::SalesTable));
nodeInstance.parmReferencedTableBuffer(_referencedTableBuffer);
return nodeInstance.isValidReference();
}
void setSettingDetail(PrintMgmtDocInstanceType _type, SRSPrintDestinationSettings _defaultSettings)
{
PrintMgmtPrintSettingDetail printSettingDetail = new PrintMgmtPrintSettingDetail();
PrintMgmtReportFormat printMgmtReportFormat;
printMgmtReportFormat = PrintMgmtReportFormat::findSystem(PrintMgmtDocumentType::SalesOrderBailee);
printSettingDetail.parmReportFormatName(printMgmtReportFormat.Name);
printSettingDetail.parmSSRS(printMgmtReportFormat.SSRS);
printSettingDetail.parmType(_type);
printSettingDetail.parmInstanceName(enum2str(_type));
// Since this will be reported to the screen, one copy is the only thing that makes sense
printSettingDetail.parmNumberOfCopies(1);
printSettingDetail.parmPrintJobSettings(_defaultSettings);
printMgmtReportRun.loadSettingDetail(printSettingDetail, _documentKeyValue);
}
if (printCopyOriginal == PrintCopyOriginal::OriginalPrint && isValidReference(_transTable))
{
// Print an original
printMgmtReportRun.load(_jourTable, _transTable, _languageId, _documentKeyValue);
}
else if (printCopyOriginal == PrintCopyOriginal::Copy)
{
// Print a copy
setSettingDetail(PrintMgmtDocInstanceType::Copy, printMgmtReportRun.parmDefaultCopyPrintJobSettings());
}
else
{
// Print an original. We also default to print one original when we are trying to
// print using Print Mgmt information, but don't have a valid table reference.
// This covers the reprint case where the original transaction record may not be present.
setSettingDetail(PrintMgmtDocInstanceType::Original, printMgmtReportRun.parmDefaultOriginalPrintJobSettings());
}
if (!printMgmtReportRun.more())
{
checkFailed("@SYS78951");
}
}
/// <summary>
/// Implements the print management functionality.
/// </summary>
/// <remarks>
/// This method loads the print settings for the business object. It then invokes any necessary
/// business logic and then calls the <c>outputReports</c> method.
/// </remarks>
protected void runPrintMgmt()
{
printCopyOriginal = this.parmArgs().parmEnum();
if (this.parmArgs().record())
{
// Get journal list from the selected record/s
journalList = FormLetter::createJournalListCopy(this.parmArgs().record());
}
else
{
journalList = this.parmArgs().object();
}
if (!journalList)
{
throw error("@SYS26348");
}
if (SysDictClass::isEqualOrSuperclass(classIdGet(args.caller()), classNum(FormletterJournalPrint)))
{
salesInvoiceJournalPrint = args.caller();
}
while (journalList.next(custInvoiceJour) && !this.parmCancelRun())
{
if (!custInvoiceJour)
{
throw error("@SYS26348");
}
this.initPrintMgmtReportRun();
this.loadPrintSettings(custInvoiceJour, custInvoiceJour.salesTable(), custInvoiceJour.LanguageId);
this.outputReports();
}
}
public static void main(Args _args)
{
SalesBaileeController reportController = new SalesBaileeController();
if (!NonSSRSPrintMgmtAdapter::runPrintMgmtNonSSRS(PrintMgmtDocumentType::SalesOrderBailee, _args))
{
return;
}
reportController.parmArgs(_args);
reportController.parmReportName(PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderBailee).getDefaultReportFormat());
reportController.parmShowDialog(false);
reportController.startOperation();
}
}