From 88480dc16132ec45dc2c69b5ef374ebfe9af6449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Mon, 24 Aug 2015 09:08:31 +0000 Subject: [PATCH 2/3] Bug 12224: (follow-up) 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 check-in 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. 8) Run unit test t/db_dependent/Members/IssueSlip.t Sponsored-by: Koha-Suomi Oy --- .../bug_12224_checkin_syspref.perl | 21 ++++ .../mysql/en/mandatory/sample_notices.sql | 18 ++-- installer/data/mysql/updatedatabase.pl | 18 ---- .../prog/en/includes/members-toolbar.inc | 4 +- t/db_dependent/Members/IssueSlip.t | 97 ++++++++++++++++++- 5 files changed, 130 insertions(+), 28 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.perl diff --git a/installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.perl b/installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.perl new file mode 100644 index 0000000000..dba6f5270e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.perl @@ -0,0 +1,21 @@ +$DBversion = 'XXX'; # will be replaced by the RM +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', '

<>

+ Checked in by <> <> <> <>
+ (<>)
+ + <>
+

Checked In Today

+ +

+ <>
+ Barcode: <>
+

+
', 'print' + );"); + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 12224 - Allow easy printing of patron check-in slip)\n"; +} \ No newline at end of file diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql index 9508bb778d..b13843dd88 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ b/installer/data/mysql/en/mandatory/sample_notices.sql @@ -316,14 +316,18 @@ 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: -
    +VALUES ( 'circulation', 'CHECKINSLIP', '', 'Printed check-in slip', '1', 'Items returned today', '

    <>

    +Checked in by <> <> <> <>
    +(<>)
    + +<>
    +

    Checked In Today

    -
  • <>: <>
    +

    +<>
    Barcode: <>
    - -

', 'print' +

+'', 'print' ); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3b6e454cbe..603dc34c14 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -18881,24 +18881,6 @@ 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 c7fa409ae0..9abb3c5d50 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -32,8 +32,8 @@
  • Print summary
  • Print slip
  • Print quick slip
  • -
  • Print checked-in today -slip
  • - [% IF Borrowers.HasOverdues( patron.borrowernumber ) %] +
  • Print check-in slip
  • + [% IF Borrowers.HasOverdues( borrowernumber ) %]
  • Print overdues
  • [% END %] diff --git a/t/db_dependent/Members/IssueSlip.t b/t/db_dependent/Members/IssueSlip.t index 2280045f27..2f35744e74 100644 --- a/t/db_dependent/Members/IssueSlip.t +++ b/t/db_dependent/Members/IssueSlip.t @@ -19,7 +19,7 @@ use Modern::Perl; use Data::Dumper; # REMOVEME with diag -use Test::More tests => 3; +use Test::More tests => 4; use Test::MockModule; use Test::MockTime qw( set_fixed_time ); use t::lib::TestBuilder; @@ -94,6 +94,18 @@ $dbh->do(q| INSERT INTO letter( module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ('circulation', 'ISSUEQSLIP', '', 'Issue Quick Slip', 0, 'Issue Quick Slip', ?, 'email') |, {}, $quick_slip_content); +my $checkin_slip_content = < +Title: <> +Barcode: <> + +EOS + +$dbh->do(q| + INSERT INTO letter( module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ('circulation', 'CHECKINSLIP', '', 'Printed check-in slip', '0', 'Items returned today', ?, 'print') +|, {}, $checkin_slip_content); + my ( $title1, $title2 ) = ( 'My title 1', 'My title 2' ); my ( $barcode1, $barcode2 ) = ('BC0101', 'BC0202' ); my $record = MARC::Record->new; @@ -128,6 +140,89 @@ $module->mock( 'userenv', sub { { branch => $branchcode } } ); my $today = dt_from_string; my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) ); +subtest 'Check-in slip' => sub { + plan tests => 2; + + subtest 'Empty slip' => sub { + plan tests => 1; + + my $today_daily = $today->clone->set( hour => 23, minute => 59 ); + my ( $date_due, $issue_date ); + $date_due = $today_daily; + $issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); + AddIssue( $borrower, $barcode1, $date_due, undef, $issue_date ); + + my $slip = CheckInSlip($borrowernumber, $branchcode ); + my $empty_slip = <{content}, $empty_slip, 'No checked in returns an empty slip' ); + + AddReturn( $barcode1, $branchcode ); + }; + + subtest 'Daily returns' => sub { + plan tests => 3; + my $slip = CheckInSlip($borrowernumber, $branchcode ); + my $expected_slip = <{content}, $expected_slip, 'CheckInSlip should return a slip with one check-in' ); + + my $today_daily = $today->clone->set( hour => 23, minute => 59 ); + my ( $date_due, $issue_date ); + $date_due = $today_daily; + $issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); + AddIssue( $borrower, $barcode1, $date_due, undef, $issue_date ); + AddReturn( $barcode1, $branchcode ); + + $slip = CheckInSlip($borrowernumber, $branchcode ); + $expected_slip = <{content}, $expected_slip, 'CheckInSlip should return a slip with 2 same check-in' ); + + $today_daily = $today->clone->set( hour => 01, minute => 59 ); + $date_due = $today_daily; + $issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); + AddIssue( $borrower, $barcode2, $date_due, undef, $issue_date ); + AddReturn( $barcode2, $branchcode ); + + $slip = CheckInSlip($borrowernumber, $branchcode ); + $expected_slip = <{content}, $expected_slip, 'CheckInSlip should return a slip with 3 check-in' ); + + }; + +}; + subtest 'Issue slip' => sub { plan tests => 3; -- 2.17.1