From 90056a6093abbf965e684c3c77136afb5d2917fe 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] 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 --- .../atomicupdate/bug_12224_checkin_syspref.sql | 14 ++++ .../data/mysql/en/mandatory/sample_notices.sql | 17 ++-- installer/data/mysql/updatedatabase.pl | 18 ---- .../prog/en/includes/members-toolbar.inc | 2 +- t/db_dependent/Members/IssueSlip.t | 98 +++++++++++++++++++++- 5 files changed, 122 insertions(+), 27 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.sql diff --git a/installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.sql b/installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.sql new file mode 100644 index 0000000..ee394c2 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_12224_checkin_syspref.sql @@ -0,0 +1,14 @@ +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' +); \ 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 cfc6ba3..7f048b7 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.sql +++ b/installer/data/mysql/en/mandatory/sample_notices.sql @@ -164,13 +164,16 @@ VALUES ( 'circulation', 'OVERDUES_SLIP', '', 'Overdues Slip', '0', 'OVERDUES_SLI ', 'print' ); 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 47a3efc..8a1d1b0 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -11341,24 +11341,6 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } -$DBversion = "3.21.00.054"; -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' -);"); - print "Upgrade to $DBversion done (Bug 12224 - Easy printing of patron check-in slip)\n"; - SetVersion($DBversion); -} - # DEVELOPER PROCESS, search for anything to execute in the db_update directory # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. 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 3766064..169574f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -165,7 +165,7 @@ function searchToHold(){ [% IF ( CAN_user_borrowers ) %]
  • Print summary
  • [% END %]
  • Print slip
  • Print quick slip
  • -
  • Print checked-in today -slip
  • +
  • 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 8c32c21..d100670 100644 --- a/t/db_dependent/Members/IssueSlip.t +++ b/t/db_dependent/Members/IssueSlip.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 4; use Test::MockModule; use C4::Biblio; @@ -74,6 +74,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; @@ -108,6 +120,90 @@ $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 ); + + my $slip = CheckInSlip($borrowernumber, $branchcode ); + my $expected_slip = <{content}, $expected_slip, 'CheckInSlip should return a slip with 2 same check-in' ); + + my $today_daily = $today->clone->set( hour => 01, 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, $barcode2, $date_due, undef, $issue_date ); + AddReturn( $barcode2, $branchcode ); + + my $slip = CheckInSlip($borrowernumber, $branchcode ); + my $expected_slip = <{content}, $expected_slip, 'CheckInSlip should return a slip with 3 check-in' ); + + }; + +}; + subtest 'Issue slip' => sub { plan tests => 3; -- 1.9.1