Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 149 lines (126 sloc) 4.145 kb
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
1 #!/usr/bin/perl
2
3 # Copyright 2000-2002 Katipo Communications
ddbedbf Paul Poulain Bug 4330 : Adding some copyright BibLibre statements
PaulPoulain authored
4 # copyright 2010 BibLibre
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 #
2c67656 Fix FSF address in directory admin/
Lars Wirzenius authored
17 # You should have received a copy of the GNU General Public License along
18 # with Koha; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
20
21 use strict;
0f47a7d bug 2799: followup
Galen Charlton authored
22 use warnings;
23
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
24 use CGI;
25 use C4::Auth;
26 use C4::Context;
27 use C4::Output;
28 use C4::Koha;
29 use C4::Branch;
0f47a7d bug 2799: followup
Galen Charlton authored
30 use C4::Circulation qw{ IsBranchTransferAllowed DeleteBranchTransferLimits CreateBranchTransferLimit };
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
31
32 my $input = new CGI;
33
34 my ($template, $loggedinuser, $cookie)
35 = get_template_and_user({template_name => "admin/branch_transfer_limits.tmpl",
36 query => $input,
37 type => "intranet",
38 flagsrequired => {borrowers => 1},
39 debug => 1,
40 });
41
42 my $dbh = C4::Context->dbh;
150f67e Henri-Damien branch transfer limits
laurenthdl authored
43 my $branchcode;
44 if((!defined($input->param('branchcode'))) & mybranch() ne '')
45 {
46 $branchcode = mybranch();
47 }
48 else
49 {
50 $branchcode = $input->param('branchcode');
51 }
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
52
e40728f Henri-Damien MT2464 : branch_transfer_limit.pl usability change
laurenthdl authored
53 my $branchname = GetBranchName($branchcode);
54
55 # Getting the branches for user selection
56 my $branches = GetBranches();
57 my @branch_loop;
58 for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
59 my %row =(value => $thisbranch,
60 branchname => $branches->{$thisbranch}->{'branchname'},
61 );
62 push @branch_loop, \%row;
63 }
64
65
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
66 # Set the template language for the correct limit type
67 my $limit_phrase = 'Collection Code';
68 my $limitType = C4::Context->preference("BranchTransferLimitsType");
69 if ( $limitType eq 'itemtype' ) {
70 $limit_phrase = 'Item Type';
71 }
72
73 my @codes;
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
74 my @branchcodes;
75
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
76 my $sth;
77 if ( $limitType eq 'ccode' ) {
78 $sth = $dbh->prepare('SELECT authorised_value AS ccode FROM authorised_values WHERE category = "CCODE"');
79 } elsif ( $limitType eq 'itemtype' ) {
80 $sth = $dbh->prepare('SELECT itemtype FROM itemtypes');
81 }
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
82 $sth->execute();
83 while ( my $row = $sth->fetchrow_hashref ) {
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
84 push( @codes, $row->{ $limitType } );
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
85 }
86
87 $sth = $dbh->prepare("SELECT branchcode FROM branches");
88 $sth->execute();
89 while ( my $row = $sth->fetchrow_hashref ) {
90 push( @branchcodes, $row->{'branchcode'} );
91 }
92
93 ## If Form Data Passed, Update the Database
94 if ( $input->param('updateLimits') ) {
e40728f Henri-Damien MT2464 : branch_transfer_limit.pl usability change
laurenthdl authored
95 DeleteBranchTransferLimits();
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
96
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
97 foreach my $code ( @codes ) {
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
98 foreach my $toBranch ( @branchcodes ) {
e40728f Henri-Damien MT2464 : branch_transfer_limit.pl usability change
laurenthdl authored
99 my $isSet = not $input->param( $code . "_" . $toBranch);
100 if ( $isSet ) {
101 CreateBranchTransferLimit( $toBranch, $branchcode, $code );
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
102 }
103 }
104 }
105 }
106
107 ## Build branchcode loop
108 my @branchcode_loop;
109 foreach my $branchcode ( @branchcodes ) {
110 my %row_data;
111 $row_data{ branchcode } = $branchcode;
112 push ( @branchcode_loop, \%row_data );
113 }
73dd78c Owen Leonard Revamp interface of branch transfer limits to give finer conrol of bulk ...
oleonard authored
114 my $branchcount = scalar(@branchcode_loop);
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
115
116 ## Build the default data
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
117 my @codes_loop;
118 foreach my $code ( @codes ) {
0f47a7d bug 2799: followup
Galen Charlton authored
119 my @to_branch_loop;
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
120 my %row_data;
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
121 $row_data{ code } = $code;
0f47a7d bug 2799: followup
Galen Charlton authored
122 $row_data{ to_branch_loop } = \@to_branch_loop;
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
123 foreach my $toBranch ( @branchcodes ) {
124 my %row_data;
e40728f Henri-Damien MT2464 : branch_transfer_limit.pl usability change
laurenthdl authored
125 my $isChecked = IsBranchTransferAllowed( $toBranch, $branchcode, $code );
126 $row_data{ code } = $code;
127 $row_data{ toBranch } = $toBranch;
128 $row_data{ isChecked } = $isChecked;
129 $row_data{ toBranchname } = GetBranchName($toBranch);
0f47a7d bug 2799: followup
Galen Charlton authored
130 push( @to_branch_loop, \%row_data );
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
131 }
132
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
133 push( @codes_loop, \%row_data );
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
134 }
135
136
137 $template->param(
73dd78c Owen Leonard Revamp interface of branch transfer limits to give finer conrol of bulk ...
oleonard authored
138 branchcount => $branchcount,
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
139 codes_loop => \@codes_loop,
e40728f Henri-Damien MT2464 : branch_transfer_limit.pl usability change
laurenthdl authored
140 branch_loop => \@branch_loop,
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
141 branchcode_loop => \@branchcode_loop,
e40728f Henri-Damien MT2464 : branch_transfer_limit.pl usability change
laurenthdl authored
142 branchcode => $branchcode,
143 branchname => $branchname,
9c72711 This patch allows the Branch Transfer Limits feature to limit transfers ...
koha authored
144 limit_phrase => $limit_phrase,
9cf0472 Kyle M Hall Added 'Branch Transfer Limits' Feature requested by Geauga County Librar...
kylemhall authored
145 );
146
147 output_html_with_http_headers $input, $cookie, $template->output;
148
Something went wrong with that request. Please try again.