Bug 40659: Add ability to customize OPACVirtualCard
To test: 1. Turn on the OPACVirtualCard. 2. Log in to the OPAC as a patron and go look at your Library card ( opac-virtual-card.pl ) 3. APPLY PATCH, updatedatabase, restart_all 4. Go again at your patron's card on the OPAC ( opac-virtual-card.pl ), it should look exactly the same. 5. Go to Tools > Notices > VIRTUALCARD 6. You should see the default content for the library card. 7. Play around with different variables from borrower, like [% borrower.firstname%] and branches, like [% branch.branchcode %] 8. You can also move around the barcode by using the placeholder value [% my_barcode %]. 9. Put the [% my_barcode %] variable anywhere you want in the notice then go to the sys pref "OPACVirtualCardBarcode". 10. Change to different barcode types and relaod the library card page ( opac-virtual-card.pl ). You should notice the barcode type is being honored. 11. Turn on OPACpatronimages AND patronimages, then upload a patron image for your patron. 12. Use the [% my_image %] variable anywhere you want in the notice to place the patron image. 13. Leaving the [% my_image %] variable as is, turn off OPACpatronimages. 14. Reload the OPAC page, no image should display. 15. Delete the VIRTUALCARD notice. 16. Go back to the OPAC page and with the notice deleted you should see the hardcoded content. ie: the page should look exactly the same as it does without this patch. Signed-off-by: Marie Martino <martinom43@morainevalley.edu> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: David Cook <dcook@prosentient.com.au> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
1d10da0e66
commit
e2d73f7926
|
|
@ -33,24 +33,28 @@
|
|||
<div class="col-lg-10 order-first order-lg-2">
|
||||
<h1>Your library card </h1>
|
||||
<div id="patron-virtual-card">
|
||||
[% IF ( display_patron_image ) %]
|
||||
<div id="image-container">
|
||||
<img id="patron-image" src="/cgi-bin/koha/opac-patron-image.pl" alt="" />
|
||||
</div>
|
||||
[% END %]
|
||||
<div id="card-details">
|
||||
<div id="barcode-container">
|
||||
<svg id="patron-barcode" data-barcode="[% patron.cardnumber | html %]" data-barcode-format="[% barcode_format | html %]"></svg>
|
||||
</div>
|
||||
<div id="lib-container">
|
||||
<p id="patron-lib"><strong>Library:</strong> [% Branches.GetName( patron.branchcode ) | html %]</p>
|
||||
</div>
|
||||
<div id="cardnumber-container">
|
||||
<p id="patron-cardnumber"><strong>Card number:</strong> [% patron.cardnumber | html %]</p>
|
||||
</div>
|
||||
<div id="dateexpiry-container">
|
||||
<p id="patron-dateexpiry"><strong>Expiration date:</strong> [% patron.dateexpiry | $KohaDates %]</p>
|
||||
</div>
|
||||
[% IF content.content %]
|
||||
[% content.content | $raw %]
|
||||
[% ELSE %]
|
||||
[% IF ( display_patron_image ) %]
|
||||
<div id="image-container">
|
||||
<img id="patron-image" src="/cgi-bin/koha/opac-patron-image.pl" alt="" />
|
||||
</div>
|
||||
[% END %]
|
||||
<div id="barcode-container">
|
||||
<svg id="patron-barcode" data-barcode="[% patron.cardnumber | html %]" data-barcode-format="[% barcode_format | html %]"></svg>
|
||||
</div>
|
||||
<div id="lib-container">
|
||||
<p id="patron-lib"><strong>Library:</strong> [% Branches.GetName( patron.branchcode ) | html %]</p>
|
||||
</div>
|
||||
<div id="cardnumber-container">
|
||||
<p id="patron-cardnumber"><strong>Card number:</strong> [% patron.cardnumber | html %]</p>
|
||||
</div>
|
||||
<div id="dateexpiry-container">
|
||||
<p id="patron-dateexpiry"><strong>Expiration date:</strong> [% patron.dateexpiry | $KohaDates %]</p>
|
||||
</div>
|
||||
[% END %]
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ use C4::Auth qw( get_template_and_user );
|
|||
use C4::Output qw( output_html_with_http_headers );
|
||||
use Koha::Libraries;
|
||||
use Koha::Patrons;
|
||||
use C4::Letters qw( GetPreparedLetter );
|
||||
use C4::Scrubber;
|
||||
|
||||
my $query = CGI->new;
|
||||
|
||||
|
|
@ -44,17 +46,41 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
my $patron = Koha::Patrons->find($borrowernumber);
|
||||
|
||||
# Find and display patron image if allowed
|
||||
if ( C4::Context->preference('OPACpatronimages') ) {
|
||||
$template->param( display_patron_image => 1 ) if $patron->image;
|
||||
my $image_html = '';
|
||||
if ( C4::Context->preference('OPACpatronimages') && $patron->image ) {
|
||||
$template->param( display_patron_image => 1 );
|
||||
$image_html =
|
||||
'<div id="image-container"><img id="patron-image" src="/cgi-bin/koha/opac-patron-image.pl" alt="" /></div>';
|
||||
}
|
||||
|
||||
# Get the desired barcode format
|
||||
my $barcode_format = C4::Context->preference('OPACVirtualCardBarcode');
|
||||
my $barcode_format = C4::Context->preference('OPACVirtualCardBarcode') || 'Code39';
|
||||
my $barcode_html =
|
||||
qq{<div id="barcode-container"><svg id="patron-barcode" data-barcode="${\$patron->cardnumber}" data-barcode-format="$barcode_format"></svg></div>};
|
||||
|
||||
my $content = C4::Letters::GetPreparedLetter(
|
||||
(
|
||||
module => 'members',
|
||||
letter_code => 'VIRTUALCARD',
|
||||
branchcode => $patron->branchcode,
|
||||
tables => {
|
||||
borrowers => $patron->borrowernumber,
|
||||
branches => $patron->branchcode,
|
||||
},
|
||||
lang => $patron->lang,
|
||||
message_transport_type => 'email',
|
||||
substitute => {
|
||||
my_barcode => $barcode_html,
|
||||
my_image => $image_html,
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
$template->param(
|
||||
virtualcardview => 1,
|
||||
patron => $patron,
|
||||
barcode_format => $barcode_format,
|
||||
content => $content,
|
||||
);
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
|
||||
|
|
|
|||
Loading…
Reference in New Issue