doPrintCheque()
Overview
doPrintCheque() renders a single cheque as an HTML block, applying the configured print layout for a given bank account. It is used inside payment voucher print pipelines where one or more cheques must be embedded in a printable HTML page. The function returns a self-contained HTML string that you concatenate into the final output sent to the browser or PDF renderer.
Function Signature
function doPrintCheque(
array $drow,
string $chqbank,
string $p_date,
string $p_payee,
string $p_amtword,
float $p_amount,
string $p_bills
): string
Returns a string of HTML representing one printed cheque.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$drow |
array |
Yes | The voucher data row fetched from the database — typically a single row from the payment voucher query. Used to resolve layout settings and bank-specific cheque dimensions. |
$chqbank |
string |
Yes | Bank identifier / account code for the cheque being printed. Determines which cheque template or dimension profile is loaded. |
$p_date |
string |
Yes | Cheque date to print, formatted as DD-MM-YYYY (or as configured for the bank's cheque layout). |
$p_payee |
string |
Yes | Name of the payee — the "Pay to" line on the cheque. |
$p_amtword |
string |
Yes | Amount expressed in words (e.g., "Rupees Fifty Thousand Only"). Usually generated by amtToWords() or equivalent before calling this function. |
$p_amount |
float |
Yes | Numeric amount to print in the amount box (e.g., 50000.00). |
$p_bills |
string |
Yes | Bill reference details — a comma-separated or pre-formatted string listing the invoice/bill numbers the payment covers. Printed in the remarks/narration area of the cheque, if the template supports it. |
Return Value
Returns a string containing an HTML <div> (or <table>) block representing the printed cheque. This block is designed for direct concatenation into a larger HTML document.
// Typical usage
$html = '<html><body>';
$html .= doPrintCheque( $drow, $chqbank, $p_date, $p_payee, $p_amtword, $p_amount, $p_bills );
$html .= '</body></html>';
echo $html;
Example — Single Cheque Print
// 1. Fetch the voucher row
$drow = $db->fetch("SELECT * FROM pj_acme_payment_voucher WHERE vch_id = ?", [$vch_id]);
// 2. Prepare cheque fields
$chqbank = $drow['bank_code']; // e.g., 'HDFC001'
$p_date = date('d-m-Y', strtotime($drow['chq_date']));
$p_payee = $drow['payee_name'];
$p_amount = (float) $drow['chq_amount'];
$p_amtword = amtToWords($p_amount); // helper function
$p_bills = $drow['bill_refs']; // e.g., 'INV/24-25/1023, INV/24-25/1024'
// 3. Render cheque HTML
$html = '';
$html .= doPrintCheque( $drow, $chqbank, $p_date, $p_payee, $p_amtword, $p_amount, $p_bills );
Example — Multiple Cheques in One Print Job
When a payment voucher covers multiple bank accounts or split cheques, call doPrintCheque() in a loop:
$html = '';
foreach ($cheque_rows as $crow) {
$chqbank = $crow['bank_code'];
$p_date = date('d-m-Y', strtotime($crow['chq_date']));
$p_payee = $crow['payee_name'];
$p_amount = (float) $crow['chq_amount'];
$p_amtword = amtToWords($p_amount);
$p_bills = $crow['bill_refs'];
$html .= doPrintCheque( $drow, $chqbank, $p_date, $p_payee, $p_amtword, $p_amount, $p_bills );
}
echo $html;
!!! tip "Page breaks between cheques"
Add <div style="page-break-after: always;"></div> between cheque blocks when printing multiple cheques, so each renders on its own page in the PDF/print output.
How the Layout Is Resolved
Internally, doPrintCheque() uses $chqbank to look up the cheque template dimensions (field positions, font sizes, line heights) stored in the ERP's bank/cheque configuration. If no custom layout is found for the bank code, a default generic cheque template is applied.
The $drow array may carry additional column values (like print_template_id or bank_cheque_layout) that override the default lookup — ensure the SQL fetching $drow selects all relevant columns.
Amount Words
$p_amtword = amtToWords($p_amount);
// Output: "Rupees Fifty Thousand Only"
Bill References ($p_bills)
$p_bills is a free-text string. Format it before passing:
```