-# in template <TMPL_IF name="I"> => instutitional (A for Adult, C for children)
-$template->param( $data->{'categorycode'} => 1 );
+if ( C4::Context->preference("ExportCircHistory") ) {
+ $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
+}
+
+my $patron_messages = Koha::Patron::Messages->search(
+ {
+ 'me.borrowernumber' => $borrowernumber,
+ },
+ {
+ join => 'manager',
+ '+select' => ['manager.surname', 'manager.firstname' ],
+ '+as' => ['manager_surname', 'manager_firstname'],
+ }
+);
+
+if( $patron_messages->count > 0 ){
+ $template->param( patron_messages => $patron_messages );
+}
+
+# Display the language description instead of the code
+# Note that this is certainly wrong
+my ( $subtag, $region ) = split '-', $patron->lang;
+my $translated_language = C4::Languages::language_get_description( $subtag, $subtag, 'language' );
+
+# if the expiry date is before today ie they have expired
+if ( $patron->is_expired || $patron->is_going_to_expire ) {
+ $template->param(
+ flagged => 1
+ );
+}
+
+my $total = $patron->account->balance;