3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
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
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.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
30 my ($template, $loggedinuser, $cookie)
31 = get_template_and_user({template_name => "admin/branch_transfer_limits.tmpl",
34 flagsrequired => {borrowers => 1},
38 my $dbh = C4::Context->dbh;
43 my $sth = $dbh->prepare("SELECT itemtype FROM itemtypes");
45 while ( my $row = $sth->fetchrow_hashref ) {
46 push( @itemtypes, $row->{'itemtype'} );
49 $sth = $dbh->prepare("SELECT branchcode FROM branches");
51 while ( my $row = $sth->fetchrow_hashref ) {
52 push( @branchcodes, $row->{'branchcode'} );
55 ## If Form Data Passed, Update the Database
56 if ( $input->param('updateLimits') ) {
57 DeleteBranchTransferLimits();
59 foreach my $itemtype ( @itemtypes ) {
60 foreach my $toBranch ( @branchcodes ) {
61 foreach my $fromBranch ( @branchcodes ) {
62 my $isSet = $input->param( $itemtype . "_" . $toBranch . "_" . $fromBranch );
64 CreateBranchTransferLimit( $toBranch, $fromBranch, $itemtype );
71 ## Build branchcode loop
73 foreach my $branchcode ( @branchcodes ) {
75 $row_data{ branchcode } = $branchcode;
76 push ( @branchcode_loop, \%row_data );
79 ## Build the default data
81 foreach my $itemtype ( @itemtypes ) {
84 $row_data{ itemtype } = $itemtype;
85 $row_data{ loop1 } = \@loop1;
86 foreach my $toBranch ( @branchcodes ) {
89 $row_data{ itemtype } = $itemtype;
90 $row_data{ toBranch } = $toBranch;
91 $row_data{ loop2 } = \@loop2;
93 foreach my $fromBranch ( @branchcodes ) {
95 my $isChecked = ! IsBranchTransferAllowed( $toBranch, $fromBranch, $itemtype );
96 $row_data{ itemtype } = $itemtype;
97 $row_data{ toBranch } = $toBranch;
98 $row_data{ fromBranch } = $fromBranch;
99 $row_data{ isChecked } = $isChecked;
101 push( @loop2, \%row_data );
104 push( @loop1, \%row_data );
107 push( @loop0, \%row_data );
113 branchcode_loop => \@branchcode_loop,
114 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
115 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
116 IntranetNav => C4::Context->preference("IntranetNav"),
119 output_html_with_http_headers $input, $cookie, $template->output;