Skip to content

Commit 7088c9d

Browse files
committed
Allow specifying the QR-Code size in invoices
1 parent 2bf9fc7 commit 7088c9d

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

application/helpers/invoice_helper.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ function invoice_recMod10($in): int
123123
* Returns a QR code for invoice payments.
124124
*
125125
* @param number invoice-id
126+
* @param number width
126127
*/
127-
function invoice_qrcode($invoice_id): string
128+
function invoice_qrcode($invoice_id, $width = 64): string
128129
{
129130
$CI = &get_instance();
130131

@@ -139,7 +140,13 @@ function invoice_qrcode($invoice_id): string
139140
$CI->load->library('QrCode', ['invoice' => $invoice]);
140141
$qrcode_data_uri = $CI->qrcode->generate();
141142

142-
return '<img src="' . $qrcode_data_uri . '" alt="QR Code" id="invoice-qr-code">';
143+
$numeric_width = intval($width);
144+
$width = '';
145+
if ($numeric_width > 0) {
146+
$width = ' width="' . strval($numeric_width) . '"';
147+
}
148+
149+
return '<img src="' . $qrcode_data_uri . '"' . $width . ' alt="QR Code" id="invoice-qr-code">';
143150
}
144151
}
145152

0 commit comments

Comments
 (0)