https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36588
--- Comment #2 from Lisette Scheer <[email protected]> --- Created attachment 211125 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211125&action=edit Bug 36588: Add a template toolkit field picker to the notice editor The field list in the notice editor could only insert Koha's bespoke <<table.column>> syntax, and listed the same tables for every notice of a module, whether the notice received them or not. This enhancement adds an "Insert as" choice to insert Template Toolkit instead, and lists the fields each notice can actually use in each syntax: - Template Toolkit: the fields of each object the notice receives (e.g. [% booking.start_date %]), a FOREACH loop for each list, and its other values (e.g. [% passwordreseturl %]) - bespoke: the columns of the tables the notice receives (e.g. <<borrowers.firstname>>), and its other values (e.g. <<user>>) Only the fields of the chosen syntax are shown, and only the syntaxes the notice can use are offered: e.g. booking notices, which only receive objects, cannot use the bespoke syntax. Some data is only available to the bespoke syntax: the claimed orders and issues of acquisition and serial claims, and the vendor contact of acquisition notices. For those notices, the choice is "Template Toolkit, bespoke where needed" instead of Template Toolkit: its list has the Template Toolkit fields and the tables only the bespoke syntax can use, inserted as <<table.column>>. Both syntaxes can be used in one notice. Koha::Notice::Template::Variables lists what each notice receives, for every call to C4::Letters::GetPreparedLetter. Notices it does not know keep the fields listed before for their module. The TT variable names come from C4::Letters::tt_table_config, extracted from _get_tt_params. A test checks that every sample notice is listed, so that adding a notice without listing what it receives fails. Patron attributes are inserted with borrower.extended_attribute_values (bug 30657), as a loop for repeatable attribute types. The list also offers the Template Toolkit plugins useful in notices (KohaDates, Price, Branches, ItemTypes, Categories, AuthorisedValues, Koha) with examples of their methods and filter options, e.g. [% checkout.date_due | $KohaDates as_due_date => 1 %]. Inserting an example adds the matching [% USE ... %] line at the top of the message if it is not there yet. The syntax defaults to the one the template already uses, and to TT for new templates. Test plan: 1. Apply the patch and restart services 2. Go to Tools > Notices and slips and edit the CHECKOUT notice 3. Open the Email template: => "Insert as" offers Template Toolkit and Bespoke, Template Toolkit is selected as the notice uses it => The list shows groups for biblio, biblioitem, borrower, branch, checkout and item, then the plugins 4. Pick checkout.date_due and click Insert: => [% checkout.date_due %] is inserted at the cursor 5. Pick "Price: amount with symbol" and insert it: => [% borrower.account.balance | $Price with_symbol => 1 %] is inserted => [% USE Price %] is added at the top as it was missing, and only once if you insert it again 6. Select Bespoke: => The list shows the BIBLIO, BIBLIOITEMS, BORROWERS, BRANCHES, ISSUES and ITEMS columns, and no plugins 7. Insert issues.date_due: => <<issues.date_due>> is inserted 8. Edit BOOKING_CONFIRMATION: => Only Template Toolkit is offered, with a note that the notice does not receive any data the bespoke syntax can use => The list shows the booking fields, e.g. booking.start_date 9. Edit TRANSFER_OWNERSHIP (Lists): => The list shows owner, old_owner and shelf 10. Edit PASSWORD_RESET (Patrons): => Template Toolkit lists user and passwordreseturl under ---VALUES---, bespoke lists them as <<user>> and <<passwordreseturl>> 11. Edit ACQCLAIM (Claim acquisition) and open the Email template: => "Insert as" offers "Template Toolkit, bespoke where needed" and Bespoke, with a note listing the data Template Toolkit cannot use => The list shows the bookseller and branch fields, then the tables marked "(bespoke only)", e.g. ---ORDERS--- (bespoke only) => Inserting bookseller.name then aqorders.ordernumber gives [% bookseller.name %]<<aqorders.ordernumber>> 12. Create a patron attribute type CODE, then reload a notice: => The borrower fields include attribute:CODE, inserting [% borrower.extended_attribute_values.CODE %] 13. Create a new notice: => "Insert as" defaults to Template Toolkit 14. prove t/Koha/Notice/Template/Variables.t t/db_dependent/Koha/Notice/Template/Variables.t t/db_dependent/Letters/TemplateToolkit.t Co-Authored-By: Claude Opus 5.5 <[email protected]> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes. _______________________________________________ Koha-bugs mailing list -- [email protected] To unsubscribe send an email to [email protected] website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
