View | Details | Raw Unified | Return to bug 35906
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-1 / +1 lines)
Lines 238-244 sub check_booking { Link Here
238
    my $end_date   = dt_from_string( $params->{end_date} );
238
    my $end_date   = dt_from_string( $params->{end_date} );
239
    my $booking_id = $params->{booking_id};
239
    my $booking_id = $params->{booking_id};
240
240
241
    my $bookable_items = $self->bookable_items;
241
    my $bookable_items = $self->bookable_items;    
242
    my $total_bookable = $bookable_items->count;
242
    my $total_bookable = $bookable_items->count;
243
243
244
    my $dtf               = Koha::Database->new->schema->storage->datetime_parser;
244
    my $dtf               = Koha::Database->new->schema->storage->datetime_parser;
(-)a/Koha/ItemType.pm (+1 lines)
Lines 234-239 sub to_api_mapping { Link Here
234
        rentalcharge_daily_calendar  => 'daily_rental_charge_calendar',
234
        rentalcharge_daily_calendar  => 'daily_rental_charge_calendar',
235
        rentalcharge_hourly          => 'hourly_rental_charge',
235
        rentalcharge_hourly          => 'hourly_rental_charge',
236
        rentalcharge_hourly_calendar => 'hourly_rental_charge_calendar',
236
        rentalcharge_hourly_calendar => 'hourly_rental_charge_calendar',
237
        bookable_itemtype            => 'bookable_itemtype',
237
    };
238
    };
238
}
239
}
239
240
(-)a/Koha/Items.pm (-1 / +4 lines)
Lines 169-175 Returns a new resultset, containing only those items that are allowed to be book Link Here
169
sub filter_by_bookable {
169
sub filter_by_bookable {
170
    my ($self) = @_;
170
    my ($self) = @_;
171
171
172
    my $params = { bookable => 1 };
172
    my $params =
173
        C4::Context->preference('item-level_booking') == 1
174
        ? { bookable => 1 }
175
        : { itype    => { -in => \'SELECT itemtype FROM itemtypes WHERE bookable = 1' } };
173
176
174
    return $self->search($params);
177
    return $self->search($params);
175
}
178
}
(-)a/Koha/REST/V1/Biblios.pm (+3 lines)
Lines 290-295 sub get_items { Link Here
290
    my $biblio        = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } );
290
    my $biblio        = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } );
291
    my $bookable_only = $c->param('bookable');
291
    my $bookable_only = $c->param('bookable');
292
292
293
    # Deletion of parameter to avoid filtering on the items table in the case of bookings on 'itemtype'
294
    $c->req->params->remove('bookable');
