Sales order batch print/email to PDF only

Discussions relating to plugin development, and the Jiwa API.

Sales order batch print/email to PDF only

Postby DannyC » Thu Jul 28, 2022 6:24 pm

I've had an interesting request. Client wants to use the sales order batch print/Email form to write all candidate invoices to PDF.

I pretty much have it sussed - I can save all PDFs to a folder when the user emails and/or prints.
But I was wondering if it's possible to do neither print or email - just write to PDF.

I've added an extra override to just PDF but not sure what extra coding I need to stop printing or emailing.

I don't think this is particularly important as it's PDFing anyway when emailed or printed so the client may just have to live with it but they may insist on purely writing PDF files.

Plugin attached.
Attachments
Plugin Attkey Batch Print Email to PDF.xml
(35.53 KiB) Downloaded 41 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Sales order batch print/email to PDF only

Postby SBarnes » Thu Jul 28, 2022 7:40 pm

Having a quick look at your code there are probably two things you need to do:

1. Put the button click in the before handler so that you can stop Jiwa with a client cancel exception.
2. The other thing which is not quite as easy, you'll need to take over the process function that the batch print function does including any events it calls so the form updates. This will be as simple as looping over the candidates and doing the pdf part but you then need to make the candidate be seen as processed, which means set the status to Succeeded and then handing the line to the displayline function on the form which is at least a public method on the form.

The line also has the property of BatchProcessErrorMessage which you could set if your pdf print fails.

You could also have the following code to let the user select the folder

Code: Select all
string selectedFoler = "";
using(var fbd = new FolderBrowserDialog())
{
    DialogResult result = fbd.ShowDialog();

    if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
    {
        selectedFoler  = fbd.SelectedPath;

     
    }
}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Sales order batch print/email to PDF only

Postby DannyC » Thu Jul 28, 2022 7:48 pm

You could also have the following code to let the user select the folder

Already doing that with a system setting.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 31 guests

cron