View | Details | Raw Unified | Return to bug 8352
Collapse All | Expand All

(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 629-634 our $PERL_DEPS = { Link Here
629
        'required' => '0',
629
        'required' => '0',
630
        'min_ver'  => '1.09',
630
        'min_ver'  => '1.09',
631
      },
631
      },
632
    'Net::Printer' => {
633
        'usage'    => 'Push to printer',
634
        'required' => '0',
635
        'min_ver'  => '1.11',
636
    },
632
};
637
};
633
638
634
1;
639
1;
(-)a/installer/data/mysql/en/mandatory/sample_notices.sql (+1 lines)
Lines 9-14 VALUES ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <<borrowers.f Link Here
9
('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
9
('circulation','PREDUEDGST','Advance Notice of Item Due (Digest)','Advance Notice of Item Due','You have <<count>> items due soon'),
10
('reserves', 'HOLD', 'Hold Available for Pickup', 'Hold Available for Pickup at <<branches.branchname>>', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\nLocation: <<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n<<branches.branchaddress3>>\r\n<<branches.branchcity>> <<branches.branchzip>>'),
10
('reserves', 'HOLD', 'Hold Available for Pickup', 'Hold Available for Pickup at <<branches.branchname>>', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\nLocation: <<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n<<branches.branchaddress3>>\r\n<<branches.branchcity>> <<branches.branchzip>>'),
11
('reserves', 'HOLD_PRINT', 'Hold Available for Pickup (print notice)', 'Hold Available for Pickup (print notice)', '<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n\r\n\r\nChange Service Requested\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>>\r\n<<borrowers.address>>\r\n<<borrowers.city>> <<borrowers.zipcode>>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>> <<borrowers.cardnumber>>\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\n'),
11
('reserves', 'HOLD_PRINT', 'Hold Available for Pickup (print notice)', 'Hold Available for Pickup (print notice)', '<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n\r\n\r\nChange Service Requested\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>>\r\n<<borrowers.address>>\r\n<<borrowers.city>> <<borrowers.zipcode>>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>> <<borrowers.cardnumber>>\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\n'),
12
('reserves', 'HOLD_PLACED_PRINT', 'Hold Placed ( Auto-Print )', 'Hold Placed ( Auto-Print )', 'Hold to pull at <<branches.branchname>>\r\nFor <<borrowers.firstname>> <<borrowers.surname>> ( <<borrowers.cardnumber>> )\r\n<<biblio.title>> by <<biblio.author>>'),
12
('circulation','CHECKIN','Item Check-in (Digest)','Check-ins','The following items have been checked in:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you.'),
13
('circulation','CHECKIN','Item Check-in (Digest)','Check-ins','The following items have been checked in:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you.'),
13
('circulation','CHECKOUT','Item Check-out (Digest)','Checkouts','The following items have been checked out:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you for visiting <<branches.branchname>>.'),
14
('circulation','CHECKOUT','Item Check-out (Digest)','Checkouts','The following items have been checked out:\r\n----\r\n<<biblio.title>>\r\n----\r\nThank you for visiting <<branches.branchname>>.'),
14
('reserves', 'HOLDPLACED', 'Hold Placed on Item', 'Hold Placed on Item','A hold has been placed on the following item : <<biblio.title>> (<<biblio.biblionumber>>) by the user <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>).'),
15
('reserves', 'HOLDPLACED', 'Hold Placed on Item', 'Hold Placed on Item','A hold has been placed on the following item : <<biblio.title>> (<<biblio.biblionumber>>) by the user <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>).'),
(-)a/installer/data/mysql/kohastructure.sql (-1 / +3 lines)
Lines 1489-1494 CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b Link Here
1489
  `lowestPriority` tinyint(1) NOT NULL, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no)
1489
  `lowestPriority` tinyint(1) NOT NULL, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no)
1490
  `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no)
1490
  `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no)
1491
  `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely)
1491
  `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely)
1492
  `printed` tinyint(1) DEFAULT NULL,
1492
  PRIMARY KEY (`reserve_id`),
