SimpleInvoices Group Forum › Forums › Fearless359 SimpleInvoices Discussion Group › Question about templates for PDF output
Tagged: extensions, pdf, style, templates
- This topic has 21 replies, 3 voices, and was last updated 2 weeks, 1 day ago by
fearless359.
-
AuthorPosts
-
October 27, 2025 at 10:57 am #2250
marcnyc
ParticipantThank you for responding and for your suggestion.
I’ve tried doing what you suggest and I’ve added the line:
‘custom_field1’ => $row[‘custom_field1’],`
around line 215 in the Inc/Claz/Invoice.php file that I’ve copied into my extensions folder, like so:
$tableRows[] = [ 'action' => $action, 'index_id' => $row['index_id'], 'custom_field1' => $row['custom_field1'], 'customer' => $row['customer'], 'preference' => $row['preference'], 'date' => $row['date'], 'total' => $row['total'], 'owing' => isset($row['status']) ? $row['owing'] : '', 'aging' => $row['aging'] ?? '', 'currency_code' => $row['currency_code'], 'locale' => preg_replace($pattern,'$1-$2', $row['locale']) ];…but I am still getting the same error…
do I need to add a custom_field1 line anywhere else in this file?October 27, 2025 at 11:52 am #2251marcnyc
ParticipantI did a bit more digging…
…your solution works but copying the Inc/Claz/Invoice.php to the extensions directory does NOT work… maybe it’s a bug in the code but the php file is not included…
I know this because if I made the changes on root/Inc/Claz/Invoice.php file then your soltuion works but if I leave that file un-edited and I put my modified version in root/extensions/MYextension/Inc/Claz/Invoice.php it does not work…
I’ve also tried putting it in:
root/extensions/MYextension/templates/Inc/Claz/Invoice.php
and in:
root/extensions/MYextension/modules/Inc/Claz/Invoice.phpNone of the locations call the new file in Inc/Claz
October 27, 2025 at 4:28 pm #2252fearless359
KeymasterI’m a bit flummoxed with the complication that using namespaces appears to have introduced.
Given this, the simplest approach might be to add logic in the extension modules\invoices\manage.php file to take the
$invoicesarray and add a loop to run through it, taking the index_id, accessing the Invoice::getOne() method to read the invoice record, pull the custom fields and add them to the row being processed. Effectively updating what Invoice::manageTable() returns with the additional fields. This is kind of ugly, in that it means reading the invoice records twice to display once. But given how namespaces work with autoloading, I can’t think of a more elegant resolution off hand.Note that if you to this, you are working with the index_id field to get the invoice. So you need to set the
$useIndexIdparameter to true.-
This reply was modified 1 month, 1 week ago by
fearless359.
-
This reply was modified 1 month, 1 week ago by
fearless359.
October 28, 2025 at 8:32 am #2255marcnyc
ParticipantThanks for continuing to provide ideas.
This method is a bit too complex for my knowledge of PHP, however I was able to find a solution… I don’t know if you read my #2251 reply, but your previous suggestion DOES work, except the inclusion of the Inc/Clazz file DOES NOT work, so there might be a bug in the code whereas it doesn’t look for an Inc/Clazz file in the Extensions dir… you know what I mean?November 6, 2025 at 7:04 am #2256marcnyc
ParticipantJust checking in to see whether you had a chance to test this on your end…
wondering if this is a bug in the code or I’m making a mistakeNovember 6, 2025 at 9:06 am #2257fearless359
KeymasterI haven’t begun working on the issue of namespaces for extensions (which is what the Inc\Claz path effectively is). I’m currently addressing screen formatting for mobile device presentation which I introduced in the last update with mobile device menu support. I need to complete my work on this before working on extension development issues.
November 21, 2025 at 11:46 am #2267fearless359
KeymasterI’ve developed a solution for this that allows you to use custom field 1 (or could be 2,3 or 4) on the invoice management table screen in place of the preference field. The extension I developed is contained in the attached zip file. I will be supplementing the help information on extension development with this example to assist future users. Note that you need to download the current version of SI (version 2026.00.04) to load a change I made to the change of Invoice class private methods to be protected so the attached solution can simply replace the methods that need to be changed thus minimizing what you have to possibly change when loading future updates. Hope this helps.
Attachments:
-
This reply was modified 1 month, 1 week ago by
-
AuthorPosts
- You must be logged in to reply to this topic.
Recent Comments