Bug 12224: Print a slip of borrower's checkins for today
authorAleisha Amohia <aleishaamohia@hotmail.com>
Thu, 17 Sep 2020 23:58:05 +0000 (11:58 +1200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 5 Mar 2021 12:49:03 +0000 (13:49 +0100)
To test:

1) Apply patch and run installer
2) Check out two items (or more) to a borrower
3) Check in two items (or more) for this borrower (you should end up on
    circ/returns.pl)
4) Notice the checked-in items table has started building. There should
be a new column with the button 'Print checkin slip' in each row.
5) Click the button and confirm the checkin slip opens for printing in a
new window.
6) Go to the patron's account
7) Click the Print dropdown. Confirm there is a 'Print checkin slip'
option. Click this and confirm the checkin slip opens for printing in a
new window.

Sponsored-by: Bibliotheksservice-Zentrum Baden-Württemberg (BSZ)
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Alexandra Speer <alexandra.speer@bsz-bw.de>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Christian Stelzenmüller <christian.stelzenmueller@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
13 files changed:
installer/data/mysql/atomicupdate/bug_12224-add_CHECKINSLIP_notice.perl [new file with mode: 0644]
installer/data/mysql/en/mandatory/sample_notices.yml
installer/data/mysql/fr-CA/obligatoire/sample_notices.sql
installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql
installer/data/mysql/it-IT/necessari/notices.sql
installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql
installer/data/mysql/pl-PL/mandatory/sample_notices.sql
installer/data/mysql/ru-RU/mandatory/sample_notices.sql
installer/data/mysql/uk-UA/mandatory/sample_notices.sql
koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
koha-tmpl/intranet-tmpl/prog/js/members-menu.js
members/printslip.pl

diff --git a/installer/data/mysql/atomicupdate/bug_12224-add_CHECKINSLIP_notice.perl b/installer/data/mysql/atomicupdate/bug_12224-add_CHECKINSLIP_notice.perl
new file mode 100644 (file)
index 0000000..fc33a72
--- /dev/null
@@ -0,0 +1,22 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{ INSERT IGNORE INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES
+        ('circulation','CHECKINSLIP','','Checkin slip',1,'Checkin slip',
+"<h3><<branches.branchname>></h3>
+Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+(<<borrowers.cardnumber>>) <br />
+
+<<today>><br />
+
+<h4>Checked in today</h4>
+<checkedin>
+<p>
+<<biblio.title>> <br />
+Barcode: <<items.barcode>><br />
+</p>
+</checkedin>",
+        'print')
+    });
+
+    NewVersion( $DBversion, 12224, "Add CHECKINSLIP notice" );
+}
index 705cebf..9d4f02e 100644 (file)
@@ -1454,3 +1454,26 @@ tables:
             - "[% ELSE %]"
             - "The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]"
             - "[% END %]"
