Bug 26468: Add damaged as a searchable status in item search

This patch removes the Damaged radio box options ( Ignore, yes, no ) in favor a full damage status search option

To test:
1. APPLY PATCH, restart services.
2. Make sure you mark some items as damaged.
3. Go to the item and search and limit by 'Damaged'
4. You should only see your 'Damaged' items.
5. Export the results as a CSV, make sure the CSV is well-formed and accurate.

Signed-off-by: Barbara Johnson <barbara.johnson@bedfordtx.gov>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Perltidied.
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Lucas Gass 2023-10-13 21:01:58 +00:00 committed by Tomas Cohen Arazi
parent 7e2f6d66d6
commit 5ef8eac364
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
5 changed files with 41 additions and 10 deletions

View File

@ -108,6 +108,14 @@ my $itemlost_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_v
$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.withdrawn', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
my $withdrawn_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : [];
$mss = Koha::MarcSubfieldStructures->search(
{
frameworkcode => '', kohafield => 'items.damaged',
authorised_value => [ -and => { '!=' => undef }, { '!=' => '' } ]
}
);
my $damaged_values = $mss->count ? GetAuthorisedValues( $mss->next->authorised_value ) : [];
if ( Koha::MarcSubfieldStructures->search( { frameworkcode => '', kohafield => 'items.new_status' } )->count ) {
$template->param( has_new_status => 1 );
}
@ -120,14 +128,16 @@ if ( defined $format ) {
filters => [],
};
foreach my $p (qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn)) {
if (my @q = $cgi->multi_param($p)) {
if ($q[0] ne '') {
foreach my $p (
qw(homebranch holdingbranch location itype ccode issues datelastborrowed notforloan itemlost withdrawn damaged))
{
if ( my @q = $cgi->multi_param($p) ) {
if ( $q[0] ne '' ) {
my $f = {
field => $p,
query => \@q,
};
if (my $op = scalar $cgi->param($p . '_op')) {
if ( my $op = scalar $cgi->param( $p . '_op' ) ) {
$f->{operator} = $op;
}
push @{ $filter->{filters} }, $f;
@ -174,7 +184,7 @@ if ( defined $format ) {
push @{ $filter->{filters} }, $f;
# Yes/No parameters
foreach my $p (qw( damaged new_status )) {
foreach my $p (qw( new_status )) {
my $v = $cgi->param($p) // '';
my $f = {
field => $p,
@ -183,10 +193,10 @@ if ( defined $format ) {
if ( $p eq 'new_status' ) {
$f->{ifnull} = 0;
}
if ($v eq 'yes') {
if ( $v eq 'yes' ) {
$f->{operator} = '!=';
push @{ $filter->{filters} }, $f;
} elsif ($v eq 'no') {
} elsif ( $v eq 'no' ) {
$f->{operator} = '=';
push @{ $filter->{filters} }, $f;
}
@ -309,6 +319,14 @@ foreach my $value (@$withdrawn_values) {
};
}
my @damageds;
foreach my $value (@$damaged_values) {
push @damageds, {
value => $value->{authorised_value},
label => $value->{lib},
};
}
my @items_search_fields = GetItemSearchFields();
my $authorised_values = {};
@ -324,6 +342,7 @@ $template->param(
ccodes => \@ccodes,
itemlosts => \@itemlosts,
withdrawns => \@withdrawns,
damageds => \@damageds,
items_search_fields => \@items_search_fields,
authorised_values_json => to_json($authorised_values),
);

View File

@ -37,6 +37,8 @@
[%- delimiter | $raw -%]
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | replace('"', '""') | $raw %]"
[%- delimiter | $raw -%]
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) || "" | replace('"', '""') | $raw %]"
[%- delimiter | $raw -%]
"[% (item.issues || 0) | $raw %]"
[%- delimiter | $raw -%]
"[% IF item.checkout %][% item.checkout.date_due | $KohaDates | $raw %][% END %]"

View File

@ -29,6 +29,7 @@
"[% AuthorisedValues.GetDescriptionByKohaField( frameworkcode => biblio.frameworkcode, kohafield => 'items.notforloan', authorised_value => item.notforloan) | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) || "" | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | html %]",
"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) || "" | html %]",
"[% (item.issues || 0) | html %]",
"[% IF item.checkout %][% item.checkout.date_due | $KohaDates %][% END %]",
"[% FILTER escape_quotes ~%]

View File

@ -3,5 +3,5 @@
[%- PROCESS 'i18n.inc' -%]
[%- SET delimiter = Koha.CSVDelimiter() -%]
[%- BLOCK -%]
"[% t("Title") | html %]"[%- delimiter | $raw -%]"[% t("Publication date") | html %]"[%- delimiter | $raw -%]"[% t("Publisher") | html %]"[%- delimiter | $raw -%]"[% t("Collection") | html %]"[%- delimiter | $raw -%]"[% t("Barcode") | html %]"[%- delimiter | $raw -%]"[% t("Serial enumeration") | html %]"[%- delimiter | $raw -%]"[% t("Call number") | html %]"[%- delimiter | $raw -%]"[% t("Home library") | html %]"[%- delimiter | $raw -%]"[% t("Current library") | html %]"[%- delimiter | $raw -%]"[% t("Shelving location") | html %]"[%- delimiter | $raw -%]"[% t("Item type") | html %]"[%- delimiter | $raw -%]"[% t("Inventory number") | html %]"[%- delimiter | $raw -%]"[% t("Not for loan status") | html %]"[%- delimiter | $raw -%]"[% t("Lost status") | html %]"[%- delimiter | $raw -%]"[% t("Withdrawn status") | html %]"[%- delimiter | $raw -%]"[% t("Checkouts") | html %]"[%- delimiter | $raw -%]"[% t("Due date") | html %]"
"[% t("Title") | html %]"[%- delimiter | $raw -%]"[% t("Publication date") | html %]"[%- delimiter | $raw -%]"[% t("Publisher") | html %]"[%- delimiter | $raw -%]"[% t("Collection") | html %]"[%- delimiter | $raw -%]"[% t("Barcode") | html %]"[%- delimiter | $raw -%]"[% t("Serial enumeration") | html %]"[%- delimiter | $raw -%]"[% t("Call number") | html %]"[%- delimiter | $raw -%]"[% t("Home library") | html %]"[%- delimiter | $raw -%]"[% t("Current library") | html %]"[%- delimiter | $raw -%]"[% t("Shelving location") | html %]"[%- delimiter | $raw -%]"[% t("Item type") | html %]"[%- delimiter | $raw -%]"[% t("Inventory number") | html %]"[%- delimiter | $raw -%]"[% t("Not for loan status") | html %]"[%- delimiter | $raw -%]"[% t("Lost status") | html %]"[%- delimiter | $raw -%]"[% t("Withdrawn status") | html %]"[%- delimiter | $raw -%]"[% t("Damaged status") | html %]"[%- delimiter | $raw -%]"[% t("Checkouts") | html %]"[%- delimiter | $raw -%]"[% t("Due date") | html %]"
[%- END -%]

View File

@ -26,9 +26,9 @@
[%- CASE 'All collection codes' %]<span>All collections</span>
[%- CASE 'notforloan' %]<span>Status</span>
[%- CASE 'All statuses' %]<span>All statuses</span>
[%- CASE 'damaged' %]<span>Damaged</span>
[%- CASE 'itemlost' %]<span>Lost</span>
[%- CASE 'withdrawn' %]<span>Withdrawn</span>
[%- CASE 'damaged' %]<span>Damaged</span>
[%- CASE 'new_status' %]<span>Is new</span>
[%- END -%]
[%- END -%]
@ -204,6 +204,9 @@
[% IF withdrawns.size %]
[% INCLUDE form_field_select name="withdrawn" options = withdrawns empty_option = "All statuses" %]
[% END %]
[% IF damageds.size %]
[% INCLUDE form_field_select name="damaged" options = damageds empty_option = "All statuses" %]
[% END %]
<div class="form-field">
<label class="form-field-label">Availability:</label>
<input type="radio" name="onloan" id="onloan_indifferent" value="" checked="checked"/>
@ -231,7 +234,6 @@
<input type="text" id="itemcallnumber_to" name="itemcallnumber_to" value="" />
<span class="hint">(inclusive)</span>
</div>
[% INCLUDE form_field_radio_yes_no name="damaged" %]
[% IF ( has_new_status ) %]
[% INCLUDE form_field_radio_yes_no name="new_status" divclass='item-new-status' %]
[% END %]
@ -383,6 +385,7 @@
+ ' <th id="items_status">' + _("Not for loan status") + '</th>'
+ ' <th id="items_itemlost">' + _("Lost status") + '</th>'
+ ' <th id="items_widthdrawn">' + _("Withdrawn status") + '</th>'
+ ' <th id="items_damaged">' + _("Damaged status") + '</th>'
+ ' <th id="items_checkouts">' + _("Checkouts") + '</th>'
+ ' <th id="items_date_due">' + _("Due date") + '</th>'
+ ' <th id=""></th>'
@ -506,6 +509,7 @@
{ 'sName': 'notforloan' },
{ 'sName': 'itemlost' },
{ 'sName': 'withdrawn' },
{ 'sName': 'damaged' },
{ 'sName': 'issues' },
{ 'sName': 'date_due' },
{ 'sName': 'actions', 'bSortable': false }
@ -558,6 +562,11 @@
[% ELSE %]
null,
[% END %]
[% IF damageds.size %]
{ 'type': 'select', 'values': [% INCLUDE escape_html_value_label elts => damageds %] },
[% ELSE %]
null,
[% END %]
{ 'type': 'text' },
{ 'type': 'text' },
null