Koha Tutorial Videos

Monday Minutes: Live from KohaUS 2024!

In this week's Monday Minutes, the Terrific-Every-Other-Thursday folks, George Williams and Christopher Brannon join Kelly and Kelly to discuss a popular topic from the KohaUS conference.

The enhancement bugs that this feature was driven from are super informative for libraries looking for a bit more information:

Bug 34136: Add the ability to render a report using a notice template

Bug 34456: Add the ability to download a template-rendered report as a file

Monday Minutes with Lucas Gass

We discussed these new features in a past Monday Minutes with Lucas Gass:

Monday Minutes: Creating Customizable Notices with Reports

the process is outlined in this blog post.

Tracking Slip Set Up

Here we will share both the Notice and the Report we showed in this Monday Minutes.

Notice Template:

[%- SET copies = 2 %]
[%- USE Price -%]
<button id="webPrint" data-printer="paper_printer" data-print="#trackingSlip">Print Tracking Slips</button>

<div id="trackingSlip" style="width:45%;">
[%- FOREACH d IN data %]
[% SET i = 0 %]
[% WHILE i < copies %]
[%- SET i = i + 1 %]
<div style="page-break-after: always;">
<br>Vendor: [% d.aqbooksellsers_name %]
<br>Basket Name: [% d.basketname %]
<br>Order #: [% d.ordernumber %]
<br>Copies: [% d.quantity %]
<br>Title: [% d.title %]
<br>Author: [% d.author %]
<br>Basket #: [% d.basketno %]
<br>ISBN: [% d.isbn %]
<br>Bib #: [% d.biblionumber %]
<br>Price: $[% d.listprice | $Price %]
<br>Internal Note: [% d.order_internalnote %]
<br>Vendor Note: [% d.order_vendornote %]

<h3>Ordering Info:</h3>
[%- UNLESS d.suppliers_report %]
[%- SET OrderingBranches = d.OrderingBranches.split(" "); %]
[%- SET OrderingCollection= d.OrderingCollection.split(" "); %]
[%- SET OrderingShelvingLocation= d.OrderingShelvingLocation.split(" "); %]
[%- SET OrderingQuantities = d.OrderingQuantities.split(" "); %]
<div class="container" style="border=2px; width=300px; height=300px; column-width: 150px;">
[%- FOREACH ob IN OrderingBranches %]
[%- SET idx = loop.index %]
[% ob %] / [% OrderingCollection.$idx %] / [% OrderingShelvingLocation.$idx %] / [% OrderingQuantities.$idx %],
[%- END %]
</div>
[%- ELSE %]
[%- SET thisline = d.suppliers_report %]
[%- PERL %]
use JSON qw(decode_json);
use Try::Tiny;
my $line = $stash->get('thisline');
my $data = decode_json($line);
$stash->set(ordering_info => $data);
[%- END %]
<p>Order Note: [% ordering_info.0.vendor_notes %]</p>
<div style="display:grid;grid-template-columns:repeat(2, 1fr);align-items: center;width:4in;">
[%- FOREACH o IN ordering_info %]
<span style="white-space:nowrap">[% o.ordering_branch %] / [% o.ordering_collection %] / [% o.ordering_shelving_loc %] / [% o.ordering_quantity %]</span>
[%- END %]
</div>
[%- END %]

<br><br><br>

<div style="border:1px solid black; padding-left: 25px; width: 300px; font-family: monospace;">
<br><br>
Opened:______________________
<br><br>
Received:____________________
<br><br>
Cataloged:___________________
<br><br>
Processed:___________________
<br><br>
Release Date:________________
<br><br>
</div>
</div>

<br><br>
[%- END %]
[%- END %]
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
if (window.location.href.indexOf("DOEET") >= 0) {
setTimeout(function() { // Delay until plugin is loaded
$("#webPrint").trigger('click');
setTimeout(function() { window.close(); }, 2000); // Delay so plugin has time to print
}, 1000);
}
}, false);
</script>

Report used:

SELECT
ExtractValue(metadata,'//datafield[@tag="961"]/subfield[@code="b"]') AS "OrderingBranches",
ExtractValue(metadata,'//datafield[@tag="960"]/subfield[@code="8"]') AS "OrderingCollection",
ExtractValue(metadata,'//datafield[@tag="960"]/subfield[@code="c"]') AS "OrderingShelvingLocation",
ExtractValue(metadata,'//datafield[@tag="961"]/subfield[@code="q"]') AS "OrderingQuantities",
ExtractValue(metadata,'//datafield[@tag="960"][1]/subfield[@code="x"]') AS "VendorNotes",
aqorders.*,
biblio.*,
biblioitems.*,
aqbasket.basketname,
aqbooksellers.name AS 'aqbooksellsers_name'
FROM aqbasket
LEFT JOIN aqorders USING ( basketno )
LEFT JOIN biblio USING ( biblionumber )
LEFT JOIN biblioitems USING ( biblionumber )
LEFT JOIN aqbooksellers ON ( aqbooksellers.id = aqbasket.booksellerid )
LEFT JOIN biblio_metadata USING ( biblionumber )
WHERE deleted_biblionumber IS NULL AND basketno = <<basketno>>

NOTE:

We are extracting MARC data from the 960 & 961 fields in this report. Other libraries may use different MARC fields to hold the item level data, so these fields in the report will need to be adjusted.

Code to add to the System Preference, IntranetuserJS

// Tracking Slip
$(document).ready(function() {
if (window.location.href.indexOf("koha/acqui/basket.pl") >= 0) {
let button = `
<div class="btn-group">
<button class="btn btn-default" onclick="printTrackingSlip();"><i class="fa fa-print"></i> Print Tracking Slip</button>
</div>
`;
$('#toolbar').append(button);
}
});

function printTrackingSlip() {
let basketno = $("input[name='basketno']").val();
let url = `/cgi-bin/koha/reports/guided_reports.pl?op=export&format=template&id=672&template=139&reportname=KohaUS&sql_params=${basketno}&param_name=basketno';
window.open(url, 'TrackingSlipWindow');

}

NOTE:

In this, our code indicates the report ID, the template ID, and the report name.

Terrific-Every-Other-Thursday Video Series

Don't forget to watch the next episode of the "Terrific-Every-Other-Thursday" video scheduled for August 29th where Jessie and Kelly join George and Christopher!

KohaUS 2024

If you weren't able to watch KohaUS live during the conference, the YouTube links will be posted this week on the KohaUS website.