From 3910adbd7eb0f1c50a5e09a13d18e2e26f563a30 Mon Sep 17 00:00:00 2001 From: Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com> Date: Thu, 2 Mar 2017 17:52:10 +0100 Subject: [PATCH] Add per borrower category create ILL privilege. * admin/categories.pl: Add validation & update for `canplaceill`. * koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt: Add `canplaceill` handling. * ill/ill-requests.pl: Pass `canplaceill` to template. * koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc: Check for `canplaceill`. * opac/opac-illrequests.pl: Pass `canplaceill` to template. * koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt: Check for `canplaceill`. * installer/data/mysql/kohastructure.sql: Create `canplaceill` column. * installer/data/mysql/atomicupdate/ill_cat_permission.sql: New file. --- admin/categories.pl | 3 ++ ill/ill-requests.pl | 2 ++ .../data/mysql/atomicupdate/ill_cat_permission.sql | 4 +++ installer/data/mysql/kohastructure.sql | 1 + .../intranet-tmpl/prog/en/includes/ill-toolbar.inc | 32 ++++++++++---------- .../prog/en/modules/admin/categories.tt | 29 ++++++++++++++++++ .../bootstrap/en/modules/opac-illrequests.tt | 34 ++++++++++++---------- opac/opac-illrequests.pl | 6 ++-- 8 files changed, 77 insertions(+), 34 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/ill_cat_permission.sql diff --git a/admin/categories.pl b/admin/categories.pl index 358ef7d8c8..753d012935 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -91,6 +91,7 @@ elsif ( $op eq 'add_validate' ) { my $category_type = $input->param('category_type'); my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions'); my $checkPrevCheckout = $input->param('checkprevcheckout'); + my $canplaceill = $input->param('canplaceill'); my $default_privacy = $input->param('default_privacy'); my @branches = grep { $_ ne q{} } $input->multi_param('branches'); @@ -121,6 +122,7 @@ elsif ( $op eq 'add_validate' ) { $category->category_type($category_type); $category->BlockExpiredPatronOpacActions($BlockExpiredPatronOpacActions); $category->checkprevcheckout($checkPrevCheckout); + $category->canplaceill($canplaceill); $category->default_privacy($default_privacy); eval { $category->store; @@ -147,6 +149,7 @@ elsif ( $op eq 'add_validate' ) { category_type => $category_type, BlockExpiredPatronOpacActions => $BlockExpiredPatronOpacActions, checkprevcheckout => $checkPrevCheckout, + canplaceill => $canplaceill, default_privacy => $default_privacy, }); eval { diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index 5ab56b8722..f56187374d 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -219,6 +219,8 @@ my $ir = Koha::Illrequest->new; $template->param( backends => $ir->available_backends, + canplaceill => Koha::Patrons->find($patronnumber) + ->_result->categorycode->canplaceill, media => [ "Book", "Article", "Journal" ], query_type => $op, branches => Koha::Libraries->search->unblessed, diff --git a/installer/data/mysql/atomicupdate/ill_cat_permission.sql b/installer/data/mysql/atomicupdate/ill_cat_permission.sql new file mode 100644 index 0000000000..aa391c86e2 --- /dev/null +++ b/installer/data/mysql/atomicupdate/ill_cat_permission.sql @@ -0,0 +1,4 @@ +-- Add new column to categories table +ALTER TABLE categories +ADD COLUMN `canplaceill` tinyint(1) NOT NULL default '0' +AFTER `checkprevcheckout`; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e37930b789..22d606e759 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -330,6 +330,7 @@ CREATE TABLE `categories` ( -- this table shows information related to Koha patr `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this category can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BlockExpiredPatronOpacActions `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category `checkprevcheckout` varchar(7) NOT NULL default 'inherit', -- produce a warning for this patron category if this item has previously been checked out to this patron if 'yes', not if 'no', defer to syspref setting if 'inherit'. + `canplaceill` tinyint(1) NOT NULL default '0', -- can this patron category place interlibrary loan requests PRIMARY KEY (`categorycode`), UNIQUE KEY `categorycode` (`categorycode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc index 3f541d9283..61aa63108f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc @@ -1,21 +1,23 @@ [% USE Koha %] [% IF Koha.Preference('ILLModule ') %] <div id="toolbar" class="btn-toolbar"> - [% IF backends.size > 1 %] - <div class="dropdown btn-group"> - <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> - <i class="fa fa-plus"></i> New ILL request <span class="caret"></span> - </button> - <ul class="dropdown-menu" aria-labelledby="ill-backend-dropdown"> - [% FOREACH backend IN backends %] - <li><a href="/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=[% backend %]">[% backend %]</a></li> - [% END %] - </ul> - </div> - [% ELSE %] - <a id="ill-new" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=[% backends.0 %]"> - <i class="fa fa-plus"></i> New ILL request - </a> + [% IF canplaceill %] + [% IF backends.size > 1 %] + <div class="dropdown btn-group"> + <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> + <i class="fa fa-plus"></i> New ILL request <span class="caret"></span> + </button> + <ul class="dropdown-menu" aria-labelledby="ill-backend-dropdown"> + [% FOREACH backend IN backends %] + <li><a href="/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=[% backend %]">[% backend %]</a></li> + [% END %] + </ul> + </div> + [% ELSE %] + <a id="ill-new" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=[% backends.0 %]"> + <i class="fa fa-plus"></i> New ILL request + </a> + [% END %] [% END %] <a id="ill-list" class="btn btn-sm btn-default btn-group" href="/cgi-bin/koha/ill/ill-requests.pl"> <i class="fa fa-list"></i> List requests diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index b28b634c3c..835cb01b8f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -211,6 +211,23 @@ </span> </li> [% END %] + [% IF ( Koha.Preference('ILLModule') ) %] + <li> + <label for="canplaceill">Can place ILL: </label> + <select id="canplaceill" name="canplaceill"> + [% IF category.canplaceill %] + <option value="0">No</option> + <option value="1" selected="selected">Yes</option> + [% ELSE %] + <option value="0" selected="selected">No</option> + <option value="1">Yes</option> + [% END %] + </select> + <span> + Choose whether patrons of this category can create new interlibrary loan requests. + </span> + </li> + [% END %] <li> <label for="default_privacy">Default privacy: </label> <select id="default_privacy" name="default_privacy"> @@ -299,6 +316,12 @@ </td> </tr> [% END %] + [% IF ( Koha.Preference('ILLModule') ) %] + <tr> + <th scope="row">Can place ILL: </th> + <td>[% IF category.canplaceill %]Yes[% ELSE %]No[% END %]</td> + </tr> + [% END %] <tr> <th scope="row">Default privacy: </th> <td> @@ -358,6 +381,9 @@ [% IF ( Koha.Preference('CheckPrevCheckout') == 'softyes' || Koha.Preference('CheckPrevCheckout') == 'softno' ) %] <th scope="col">Check previous checkout?</th> [% END %] + [% IF ( Koha.Preference('ILLModule') ) %] + <th scope="col">Can place ILL?</th> + [% END %] <th scope="col">Default privacy</th> <th scope="col">Actions</th> </tr> @@ -446,6 +472,9 @@ [% END %] </td> [% END %] + [% IF ( Koha.Preference('ILLModule') ) %] + <td>[% IF category.canplaceill %]Yes[% ELSE %]No[% END %]</td> + [% END %] <td> [% SWITCH category.default_privacy %] [% CASE 'default' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt index 0c4600fd87..cfa40ff329 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -74,22 +74,24 @@ <h2>Interlibrary loan requests</h2> [% INCLUDE messages %] - <div id="illrequests-create-button" class="dropdown btn-group"> - [% IF backends.size > 1 %] - <button class="btn btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> - <i class="fa fa-plus"></i> Create a new request <span class="caret"></span> - </button> - <ul id="backend-dropdown-options" class="dropdown-menu nojs" aria-labelledby="ill-backend-dropdown"> - [% FOREACH backend IN backends %] - <li><a href="/cgi-bin/koha/opac-illrequests.pl?method=create&backend=[% backend %]">[% backend %]</a></li> - [% END %] - </ul> - [% ELSE %] - <a id="ill-new" class="btn btn-default" href="/cgi-bin/koha/opac-illrequests.pl?method=create&backend=[% backends.0 %]"> - <i class="fa fa-plus"></i> Create a new request - </a> - [% END %] - </div> + [% IF canplaceill %] + <div id="illrequests-create-button" class="dropdown btn-group"> + [% IF backends.size > 1 %] + <button class="btn btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> + <i class="fa fa-plus"></i> Create a new request <span class="caret"></span> + </button> + <ul id="backend-dropdown-options" class="dropdown-menu nojs" aria-labelledby="ill-backend-dropdown"> + [% FOREACH backend IN backends %] + <li><a href="/cgi-bin/koha/opac-illrequests.pl?method=create&backend=[% backend %]">[% backend %]</a></li> + [% END %] + </ul> + [% ELSE %] + <a id="ill-new" class="btn btn-default" href="/cgi-bin/koha/opac-illrequests.pl?method=create&backend=[% backends.0 %]"> + <i class="fa fa-plus"></i> Create a new request + </a> + [% END %] + </div> + [% END %] <table id="illrequestlist" class="table table-bordered table-striped"> <thead> diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl index 9ff413adf7..6d26388f99 100755 --- a/opac/opac-illrequests.pl +++ b/opac/opac-illrequests.pl @@ -49,6 +49,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ }); my $op = $params->{'method'} || 'list'; +my $patron = Koha::Patrons->find($loggedinuser); if ( $op eq 'list' ) { @@ -102,9 +103,7 @@ if ( $op eq 'list' ) { } else { my $request = Koha::Illrequest->new ->load_backend($params->{backend}); - $params->{cardnumber} = Koha::Patrons->find({ - borrowernumber => $loggedinuser - })->cardnumber; + $params->{cardnumber} = $patron->cardnumber; my $backend_result = $request->backend_create($params); $template->param( media => [ "Book", "Article", "Journal" ], @@ -121,6 +120,7 @@ if ( $op eq 'list' ) { } $template->param( + canplaceill => $patron->_result->categorycode->canplaceill, message => $params->{message}, illrequestsview => 1, method => $op -- 2.11.1