ISSUESLIP and old_checkouts in template code
I'm trying to access old_checkouts in an ISSUESLIP like this: [% FOREACH checkout IN old_checkouts %] This seems to return an empty list, which is not surprising given that the ISSUESLIP supposedly doesn't get passed the old_checkouts variable, according to the wiki: https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit I've been trying to figure out how to get old_checkouts passed to ISSUESLIP, but I'm not too familiar with the code. As best as I can tell, this needs to be done somewhere in C4/Members.pm, perhaps in the IssueSlip function, but it's not clear to me what I need to do. Any guidance would be appreciated. Thanks in advance!
Hi Mark, Try this: @ Members.pm:596 @ sub IssueSlip { ); %loops = ( issues => [ map { $_->{issues}{itemnumber} } @checkouts ], + old_issues => [ $patron->old_checkouts->get_column('itemnumber') ], overdues => [ map { $_->{issues}{itemnumber} } @overdues ], opac_news => [ map { $_->{opac_news}{idnew} } @news ], ); Then, in the template of the notice: [% FOR c IN old_checkouts %] [% c.item.barcode %]<p> [% END %] Cheers, Jonathan Le jeu. 24 oct. 2019 à 15:24, Mark Alexander <marka@pobox.com> a écrit :
I'm trying to access old_checkouts in an ISSUESLIP like this:
[% FOREACH checkout IN old_checkouts %]
This seems to return an empty list, which is not surprising given that the ISSUESLIP supposedly doesn't get passed the old_checkouts variable, according to the wiki:
https://wiki.koha-community.org/wiki/Notices_with_Template_Toolkit
I've been trying to figure out how to get old_checkouts passed to ISSUESLIP, but I'm not too familiar with the code. As best as I can tell, this needs to be done somewhere in C4/Members.pm, perhaps in the IssueSlip function, but it's not clear to me what I need to do.
Any guidance would be appreciated. Thanks in advance! _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
Excerpts from Jonathan Druart's message of 2019-10-24 16:11:50 +0200:
@ Members.pm:596 @ sub IssueSlip { ); %loops = ( issues => [ map { $_->{issues}{itemnumber} } @checkouts ], + old_issues => [ $patron->old_checkouts->get_column('itemnumber') ], overdues => [ map { $_->{issues}{itemnumber} } @overdues ], opac_news => [ map { $_->{opac_news}{idnew} } @news ], );
This didn't quite work as expected; see the SQL error below. But it does get me on the right track, so thank you for that! I'll continue playing with this, perhaps by trying to get old_issues to look exactly like issues in the way it's constructed. Thanks again! SQL error follows: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , , , , , , , , , , , , , , , , , , , 3950, 26730, 26730, 28220, 26730, 28220' at line 1 [for Statement "SELECT `me`.`issue_id`, `me`.`borrowernumber`, `me`.`itemnumber`, `me`.`date_due`, `me`.`branchcode`, `me`.`returndate`, `me`.`lastreneweddate`, `me`.`renewals`, `me`.`auto_renew`, `me`.`auto_renew_error`, `me`.`timestamp`, `me`.`issuedate`, `me`.`onsite_checkout`, `me`.`note`, `me`.`notedate`, `me`.`noteseen` FROM `old_issues` `me` WHERE ( ( `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` = ? OR `itemnumber` IS NULL OR `itemnumber` IS NULL OR `itemnumber` = ? ) ) ORDER BY field(itemnumber, , , , , , , , , , , , , , , , , , , , , , 3950, 26730, 26730, 28220, 26730, 28220, 26730, 22133, 25086, 28133, 27996, 24500, 28480, 18222, 28491, , , 28494)" with ParamValues: 0='3950', 1='26730', 2='26730', 3='28220', 4='26730', 5='28220', 6='26730', 7='22133', 8='25086', 9='28133', 10='27996', 11='24500', 12='28480', 13='18222', 14='28491', 15='28494'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832. ERROR PROCESSING TEMPLATE: undef error - DBIx::Class::Storage::DBI::_dbh_execute(): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , , , , , , , , , , , , , , , , , , , 3950, 26730, 26730, 28220, 26730, 28220' at line 1 at /usr/share/koha/lib/Koha/Objects.pm line 269 at /usr/share/koha/lib/C4/Members.pm line 602.
participants (2)
-
Jonathan Druart -
Mark Alexander