The-Network-Crew / BPAY-for-WHMCS

(Payment Gateway Module) BPAY for the WHMCS Automation System.
https://marketplace.whmcs.com/product/7388-bpay-for-whmcs
GNU General Public License v3.0
4 stars 4 forks source link

BPAY Image on each page of Invoice - Add option for 1st page only #10

Open bakkbone opened 1 year ago

bakkbone commented 1 year ago

Hi again all

Once again I'm not sure if this is behaviour as intended or a bug but should the image be displaying on every page of the PDF? We based our template layout off it appearing on the first page only but I notice it's appearing on all pages

File Permissions File / Directory Name File Type Status Permission Level Action /modules/gateways/bpay.php PHP (Hypertext Preprocessor) Found 0644 /modules/gateways/bpay/arial.ttf TTF (TrueType Font) Found 0644 bpay_mgr_hooks.php (Addon folder) PHP (Hypertext Preprocessor) Found 0644 /includes/hooks/bpay_mgr_inc.php PHP (Hypertext Preprocessor) Found 0644 Customers (Gateway folder) Directory Found 0755 Invoices (Gateway folder) Directory Found 0755

System Environment Environment Type Result Operating System (OS) Linux Web Server (Software) Apache WHMCS Version 8.5.1 IonCube Version 12...2 BPAY Manager: Addon Version 2.1.9 BPAY Manager: Hooks Version 2.1.9 BPAY Gateway: Version 2.1.9

PHP 7.4 running on Ubuntu 20.04

lsthompson commented 1 year ago

Thanks for raising this. I'll check, though can see every page as being valid - especially if you consider placing the BPAY info in the footer.

bakkbone commented 1 year ago

I can see a case for that - but in our case (as with many in telecommunications which is what we're using WHMCS for), we would either include it with customer details at the start or in a payment stub which need only appear once - so, either the first or last page. And the first page is easier to control in this environment than the last.

lsthompson commented 1 year ago

Fair call. Sounds like a configuration option for multi-page would be wise to accommodate.

Have renamed the issue and will give this some time in November, worst case December.

It should have had more time by now - we've had major projects to get out by year end.

lsthompson commented 1 year ago

We're leaning towards changing the behaviour to do 1st-page-only by default & potentially only that way.

In most cases we'd imagine it would be ideal to have it be single-instance. Will explore this soon.

function insertInvoiceFunc($replace = false){
    $insertString = '///////////////////////////////////////////////////////////////////////////
/// START: BPAY GENERATOR
///////////////////////////////////////////////////////////////////////////
    if (file_exists(ROOTDIR."/modules/gateways/bpay.php")) {
        require_once(ROOTDIR."/modules/gateways/bpay.php");
        $output = BPAY_PDF($clientsdetails["id"],$invoicenum);

        $pagecount = $pdf->getNumPages();
        for($i = 1; $i <= $pagecount; $i++){
            $pdf->setPage($i);
            if($output["mode"] == 1){
                $pdf->Image(ROOTDIR."/modules/gateways/bpay/customers/".$clientsdetails["id"].".jpg",$output["Xaxis"],$output["Yaxis"],$output["size"]);
            }else if($output["mode"] == 2){
                $pdf->Image(ROOTDIR."/modules/gateways/bpay/invoices/".$invoicenum.".jpg",$output["Xaxis"],$output["Yaxis"],$output["size"]);
            }
        }
    }
///////////////////////////////////////////////////////////////////////////
/// END: BPAY GENERATOR
///////////////////////////////////////////////////////////////////////////';

The above starts (currently) at L2223 in bpay_mgr.php - you can see the page # increment to loop through.

lsthompson commented 1 year ago

The default behaviour is changing to include the BPAY image on the first page of invoices only.

Current plan is to include this change in the next release which should be published this week.

(If there's enough push to re-include the old functionality, we may add an option for all pages)