1493
  PRIMARY KEY (`reserve_id`),
1493
  KEY `old_reserves_borrowernumber` (`borrowernumber`),
1494
  KEY `old_reserves_borrowernumber` (`borrowernumber`),
1494
  KEY `old_reserves_biblionumber` (`biblionumber`),
1495
  KEY `old_reserves_biblionumber` (`biblionumber`),
Lines 1688-1693 CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha Link Here
1688
  `lowestPriority` tinyint(1) NOT NULL,
1689
  `lowestPriority` tinyint(1) NOT NULL,
1689
  `suspend` BOOLEAN NOT NULL DEFAULT 0,
1690
  `suspend` BOOLEAN NOT NULL DEFAULT 0,
1690
  `suspend_until` DATETIME NULL DEFAULT NULL,
1691
  `suspend_until` DATETIME NULL DEFAULT NULL,
1692
  `printed` tinyint(1) DEFAULT NULL,
1691
  PRIMARY KEY (`reserve_id`),
1693
  PRIMARY KEY (`reserve_id`),
1692
  KEY priorityfoundidx (priority,found),
1694
  KEY priorityfoundidx (priority,found),
1693
  KEY `borrowernumber` (`borrowernumber`),
1695
  KEY `borrowernumber` (`borrowernumber`),
Lines 2336-2342 CREATE TABLE `tmp_holdsqueue` ( Link Here
2336
  `holdingbranch` varchar(10) default NULL,
2338
  `holdingbranch` varchar(10) default NULL,
2337
  `pickbranch` varchar(10) default NULL,
2339
  `pickbranch` varchar(10) default NULL,
2338
  `notes` text,
2340
  `notes` text,
2339
  `item_level_request` tinyint(4) NOT NULL default 0
2341
  `item_level_request` tinyint(4) NOT NULL default 0,
2340
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2342
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2341
2343
2342
--
2344
--
(-)a/installer/data/mysql/updatedatabase.pl (+24 lines)
Lines 6055-6060 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6055
   SetVersion ($DBversion);
6055
   SetVersion ($DBversion);
6056
}
6056
}
6057
6057
6058
$DBversion = "3.09.00.XXX";
6059
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6060
    $dbh->do("ALTER TABLE reserves ADD printed BOOLEAN NULL AFTER suspend_until");
6061
    $dbh->do("INSERT INTO  `letter` (
6062
    `module` ,
6063
    `code` ,
6064
    `branchcode` ,
6065
    `name` ,
6066
    `is_html` ,
6067
    `title` ,
6068
    `content`
6069
    )
6070
    VALUES (
6071
    'reserves',  'HOLD_PLACED_PRINT',  '',  'Hold Placed ( Auto-Print )',  '0',  'Hold Placed ( Auto-Print )',  'Hold to pull at <<branches.branchname>>
6072
6073
    For <<borrowers.firstname>> <<borrowers.surname>> ( <<borrowers.cardnumber>> )
6074
6075
    <<biblio.title>> by <<biblio.author>>'
6076
    )");
6077
6078
    print "Upgrade to $DBversion done (Add print holds to pull notices on demand feature)\n";
6079
    SetVersion($DBversion);
