Bugzilla – Attachment 72832 Details for
Bug 8137
Checkout limit for all libraries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8137 - Add default issuing rule for all branches.
Bug-8137---Add-default-issuing-rule-for-all-branch.patch (text/plain), 10.90 KB, created by
Alex Arnaud
on 2018-03-14 09:19:19 UTC
(
hide
)
Description:
Bug 8137 - Add default issuing rule for all branches.
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2018-03-14 09:19:19 UTC
Size:
10.90 KB
patch
obsolete
>From 1ed5087cc70f49b4a01572956279badc915408f9 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Fri, 7 Jul 2017 08:31:37 +0000 >Subject: [PATCH] Bug 8137 - Add default issuing rule for all branches. > >This patch does the same that for 'Default checkout limit by patron >category'. > >test plan: > > - Create an issuing rule a patron category and itemtype. make it > has priority, > - create more permissive issuing rules for all other branches, > - check that the priority rule is taken into account for this > category > and itemtype. > >Rebased: 2018-03-14, by: Alex Arnaud <alex.arnaud@biblibre.com> >--- > Koha/IssuingRules.pm | 16 +++++++++++ > admin/smart-rules.pl | 2 ++ > ...137-add-column-has_priority-in-issuingrules.sql | 3 ++ > .../prog/en/modules/admin/smart-rules.tt | 32 +++++++++++++++++++--- > t/db_dependent/Koha/IssuingRules.t | 29 +++++++++++++++++++- > 5 files changed, 77 insertions(+), 5 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql > >diff --git a/Koha/IssuingRules.pm b/Koha/IssuingRules.pm >index e0fffd1..1528dc9 100644 >--- a/Koha/IssuingRules.pm >+++ b/Koha/IssuingRules.pm >@@ -58,6 +58,22 @@ sub get_effective_issuing_rule { > $search_branchcode = { 'in' => [ $branchcode, $default ] }; > } > >+ # First check for priority rules >+ if (my $rule = $self->search({ >+ categorycode => $search_categorycode, >+ itemtype => $search_itemtype, >+ branchcode => '*', >+ has_priority => 1, >+ }, { >+ order_by => { >+ -desc => ['branchcode', 'categorycode', 'itemtype'] >+ }, >+ rows => 1, >+ })->single) { >+ return $rule; >+ } >+ >+ > my $rule = $self->search({ > categorycode => $search_categorycode, > itemtype => $search_itemtype, >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index 9eb0a26..eae3091 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -121,6 +121,7 @@ elsif ($op eq 'add') { > my $br = $branch; # branch > my $bor = $input->param('categorycode'); # borrower category > my $itemtype = $input->param('itemtype'); # item type >+ my $has_priority = $input->param('has_priority') ? 1 : 0; > my $fine = $input->param('fine'); > my $finedays = $input->param('finedays'); > my $maxsuspensiondays = $input->param('maxsuspensiondays'); >@@ -165,6 +166,7 @@ elsif ($op eq 'add') { > branchcode => $br, > categorycode => $bor, > itemtype => $itemtype, >+ has_priority => $has_priority, > fine => $fine, > finedays => $finedays, > maxsuspensiondays => $maxsuspensiondays, >diff --git a/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql >new file mode 100644 >index 0000000..c632b05 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/Bug_8137-add-column-has_priority-in-issuingrules.sql >@@ -0,0 +1,3 @@ >+ALTER TABLE issuingrules ADD has_priority INT(1) DEFAULT 0 AFTER itemtype; >+ALTER TABLE issuingrules DROP primary key; >+ALTER TABLE issuingrules ADD primary key(branchcode , categorycode, itemtype, has_priority); >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index 4c47b64..062227d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -65,6 +65,7 @@ > <th>Patron category</th> > <th>Item type</th> > <th>Actions</th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> > <th>Current on-site checkouts allowed</th> > <th>Loan period</th> >@@ -113,6 +114,15 @@ > <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&itemtype=[% rule.itemtype %]&categorycode=[% rule.categorycode %]&branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a> > </td> > >+ [% UNLESS humanbranch %] >+ <td> >+ [% IF rule.has_priority %] >+ <input type="checkbox" checked="checked" disabled="disabled"/> >+ [% ELSE %] >+ <input type="checkbox" disabled="disabled"/> >+ [% END %] >+ </td> >+ [% END %] > <td>[% IF ( rule.unlimited_maxissueqty ) %] > Unlimited > [% ELSE %] >@@ -223,6 +233,11 @@ > <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button> > <button name="cancel" class="clear_edit btn btn-default btn-xs"><i class="fa fa-undo"></i> Clear</button> > </td> >+ [% UNLESS humanbranch %] >+ <td> >+ <input type="checkbox" name="has_priority" id="has_priority"/> >+ </td> >+ [% END %] > <td><input type="text" name="maxissueqty" id="maxissueqty" size="3" /></td> > <td><input type="text" name="maxonsiteissueqty" id="maxonsiteissueqty" size="3" /></td> > <td><input type="text" name="issuelength" id="issuelength" size="3" /> </td> >@@ -304,6 +319,7 @@ > <th>Patron category</th> > <th>Item type</th> > <th> </th> >+ [% UNLESS humanbranch %]<th>Has priority</th>[% END %] > <th>Current checkouts allowed</th> > <th>Current on-site checkouts allowed</th> > <th>Loan period</th> >@@ -497,7 +513,11 @@ > </td> > [% UNLESS humanbranch %] > <td> >- <input type="checkbox" [% IF branch_cat_rule_loo.has_priority %]checked[% END %] disabled/> >+ [% IF branch_cat_rule_loo.has_priority %] >+ <input type="checkbox" checked="checked" disabled/> >+ [% ELSE %] >+ <input type="checkbox" disabled/> >+ [% END %] > </td> > [% END %] > >@@ -795,7 +815,7 @@ > itm = $(this).text(); > itm = itm.replace(/^\s*|\s*$/g,''); > var current_column = $("#edit_row td:eq("+i+")"); >- if ( i == 7 ) { >+ if ( i == 8 ) { > // specific processing for the Hard due date column > var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); > var input_value = ''; >@@ -806,11 +826,15 @@ > } > $(current_column).find("input[type='text']").val(input_value); > $(current_column).find("select").val(select_value); >- } else if ( i == 13 ) { >+ } else if ( i == 14 ) { > // specific processing for cap_fine_to_replacement_price > var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); > $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') ); > $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); >+ } else if ( i == 3 ) { >+ var has_priority = $(this).find("input[type='checkbox']"); >+ $('#has_priority').prop('checked', has_priority.is(':checked') ); >+ //$('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); > } else { > $(current_column).find("input[type='text']").val(itm); > // select the corresponding option >@@ -831,7 +855,7 @@ > // Remove potential previous input added > $(current_column).find("input").remove(); > $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); >- } else if ( i == 3 || i == 4 ) { >+ } else if ( i == 4 || i == 5 ) { > // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed" > // The value is "Unlimited" (or an equivalent translated string) > // an it should be set to an empty string >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index 66e2836..c327aaa 100644 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -34,7 +34,7 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > > subtest 'get_effective_issuing_rule' => sub { >- plan tests => 3; >+ plan tests => 4; > > my $patron = $builder->build({ source => 'Borrower' }); > my $item = $builder->build({ source => 'Item' }); >@@ -43,6 +43,33 @@ subtest 'get_effective_issuing_rule' => sub { > my $itemtype = $item->{'itype'}; > my $branchcode = $item->{'homebranch'}; > >+ subtest 'Priority rule' => sub { >+ plan tests => 3; >+ >+ Koha::IssuingRules->delete; >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ })->store, "Given I added an issuing rule branchcode => $branchcode,' >+ .' categorycode => $categorycode, itemtype => $itemtype,"); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => '*', >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ has_priority => 1, >+ })->store, "Add a priority rule."); >+ >+ my $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ is($rule->has_priority, 1, 'Priority rule should be returned'); >+ }; >+ > subtest 'Call with undefined values' => sub { > plan tests => 4; > >-- >2.7.4
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 8137
:
9705
|
9706
|
11079
|
64703
|
64704
|
64791
|
64891
|
72831
|
72832
|
107207
|
107208
|
107209
|
107459
|
111368
|
111369
|
111370
|
112640
|
113797
|
113882
|
114531
|
114532
|
114533
|
114534
|
116676
|
116677
|
116678
|
116679
|
116680
|
145476
|
145477
|
145478
|
145479
|
145480
|
152040
|
152041
|
152042
|
152043
|
152044
|
152045
|
156316
|
156317
|
156318
|
156319
|
156320
|
156321
|
156322
|
159712
|
162367
|
167208
|
167923
|
168119
|
169084
|
169696
|
169700
|
169727
|
169927
|
169928
|
170411
|
173605
|
173608
|
175837
|
175838
|
177464