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

(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 534-539 our $PERL_DEPS = { Link Here
534
        'required' => '1',
534
        'required' => '1',
535
        'min_ver'  => '0.03',
535
        'min_ver'  => '0.03',
536
    },
536
    },
537
    'Net::Printer' => {
538
        'usage'    => 'Push to printer',
539
        'required' => '0',
540
        'min_ver'  => '1.11',
541
    },
537
};
542
};
538
543
539
1;
544
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_TO_PULL', 'Hold to Pull (push to print notice )', 'Hold to Pull (push to print notice )', '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 / +2 lines)
Lines 2304-2310 CREATE TABLE `tmp_holdsqueue` ( Link Here
2304
  `holdingbranch` varchar(10) default NULL,
2304
  `holdingbranch` varchar(10) default NULL,
2305
  `pickbranch` varchar(10) default NULL,
2305
  `pickbranch` varchar(10) default NULL,
2306
  `notes` text,
2306
  `notes` text,
2307
  `item_level_request` tinyint(4) NOT NULL default 0
2307
  `item_level_request` tinyint(4) NOT NULL default 0,
2308
  `printed` tinyint(1) DEFAULT NULL
2308
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2309
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2309
2310
2310
--
2311
--
(-)a/installer/data/mysql/updatedatabase.pl (+24 lines)
Lines 5452-5457 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5452
    SetVersion($DBversion);
5452
    SetVersion($DBversion);
5453
}
5453
}
5454
5454
5455
$DBversion = "3.09.00.XXX";
5456
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5457
    $dbh->do("ALTER TABLE tmp_holdsqueue ADD printed BOOLEAN NULL AFTER item_level_request");
5458
    $dbh->do("INSERT INTO  `letter` (
5459
    `module` ,
5460
    `code` ,
5461
    `branchcode` ,
5462
    `name` ,
5463
    `is_html` ,
5464
    `title` ,
5465
    `content`
5466
    )
5467
    VALUES (
5468
    'reserves',  'HOLD_TO_PULL',  '',  'Hold to Pull',  '0',  'Hold to Pull',  'Hold to pull at <<branches.branchname>>
5469
    
5470
    For <<borrowers.firstname>> <<borrowers.surname>> ( <<borrowers.cardnumber>> )
5471
    
5472
    <<biblio.title>> by <<biblio.author>>'
5473
    )");
5474
    
5475
    print "Upgrade to $DBversion done (Add print holds to pull notices on demand feature)\n";
5476
    SetVersion($DBversion);
5477
}
5478
5455
=head1 FUNCTIONS
5479
=head1 FUNCTIONS
5456
5480
5457
=head2 TableExists($table)
5481
=head2 TableExists($table)
(-)a/misc/cronjobs/holds/print_holds_to_pull_on_demand.pl (-1 / +165 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 tmp_holdsqueue WHERE printed IS NULL";
63
my $sth   = $dbh->prepare($query);
64
$sth->execute();
65
66
my $set_printed_query = "
67
    UPDATE tmp_holdsqueue 
68
    SET printed = 1 
69
    WHERE biblionumber = ? 
70
    AND itemnumber = ?
71
    AND borrowernumber = ?
72
    AND reservedate = ?
73
    AND holdingbranch = ?
74
";
75
my $set_printed_sth = $dbh->prepare($set_printed_query);
76
77
while ( my $hold = $sth->fetchrow_hashref() ) {
78
    print "\nFound Notice to Print\n"
79
      if ($verbose);
80
    print "Borrowernumber: " . $hold->{'borrowernumber'} . "\n" if ($verbose);
81
    print "Biblionumber: " . $hold->{'biblionumber'} . "\n"     if ($verbose);
82
    print "Holding Branch: " . $hold->{'holdingbranch'} . "\n"  if ($verbose);
83
84
    my $borrower =
85
      C4::Members::GetMember( 'borrowernumber' => $hold->{'borrowernumber'} );
86
87
    my $letter = GetPreparedLetter(
88
        module      => 'reserves',
89
        letter_code => 'HOLD_TO_PULL',
90
        branchcode  => $hold->{holdingbranch},
91
        tables      => {
92
            'branches'    => $hold->{'holdingbranch'},
93
            'biblio'      => $hold->{'biblionumber'},
94
            'biblioitems' => $hold->{'biblionumber'},
95
            'items'       => $hold->{'itemnumber'},
96
            'borrowers'   => $borrower,
97
        }
98
    );
99
100
    if ( defined( $printers{ $hold->{holdingbranch} } ) ) {
101
        unless ($test) {
102
            my $result =
103
              $printers{ $hold->{'holdingbranch'} }
104
              ->printstring( $letter->{'content'} );
105
            my $error = $printers{ $hold->{'holdingbranch'} }->printerror();
106
107
            unless ($error) {
108
                $set_printed_sth->execute(
109
                    $hold->{'biblionumber'},   $hold->{'itemnumber'},
110
                    $hold->{'borrowernumber'}, $hold->{'reservedate'},
111
                    $hold->{'holdingbranch'}
112
                );
113
            }
114
            else {
115
                warn "ERROR: $error";
116
            }
117
        }
118
        else {
119
            print "TEST MODE, notice will not be printed\n";
120
        }
121
    }
122
    else {
123
        print "WARNING: No printer defined for branchcode "
124
          . $hold->{'holdingbranch'}
125
          if ($verbose);
126
    }
127
128
}
129
130
__END__
131
132
=head1 NAME
133
134
Print Holds to Pull on Demand
135
136
=head1 SYNOPSIS
137
138
print_holds_to_pull_on_demand.pl --printer <branchcode>,<printer>,<server>,<port>
139
140
=head1 OPTIONS
141
142
=over 8
143
144
=item B<-help>
145
146
Print a brief help message and exits.
147
148
=item B<-printer>
149
150
Adds a printer, the value is the branchcode, printer name, server name and server port separated by commas.
151
152
e.g. print_holds_to_pull_on_demand.pl --printer MPL,lp,printserver,515 --printer CPL,lp2,printserver,516
153
154
would add printers for branchcodes MPL and CPL. If a printer is not defined for a given branch, notices for
155
that branch will not be printed.
156
157
=head1 DESCRIPTION
158
159
B<This program> will print on-demand notices for items in the holds queue as they appear.
160
161
=head1 AUTHOR
162
163
Kyle M Hall <kyle@bywatersolutions.com>
164
165
=cut

Return to bug 8352