new feature : image for itemtypes.

* run updater/updatedatabase to create imageurl field in itemtypes.
* go to Koha >> parameters >> itemtypes >> modify (or add) an itemtype. You will see around 20 nice images to choose between (thanks to owen). If you prefer your own image, you also can type a complete url (http://www.myserver.lib/path/to/my/image.gif)
* go to OPAC, and search something. In the result list, you now have the picture instead of the text itemtype.
This commit is contained in:
tipaul 2005-09-02 14:18:38 +00:00
parent d2b2eb603b
commit cf94bf34fb
70 changed files with 77 additions and 10 deletions

View File

@ -96,16 +96,42 @@ if ($op eq 'add_form') {
my $data;
if ($itemtype) {
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("select itemtype,description,renewalsallowed,rentalcharge,notforloan from itemtypes where itemtype=?");
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'},
renewalsallowed => $data->{'renewalsallowed'},
rentalcharge => sprintf("%.2f",$data->{'rentalcharge'}),
notforloan => $data->{'notforloan'}
notforloan => $data->{'notforloan'},
imageurl => $data->{'imageurl'},
opacthemes => C4::Context->preference('opacthemes'),
IMAGESLOOP => \@imagelist,
);
;
# END $OP eq ADD_FORM
@ -113,11 +139,12 @@ if ($op eq 'add_form') {
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
my $dbh = C4::Context->dbh;
my $sth=$dbh->prepare("replace itemtypes (itemtype,description,renewalsallowed,rentalcharge,notforloan) values (?,?,?,?,?)");
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('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;
@ -143,9 +170,10 @@ if ($op eq 'add_form') {
$sth->finish;
$template->param(itemtype => $itemtype,
description => $data->{'description'},
renewalsallowed => $data->{'renewalsallowed'},
rentalcharge => sprintf("%.2f",$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 ##################################
@ -180,10 +208,16 @@ if ($op eq 'add_form') {
$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{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);

View File

@ -56,6 +56,10 @@ function Check(f) {
alert(alertString2);
}
}
function report_itemtype(value_to_report) {
Aform.imageurl.value=value_to_report;
}
</script>
<div id="mainbloc">
<!-- TMPL_IF NAME="add_form" -->
@ -76,6 +80,13 @@ function Check(f) {
<label class="label100">Description</label>
<input type="text" name="description" size="40" maxlength="80" value="<!-- TMPL_VAR NAME="description" escape=HTML -->">
</p>
<p>
<label class="label100">Image</label>
<input type="text" name="imageurl" value="<!-- TMPL_VAR name="imageurl" -->" size="40" maxlength="80">
<!-- TMPL_LOOP NAME="IMAGESLOOP" -->
<a href="javascript:report_itemtype('<!-- TMPL_VAR name="KohaImage" -->')"><img src="/opac-tmpl/<!-- TMPL_VAR name="opacthemes" -->/itemtypeimg/<!-- TMPL_VAR name="KohaImage" -->"></a>
<!-- /TMPL_LOOP -->
</p>
<p>
<label class="label100">Not for loan</label>
<!-- TMPL_IF NAME="notforloan" -->
@ -138,7 +149,16 @@ function Check(f) {
</tr>
<!-- TMPL_LOOP NAME="loop" -->
<tr>
<td><!-- TMPL_VAR NAME="itemtype" --></td>
<td>
<!-- TMPL_IF name="imageurl" -->
<!-- TMPL_IF name="absoluteurl" -->
<img src="<!-- TMPL_VAR name="imageurl" -->">
<!-- TMPL_ELSE -->
<img src="/opac-tmpl/<!-- TMPL_VAR name="opacthemes" -->/itemtypeimg/<!-- TMPL_VAR name="imageurl" -->">
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_VAR NAME="itemtype" -->
</td>
<td><!-- TMPL_VAR NAME="description" --></td>
<td><!-- TMPL_IF NAME="notforloan" -->Yes<!-- /TMPL_IF --></td>
<td><!-- TMPL_UNLESS name="notforloan" -->

View File

@ -79,7 +79,11 @@
</p>
</td>
<td align="center" <!-- TMPL_IF name="even" --> class="hilighted"<!-- /TMPL_IF -->>
<!-- TMPL_VAR name="description" -->
<!-- TMPL_IF name="imageurl" -->
<img src="/opac-tmpl/<!-- TMPL_VAR name="theme" -->/itemtypeimg/<!-- TMPL_VAR name="imageurl" -->" title="<!-- TMPL_VAR name="description" -->"
<!-- TMPL_ELSE -->
<!-- TMPL_VAR name="description" -->
<!-- /TMPL_IF -->
</td>
<td align="center" <!-- TMPL_IF name="even" --> class="hilighted"<!-- /TMPL_IF -->>
<!-- TMPL_VAR name="totitem" -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

View File

@ -98,6 +98,7 @@ my %requiretables = (
my %requirefields = (
subscription => { 'letter' => 'char(20) NULL'},
itemtypes => { 'imageurl' => 'char(200) NULL'},
# tablename => { 'field' => 'fieldtype' },
);
@ -276,6 +277,7 @@ foreach $table ( keys %fielddefinitions ) {
my $field = $row->{field};
my $type = $row->{type};
my $null = $row->{null};
# $null = 'YES' if $row->{null} eq 'NULL';
my $key = $row->{key};
my $default = $row->{default};
$default="''" unless $default;
@ -619,6 +621,13 @@ sub MARCgetitem {
exit;
# $Log$
# Revision 1.122 2005/09/02 14:18:38 tipaul
# new feature : image for itemtypes.
#
# * run updater/updatedatabase to create imageurl field in itemtypes.
# * go to Koha >> parameters >> itemtypes >> modify (or add) an itemtype. You will see around 20 nice images to choose between (thanks to owen). If you prefer your own image, you also can type a complete url (http://www.myserver.lib/path/to/my/image.gif)
# * go to OPAC, and search something. In the result list, you now have the picture instead of the text itemtype.
#
# Revision 1.121 2005/08/24 08:49:03 hdl
# Adding a note field in serial table.
# This will allow librarian to mention a note on a peculiar waiting serial number.