+
+        - module: circulation
+          code: CHECKINSLIP
+          branchcode: ""
+          name: "Checkin slip"
+          is_html: 1
+          title: "Checkin slip"
+          message_transport_type: print
+          lang: default
+          content:
+            - "<h3><<branches.branchname>></h3>"
+            - "Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />"
+            - "(<<borrowers.cardnumber>>) <br />"
+            - ""
+            - "<<today>><br />"
+            - ""
+            - "<h4>Checked in today</h4>"
+            - "<checkedin>"
+            - "<p>"
+            - "<<biblio.title>> <br />"
+            - "Barcode: <<items.barcode>><br />"
+            - "</p>"
+            - "</checkedin>"
index b18d659..d8d4f40 100644 (file)
@@ -22,7 +22,20 @@ INSERT INTO `letter` (module, code, branchcode, name, is_html, title, content, m
 ('suggestions','ACCEPTED','','Suggestion d\'achat acceptée',0,'Suggestion d\'achat acceptée','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous nous avez suggéré l\'achat du document <<suggestions.title>> par <<suggestions.author>>.\r\n\r\nNous avons évalué votre suggestion aujourdhui. Le document sera commandé dès que possible. Vous serez tenu au courant par courriel quand le document aura été commandé et quand il sera disponible à la bibliothèque.\r\n\r\nPour toute question, veuillez nous contacter à l\'adresse suivante : <<branches.branchemail>>.\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'),
 ('suggestions','AVAILABLE','','Suggestion d\'achat disponible',0,'Suggestion d\'achat disponible','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous nous avez suggéré l\'achat du document <<suggestions.title>> par <<suggestions.author>>.\r\n\r\nNous avons le plaisir de vous informer que le document fait aujourd\'hui partie de nos collection et qu\'il est disponible à la bibliothèque.\r\n\r\nPour toute question, veuillez nous contacter à l\'adresse suivante : <<branches.branchemail>>.\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'),
 ('suggestions','ORDERED','','Suggestion d\'achat commandée',0,'Suggestion d\'achat commandée','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous nous avez suggéré l\'achat du document <<suggestions.title>> par <<suggestions.author>>.\r\n\r\nNous avons le plaisir de vous informer que le document a été commandé.\r\n\r\nVous recevrez une nouvelle notification quand le document sera disponible à bibliothèque.\r\n\r\nPour toute question, veuillez nous contacter à l\'adresse suivante : <<branches.branchemail>>.\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'),
-('suggestions','REJECTED','','Suggestion d\'achat rejetée',0,'Suggestion d\'achat rejetée','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous nous avez suggéré l\'achat du document <<suggestions.title>> par <<suggestions.author>>.\r\n\r\nNous avons évalué votre suggestion aujourd\'hui et décidé de ne pas l\'acheter cette fois.\r\n\r\nLa raison de notre refus est : <<suggestions.reason>>\r\n\r\nPour toute question, veuillez nous contacter à l\'adresse suivante : <<branches.branchemail>>.\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email');
+('suggestions','REJECTED','','Suggestion d\'achat rejetée',0,'Suggestion d\'achat rejetée','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous nous avez suggéré l\'achat du document <<suggestions.title>> par <<suggestions.author>>.\r\n\r\nNous avons évalué votre suggestion aujourd\'hui et décidé de ne pas l\'acheter cette fois.\r\n\r\nLa raison de notre refus est : <<suggestions.reason>>\r\n\r\nPour toute question, veuillez nous contacter à l\'adresse suivante : <<branches.branchemail>>.\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'),
+('circulation','CHECKINSLIP','','Checkin slip',1,'Checkin slip',"<h3><<branches.branchname>></h3>
+Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+(<<borrowers.cardnumber>>) <br />
+
+<<today>><br />
+
+<h4>Checked in today</h4>
+<checkedin>
+<p>
+<<biblio.title>> <br />
+Barcode: <<items.barcode>><br />
+</p>
+</checkedin>", 'print');
 
 INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type)
 VALUES ('suggestions','NEW_SUGGESTION','Nouvelle suggestion','Nouvelle suggestion','<h3>Suggestion en attente</h3>
index 7a6a858..5e1b68c 100644 (file)
@@ -50,7 +50,22 @@ VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Su
     <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
     <li><b>Notes:</b> <<suggestions.note>></li>
     </ul>
-    </p>',1, 'email');
+    </p>',1, 'email'),
+    ('circulation','CHECKINSLIP','Checkin slip','Checkin slip',
+    "<h3><<branches.branchname>></h3>
+    Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+    (<<borrowers.cardnumber>>) <br />
+
+    <<today>><br />
+
+    <h4>Checked in today</h4>
+    <checkedin>
+    <p>
+    <<biblio.title>> <br />
+    Barcode: <<items.barcode>><br />
+    </p>
+    </checkedin>",1, 'print');
+
 INSERT INTO `letter` (module, code, name, title, content, is_html)
 VALUES ('circulation','ISSUESLIP','Ticket de de prêt','Ticket de prêt', '<h3><<branches.branchname>></h3>
 Prêts à <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
index 4698c35..2deffe4 100644 (file)
@@ -55,7 +55,22 @@ VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Su
     <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
     <li><b>Notes:</b> <<suggestions.note>></li>
     </ul>
-    </p>',1, 'email');
+    </p>',1, 'email'),
+    ('circulation','CHECKINSLIP','Checkin slip','Checkin slip',
+    "<h3><<branches.branchname>></h3>
+    Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+    (<<borrowers.cardnumber>>) <br />
+
+    <<today>><br />
+
+    <h4>Checked in today</h4>
+    <checkedin>
+    <p>
+    <<biblio.title>> <br />
+    Barcode: <<items.barcode>><br />
+    </p>
+    </checkedin>",1, 'print');
+
 INSERT INTO letter (module, code, name, title, content, is_html)
 VALUES ('circulation','ISSUESLIP','Ricevuta di prestito','Ricevuta di prestito', '<h3><<branches.branchname>></h3>
 Prestito a <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
index 30083c9..1e05637 100644 (file)
@@ -70,7 +70,22 @@ VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Su
     <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
     <li><b>Notes:</b> <<suggestions.note>></li>
     </ul>
-    </p>',1, 'email');
+    </p>',1, 'email'),
+    ('circulation','CHECKINSLIP','Checkin slip','Checkin slip',
+    "<h3><<branches.branchname>></h3>
+    Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+    (<<borrowers.cardnumber>>) <br />
+
+    <<today>><br />
+
+    <h4>Checked in today</h4>
+    <checkedin>
+    <p>
+    <<biblio.title>> <br />
+    Barcode: <<items.barcode>><br />
+    </p>
+    </checkedin>",1, 'print');
+
 INSERT INTO `letter` (module, code, name, title, content, is_html)
 VALUES ('circulation','ISSUESLIP','Utlån','Utlån', '<h3><<branches.branchname>></h3>
 Utlånt til <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
index 64970f6..e320733 100644 (file)
@@ -49,7 +49,22 @@ VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Su
     <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
     <li><b>Notes:</b> <<suggestions.note>></li>
     </ul>
-    </p>',1, 'email');
+    </p>',1, 'email'),
+    ('circulation','CHECKINSLIP','Checkin slip','Checkin slip',
+    "<h3><<branches.branchname>></h3>
+    Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+    (<<borrowers.cardnumber>>) <br />
+
+    <<today>><br />
+
+    <h4>Checked in today</h4>
+    <checkedin>
+    <p>
+    <<biblio.title>> <br />
+    Barcode: <<items.barcode>><br />
+    </p>
+    </checkedin>",1, 'print');
+
 INSERT INTO `letter` (module, code, name, title, content, is_html)
 VALUES ('circulation','ISSUESLIP','Issue slip','Issue slip', '<h3><<branches.branchname>></h3>
 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
index 465e5f1..8341257 100644 (file)
@@ -48,7 +48,22 @@ VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Su
     <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
     <li><b>Notes:</b> <<suggestions.note>></li>
     </ul>
-    </p>',1, 'email');
+    </p>',1, 'email'),
+    ('circulation','CHECKINSLIP','Checkin slip','Checkin slip',
+    "<h3><<branches.branchname>></h3>
+    Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+    (<<borrowers.cardnumber>>) <br />
+
+    <<today>><br />
+
+    <h4>Checked in today</h4>
+    <checkedin>
+    <p>
+    <<biblio.title>> <br />
+    Barcode: <<items.barcode>><br />
+    </p>
+    </checkedin>",1, 'print');
+
 INSERT INTO `letter` (module, code, name, title, content, is_html)
 VALUES ('circulation','ISSUESLIP','Issue slip','Issue slip', '<h3><<branches.branchname>></h3>
 Checked out to <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
index 3c79c28..857a1a9 100644 (file)
@@ -113,7 +113,22 @@ VALUES ('suggestions','NEW_SUGGESTION','New suggestion','New suggestion','<h3>Su
     <li><b>Reason for suggestion:</b> <<suggestions.patronreason>></li>
     <li><b>Notes:</b> <<suggestions.note>></li>
     </ul>
-    </p>',1, 'email');
+    </p>',1, 'email'),
+    ('circulation','CHECKINSLIP','Checkin slip','Checkin slip',
+    "<h3><<branches.branchname>></h3>
+    Checked in items for <<borrowers.title>> <<borrowers.firstname>> <<borrowers.initials>> <<borrowers.surname>> <br />
+    (<<borrowers.cardnumber>>) <br />
+
+    <<today>><br />
+
+    <h4>Checked in today</h4>
+    <checkedin>
+    <p>
+    <<biblio.title>> <br />
+    Barcode: <<items.barcode>><br />
+    </p>
+    </checkedin>",1, 'print');
+
 INSERT INTO `letter` (module, code, name, title, content, is_html, message_transport_type) VALUES
 ('members', 'DISCHARGE', 'підтвердження на розрахування',
 'Розрахування для відвідувача — <<borrowers.firstname>> <<borrowers.surname>>', '
index bebe5a1..bb9abf4 100644 (file)
@@ -27,6 +27,7 @@
                 [% IF patron.has_overdues %]
                     <li><a id="print_overdues" href="#">Print overdues</a></li>
                 [% END %]
+                <li><a id="printcheckinslip" href="#">Print checkin slip</a></li>
             </ul>
     </div>
     [% END %]
index b5754e8..a956317 100644 (file)
                                         <th class="ci-collection">Collection</th>
                                         <th class="ci-patron">Patron</th>
                                         <th class="ci-note">Note</th>
+                                        <th class="ci-printslip">&nbsp;</th>
                                     </tr>
                                 </thead>
 
                                                 <p><span class="circ-hlt item-note-nonpublic">[% riloo.itemnotes_nonpublic | html %]</span></p>
                                             [% END %]
                                         </td>
+                                        <td class="ci-printslip actions">
+                                            <a id="printcheckinslip" href="#" class="btn btn-default" data-borrowernumber="[% riloo.patron.borrowernumber | html %]"><i class="fa fa-print"></i> Print checkin slip</a>
+                                        </td>
                                     </tr>
                                 [% END # /FOREACH riloo %]
                             </table> <!-- /#checkedintable -->
                 }
             });
             $('[data-toggle="tooltip"]').tooltip();
+
+            $("#printcheckinslip").click(function(){
+                var borrowernumber = $(this).data('borrowernumber');
+                window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=checkinslip", "printwindow");
+                return false;
+            });
+
         });
     </script>
 [% END %]
index 9db8b24..806c063 100644 (file)
@@ -71,6 +71,11 @@ $(document).ready(function(){
         $(".btn-group").removeClass("open");
         return false;
     });
+    $("#printcheckinslip").click(function(){
+        printx_window("checkinslip");
+        $(".btn-group").removeClass("open");
+        return false;
+    });
     $("#printclearscreen").click(function(){
         printx_window("slip");
         window.location.replace("/cgi-bin/koha/circ/circulation.pl");
index debbbde..389f5a6 100755 (executable)
@@ -39,6 +39,7 @@ use C4::Auth qw/:DEFAULT get_session/;
 use C4::Output;
 use C4::Members;
 use C4::Koha;
+use Koha::DateUtils;
 
 #use Smart::Comments;
 #use Data::Dumper;
@@ -79,7 +80,50 @@ 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' ) {
+    my $checkinslip_branch = $session->param('branch') ? $session->param('branch') : $branch;
+
+    # get today's checkins
+    my $today_start = dt_from_string->set( hour => 0, minute => 0, second => 0 );
+    my $today_end = dt_from_string->set( hour => 23, minute => 59, second => 0 );
+    $today_start = Koha::Database->new->schema->storage->datetime_parser->format_datetime( $today_start );
+    $today_end = Koha::Database->new->schema->storage->datetime_parser->format_datetime( $today_end );
+    my $todays_checkins = Koha::Old::Checkouts->search({
+        returndate => {
+            '>=' => $today_start,
+            '<=' => $today_end,
+        },
+        borrowernumber => $borrowernumber,
+        branchcode => $checkinslip_branch,
+    });
+
+    my @checkins;
+    while ( my $c = $todays_checkins->next ) {
+        push @checkins, {
+            biblio => $c->item->biblio->unblessed,
+            items => $c->item->unblessed,
+        };
+    }
+    my %repeat = (
+        checkedin => \@checkins,
+    );
+
+    my $letter = C4::Letters::GetPreparedLetter(
+        module => 'circulation',
+        letter_code => 'CHECKINSLIP',
+        branchcode => $checkinslip_branch,
+        tables => {
+            branches => $checkinslip_branch,
+            borrowers => $borrowernumber,
+        },
+        repeat => \%repeat,
+        message_transport_type => 'print'
+    );
+
+    $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};
 }