$searchstring=~ s/\'/\\\'/g;
my @data=split(' ',$searchstring);
my $count=@data;
- my $query="Select * from itemtypes where (description like \"$data[0]%\") order by itemtype";
- my $sth=$dbh->prepare($query);
- $sth->execute;
+ my $sth=$dbh->prepare("Select * from itemtypes where (description like ?) order by itemtype");
+ $sth->execute("$data[0]%");
my @results;
- my $cnt=0;
while (my $data=$sth->fetchrow_hashref){
push(@results,$data);
- $cnt ++;
}
# $sth->execute;
$sth->finish;
- return ($cnt,\@results);
+ return (scalar(@results),\@results);
}
my $input = new CGI;
my $data;
if ($itemtype) {
my $dbh = C4::Context->dbh;
- my $sth=$dbh->prepare("select itemtype,description,loanlength,renewalsallowed,rentalcharge from itemtypes where itemtype='$itemtype'");
- $sth->execute;
+ my $sth=$dbh->prepare("select itemtype,description,renewalsallowed,rentalcharge,notforloan from itemtypes where itemtype=?");
+ $sth->execute($itemtype);
$data=$sth->fetchrow_hashref;
$sth->finish;
}
$template->param(itemtype => $itemtype,
description => $data->{'description'},
- loanlength => $data->{'loanlength'},
renewalsallowed => $data->{'renewalsallowed'},
- rentalcharge => $data->{'rentalcharge'});
+ rentalcharge => $data->{'rentalcharge'},
+ notforloan => $data->{'notforloan'}
+ );
;
# END $OP eq ADD_FORM
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh = C4::Context->dbh;
- my $query = "replace itemtypes (itemtype,description,loanlength,renewalsallowed,rentalcharge) values (";
- $query.= $dbh->quote($input->param('itemtype')).",";
- $query.= $dbh->quote($input->param('description')).",";
- $query.= $dbh->quote($input->param('loanlength')).",";
- if ($input->param('renewalsallowed') ne 1) {
- $query.= "0,";
- } else {
- $query.= "1,";
- }
- $query.= $dbh->quote($input->param('rentalcharge')).")";
- my $sth=$dbh->prepare($query);
- $sth->execute;
+ my $sth=$dbh->prepare("replace itemtypes (itemtype,description,renewalsallowed,rentalcharge,notforloan) values (?,?,?,?,?)");
+ $sth->execute(
+ $input->param('itemtype'),$input->param('description'),
+ $input->param('renewalsallowed'),$input->param('rentalcharge'),
+ $input->param('notforloan')?1:0);
$sth->finish;
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=itemtypes.pl\"></html>";
exit;
# Check both categoryitem and biblioitems, see Bug 199
my $total = 0;
- for my $table ('categoryitem', 'biblioitems') {
+ for my $table ('biblioitems') {
my $sth=$dbh->prepare("select count(*) as total from $table where itemtype=?");
$sth->execute($itemtype);
$total += $sth->fetchrow_hashref->{total};
$sth->finish;
}
- my $sth=$dbh->prepare("select itemtype,description,loanlength,renewalsallowed,rentalcharge from itemtypes where itemtype=?");
+ my $sth=$dbh->prepare("select itemtype,description,renewalsallowed,rentalcharge from itemtypes where itemtype=?");
$sth->execute($itemtype);
my $data=$sth->fetchrow_hashref;
$sth->finish;
$template->param(itemtype => $itemtype,
description => $data->{'description'},
- loanlength => $data->{'loanlength'},
renewalsallowed => $data->{'renewalsallowed'},
rentalcharge => $data->{'rentalcharge'},
total => $total);
#start the page and read in includes
my $dbh = C4::Context->dbh;
my $itemtype=uc($input->param('itemtype'));
- my $query = "delete from itemtypes where itemtype='$itemtype'";
- my $sth=$dbh->prepare($query);
- $sth->execute;
+ my $sth=$dbh->prepare("delete from itemtypes where itemtype=?");
+ $sth->execute($itemtype);
+ $sth = $dbh->prepare("delete from issuingrules where itemtype=?");
+ $sth->execute($itemtype);
$sth->finish;
print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=itemtypes.pl\"></html>";
exit;
}
$row_data{itemtype} = $results->[$i]{'itemtype'};
$row_data{description} = $results->[$i]{'description'};
- $row_data{loanlength} = $results->[$i]{'loanlength'};
$row_data{renewalsallowed} = $results->[$i]{'renewalsallowed'};
$row_data{rentalcharge} = $results->[$i]{'rentalcharge'};
push(@loop_data, \%row_data);
}
$template->param(loop => \@loop_data);
+ if ($offset>0) {
+ my $prevpage = $offset-$pagesize;
+ $template->param(previous => "$script_name?offset=".$prevpage);
+ }
+ if ($offset+$pagesize<$count) {
+ my $nextpage =$offset+$pagesize;
+ $template->param(next => "$script_name?offset=".$nextpage);
+ }
} #---- END $OP eq DEFAULT
output_html_with_http_headers $input, $cookie, $template->output;