Kasluc Komleshi
Kasluc Komleshi

Reputation: 39

WHMCS Separate Quote & Invoice Templates (Multibranding)

We are looking for a possibility of sending quotes and invoices with different layouts for different clients in WHMCS. Practically we want to have two brands that coexist in WHMCS and generate quotes and invoices with different logo and address for different clients. This way if a client is part of a specific brand, the quote and invoice that he will receive will be regarding the specific brand.

We were thinking on editing the quotepdf.tpl file to define the client based on the client group. if a client is part of a group, we send a specific quote and invoice, otherwise we send a different one.

The part regarding our task is this one below. Do you think this is a correct way to go? If yes, how can we check the group of which the client is a member every time an invoice or quote is generated and decide which layout to use?

Thank you

    # Logo
if (file_exists(ROOTDIR.'/assets/img/logo.png')) $pdf->Image(ROOTDIR.'/assets/img/logo.png', 20, 25, 75);
elseif (file_exists(ROOTDIR.'/assets/img/logo.jpg')) $pdf->Image(ROOTDIR.'/assets/img/logo.jpg', 20, 25, 75);
else $pdf->Image(ROOTDIR.'/assets/img/placeholder.png', 20, 25, 75);

# Company Details
$pdf->SetFont($pdfFont,'',13);
$pdf->Cell(0,6,trim($companyaddress[0]),0,1,'R');
$pdf->SetFont($pdfFont,'',9);
for ( $i = 1; $i <= ((count($companyaddress)>6) ? count($companyaddress) : 6); $i += 1) {
    $pdf->Cell(0,4,trim($companyaddress[$i]),0,1,'R');
}

Upvotes: 0

Views: 428

Answers (1)

wesamly
wesamly

Reputation: 1584

Create different invoice template for each client group, copy the default template into it, and customize.

For group id: 2, create invoicepdf_2.tpl,

For group id: 3, create invoicepdf_3.tpl,

For no group: create invoicepdf_0.tpl

In invoicepdf.tpl, delete all lines and add the following:

<?php
$invoiceFile = __DIR__ . '/invoicepdf_' . $clientsdetails['groupid'] . '.tpl';
if (file_exists($invoiceFile)) {
    include $invoiceFile;
}

This way you can customize each file without adding many conditions and checks.

Upvotes: 0

Related Questions