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

(-)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 191-197 Returns a new resultset, containing only those items that are allowed to be book Link Here
191
sub filter_by_bookable {
191
sub filter_by_bookable {
192
    my ($self) = @_;
192
    my ($self) = @_;
193
193
194
    my $params = { bookable => 1 };
194
    my $params =
195
        C4::Context->preference('item-level_booking') == 1
196
        ? { bookable => 1 }
197
        : { itype    => { -in => \'SELECT itemtype FROM itemtypes WHERE bookable = 1' } };
195
198
196
    return $self->search($params);
199
    return $self->search($params);
197
}
200
}
(-)a/Koha/REST/V1/Biblios.pm (+3 lines)
Lines 266-271 sub get_items { Link Here
266
    my $biblio        = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } );
266
    my $biblio        = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } );
267
    my $bookable_only = $c->param('bookable');
267
    my $bookable_only = $c->param('bookable');
268
268
269
    # Deletion of parameter to avoid filtering on the items table in the case of bookings on 'itemtype'
270
    $c->req->params->remove('bookable');
271
269
    return $c->render_resource_not_found("Bibliographic record")
272
    return $c->render_resource_not_found("Bibliographic record")
270
        unless $biblio;
273
        unless $biblio;
271
274
(-)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 4142-4147 CREATE TABLE `itemtypes` ( Link Here
4142
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4142
  `hideinopac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hide the item type from the search options in OPAC',
4143
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4143
  `searchcategory` varchar(80) DEFAULT NULL COMMENT 'Group this item type with others with the same value on OPAC search options',
4144
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4144
  `automatic_checkin` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'If automatic checkin is enabled for items of this type',
4145
  `bookable` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Activate bookable feature for items related to this item type',
4145
  PRIMARY KEY (`itemtype`),
4146
  PRIMARY KEY (`itemtype`),
4146
  UNIQUE KEY `itemtype` (`itemtype`),
4147
  UNIQUE KEY `itemtype` (`itemtype`),
4147
  KEY `itemtypes_ibfk_1` (`parent_type`),
4148
  KEY `itemtypes_ibfk_1` (`parent_type`),
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 354-359 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
354
('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'),
354
('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'),
355
('IssuingInProcess','0',NULL,'If ON, disables fines if the patron is issuing item that accumulate debt','YesNo'),
355
('IssuingInProcess','0',NULL,'If ON, disables fines if the patron is issuing item that accumulate debt','YesNo'),
356
('item-level_itypes','1','','If ON, enables Item-level Itemtype / Issuing Rules','YesNo'),
356
('item-level_itypes','1','','If ON, enables Item-level Itemtype / Issuing Rules','YesNo'),
357
('item-level_booking','1','','If ON, enables Item-level for future booking feature','YesNo'),
357
('itemBarcodeFallbackSearch','0',NULL,'If set, uses scanned item barcodes as a catalogue search if not found as barcodes','YesNo'),
358
('itemBarcodeFallbackSearch','0',NULL,'If set, uses scanned item barcodes as a catalogue search if not found as barcodes','YesNo'),
358
('itemBarcodeInputFilter','','whitespace|T-prefix|cuecat|libsuite8|EAN13','If set, allows specification of a item barcode input filter','Choice'),
359
('itemBarcodeInputFilter','','whitespace|T-prefix|cuecat|libsuite8|EAN13','If set, allows specification of a item barcode input filter','Choice'),
359
('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'),
360
('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 258-263 Link Here
258
                        [% END %]
258
                        [% END %]
259
                        <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
                        <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>
260
                </li>
260
                </li>
261
                [% IF Koha.Preference('item-level_booking') == 0 %]
262
                    <li>
263
                        <label for="bookable">Bookable: </label>
264
                            [% IF itemtype.bookable %]
265
                                <input type="checkbox" id="bookable" name="bookable" checked="checked" value="1" />
266
                            [% ELSE %]
267
                                <input type="checkbox" id="bookable" name="bookable" value="1" />
268
                            [% END %]
269
                            <span class="hint">If checked, all items of this type will be enabled for future bookings.</span>
270
                    </li>
271
                [% END %]
261
                <li>
272
                <li>
262
                    <label for="rentalcharge">Rental charge: </label>
273
                    <label for="rentalcharge">Rental charge: </label>
263
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price on_editing => 1 %]" min="0" />
274
                    <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 1082-1087 Circulation: Link Here
1082
                  1: "Do"
1082
                  1: "Do"
1083
                  0: "Don't"
1083
                  0: "Don't"
1084
            - place a hold when ordering from a suggestion.
1084
            - place a hold when ordering from a suggestion.
1085
        -
1086
            - Use the type of the
1087
            - pref: item-level_booking
1088
              choices:
1089
                  1: item
1090
                  0: itemtype
1091
            - level to defined witch items can be bookable in future.
1085
    Patron restrictions:
1092
    Patron restrictions:
1086
        -
1093
        -
1087
            - pref: PatronRestrictionTypes
1094
            - pref: PatronRestrictionTypes
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-4 / +5 lines)
Lines 350-364 Link Here
350
                                            </form>
350
                                            </form>
351
                                        </li>
351
                                        </li>
352
                                        <li>
352
                                        <li>
353
                                            <span class="label">Bookable:</span>
353
                                            <span class="label">
354
                                                Bookable:
355
                                            </span>
354
                                            [% IF ( CAN_user_circulate ) %]
356
                                            [% IF ( CAN_user_circulate ) %]
355
                                                <form action="updateitem.pl" method="post">
357
                                                <form action="updateitem.pl" method="post">
356
                                                    [% INCLUDE 'csrf-token.inc' %]
358
                                                    [% INCLUDE 'csrf-token.inc' %]
357
                                                    <input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" />
359
                                                    <input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" />
358
                                                    <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" />
360
                                                    <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" />
359
                                                    <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
361
                                                    <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" />
360
                                                    <select name="bookable">
362
                                                    <select name="bookable" [% IF ITEM_DAT.effective_itemtype.bookable == 1 && Koha.Preference('item-level_booking') == 0 %]disabled[% END %]>
361
                                                        [% IF ITEM_DAT.bookable == 1 %]
363
                                                    [% IF ITEM_DAT.bookable == 1 || ITEM_DAT.effective_itemtype.bookable == 1 %]
362
                                                        <option value="1" selected="selected">Yes</option>
364
                                                        <option value="1" selected="selected">Yes</option>
363
                                                        <option value="0">No</option>
365
                                                        <option value="0">No</option>
364
                                                        [% ELSE %]
366
                                                        [% ELSE %]
365
- 

Return to bug 35906