Bugzilla – Attachment 161397 Details for
Bug 35906
Add bookable option on itemtypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35906: Add bookable option on itemtype
Bug-35906-Add-bookable-option-on-itemtype.patch (text/plain), 8.26 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-01-25 13:31:37 UTC
(
hide
)
Description:
Bug 35906: Add bookable option on itemtype
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-01-25 13:31:37 UTC
Size:
8.26 KB
patch
obsolete
>From 05822803b9294e743ec1f89b2cb9410c67423cc1 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Thu, 25 Jan 2024 14:14:07 +0100 >Subject: [PATCH] Bug 35906: Add bookable option on itemtype > >Actually new "booking" feature can be set on an item but no directly on >an itemtype. This patch adds this possibility. > >Test plan: >1) Test this new feature on an item as it were currently working. >2) Apply this patch >3) Run updatedatabase.pl >4) Reload Schema by running update_dbix_class_files.pl >5) Edit an itemtype, there is a new checkbox to add 'bookable' option >6) Test it with item with this itemtype, go to edit item view >("Booking" tab is already in biblio-view-menu even if there is no booking on item, due to bookable option on itemtype) >7) Next to the bookable item option you can see a warn with a message if > both options (item/itemtype) are not the same. >8) Test it > >Sponsored by: BibLibre >--- > 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 > >diff --git a/Koha/Template/Plugin/Biblio.pm b/Koha/Template/Plugin/Biblio.pm >index 79c7284..92146fd 100644 >--- a/Koha/Template/Plugin/Biblio.pm >+++ b/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 { >diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl >index 44e9ad5..ed13f33 100755 >--- a/admin/itemtypes.pl >+++ b/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 { >diff --git a/installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl b/installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl >new file mode 100644 >index 0000000..8058965 >--- /dev/null >+++ b/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'"; >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 16310f0..dd2a610 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/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`), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >index 97f463c..6a17f74 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >@@ -256,6 +256,15 @@ > [% END %] > <span class="hint">If checked, items will be automatically checked in once they've reached their due date. This feature requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.</span> > </li> >+ <li> >+ <label for="bookable">Bookable: </label> >+ [% IF itemtype.bookable %] >+ <input type="checkbox" id="bookable" name="bookable" checked="checked" value="1" /> >+ [% ELSE %] >+ <input type="checkbox" id="bookable" name="bookable" value="1" /> >+ [% END %] >+ <span class="hint">If checked, items related to this item type will benefit from the "booking" feature.</span> >+ </li> > <li> > <label for="rentalcharge">Rental charge: </label> > <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" /> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index ad31298..5a8384f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -346,7 +346,11 @@ > </form> > </li> > <li> >- <span class="label">Bookable:</span> >+ [% SET itemtype_bookable_status = ITEM_DAT.effective_itemtype.bookable == 1 ? "bookable" : "not bookable" %] >+ <span class="label"> >+ Bookable: >+ [% IF ITEM_DAT.bookable != ITEM_DAT.effective_itemtype.bookable %]<i class="fa fa-warning warn" Title="Itemtype is actually [% itemtype_bookable_status | html %]"></i>[% END %] >+ </span> > [% IF ( CAN_user_circulate ) %] > <form action="updateitem.pl" method="post"> > <input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" /> >@@ -365,7 +369,7 @@ > <input type="submit" name="submit" class="btn btn-primary btn-xs" value="Update" /> > </form> > [% ELSE %] >- [% IF ITEM_DAT.bookable == 1 %] Yes [% ELSE %] No [% END %] >+ [% IF ITEM_DAT.bookable == 1 || ITEM_DAT.effective_itemtype.bookable == 1 %] Yes [% ELSE %] No [% END %] > [% END %] > </li> > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35906
:
161397
|
161638
|
161744
|
161961
|
162242
|
162365
|
162465
|
162466
|
162467
|
162468
|
162469
|
162470
|
162472
|
163291
|
163292
|
163293
|
163294
|
163295
|
163547
|
163548
|
163549
|
163550
|
163551
|
164579
|
164580
|
164581
|
164582
|
164583
|
164584
|
164585
|
165437
|
166866
|
166867
|
166868
|
166869
|
166870
|
166871
|
168120
|
168121
|
168122
|
168160
|
168161
|
168162
|
168163
|
168164
|
170187
|
170188
|
170189
|
170190
|
170191
|
170582
|
170583
|
170584
|
170585
|
170586
|
172127
|
172128
|
172129
|
172130
|
172131
|
172132
|
172941
|
172945
|
172950
|
172951
|
172952
|
172953
|
172954
|
172955
|
172956
|
172957
|
172958
|
172959
|
172960
|
172961
|
173324
|
173325
|
173326
|
173327
|
173328
|
173329
|
173330
|
173331
|
173332
|
173333
|
173334
|
173335
|
173893