Bugzilla – Attachment 123396 Details for
Bug 25260
Merge 'reserves' and 'old_reserves' into a new 'holds' table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25260: Fix pendingreserves.pl
Bug-25260-Fix-pendingreservespl.patch (text/plain), 9.83 KB, created by
Tomás Cohen Arazi
on 2021-08-02 18:32:46 UTC
(
hide
)
Description:
Bug 25260: Fix pendingreserves.pl
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi
Created:
2021-08-02 18:32:46 UTC
Size:
9.83 KB
patch
obsolete
>From a82c001f478bb08055aec24ff88e540fbe5e53d0 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 2 Aug 2021 14:26:24 -0300 >Subject: [PATCH] Bug 25260: Fix pendingreserves.pl > >--- > circ/pendingreserves.pl | 50 +++++++++---------- > circ/reserveratios.pl | 31 ++++++------ > .../prog/en/modules/circ/pendingreserves.tt | 14 +++--- > 3 files changed, 47 insertions(+), 48 deletions(-) > >diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl >index 0b2fea2195..6e9032c1fc 100755 >--- a/circ/pendingreserves.pl >+++ b/circ/pendingreserves.pl >@@ -155,13 +155,13 @@ unless ( $enddate ) { > > # building query parameters > my %where = ( >- 'reserve.found' => undef, >- 'reserve.priority' => 1, >- 'reserve.suspend' => 0, >- 'itembib.itemlost' => 0, >- 'itembib.withdrawn' => 0, >- 'itembib.notforloan' => 0, >- 'itembib.itemnumber' => { -not_in => \'SELECT itemnumber FROM branchtransfers WHERE datearrived IS NULL' } >+ 'me.status' => 'placed', >+ 'me.priority' => 1, >+ 'me.suspended' => 0, >+ 'item.itemlost' => 0, >+ 'item.withdrawn' => 0, >+ 'item.notforloan' => 0, >+ 'item.itemnumber' => { -not_in => \'SELECT itemnumber FROM branchtransfers WHERE datearrived IS NULL' } > ); > > # date boundaries >@@ -169,28 +169,28 @@ my $dtf = Koha::Database->new->schema->storage->datetime_parser; > my $startdate_iso = $dtf->format_date($startdate); > my $enddate_iso = $dtf->format_date($enddate); > if ( $startdate_iso && $enddate_iso ){ >- $where{'reserve.reservedate'} = [ -and => { '>=', $startdate_iso }, { '<=', $enddate_iso } ]; >+ $where{'me.created_date'} = [ -and => { '>=', $startdate_iso }, { '<=', $enddate_iso } ]; > } elsif ( $startdate_iso ){ >- $where{'reserve.reservedate'} = { '>=', $startdate_iso }; >+ $where{'me.created_date'} = { '>=', $startdate_iso }; > } elsif ( $enddate_iso ){ >- $where{'reserve.reservedate'} = { '<=', $enddate_iso }; >+ $where{'me.created_date'} = { '<=', $enddate_iso }; > } > > # Bug 21320 > if ( !C4::Context->preference('AllowHoldsOnDamagedItems') ){ >- $where{'itembib.damaged'} = 0; >+ $where{'item.damaged'} = 0; > } > > if ( C4::Context->preference('IndependentBranches') ){ >- $where{'itembib.holdingbranch'} = C4::Context->userenv->{'branch'}; >+ $where{'item.holdingbranch'} = C4::Context->userenv->{'branch'}; > } > > # get all distinct unfulfilled reserves > my $holds = Koha::Holds->search( > { %where }, >- { join => 'itembib', alias => 'reserve', distinct => 1, columns => qw[me.biblionumber] } >+ { join => 'item', distinct => 1, columns => qw[me.biblio_id] } > ); >-my @biblionumbers = $holds->get_column('biblionumber'); >+my @biblionumbers = $holds->get_column('biblio_id'); > > my $all_items; > foreach my $item ( $holds->get_items_that_can_fill ) { >@@ -199,35 +199,33 @@ foreach my $item ( $holds->get_items_that_can_fill ) { > > # patrons count per biblio > my $patrons_count = { >- map { $_->{biblionumber} => $_->{patrons_count} } @{ Koha::Holds->search( >+ map { $_->{biblio_id} => $_->{patrons_count} } @{ Koha::Holds->search( > {}, > { >- select => [ 'biblionumber', { count => { distinct => 'borrowernumber' } } ], >- as => [qw( biblionumber patrons_count )], >- group_by => [qw( biblionumber )] >+ select => [ 'biblio_id', { count => { distinct => 'patron_id' } } ], >+ as => [qw( biblio_id patrons_count )], >+ group_by => [qw( biblio_id )] > }, > )->unblessed > } > }; > > my $holds_biblios_map = { >- map { $_->{biblionumber} => $_->{reserve_id} } @{ Koha::Holds->search( >+ map { $_->{biblio_id} => $_->{hold_id} } @{ Koha::Holds->search( > {%where}, > { >- join => ['itembib', 'biblio'], >- alias => 'reserve', >- select => ['reserve.biblionumber', 'reserve.reserve_id'], >+ join => ['item', 'biblio'], >+ select => ['me.biblio_id', 'me.hold_id'], > } > )->unblessed > } > }; > > my $all_holds = { >- map { $_->biblionumber => $_ } @{ Koha::Holds->search( >- { reserve_id => [ values %$holds_biblios_map ]}, >+ map { $_->biblio_id => $_ } @{ Koha::Holds->search( >+ { hold_id => [ values %$holds_biblios_map ]}, > { >- prefetch => [ 'borrowernumber', 'itembib', 'biblio' ], >- alias => 'reserve', >+ prefetch => [ 'patron', 'item', 'biblio' ] > } > )->as_list > } >diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl >index 7311d1e8c9..6fbaa82e78 100755 >--- a/circ/reserveratios.pl >+++ b/circ/reserveratios.pl >@@ -84,9 +84,9 @@ my $dbh = C4::Context->dbh; > my $sqldatewhere = ""; > my @query_params = (); > >-$sqldatewhere .= " AND reservedate >= ?"; >+$sqldatewhere .= " AND holds.created_date >= ?"; > push @query_params, output_pref({ dt => $startdate, dateformat => 'iso' }) ; >-$sqldatewhere .= " AND reservedate <= ?"; >+$sqldatewhere .= " AND holds.created_date <= ?"; > push @query_params, output_pref({ dt => $enddate, dateformat => 'iso' }); > > my $include_aqorders_qty = >@@ -96,16 +96,16 @@ my $include_aqorders_qty = > > my $include_aqorders_qty_join = > $effective_create_items eq 'receiving' >- ? 'LEFT JOIN aqorders ON reserves.biblionumber=aqorders.biblionumber' >+ ? 'LEFT JOIN aqorders ON holds.biblio_id=aqorders.biblionumber' > : q{}; > > my $nfl_comparison = $include_ordered ? '<=' : '='; > my $sus_comparison = $include_suspended ? '<=' : '<'; > my $strsth = >-"SELECT reservedate, >- reserves.borrowernumber as borrowernumber, >- reserves.biblionumber, >- reserves.branchcode as branch, >+"SELECT created_date, >+ holds.patron_id, >+ holds.biblio_id, >+ holds.pickup_library_id as branch, > items.holdingbranch, > items.itemcallnumber, > items.itemnumber, >@@ -120,22 +120,23 @@ my $strsth = > GROUP_CONCAT(DISTINCT items.itype > ORDER BY items.itemnumber SEPARATOR '|') as l_itype, > >- reserves.found, >+ holds.status, > biblio.title, > biblio.subtitle, > biblio.medium, > biblio.part_number, > biblio.part_name, > biblio.author, >- count(DISTINCT reserves.borrowernumber) as reservecount, >+ count(DISTINCT holds.patron_id) as reservecount, > count(DISTINCT items.itemnumber) $include_aqorders_qty as itemcount >- FROM reserves >- LEFT JOIN items ON items.biblionumber=reserves.biblionumber >- LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber >+ FROM holds >+ LEFT JOIN items ON items.biblionumber=holds.biblio_id >+ LEFT JOIN biblio ON biblio.biblionumber=holds.biblio_id > $include_aqorders_qty_join > WHERE > notforloan $nfl_comparison 0 AND damaged = 0 AND itemlost = 0 AND withdrawn = 0 >- AND suspend $sus_comparison 1 >+ AND holds.completed=0 >+ AND suspended $sus_comparison 1 > $sqldatewhere > "; > >@@ -144,7 +145,7 @@ if (C4::Context->preference('IndependentBranches')){ > push @query_params, C4::Context->userenv->{'branch'}; > } > >-$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC"; >+$strsth .= " GROUP BY holds.biblio_id ORDER BY reservecount DESC"; > > $template->param(sql => $strsth); > my $sth = $dbh->prepare($strsth); >@@ -158,7 +159,7 @@ while ( my $data = $sth->fetchrow_hashref ) { > push( > @reservedata, > { >- reservedate => $data->{reservedate}, >+ reservedate => $data->{created_date}, > priority => $data->{priority}, > name => $data->{borrower}, > title => $data->{title}, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt >index fb90eeacdd..491b9d8bad 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt >@@ -176,17 +176,17 @@ > [% END %] > </ul> > </td> >- <td data-order="[% hold.reservedate | html %]"> >- [% hold.reservedate | $KohaDates %] in [% Branches.GetName ( hold.branchcode ) | html %] >+ <td data-order="[% hold.created_date | html %]"> >+ [% hold.created_date | $KohaDates %] in [% Branches.GetName ( hold.pickup_library_id ) | html %] > </td> >- <td>[% hold.reservenotes | html %]</td> >+ <td>[% hold.notes | html %]</td> > <td> >- [% Branches.GetName ( hold.branchcode ) | html %] >+ [% Branches.GetName ( hold.pickup_library_id ) | html %] > </td> > <td> > <form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post"> > <input type="hidden" name="op" value="cancel_reserve" /> >- <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" /> >+ <input type="hidden" name="reserve_id" value="[% hold.hold_id | html %]" /> > > [% SET hold_cancellation = AuthorisedValues.GetAuthValueDropbox('HOLD_CANCELLATION') %] > [% IF hold_cancellation %] >@@ -209,9 +209,9 @@ > </form> > > [% IF Koha.Preference('CanMarkHoldsToPullAsLost') != 'do_not_allow' %] >- [% IF hold.itemnumber %] >+ [% IF hold.item_id %] > <form name="cancelReserve" action="/cgi-bin/koha/circ/pendingreserves.pl" method="post"> >- <input type="hidden" name="reserve_id" value="[% hold.reserve_id | html %]" /> >+ <input type="hidden" name="reserve_id" value="[% hold.hold_id | html %]" /> > [% IF Koha.Preference('CanMarkHoldsToPullAsLost') == 'allow' %] > <input type="hidden" name="op" value="mark_as_lost" /> > <input type="submit" value="Mark item as lost" /> >-- >2.32.0
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 25260
:
103984
|
103985
|
103986
|
103987
|
103988
|
103989
|
103990
|
103991
|
103992
|
103993
|
104053
|
104054
|
104055
|
104056
|
104057
|
117745
|
117746
|
117747
|
117748
|
117749
|
117750
|
117751
|
122761
|
122762
|
122763
|
122764
|
122765
|
122766
|
122767
|
122787
|
122788
|
122789
|
122790
|
122791
|
122792
|
122793
|
122976
|
122977
|
122978
|
122979
|
122980
|
122981
|
122982
|
122983
|
123071
|
123072
|
123073
|
123074
|
123075
|
123076
|
123077
|
123078
|
123079
|
123080
|
123257
|
123258
|
123259
|
123260
|
123261
| 123396