@@ -, +, @@
both options (item/itemtype) are not the same.
---
Koha/Template/Plugin/Biblio.pm | 6 +++++-
admin/itemtypes.pl | 3 +++
.../Bug_35906_add-column-bookable-itemtype.pl | 14 ++++++++++++++
installer/data/mysql/kohastructure.sql | 1 +
.../prog/en/modules/admin/itemtypes.tt | 9 +++++++++
.../prog/en/modules/catalogue/moredetail.tt | 8 ++++++--
6 files changed, 38 insertions(+), 3 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl
--- a/Koha/Template/Plugin/Biblio.pm
+++ a/Koha/Template/Plugin/Biblio.pm
@@ -73,7 +73,11 @@ sub CanBook {
my $biblio = Koha::Biblios->find($biblionumber);
return 0 unless $biblio;
- return $biblio->bookable_items->count ? 1 : 0;
+ my $biblio_itemtype = Koha::ItemTypes->find($biblio->itemtype);
+ my $bookable_itemtype = $biblio_itemtype->bookable;
+
+ return 1 if $bookable_itemtype || $biblio->bookable_items->count;
+ return 0;
}
sub BookingsCount {
--- a/admin/itemtypes.pl
+++ a/admin/itemtypes.pl
@@ -98,6 +98,7 @@ if ( $op eq 'add_form' ) {
my $rentalcharge_daily_calendar = $input->param('rentalcharge_daily_calendar') // 0;
my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
my $automatic_checkin = $input->param('automatic_checkin') // 0;
+ my $bookable = $input->param('bookable')// 0;
if ( $itemtype and $is_a_modif ) { # it's a modification
$itemtype->description($description);
@@ -118,6 +119,7 @@ if ( $op eq 'add_form' ) {
$itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
$itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
$itemtype->automatic_checkin($automatic_checkin);
+ $itemtype->bookable($bookable);
eval {
$itemtype->store;
@@ -151,6 +153,7 @@ if ( $op eq 'add_form' ) {
rentalcharge_daily_calendar => $rentalcharge_daily_calendar,
rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
automatic_checkin => $automatic_checkin,
+ bookable => $bookable,
}
);
eval {
--- a/installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl
+++ a/installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl
@@ -0,0 +1,14 @@
+use Modern::Perl;
+
+return {
+ bug_number => "35906",
+ description => "Add bookable column on itemtypes table",
+ up => sub {
+ my ($args) = @_;
+ my ( $dbh, $out ) = @$args{qw(dbh out)};
+
+ $dbh->do('ALTER TABLE itemtypes ADD IF NOT EXISTS bookable INT(1) DEFAULT 0');
+
+ say $out "Added column 'itemtypes.bookable'";
+ },
+};
--- a/installer/data/mysql/kohastructure.sql
+++ a/installer/data/mysql/kohastructure.sql
@@ -4123,6 +4123,7 @@ CREATE TABLE `itemtypes` (
`hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
`searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
`automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
+ `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Activate bookable feature for items related to this item type',
PRIMARY KEY (`itemtype`),
UNIQUE KEY `itemtype` (`itemtype`),
KEY `itemtypes_ibfk_1` (`parent_type`),
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt
@@ -256,6 +256,15 @@
[% END %]
If checked, items will be automatically checked in once they've reached their due date. This feature requires the misc/cronjobs/automatic_checkin.pl
cronjob. Ask your system administrator to schedule it.
+