Bugzilla – Attachment 158574 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: (follow-up) Perltidy
Bug-21173-follow-up-Perltidy.patch (text/plain), 7.70 KB, created by
Alex Buckley
on 2023-11-06 22:15:01 UTC
(
hide
)
Description:
Bug 21173: (follow-up) Perltidy
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2023-11-06 22:15:01 UTC
Size:
7.70 KB
patch
obsolete
>From 2ba586f822127df61aef8bc7bbe3be5ebeb7caba Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 6 Nov 2023 20:33:54 +0000 >Subject: [PATCH] Bug 21173: (follow-up) Perltidy > >Sponsored-by: Toi Ohomai Institute of Technology, New Zealand >--- > C4/Items.pm | 10 ++++--- > .../js/automatic_item_modification_by_age.js | 28 +++++++++--------- > .../Items/AutomaticItemModificationByAge.t | 29 ++++++++++++------- > tools/automatic_item_modification_by_age.pl | 7 +++-- > 4 files changed, 43 insertions(+), 31 deletions(-) > >diff --git a/C4/Items.pm b/C4/Items.pm >index 09b6da14195..6a189be2e62 100644 >--- a/C4/Items.pm >+++ b/C4/Items.pm >@@ -1609,16 +1609,18 @@ sub ToggleNewStatus { > } > } > if ( defined $age ) { >- if ( defined $rule >+ if ( >+ defined $rule > && $unit eq "Hours" >- && ( >- $agefield eq "items.damaged_on" >+ && ( $agefield eq "items.damaged_on" > || $agefield eq "items.itemlost_on" > || $agefield eq "items.withdrawn_on" ) >- ) { >+ ) >+ { > # Calculate item age based on hours since damaged_on, itemlost_on, withdrawn_on > $query .= qq| AND HOUR(TIMEDIFF(NOW(), $agefield)) >= ? |; > } else { >+ > # Calculate item age based on days > $query .= qq| AND TO_DAYS(NOW()) - TO_DAYS($agefield) >= ? |; > } >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 c32a229e406..48af2cd3ed5 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 >@@ -49,22 +49,22 @@ function update_rule_count(){ > }); > } > >-function unit_display(){ >- var rules = document.querySelectorAll("input[name='unique_id'"); >- for (var i = 0; i < rules.length; i++) { >- var rule_id = rules[i].value; >+function unit_display() { >+ var rules = document . querySelectorAll("input[name='unique_id'"); >+ for ( var i = 0 ; i < rules . length ; i++ ) { >+ var rule_id = rules [i] . value; > if (rule_id) { >- var age_field = $("select[name='agefield_" + rule_id + "']").val(); >- if ( age_field == 'items.damaged_on' >- || age_field == 'items.itemlost_on' >- || age_field == 'items.withdrawn_on' ) >- { >- $("select[name='ageunit_" + rule_id + "'] option[value='Days']").removeAttr('selected'); >- >- $("select[name='ageunit_" + rule_id + "']").attr("disabled", false); >+ var age_field = $( "select[name='agefield_" + rule_id + "']" ) . val(); >+ if ( age_field == 'items.damaged_on' >+ || age_field == 'items.itemlost_on' >+ || age_field == 'items.withdrawn_on' ) >+ { >+ $( "select[name='ageunit_" + rule_id + "'] option[value='Days']" ) . removeAttr('selected'); >+ >+ $( "select[name='ageunit_" + rule_id + "']" ) . attr( "disabled", false ); > } else { >- $("select[name='ageunit_" + rule_id + "'] option[value='Days']").attr('selected','selected'); >- $("select[name='ageunit_" + rule_id + "']").attr("disabled", true); >+ $( "select[name='ageunit_" + rule_id + "'] option[value='Days']" ) . attr( 'selected', 'selected' ); >+ $( "select[name='ageunit_" + rule_id + "']" ) . attr( "disabled", true ); > } > } > } >diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t >index b16a3d005fd..42fc81e57a5 100755 >--- a/t/db_dependent/Items/AutomaticItemModificationByAge.t >+++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t >@@ -332,7 +332,7 @@ is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 2 > > # Play with the unit field > $dt_today = dt_from_string; >-my $hours2ago = dt_from_string->subtract( hours => 2 ); >+my $hours2ago = dt_from_string->subtract( hours => 2 ); > my $hours10ago = dt_from_string->subtract( hours => 10 ); > $modified_item->itemlost_on($hours2ago)->store; > $modified_item->dateaccessioned($hours10ago)->store; >@@ -350,10 +350,10 @@ $modified_item->dateaccessioned($hours10ago)->store; > { > field => 'items.new_status', > value => 'ageunit_new_value', >- }, >+ }, > ], >- age => '5', >- ageunit => 'Hours', >+ age => '5', >+ ageunit => 'Hours', > agefield => 'items.dateaccessioned' > }, > ); >@@ -361,21 +361,30 @@ $modified_item->dateaccessioned($hours10ago)->store; > # Confirm a rule with unit = 'Hours' does not work with fields other than items.damaged_on, > # items.itemlost_on, or items.withdrawn_on > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = Koha::Items->find( $itemnumber ); >-is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.dateaccessioned' : The new_status value is not updated|); >+$modified_item = Koha::Items->find($itemnumber); >+is( >+ $modified_item->new_status, 'agefield_new_value', >+ q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.dateaccessioned' : The new_status value is not updated| >+); > > # Confirm a rule on a datetime field (items.itemlost_on) with unit = 'Hours' does > # change an item correctly based on the age in hours > $rules[0]->{agefield} = 'items.itemlost_on'; > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = Koha::Items->find( $itemnumber ); >+$modified_item = Koha::Items->find($itemnumber); > $modified_item->itemlost_on; >-is( $modified_item->new_status, 'agefield_new_value', q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is not updated|); >+is( >+ $modified_item->new_status, 'agefield_new_value', >+ q|ToggleNewStatus: Age = 5, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is not updated| >+); > > $rules[0]->{age} = 1; > C4::Items::ToggleNewStatus( { rules => \@rules } ); >-$modified_item = Koha::Items->find( $itemnumber ); >-is( $modified_item->new_status, 'ageunit_new_value', q|ToggleNewStatus: Age = 1, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is updated|); >+$modified_item = Koha::Items->find($itemnumber); >+is( >+ $modified_item->new_status, 'ageunit_new_value', >+ q|ToggleNewStatus: Age = 1, ageunit = 'Hours', agefield = 'items.itemlost_on' : The new_status value is updated| >+); > > # Run twice > t::lib::Mocks::mock_preference('CataloguingLog', 1); >diff --git a/tools/automatic_item_modification_by_age.pl b/tools/automatic_item_modification_by_age.pl >index e149d503bac..b8984709de2 100755 >--- a/tools/automatic_item_modification_by_age.pl >+++ b/tools/automatic_item_modification_by_age.pl >@@ -92,10 +92,11 @@ if ( $op eq 'update' ) { > $rule->{agefield} = $age_field ? $age_field : "items.dateaccessioned"; > } > >- for my $age_unit ( @age_units ) { >- if ($rule->{agefield} ne 'items.damaged_on' >+ for my $age_unit (@age_units) { >+ if ( $rule->{agefield} ne 'items.damaged_on' > && $rule->{agefield} ne 'items.itemlost_on' >- && $rule->{agefield} ne 'items.withdrawn_on') { >+ && $rule->{agefield} ne 'items.withdrawn_on' ) >+ { > $rule->{ageunit} = "Days"; > } else { > $rule->{ageunit} = $age_unit ? $age_unit : "Days"; >-- >2.20.1
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