$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;
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {parameters => 1},
+ flagsrequired => {parameters => 1, management => 1},
debug => 1,
});
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 * from itemtypes where itemtype=?");
+ $sth->execute($itemtype);
$data=$sth->fetchrow_hashref;
$sth->finish;
}
+ # build list of images
+ my $imagedir = C4::Context->opachtdocs."/".C4::Context->preference('opacthemes');
+ warn "img : $imagedir";
+ unless (opendir(DIR, "$imagedir/itemtypeimg/")) {
+# my $cgidir = C4::Context->intranetdir;
+ opendir(DIR, "$imagedir/value_builder") || die "can't opendir $imagedir/value_builder: $!";
+ }
+ my @imagelist;
+ while (my $line = readdir(DIR)) {
+ if ($line =~ /\.gif$/) {
+ my %x;
+ $x{KohaImage} = "$line";
+ push @imagelist, \%x;
+ }
+ }
+ closedir DIR;
+# my $CGIitemtypes = CGI::scrolling_list(-name=>'itemtypes',
+# -id=>"itemtypes",
+# -values=> \@imagelist,
+# -size=>1,
+# -multiple=>0,
+# );
+#
$template->param(itemtype => $itemtype,
description => $data->{'description'},
- loanlength => $data->{'loanlength'},
renewalsallowed => $data->{'renewalsallowed'},
- rentalcharge => $data->{'rentalcharge'});
+ rentalcharge => sprintf("%.2f",$data->{'rentalcharge'}),
+ notforloan => $data->{'notforloan'},
+ imageurl => $data->{'imageurl'},
+ opacthemes => C4::Context->preference('opacthemes'),
+ IMAGESLOOP => \@imagelist,
+ );
;
# 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,imageurl) values (?,?,?,?,?,?)");
+ $sth->execute(
+ $input->param('itemtype'),$input->param('description'),
+ $input->param('renewalsallowed'),$input->param('rentalcharge'),
+ $input->param('notforloan')?1:0,
+ $input->param('imageurl'));
$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'},
+ description => $data->{description},
+ renewalsallowed => $data->{renewalsallowed},
+ rentalcharge => sprintf("%.2f",$data->{rentalcharge}),
+ imageurl => $data->{imageurl},
total => $total);
# END $OP eq DELETE_CONFIRM
################## DELETE_CONFIRMED ##################################
#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;
} else { # DEFAULT
my $env;
my ($count,$results)=StringSearch($env,$searchfield,'web');
- my $toggle="white";
+ my $toggle=0;
my @loop_data;
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
my %row_data;
- if ($toggle eq 'white'){
- $row_data{toggle}="#ffffcc";
+ if ($toggle eq 0){
+ $toggle=1;
} else {
- $row_data{toggle}="white";
+ $toggle=0;
+ }
+ $row_data{toggle} = $toggle;
+ $row_data{itemtype} = $results->[$i]{itemtype};
+ $row_data{description} = $results->[$i]{description};
+ $row_data{renewalsallowed} = $results->[$i]{renewalsallowed};
+ $row_data{notforloan} = $results->[$i]{notforloan};
+ if ($results->[$i]{imageurl} =~ /^http/) {
+ $row_data{absoluteurl} = 1;
}
- $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'};
+ $row_data{imageurl} = $results->[$i]{imageurl};
+ $row_data{rentalcharge} = sprintf("%.2f",$results->[$i]{rentalcharge});
push(@loop_data, \%row_data);
}
- $template->param(loop => \@loop_data);
+ $template->param(loop => \@loop_data,
+ opacthemes => C4::Context->preference('opacthemes')
+ );
+ 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;