6080
}
6081
6058
=head1 FUNCTIONS
6082
=head1 FUNCTIONS
6059
6083
6060
=head2 TableExists($table)
6084
=head2 TableExists($table)
(-)a/misc/cronjobs/holds/print_holds.pl (-1 / +159 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2009-2010 Kyle Hall
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
BEGIN {
23
24
    # find Koha's Perl modules
25
    # test carefully before changing this
26
    use FindBin;
27
    eval { require "$FindBin::Bin/../kohalib.pl" };
28
}
29
30
use Getopt::Long;
31
use Pod::Usage;
32
use Net::Printer;
33
34
use C4::Context;
35
use C4::Members qw(GetMember);
36
use C4::Letters qw(GetPreparedLetter);
37
38
my $help    = 0;
39
my $test    = 0;
40
my $verbose = 0;
41
my @printers;
42
GetOptions(
43
    "help|?"      => \$help,
44
    "verbose|v"   => \$verbose,
45
    "test|t"      => \$test,
46
    "printer|p=s" => \@printers,
47
);
48
pod2usage(1) if $help;
49
pod2usage(1) unless @printers;
50
51
my %printers;
52
foreach my $p (@printers) {
53
    my ( $branchcode, $printer, $server, $port ) = split( /,/, $p );
54
    my %options;
55
    $options{'printer'} = $printer if ($printer);
56
    $options{'server'}  = $server  if ($server);
57
    $options{'port'}    = $port    if ($port);
58
    $printers{$branchcode} = new Net::Printer(%options);
59
}
60
61
my $dbh   = C4::Context->dbh;
62
my $query = "SELECT * FROM reserves WHERE printed IS NULL";
63
my $sth   = $dbh->prepare($query);
64
$sth->execute();
65
66
my $set_printed_query = "
67
    UPDATE reserves
68
    SET printed = 1
69
    WHERE reserve_id = ?
70
";
71
my $set_printed_sth = $dbh->prepare($set_printed_query);
72
73
while ( my $hold = $sth->fetchrow_hashref() ) {
74
    if ($verbose) {
75
        print "\nFound Notice to Print\n";
76
        print "Borrowernumber: " . $hold->{'borrowernumber'} . "\n";
77
        print "Biblionumber: " . $hold->{'biblionumber'} . "\n";
78
        print "Branch: " . $hold->{'branchcode'} . "\n";
79
    }
80
81
    my $borrower =
82
      C4::Members::GetMember( 'borrowernumber' => $hold->{'borrowernumber'} );
83
84
    my $letter = GetPreparedLetter(
85
        module      => 'reserves',
86
        letter_code => 'HOLD_PLACED_PRINT',
87
        branchcode  => $hold->{branchcode},
88
        tables      => {
89
            'branches'    => $hold->{'branchcode'},
90
            'biblio'      => $hold->{'biblionumber'},
91
            'biblioitems' => $hold->{'biblionumber'},
92
            'items'       => $hold->{'itemnumber'},
93
            'borrowers'   => $borrower,
94
        }
95
    );
96
97
    if ( defined( $printers{ $hold->{branchcode} } ) ) {
98
        unless ($test) {
99
            my $result =
100
              $printers{ $hold->{'branchcode'} }
101
              ->printstring( $letter->{'content'} );
102
            my $error = $printers{ $hold->{'branchcode'} }->printerror();
103
104
            unless ($error) {
105
                $set_printed_sth->execute( $hold->{'reserve_id'} );
106
            }
107
            else {
108
                warn "ERROR: $error";
109
            }
110
        }
111
        else {
112
            print "TEST MODE, notice will not be printed\n";
113
            print $letter->{'content'} . "\n";
114
        }
115
    }
116
    else {
117
        print "WARNING: No printer defined for branchcode "
118
          . $hold->{'branchcode'}
119
          if ($verbose);
120
    }
121
122
}
123
124
__END__
125
126
=head1 NAME
127
128
Print Holds
129
130
=head1 SYNOPSIS
131
132
print_holds.pl --printer <branchcode>,<printer>,<server>,<port>
133
134
=head1 OPTIONS
135
136
=over 8
137
138
=item B<-help>
139
140
Print a brief help message and exits.
141
142
=item B<-printer>
143
144
Adds a printer, the value is the branchcode, printer name, server name and server port separated by commas.
145
146
e.g. print_holds_to_pull_on_demand.pl --printer MPL,lp,printserver,515 --printer CPL,lp2,printserver,516
147
148
would add printers for branchcodes MPL and CPL. If a printer is not defined for a given branch, notices for
149
that branch will not be printed.
150
151
=head1 DESCRIPTION
152
153
B<This program> will print on-demand notices for items in the holds queue as they appear.
154
155
=head1 AUTHOR
156
157
Kyle M Hall <kyle@bywatersolutions.com>
158
159
=cut

Return to bug 8352