From 91f57aa83a5c58525cc6e1b85085acbf2d999cd4 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 12 May 2014 12:24:48 +0300 Subject: [PATCH 1/3] Bug 12224: Allow easy printing of patron check-ins for today This adds a printing option to the staff client patron details page to print a list of items the patron returned today at this branch. To test: 1) Apply patch. 2) Check in tools > Notices & Slips that you have CHECKINSLIP slip, and have print message there. If not, run updatedatabase.pl 3) Check-in items for a patron. 4) Go to that patron's detail page, and from the Print-menu in the toolbar, select "Print checked-in today -slip" 5) You should get a slip of the patron's checked-in items. 6) Optionally, test Check-ins for the same patron, but in different branches - should only print items for the current branch. 7) Optionally, test Check-ins for the same patron, but returned in different day - should only print items for today. Sponsored-by: Koha-Suomi Oy Signed-off-by: Aleisha --- C4/Members.pm | 70 +++++++++++++++++++ .../mysql/en/mandatory/sample_notices.sql | 11 +++ installer/data/mysql/updatedatabase.pl | 18 +++++ .../prog/en/includes/members-toolbar.inc | 1 + .../intranet-tmpl/prog/js/members-menu.js | 5 ++ members/printslip.pl | 7 +- 6 files changed, 111 insertions(+), 1 deletion(-) diff --git a/C4/Members.pm b/C4/Members.pm index 205f45bd7b..0f32fdaa67 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -60,6 +60,7 @@ BEGIN { &GetBorrowersToExpunge &IssueSlip + &CheckInSlip ); #Check data @@ -612,6 +613,75 @@ sub IssueSlip { ); } +=head2 GetTodaysReturnsForBorrower + + $returns = GetTodaysReturnsForBorrower($borrowernumber, $branch); + +Return a list of items borrower has checked-in today in branch. + +=cut + +sub GetTodaysReturnsForBorrower { + my ($borrowernumber, $branch) = @_; + my $dbh = C4::Context->dbh; + my $date = POSIX::strftime("%Y-%m-%d",localtime()); + + my $query = " + SELECT itemnumber + FROM old_issues + WHERE DATE(returndate) = ? + AND borrowernumber = ? + AND branchcode = ? + "; + + my $sth = $dbh->prepare($query); + $sth->execute($date, $borrowernumber, $branch); + my @results; + + while ( my $data = $sth->fetchrow_hashref ) { + my $item = Koha::Items->find( $data->{itemnumber} ); + my $biblio = $item->biblio->unblessed; + my $biblioitem = $item->biblioitem->unblessed; + $item = $item->unblessed; + my $merged = {%$item, %$biblio, %$biblioitem}; + push @results, $merged; + } + return \@results; +} + +=head2 CheckInSlip + + $letter = CheckInSlip($borrowernumber, $branch [, $message_transport_type ] ); + +Returns the prepared letter data for items patron checked-in today in branch. +message_transport_type defaults to 'print'. + +=cut + +sub CheckInSlip { + my ($borrowernumber, $branch, $mtt) = @_; + my $issues = GetTodaysReturnsForBorrower($borrowernumber, $branch); + my %repeat = ( + 'checkedin' => [ map { + 'biblio' => $_, + 'items' => $_, + 'issues' => $_, + }, @$issues ], + ); + + return C4::Letters::GetPreparedLetter ( + module => 'circulation', + letter_code => 'CHECKINSLIP', + branchcode => $branch, + tables => { + 'branches' => $branch, + 'borrowers' => $borrowernumber, + }, + repeat => \%repeat, + message_transport_type => $mtt || 'print', + ); +} + =head2 DeleteExpiredOpacRegistrations Delete accounts that haven't been upgraded from the 'temporary' category diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql index 6d676e73e6..9508bb778d 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ b/installer/data/mysql/en/mandatory/sample_notices.sql @@ -316,3 +316,14 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, INSERT INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES ('circulation', 'SR_SLIP', '', 'Stock rotation slip', 0, 'Stock rotation report', 'Stock rotation report for [% branch.name %]:\r\n\r\n[% IF branch.items.size %][% branch.items.size %] items to be processed for this branch.\r\n[% ELSE %]No items to be processed for this branch\r\n[% END %][% FOREACH item IN branch.items %][% IF item.reason != \'in-demand\' %]Title: [% item.title %]\r\nAuthor: [% item.author %]\r\nCallnumber: [% item.callnumber %]\r\nLocation: [% item.location %]\r\nBarcode: [% item.barcode %]\r\nOn loan?: [% item.onloan %]\r\nStatus: [% item.reason %]\r\nCurrent library: [% item.branch.branchname %] [% item.branch.branchcode %]\r\n\r\n[% END %][% END %]', 'email'); +INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) +VALUES ( 'circulation', 'CHECKINSLIP', '', 'Printed check-in slip', '1', 'Items returned today', '<> <>
+<>, <>
+You returned these items today: +
    + +
  • <>: <>
    +Barcode: <>
    + +
', 'print' +); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 603dc34c14..3b6e454cbe 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -18881,6 +18881,24 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 18928 - Move holdallowed, hold_fulfillment_policy, returnbranch to circulation_rules)\n"; } +$DBversion = '19.06.00.011'; +if ( CheckVersion($DBversion) ) { + $dbh->do(" + INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) + VALUES ( 'circulation', 'CHECKINSLIP', '', 'Printed check-in slip', '1', 'Items returned today', '<> <>
+ <>, <>
+ You returned these items today: +
    + +
  • <>: <>
    + Barcode: <>
    + +
', 'print' + );"); + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 12224 - Easy printing of patron check-in slip)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 6e51ff5566..c7fa409ae0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -32,6 +32,7 @@
  • Print summary
  • Print slip
  • Print quick slip
  • +
  • Print checked-in today -slip
  • [% IF Borrowers.HasOverdues( patron.borrowernumber ) %]
  • Print overdues
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js index c6e751b0f1..e79217569a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js @@ -66,6 +66,11 @@ $(document).ready(function(){ $(".btn-group").removeClass("open"); return false; }); + $("#printcheckinslip").click(function(){ + printx_window("checkinslip"); + $(".btn-group").removeClass("open"); + return false; + }); $("#print_overdues").click(function(){ window.open("/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow"); $(".btn-group").removeClass("open"); diff --git a/members/printslip.pl b/members/printslip.pl index a3d2d50031..5a24f85695 100755 --- a/members/printslip.pl +++ b/members/printslip.pl @@ -80,7 +80,12 @@ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', log my $branch=C4::Context->userenv->{'branch'}; my ($slip, $is_html); -if (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) { +if ($print eq 'checkinslip') { + if (my $letter = CheckInSlip($borrowernumber, $session->param('branch') || $branch)) { + $slip = $letter->{content}; + $is_html = $letter->{is_html}; + } +} elsif (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) { $slip = $letter->{content}; $is_html = $letter->{is_html}; } -- 2.17.1