Topic: Add stamp or watermark to reports on the fly – ad hoc.
The following modification will improve the paperless office workflow – no more rubber stamps (and add a watermark when you want).
--- reporting\reports_main ORIGINAL.php
+++ reporting\reports_main.php
@@ -110,6 +110,8 @@
_('To') => 'INVOICE',
_('Currency Filter') => 'CURRENCY',
_('email Customers') => 'YES_NO',
+ _('Stamp/Watermark Text') => 'TEXT',
+ _('Stamp/Watermark Colour') => 'COLOR',
_('Payment Link') => 'PAYMENT_LINK',
_('Comments') => 'TEXTBOX',
_('Customer') => 'CUSTOMERS_NO_FILTER',
--- reporting\rep107 ORIGINAL.php
+++ reporting\rep107.php
@@ -58,10 +58,12 @@
$to = $_POST['PARAM_1'];
$currency = $_POST['PARAM_2'];
$email = $_POST['PARAM_3'];
- $pay_service = $_POST['PARAM_4'];
- $comments = $_POST['PARAM_5'];
- $customer = $_POST['PARAM_6'];
- $orientation = $_POST['PARAM_7'];
+ $watermark_text = $_POST['PARAM_4'];
+ $watermark_color = $_POST['PARAM_5'];
+ $pay_service = $_POST['PARAM_6'];
+ $comments = $_POST['PARAM_7'];
+ $customer = $_POST['PARAM_8'];
+ $orientation = $_POST['PARAM_9'];
if (!$from || !$to) return;
@@ -122,6 +124,8 @@
$rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
$rep->SetHeaderType('Header2');
$rep->NewPage();
+ if ($watermark_text != '')
+ $rep->Draw_watermark($watermark_text, $watermark_color);
// calculate summary start row for later use
$summary_start_row = $rep->bottomMargin + (15 * $rep->lineHeight);
--- reporting\includes\reports_classes ORIGINAL.inc
+++ reporting\includes\reports_classes.inc
@@ -263,6 +263,9 @@
case 'TEXT':
return "<input type='text' name='$name'>";
+ case 'COLOR':
+ return "<input type='color' name='$name'>";
+
case 'TEXTBOX':
$value = (isset($_POST[$name]) ? $_POST[$name] : "");
return "<textarea rows=4 cols=30 maxlength=130 name='$name'>$value</textarea>";
I added the new function to the report construct so its available for all reports
--- reporting\includes\pdf_report ORIGINAL.inc
+++ reporting\includes\pdf_report.inc
@@ -291,6 +291,25 @@
$this->footerEnable = $footerenable;
$this->footerText = $footertext;
}
+
+ function Draw_watermark($watermark_text, $watermark_color)
+ {
+ $this->SetX(30);
+ $this->SetY(550);
+ $this->SetFontSize(48);
+ $this->setAlpha(0.5);
+ $this->SetTextColorArray($this->convertHTMLColorToDec($watermark_color));
+ $this->Font('B');
+ $this->StartTransform();
+ $this->Rotate(45);
+ $this->MultiCell(0,10, $watermark_text,0,'C',0,1,0,0);
+ $this->StopTransform();
+ $this->setAlpha(1);
+ $this->SetTextColor(0, 0, 0);
+ $this->SetFontSize(9);
+ $this->Font();
+ }
+
//
// Header for listings
//
Demo here
username: demo
Password: password
Currently I have only modified rep107.php so go to Sales->Customer and Sales Reports->Print Invoices: Choose a lighter-ish shade as transparency is set to 50%.
All ten document files would need to be changed as well (Paid, Payment Due Immediately, Urgent, etc) as well as all Banking and General Ledger Reports (Confidential, For Your Eyes Only, Projected, etc) Not sure if it would be required on anyother reports?
Notes:
I’ve used MultiCell, so long text will wrap and center; function MultiCell states that ‘\n’ can be used to start a new line, whilst this works it still prints the \n! Using report class ‘TEXTBOX’ (and pressing enter for a newline) instead of ‘TEXT’ does work perfectly, but is there a solution to just using ‘TEXT’ with \n? As 'TEXTBOX' takes up so much room on the page and for most cases would not be needed
I’ve also hard coded most of the variables, as a) It could possibly over complicate the input and b)There is not that much space left in some of the report options. I can only think of a popup window to add the rest of the variables: Anyone else have an idea?
Screenshots
Interface