Bugzilla – Attachment 79914 Details for
Bug 21173
Add hours as age unit to auto item modifications by age for damaged_on, itemlost_on and withdrawn_on fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21173: Fixed rebase removal of filters and changed items.dateaccessioned to datetime datatype
Bug-21173-Fixed-rebase-removal-of-filters-and-chan.patch (text/plain), 12.65 KB, created by
Alex Buckley
on 2018-10-04 04:55:15 UTC
(
hide
)
Description:
Bug 21173: Fixed rebase removal of filters and changed items.dateaccessioned to datetime datatype
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2018-10-04 04:55:15 UTC
Size:
12.65 KB
patch
obsolete
>From 306305847e6570e9f1d433099f4b52be00cb7089 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 3 Oct 2018 22:53:27 +0000 >Subject: [PATCH] Bug 21173: Fixed rebase removal of filters and changed > items.dateaccessioned to datetime datatype > >This means we can make the auto item modification tool work for hours since item was created > >Updated test plan: > >1. Go to Tools->Automatic item modifications by age and create a new >rule by selecting the 'Edit rules' button > >2. Notice you can only set the age in the unit of days not >hours. Also although not visible in the interface the rule will >calculate the age of the item based on when it was created (i.e. added to >Koha). > >3. Apply patch and run ./updatedatabase.pl in the >koha-shell > >4. Now revisit Tools->Automatic item modifications by age. Notice the >table of existing rules now contains a new column 'Age starting point' >this is the date from which the item age is calculated. This enhancement >offers you two options as the age starting point: Created (displayed in >this table as 'itemcreated') or Last altered (displayed in this table as >'itemaltered'). > >5. Click 'Edit rules' to create a new rule. Notice in the form >for creating the new rule you can set the unit to either >'Hours' or 'Days'. > >6. In the new rule set the following values: Age: 1, Unit: Hours, >condition items.location = 'CART', items.location = '' > >7. Now save the rule and confirm the correct values are >dispayed in the rules table which is loaded > >8. Click 'Edit rules' button again. > >9. Modify the rule you just created changing Age to >2 and create another new rule with the following >values: Age='1', Unit='Hour', 'Age starting >point'='Created', Condition 'items.homebranch'='<a >branchcode of a branch in your Koha instance>', >substituions 'items.homebranch'='<another >branchcode in your Koha instance>' > >10. Now click 'Save' and confirm the data displayed for both rules is >correct. > >11. Create two new items and set their location field >to 'CART'. Then in the database set their dateaccessioned value to 2 hours before the >current time > >12. Exit out of the database terminal and manually run >the automatic_item_modification_by_age.pl cronjob from >the koha-shell with this command: >./automatic_item_modification_by_age.pl --confirm > >13. Now return to the database and notice the two items you set have >a location of 'CART' now have a blank location field because the >manually run cronjob altered them as they meet the conditions of the >rule. > >14. Repeat step 11 but this time change the rule in the Auto item modification tool interface to 'Age starting point='Altered'' so we can test the auto item mod tool on items that have been last altered more than 2 hours ago. > >15. Enter this text into your /etc/cron.d/koha-common file: >*/2 * * * * root koha-foreach --enabled >/usr/share/koha/bin/cronjobs/automatic_item_modification_by_age.pl >--confirm > >This will make the cronjob run every 2 minutes. > >16. Now restart koha-common with this command: sudo >/etc/init.d/koha-common restart > >17. Now wait for more than 2 minutes and check the >database again and notice that the two items have blank location fields >as the automatically running cronjob altered the items. > >18. Repeat steps 9-17 with the new rules in the auto item modification >tool for the following rule conditions: > >New rule: > Age: 2 > Age starting point: Created > Units: Days > Condition 'items.homebranch'='<a branchcode of a branch in your Koha instance>', > Substitutions 'items.homebranch'='<another branchcode in your Koha instance>' > >New rule: > Age: 2 > Age starting point: Altered > Units: Days > Condition 'items.homebranch'='<a branchcode of a branch in your Koha instance>', > Substitutions 'items.homebranch'='<another branchcode in your Koha instance>' > >Sponsored-By: Toi Ohomai Institute of Technology, New Zealand >--- > C4/Items.pm | 10 +++++++--- > ...ble_change_dateaccessioned_to_datetime_datatype.sql | 1 + > .../tools/automatic_item_modification_by_age.tt | 18 +++++++++--------- > .../prog/js/automatic_item_modification_by_age.js | 11 ----------- > 4 files changed, 17 insertions(+), 23 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_21173-alter_item_table_change_dateaccessioned_to_datetime_datatype.sql > >diff --git a/C4/Items.pm b/C4/Items.pm >index d70256c..9ff6a14 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -289,7 +289,6 @@ sub AddItem { > $itype_sth->execute( $item->{'biblionumber'} ); > ( $item->{'itype'} ) = $itype_sth->fetchrow_array; > } >- > my ( $itemnumber, $error ) = _koha_new_item( $item, $item->{barcode} ); > return if $error; > >@@ -1630,7 +1629,7 @@ C<items.withdrawn> > > sub _set_defaults_for_add { > my $item = shift; >- $item->{dateaccessioned} ||= output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }); >+ $item->{dateaccessioned} ||= DateTime->now( time_zone => C4::Context->tz() ); > $item->{$_} ||= 0 for (qw( notforloan damaged itemlost withdrawn)); > } > >@@ -1936,11 +1935,16 @@ sub _mod_item_dates { # date formatting for date fields in item hash > my @keys = grep > { $_ =~ /^onloan$|^date|date$|datetime$/ } > keys %$item; >- # Incl. dateaccessioned,replacementpricedate,datelastborrowed,datelastseen >+ # Incl. replacementpricedate,datelastborrowed,datelastseen > # NOTE: We do not (yet) have items fields ending with datetime > # Fields with _on$ have been handled already > > foreach my $key ( @keys ) { >+ # If the key is 'dateaccessioned' then escape out of this loop >+ # We want to store the date and time for the dateaccessioned field >+ if ($key eq "dateaccessioned") { >+ last; >+ } > next if !defined $item->{$key}; # skip undefs > my $dt = eval { dt_from_string( $item->{$key} ) }; > # eval: dt_from_string will die on us if we pass illegal dates >diff --git a/installer/data/mysql/atomicupdate/bug_21173-alter_item_table_change_dateaccessioned_to_datetime_datatype.sql b/installer/data/mysql/atomicupdate/bug_21173-alter_item_table_change_dateaccessioned_to_datetime_datatype.sql >new file mode 100644 >index 0000000..9a9b254 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_21173-alter_item_table_change_dateaccessioned_to_datetime_datatype.sql >@@ -0,0 +1 @@ >+ALTER TABLE items MODIFY COLUMN dateaccessioned datetime; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt >index 2d35848..42d26d5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt >@@ -72,12 +72,12 @@ > <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled --> > <div class="age"> > <h5>Age</h5> >- <input class="age" type="number" value="[% rule.age %]" name="age_[% id %]" /> >+ <input class="age" type="number" value="[% rule.age | html %]" name="age_[% id | html %]" /> > </div> > <div> > <h5>Unit</h5> > <p>Note: If the unit of 'Hours' is set then you cannot choose an age starting point, the item age starting point will default to the last item alteration event. The Age starting point selection will be hidden if you have set the unit to 'Hours'.</p> >- <select id="existing_rule_unit" name="unit_[% id %]" id="unit"> >+ <select id="existing_rule_unit" name="unit_[% id | html %]" id="unit"> > <option value="">Choose a unit</option> > [% IF rule.unit == "hours" %] > <option value="hours" selected="selected">Hours</option> >@@ -91,7 +91,7 @@ > [% IF rule.unit == "days" %] > <div id="age_starting_point_div"> > <h5>Age starting point (starting point from which the item age is calculated)</h5> >- <select name="age_starting_point_[% id %]" id="age_starting_point"> >+ <select name="age_starting_point_[% id | html %]" id="age_starting_point"> > <option value="">Choose age starting point</option> > [% IF rule.age_starting_point == "itemcreation" %] > <option value="itemcreation" selected="selected">Created</option> >@@ -117,7 +117,7 @@ > [% END %] > [% END %] > </select> >- <input type="text" value="[% condition.value %]" name="condition_value_[% id%]" /> >+ <input type="text" value="[% condition.value | html %]" name="condition_value_[% id | html %]" /> > <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a condition</a> > <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove condition</a> > </div> >@@ -137,7 +137,7 @@ > [% END %] > [% END %] > </select> >- <input type="text" value="[% substitution.value %]" name="substitution_value_[% id %]" /> >+ <input type="text" value="[% substitution.value | html %]" name="substitution_value_[% id | html %]" /> > <a class="add_block" href="#"><i class="fa fa-plus"></i> Add a substitution</a> > <a class="remove_block" href="#"><i class="fa fa-trash"></i> Remove substitution</a> > <span class="required">A field name is required</span> >@@ -228,12 +228,12 @@ > [% IF rule.age.defined and rule.unit.defined and rule.age.length > 0 %] > [% IF rule.age == 1 %] > [% IF rule.unit == "days" %] >- [% rule.age %] day >+ [% rule.age | html %] day > [% ELSE %] >- [% rule.age %] hour >+ [% rule.age | html %] hour > [% END %] > [% ELSE %] >- [% rule.age %] [% rule.unit %] >+ [% rule.age | html %] [% rule.unit | html %] > [% END %] > [% ELSE %] > There is no age for this rule. >@@ -241,7 +241,7 @@ > </td> > <td> > [% IF rule.age_starting_point.defined %] >- [% rule.age_starting_point %] >+ [% rule.age_starting_point | html %] > [% ELSE %] > There is no age starting point for this rule. > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js b/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js >index ea5e686..a2b7ca3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js >@@ -52,7 +52,6 @@ function update_rule_count(){ > $(document).ready(function() { > $("#new_rule .remove_rule").hide(); > $("#new_rule a.remove_block").hide(); >- $("#new_rule_age_starting_point_div").hide(); > > $("#rules a.remove_block").click(function(e){ > e.preventDefault(); >@@ -63,16 +62,6 @@ $(document).ready(function() { > remove_rule_action($(this)); > }); > >- $("#new_rule_unit").change(function(){ >- var unitselected = $(this).find("option:selected").attr("id"); >- var newruleagestart = document.getElementById("new_rule_age_starting_point_div"); >- if (unitselected == "days") { >- newruleagestart.style.display = "block" >- } else { >- newruleagestart.style.display = "none"; >- } >- }); >- > var unique_id = $(".rule").length + 1; > $(".add_rule").click(function(e){ > e.preventDefault(); >-- >2.1.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 21173
:
77547
|
77548
|
77604
|
77605
|
78917
|
79914
|
138870
|
138871
|
138872
|
138894
|
138895
|
138896
|
156137
|
156138
|
156139
|
158574
|
158575
|
160715
|
160716