I have this working.
/public_html/webERP/includes/tcpdf/tcpdf.php has a function Output()
public function Output($name='doc.pdf', $dest='I') {
There was already in place a case statement:
case 'F': {
// Save PDF to a local file
if ($this->diskcache) {
copy($this->buffer, $name);
} else {
$f = fopen($name, 'wb');
if (!$f) {
$this->Error('Unable to create output file: '.$name);
}
fwrite($f, $this->getBuffer(), $this->bufferlen);
fclose($f);
}
break;
}
/public_html/webERP/includes/class.pdf.php has two functions:
function OutputI($DocumentFilename = 'Document.pdf') {
function OutputD($DocumentFilename = 'Document.pdf') {
I added a third:
function OutputF($DocumentFilename = 'Document.pdf') {
if (($DocumentFilename == null) or ($DocumentFilename == '')) {
$DocumentFilename = _('Document'.date(DATE_ATOM).'pdf');
}
$this->Output($DocumentFilename,'F');
}
(I should later change the date(DATE_ATOM).
The ":"'s in the filename caused me much lost sleep last night
from using it in the higher level function call.
But that one line of code will only run if you forget to pass a parameter.)
I duplicated /public_html/webERP/PrintCustOrder_generic.php and created
PrintCustOrder_generic_tofile.php
I added my new scripts to the "scripts" table and set the security setting the same.
In PrintCustOrder_generic_tofile.php
I replaced:
$pdf->OutputD($_SESSION['DatabaseName'] . '_PackingSlip_' . date('Y-m-d') . '.pdf');
with
$tempname = date(DATE_ATOM);
$tempname = str_replace(":", "_", $tempname);
$pdf->OutputF('pdf/' . $_SESSION['DatabaseName'] . '_PackingSlip_'. $_GET['TransNo'] . $tempname . '.pdf');
There should also be a check here to see if the file already exists
and to generate a new DATE_ATOM name but for my purposes a
duplicate filename would be extremely unlikely.
In /public_html/webERP/DeliveryDetails.php I added an additional choice:
echo '<tr>
<td><img src="'.$rootpath.'/css/'.$theme.'/images/printer.png" title="' . _('Print') . '" alt="" /></td>
<td>' . ' ' . '<a target="_blank" href="' . $rootpath . '/PrintCustOrder_generic_tofile.php?identifier='.$identifier . '&TransNo=' . $OrderNo . '">'. _('Print packing slip To Temporary Folder') . ' (' . _('Laser') . ')' .'</a></td>
</tr>';
So a "pdf" folder under the webERP folder collects these created PDF files.
I am using WatchFTP
http://www.watchftp.com/index.html
to download these files to a personal computer running Windows
and deleting them from the server once downloaded.
I am using WatchDirectory
http://www.watchdirectory.net/index.html
to print any files that have not yet been printed,
which have been downloaded to a specific folder
The Vendor of these products,
which are very reasonable in cost,
tells me that I can have WatchFTP run a batch command
to have FoxIt print each file
and he has sent me an example batch file which I will try soon.
So a call to $pdf->OutputF from other scripts in the code base
should allow
accumulating all print jobs in a folder or an assortment of folders.
Naming conventions can be changed depending on if it is a Sales Order or Packing Slip or Invoice or Workorder etc
The flexibility with a third party FTP and naming conventions and printing mechanism
can let you direct certain print job types to a variety of printers at the users locations.
My only problem right now is that my call to PrintCustOrder_generic_tofile.php
leaves a blank window open and I have to close it manually
then I return to DeliveryDetails.php. I expect that this is an easy fix,
but I don't know what command to use and where to put it yet.