Koha Tutorial Videos
Monday Minutes: Customizing the Staff Client News Area
In this week's Monday Minutes, Andrew from the Dubuque County Library District shared some customizations with Kelly and Jessie that were added to their library's Koha Staff interface. It was so fun to have Andrew on Monday Minutes again!
Sharing the Customizations
We were so happy to have Andrew show off their Library Staff Interface where the staff decided what they would like to see on their main page. The kitty picture with the information on what/when the library should pull their new books.
Andrew (with the help of Lucas at ByWater Solutions) created this jquery to be added to the system preference, intranetuserjs
//Old new book reminder, RT106658 11.22.22 LG
if ( $('#main_intranet-main').length ) {
const month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
const t = new Date();
let today = t.getDate();
if ( today < 5 || today > 26 ) {
$('#container-main .col-sm-3').prepend(`
<div id="pullreminder">
<h1>It's<span id="soon"></span> time to pull new books added in or before <span id="pullfrom"></span>.</h1>
<img src="link" width="200" height="235" alt="old book cat" />
}
today > 5 ? ( $('#pullfrom').html(month[ t.getMonth() -6 ]) ) : ( $('#pullfrom').html(month[ t.getMonth() -7 ]) );
today > 5 ? ( $('#soon').html(' almost')) : ( $('#soon').html('') );
}
NOTE:
The <img src='"link" section
Link to the picture Andrew used is here.
Here is a picture of the entire jquery that Andrew showed:
Report Showing Closures in the Library
In the tutorial video, Andrew showed their library staff client, they display their closures, here is the SQL to use:
SELECT date, title
FROM
(
SELECT date, title, branchcode
FROM (
SELECT concat(year,'-',month,'-',day) as date, title, branchcode
FROM special_holidays
WHERE isexception=0
) tinkywinky
UNION ALL
SELECT date, title, branchcode
FROM (
SELECT concat(year(curdate()),'-',month,'-',day) as date, title, branchcode
FROM repeatable_holidays
WHERE concat(year(curdate()),'-',month,'-',day,branchcode) not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
) dipsy
UNION ALL
SELECT date, title, branchcode
FROM (
SELECT concat(year(curdate())+1,'-',month,'-',day) as date, title, branchcode
FROM repeatable_holidays
WHERE concat(year(curdate()),'-',month,'-',day,branchcode) not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
) lala
) tubbies
WHERE date between curdate() and date_add(curdate(),interval 4 week)
GROUP BY date
Once this report is created, grab the report ID (in this jquery below, their report ID is 387) and use it with this jquery. This jquery will need to be added to the system preference, intranetuserjs.
//Upcoming closures
if ( $('#main_intranet-main').length ) {
$('#container-main .col-sm-3').prepend('<h3>Upcoming closures</h3><div id="closures"></div>');
$.getJSON("/cgi-bin/koha/svc/report?id=387", function(data) {
let table_thing = "<table class='table'><thead><tr><th>Date</th><th>Reason</th></tr></thead>"
$.each(data, function(index, value) {
table_thing += "<tr>";
for( i = 0; i < value.length; i++){
table_thing += "<td>" + value[i] + "</td>";
}
table_thing += "</tr>";
});
table_thing += "</table>";
$("#closures").html( table_thing );
});
}
Multi Branch Libraries
For multiple branches that have different holidays, this report was created by Christopher Brannon and shared in the ByWater Slack Channel
SELECT date, title
FROM
(
SELECT date, title, branchcode
FROM (
SELECT concat(year,'-',month,'-',day) as date, title, branchcode
FROM special_holidays
WHERE isexception=0 AND branchcode = <<Branch|branches>>
) tinkywinkyUNION ALLSELECT date, title, branchcode
FROM (
SELECT concat(year(curdate()),'-',month,'-',day) as date, title, branchcode
FROM repeatable_holidays
WHERE concat(year(curdate()),'-',month,'-',day,branchcode) not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
AND branchcode = <<Branch|branches>>
) dipsyUNION ALLSELECT date, title, branchcode
FROM (
SELECT concat(year(curdate())+1,'-',month,'-',day) as date, title, branchcode
FROM repeatable_holidays
WHERE concat(year(curdate()),'-',month,'-',day,branchcode) not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
AND branchcode = <<Branch|branches>>
) lalaUNION ALLSELECT date, title, branchcode
FROM (
SELECT CASE
WHEN dayofweek(curdate()) = weekday+1 THEN date_add(curdate(), interval 1 week)
WHEN dayofweek(curdate()) = (weekday + 2) THEN date_add(curdate(), interval 6 day)
WHEN dayofweek(curdate()) = (weekday + 3) THEN date_add(curdate(), interval 5 day)
WHEN dayofweek(curdate()) = (weekday + 4) THEN date_add(curdate(), interval 4 day)
WHEN dayofweek(curdate()) = (weekday + 5) THEN date_add(curdate(), interval 3 day)
WHEN dayofweek(curdate()) = (weekday + 6) THEN date_add(curdate(), interval 2 day)
WHEN dayofweek(curdate()) = (weekday + 7) THEN date_add(curdate(), interval 1 day)
END as date, title, branchcode
FROM repeatable_holidays
WHERE weekday is not null
) po_1
WHERE date not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
AND branchcode = <<Branch|branches>>UNION ALLSELECT date, title, branchcode
FROM (
SELECT CASE
WHEN dayofweek(curdate()) = weekday+1 THEN date_add(curdate(), interval 2 week)
WHEN dayofweek(curdate()) = (weekday + 2) THEN date_add(curdate(), interval 13 day)
WHEN dayofweek(curdate()) = (weekday + 3) THEN date_add(curdate(), interval 12 day)
WHEN dayofweek(curdate()) = (weekday + 4) THEN date_add(curdate(), interval 11 day)
WHEN dayofweek(curdate()) = (weekday + 5) THEN date_add(curdate(), interval 10 day)
WHEN dayofweek(curdate()) = (weekday + 6) THEN date_add(curdate(), interval 9 day)
WHEN dayofweek(curdate()) = (weekday + 7) THEN date_add(curdate(), interval 8 day)
END as date, title, branchcode
FROM repeatable_holidays
WHERE weekday is not null
) po_2
WHERE date not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
AND branchcode = <<Branch|branches>>UNION ALLSELECT date, title, branchcode
FROM (
SELECT CASE
WHEN dayofweek(curdate()) = weekday+1 THEN date_add(curdate(), interval 3 week)
WHEN dayofweek(curdate()) = (weekday + 2) THEN date_add(curdate(), interval 20 day)
WHEN dayofweek(curdate()) = (weekday + 3) THEN date_add(curdate(), interval 19 day)
WHEN dayofweek(curdate()) = (weekday + 4) THEN date_add(curdate(), interval 18 day)
WHEN dayofweek(curdate()) = (weekday + 5) THEN date_add(curdate(), interval 17 day)
WHEN dayofweek(curdate()) = (weekday + 6) THEN date_add(curdate(), interval 16 day)
WHEN dayofweek(curdate()) = (weekday + 7) THEN date_add(curdate(), interval 15 day)
END as date, title, branchcode
FROM repeatable_holidays
WHERE weekday is not null
) po_3
WHERE date not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
AND branchcode = <<Branch|branches>>UNION ALLSELECT date, title, branchcode
FROM (
SELECT CASE
WHEN dayofweek(curdate()) = weekday+1 THEN date_add(curdate(), interval 4 week)
WHEN dayofweek(curdate()) = (weekday + 2) THEN date_add(curdate(), interval 27 day)
WHEN dayofweek(curdate()) = (weekday + 3) THEN date_add(curdate(), interval 26 day)
WHEN dayofweek(curdate()) = (weekday + 4) THEN date_add(curdate(), interval 25 day)
WHEN dayofweek(curdate()) = (weekday + 5) THEN date_add(curdate(), interval 24 day)
WHEN dayofweek(curdate()) = (weekday + 6) THEN date_add(curdate(), interval 23 day)
WHEN dayofweek(curdate()) = (weekday + 7) THEN date_add(curdate(), interval 22 day)
END as date, title, branchcode
FROM repeatable_holidays
WHERE weekday is not null
) po_4
WHERE date not in
(
SELECT concat(year,'-',month,'-',day,branchcode)
FROM special_holidays
WHERE isexception=1
)
AND branchcode = <<Branch|branches>>
) tubbies
WHERE date between curdate() and date_add(curdate(),interval 4 week)
GROUP BY date
Christopher also added this code the system preference, intranetuserjs:
if ( $('#main_intranet-main').length ) {
var branch = $('#logged-in-info-full .logged-in-branch-code').text();
$('#container-main .col-sm-3').prepend('<h3>Upcoming closures</h3><div id="closures"></div>');
$.getJSON("/cgi-bin/koha/svc/report?id=938&sql_params=" + branch, function(data) {
let table_thing = "<table class='table'><thead><tr><th>Date</th><th>Reason</th></tr></thead>"
$.each(data, function(index, value) {
table_thing += "<tr>";
for( i = 0; i < value.length; i++){
table_thing += "<td>" + value[i] + "</td>";
}
table_thing += "</tr>";
});
table_thing += "</table>";
$("#closures").html( table_thing );
});
}
If you are using this, please adjust this jquery to have your library's report ID and not 938 which is included above.
Read more by Kelly McElligott