Lines 19-24
Link Here
|
19 |
|
19 |
|
20 |
use strict; |
20 |
use strict; |
21 |
use warnings; |
21 |
use warnings; |
|
|
22 |
use Carp; |
22 |
use CGI qw ( -utf8 ); |
23 |
use CGI qw ( -utf8 ); |
23 |
use List::Util qw/min/; |
24 |
use List::Util qw/min/; |
24 |
use File::Spec; |
25 |
use File::Spec; |
Lines 34-41
use Data::Dumper;
Link Here
|
34 |
sub StringSearch { |
35 |
sub StringSearch { |
35 |
my ( $searchstring, $type ) = @_; |
36 |
my ( $searchstring, $type ) = @_; |
36 |
my $dbh = C4::Context->dbh; |
37 |
my $dbh = C4::Context->dbh; |
|
|
38 |
$searchstring = "" unless $searchstring; |
37 |
$searchstring =~ s/\'/\\\'/g; |
39 |
$searchstring =~ s/\'/\\\'/g; |
38 |
my @data = split( ' ', $searchstring ); |
40 |
my @data = split( ' ', $searchstring ); |
|
|
41 |
$data[0] = "" unless scalar @data; |
39 |
my $sth = $dbh->prepare( |
42 |
my $sth = $dbh->prepare( |
40 |
"SELECT * FROM overduerules WHERE (branchcode LIKE ?) or (categorycode LIKE ?) or (letter LIKE ?) or (itemtype LIKE ?) ORDER BY branchcode, delay" |
43 |
"SELECT * FROM overduerules WHERE (branchcode LIKE ?) or (categorycode LIKE ?) or (letter LIKE ?) or (itemtype LIKE ?) ORDER BY branchcode, delay" |
41 |
); |
44 |
); |
Lines 47-54
sub StringSearch {
Link Here
|
47 |
my $input = new CGI; |
50 |
my $input = new CGI; |
48 |
my $searchfield = $input->param('description'); |
51 |
my $searchfield = $input->param('description'); |
49 |
my $script_name = "/cgi-bin/koha/tools/overduerules.pl"; |
52 |
my $script_name = "/cgi-bin/koha/tools/overduerules.pl"; |
50 |
my $op = $input->param('op'); |
53 |
my $op = $input->param('op') || 'search'; |
51 |
my $overduerules_id = $input->param('overduerules_id'); |
54 |
my $overduerules_id = $input->param('overduerules_id'); |
|
|
55 |
$overduerules_id = 0 unless (defined $overduerules_id && $overduerules_id =~ /\d+/); |
52 |
my $branch = $input->param('branchcode'); |
56 |
my $branch = $input->param('branchcode'); |
53 |
my $cat = $input->param('categorycode'); |
57 |
my $cat = $input->param('categorycode'); |
54 |
my $itemtype = $input->param('itemtype'); |
58 |
my $itemtype = $input->param('itemtype'); |
Lines 59-65
foreach ($input->param){
Link Here
|
59 |
push (@mttparams, $1) if ($_ =~ /^mtt-(.*)/); |
63 |
push (@mttparams, $1) if ($_ =~ /^mtt-(.*)/); |
60 |
} |
64 |
} |
61 |
|
65 |
|
62 |
$searchfield =~ s/\,//g; |
66 |
$searchfield =~ s/\,//g if $searchfield; |
63 |
my ($template, $borrowernumber, $cookie ) = get_template_and_user( |
67 |
my ($template, $borrowernumber, $cookie ) = get_template_and_user( |
64 |
{ |
68 |
{ |
65 |
template_name => "tools/overduerules.tt", |
69 |
template_name => "tools/overduerules.tt", |
Lines 92-100
$template->param(
Link Here
|
92 |
|
96 |
|
93 |
# operations |
97 |
# operations |
94 |
if ( $op =~ m/add/ ) { |
98 |
if ( $op =~ m/add/ ) { |
95 |
$op =~ s/\D//g; |
|
|
96 |
$branch = (!defined $branch ) ? '' : $branch; |
99 |
$branch = (!defined $branch ) ? '' : $branch; |
97 |
$op = ($op eq '') ? 0 : $op; |
|
|
98 |
$cat = (!defined $cat ) ? 0 : $cat; |
100 |
$cat = (!defined $cat ) ? 0 : $cat; |
99 |
$itemtype = (!defined $itemtype ) ? '' :$itemtype; |
101 |
$itemtype = (!defined $itemtype ) ? '' :$itemtype; |
100 |
$onhold = (!defined $onhold ) ? 0 : $onhold; |
102 |
$onhold = (!defined $onhold ) ? 0 : $onhold; |
Lines 109-122
if ( $op =~ m/add/ ) {
Link Here
|
109 |
$sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay); |
111 |
$sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay); |
110 |
$dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $ruleId"); |
112 |
$dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $ruleId"); |
111 |
} |
113 |
} |
112 |
elsif ($op != 0) { # case edit pkeys |
114 |
elsif ($overduerules_id != 0) { # case edit pkeys |
113 |
my $query2 = " |
115 |
my $query2 = " |
114 |
UPDATE overduerules |
116 |
UPDATE overduerules |
115 |
SET letter = ?, debarred = ?, branchcode = ?, categorycode = ?, itemtype = ?, onhold = ?, delay = ? |
117 |
SET letter = ?, debarred = ?, branchcode = ?, categorycode = ?, itemtype = ?, onhold = ?, delay = ? |
116 |
WHERE overduerules_id = ? "; |
118 |
WHERE overduerules_id = ? "; |
117 |
my $sth = $dbh->prepare($query2); |
119 |
my $sth = $dbh->prepare($query2); |
118 |
$sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay, $op); |
120 |
$sth->execute($input->param('letter') || '', $debarred , $branch, $cat, $itemtype, $onhold, $delay, $overduerules_id); |
119 |
$dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $op"); |
121 |
$dbh->do("DELETE FROM overduerules_transport_types where overduerules_id = $overduerules_id"); |
120 |
} else { # add a new entry in overrules |
122 |
} else { # add a new entry in overrules |
121 |
my $query = " |
123 |
my $query = " |
122 |
INSERT INTO overduerules (branchcode, categorycode, itemtype, onhold, delay, letter, debarred) |
124 |
INSERT INTO overduerules (branchcode, categorycode, itemtype, onhold, delay, letter, debarred) |
123 |
- |
|
|