295
293
    unless ($biblio) {
296
    unless ($biblio) {
294
        return $c->render(
297
        return $c->render(
295
            status  => 404,
298
            status  => 404,
(-)a/Koha/Template/Plugin/Biblio.pm (-1 / +5 lines)
Lines 73-79 sub CanBook { Link Here
73
73
74
    my $biblio = Koha::Biblios->find($biblionumber);
74
    my $biblio = Koha::Biblios->find($biblionumber);
75
    return 0 unless $biblio;
75
    return 0 unless $biblio;
76
    return $biblio->bookable_items->count ? 1 : 0;
76
    my $biblio_itemtype = Koha::ItemTypes->find($biblio->itemtype);
77
    my $bookable_itemtype = $biblio_itemtype->bookable;
78
79
    return 1 if ( $bookable_itemtype && $biblio->items->count == 1 && C4::Context->preference('item-level_booking') == 0 );
80
    return $biblio->bookable_items->count && C4::Context->preference('item-level_booking') == 1 ? 1 : 0;
77
}
81
}
78
82
79
sub BookingsCount {
83
sub BookingsCount {
(-)a/admin/itemtypes.pl (+3 lines)
Lines 98-103 if ( $op eq 'add_form' ) { Link Here
98
    my $rentalcharge_daily_calendar  = $input->param('rentalcharge_daily_calendar') // 0;
98
    my $rentalcharge_daily_calendar  = $input->param('rentalcharge_daily_calendar') // 0;
99
    my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
99
    my $rentalcharge_hourly_calendar = $input->param('rentalcharge_hourly_calendar') // 0;
100
    my $automatic_checkin = $input->param('automatic_checkin') // 0;
100
    my $automatic_checkin = $input->param('automatic_checkin') // 0;
101
    my $bookable = $input->param('bookable')// 0;
101
102
102
    if ( $itemtype and $is_a_modif ) {    # it's a modification
103
    if ( $itemtype and $is_a_modif ) {    # it's a modification
103
        $itemtype->description($description);
104
        $itemtype->description($description);
Lines 118-123 if ( $op eq 'add_form' ) { Link Here
118
        $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
119
        $itemtype->rentalcharge_daily_calendar($rentalcharge_daily_calendar);
119
        $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
120
        $itemtype->rentalcharge_hourly_calendar($rentalcharge_hourly_calendar);
120
        $itemtype->automatic_checkin($automatic_checkin);
121
        $itemtype->automatic_checkin($automatic_checkin);
122
        $itemtype->bookable($bookable);
121
123
122
        eval {
124
        eval {
123
          $itemtype->store;
125
          $itemtype->store;
Lines 151-156 if ( $op eq 'add_form' ) { Link Here
151
                rentalcharge_daily_calendar  => $rentalcharge_daily_calendar,
153
                rentalcharge_daily_calendar  => $rentalcharge_daily_calendar,
152
                rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
154
                rentalcharge_hourly_calendar => $rentalcharge_hourly_calendar,
153
                automatic_checkin   => $automatic_checkin,
155
                automatic_checkin   => $automatic_checkin,
156
                bookable   => $bookable,
154
            }
157
            }
155
        );
158
        );
156
        eval {
159
        eval {
(-)a/installer/data/mysql/atomicupdate/Bug_35906_add-column-bookable-itemtype.pl (+21 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "35906",
5
    description => "Add bookable column on itemtypes table",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{
11
            INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES  ('item-level_booking', 1, '', 'enables item type level for future booking', 'YesNo');
12
        });
13
14
        $dbh->do(q{
15
            ALTER TABLE itemtypes ADD IF NOT EXISTS bookable INT(1) DEFAULT 0
16
        });
17
18
        say $out "Added new system preference 'item-level_booking'";
19
        say $out "Added column 'itemtypes.bookable'";
20
    },
21
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 4123-4128 CREATE TABLE `itemtypes` ( Link Here
4123
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4123
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4124
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4124
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4125
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4125
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4126
  `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Activate bookable feature for items related to this item type',
4126
  PRIMARY KEY (`itemtype`),
4127
  PRIMARY KEY (`itemtype`),
4127
  UNIQUE KEY `itemtype` (`itemtype`),
4128
  UNIQUE KEY `itemtype` (`itemtype`),
4128
  KEY `itemtypes_ibfk_1` (`parent_type`),
4129
  KEY `itemtypes_ibfk_1` (`parent_type`),
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 345-350 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
345
('IssueLostItem','alert','Defines what should be done when an attempt is made to issue an item that has been marked as lost.','alert|confirm|nothing','Choice'),
345
('IssueLostItem','alert','Defines what should be done when an attempt is made to issue an item that has been marked as lost.','alert|confirm|nothing','Choice'),
346
('IssuingInProcess','0',NULL,'If ON, disables fines if the patron is issuing item that accumulate debt','YesNo'),
346
('IssuingInProcess','0',NULL,'If ON, disables fines if the patron is issuing item that accumulate debt','YesNo'),
347
('item-level_itypes','1','','If ON, enables Item-level Itemtype / Issuing Rules','YesNo'),
347
('item-level_itypes','1','','If ON, enables Item-level Itemtype / Issuing Rules','YesNo'),
348
('item-level_booking','1','','If ON, enables Item-level for future booking feature','YesNo'),
348
('itemBarcodeFallbackSearch','0',NULL,'If set, uses scanned item barcodes as a catalogue search if not found as barcodes','YesNo'),
349
('itemBarcodeFallbackSearch','0',NULL,'If set, uses scanned item barcodes as a catalogue search if not found as barcodes','YesNo'),
349
('itemBarcodeInputFilter','','whitespace|T-prefix|cuecat|libsuite8|EAN13','If set, allows specification of a item barcode input filter','Choice'),
350
('itemBarcodeInputFilter','','whitespace|T-prefix|cuecat|libsuite8|EAN13','If set, allows specification of a item barcode input filter','Choice'),
350
('itemcallnumber','',NULL,'The MARC field/subfield that is used to calculate the itemcallnumber (Dewey would be 082ab or 092ab; LOC would be 050ab or 090ab) could be 852hi from an item record','free'),
351
('itemcallnumber','',NULL,'The MARC field/subfield that is used to calculate the itemcallnumber (Dewey would be 082ab or 092ab; LOC would be 050ab or 090ab) could be 852hi from an item record','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (+11 lines)
Lines 257-262 Link Here
257
                        [% END %]
257
                        [% END %]
258
                        <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>
258
                        <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>
259
                </li>
259
                </li>
260
                [% IF Koha.Preference('item-level_booking') == 0 %]
261
                    <li>
262
                        <label for="bookable">Bookable: </label>
263
                            [% IF itemtype.bookable %]
264
                                <input type="checkbox" id="bookable" name="bookable" checked="checked" value="1" />
265
                            [% ELSE %]
266
                                <input type="checkbox" id="bookable" name="bookable" value="1" />
267
                            [% END %]
268
                            <span class="hint">If checked, all items of this type will be enabled for future bookings.</span>
269
                    </li>
270
                [% END %]
260
                <li>
271
                <li>
261
                    <label for="rentalcharge">Rental charge: </label>
272
                    <label for="rentalcharge">Rental charge: </label>
262
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" />
273
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+7 lines)
Lines 1008-1013 Circulation: Link Here
1008
                  0: "Don't allow"
1008
                  0: "Don't allow"
1009
            - holds to be automatically filled after being automatically checked in.
1009
            - holds to be automatically filled after being automatically checked in.
1010
            - '<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.'
1010
            - '<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/automatic_checkin.pl</code> cronjob. Ask your system administrator to schedule it.'
1011
        -
1012
            - Use the type of the
1013
            - pref: item-level_booking
1014
              choices:
1015
                  1: item
1016
                  0: itemtype
1017
            - level to defined witch items can be bookable in future.
1011
    Patron restrictions:
1018
    Patron restrictions:
1012
        -
1019
        -
1013
            - pref: PatronRestrictionTypes
1020
            - pref: PatronRestrictionTypes
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-4 / +5 lines)
Lines 347-360 Link Here
347
                                            </form>
347
                                            </form>
348
                                        </li>
348
                                        </li>
349
                                        <li>
349
                                        <li>
350
                                            <span class="label">Bookable:</span>
350
                                            <span class="label">
351
                                                Bookable:
352
                                            </span>
351
                                            [% IF ( CAN_user_circulate ) %]
353
                                            [% IF ( CAN_user_circulate ) %]
352
                                                <form action="updateitem.pl" method="post">
354
                                                <form action="updateitem.pl" method="post">
353
                                                    <input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" />
355
                                                    <input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" />
354
                                                    <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" />
356
                                                    <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" />
355
                                                    <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
357
                                                    <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
356
                                                    <select name="bookable">
358
                                                    <select name="bookable" [% IF ITEM_DAT.effective_itemtype.bookable == 1 && Koha.Preference('item-level_booking') == 0 %]disabled[% END %]>
357
                                                        [% IF ITEM_DAT.bookable == 1 %]
359
                                                    [% IF ITEM_DAT.bookable == 1 || ITEM_DAT.effective_itemtype.bookable == 1 %]
358
                                                        <option value="1" selected="selected">Yes</option>
360
                                                        <option value="1" selected="selected">Yes</option>
359
                                                        <option value="0">No</option>
361
                                                        <option value="0">No</option>
360
                                                        [% ELSE %]
362
                                                        [% ELSE %]
361
- 

Return to bug 35906