From a9cca817deb276e933447e9fb600f337cfbaf01e Mon Sep 17 00:00:00 2001 From: Jacek Ablewicz Date: Sun, 2 Feb 2014 18:04:00 +0100 Subject: Bug 11665: An ability to place orders directly from hold ratios list This enhancement introduces a possibility to place orders from hold ratios list: - new option "Add order to basket" -> "From titles w/ highest hold ratios"; (user gets redirected from acqusition to "hold ratios" list in circulation) - "N to order" in "Items needed" column now becomes a link - when clicked, user gets redirected back to acquisition, directly to order form for a choosen title (suggested quantity "N to order" is being preserved) - in the "Items needed" column, there is an additional indication if there are any pending (not yet received) orders for a given title This solution is not exactly ideal.. most important drawback: to use it librarian needs both acquisition & circulation priviledges; if not having both - new options will not show / wouldn't be active. But it requires relatively small amount of changes in the code. To test: - apply patch, - test new functions (try to place some orders using an newly added option, examine resulting order records etc.) - check modified hold ratios list for possible problems (for user with only circulation priviledges, additional information regarding pending orders should be still visible, but not the link to order form) - ensure the two following existing options for adding orders to basket ("From an existing record", "From a new (empty) record") a still working properly. --- acqui/neworderempty.pl | 12 ++++++-- circ/reserveratios.pl | 30 ++++++++++++++++++++ .../en/includes/acquisitions-add-to-basket.inc | 1 + .../prog/en/modules/circ/reserveratios.tt | 7 ++++- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 9fdf032..017e6ca 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -358,6 +358,14 @@ my @gst_values = map { option => $_ }, split( '\|', C4::Context->preference("gist") ); +my $quantity = $data->{'quantity'}; +{ + defined($quantity) && last; + my $rr_quantity_to_order = $input->param('rr_quantity_to_order'); + (defined($rr_quantity_to_order) && $rr_quantity_to_order) || last; + $quantity = $rr_quantity_to_order; +} + $template->param( existing => $biblionumber, ordernumber => $ordernumber, @@ -400,8 +408,8 @@ $template->param( ean => $data->{'ean'}, seriestitle => $data->{'seriestitle'}, itemtypeloop => \@itemtypes, - quantity => $data->{'quantity'}, - quantityrec => $data->{'quantity'}, + quantity => $quantity, + quantityrec => $quantity, rrp => $data->{'rrp'}, gst_values => \@gst_values, gstrate => $data->{gstrate} ? $data->{gstrate}+0.0 : $bookseller->{gstrate} ? $bookseller->{gstrate}+0.0 : 0, diff --git a/circ/reserveratios.pl b/circ/reserveratios.pl index 55eb018..0002e19 100755 --- a/circ/reserveratios.pl +++ b/circ/reserveratios.pl @@ -30,6 +30,7 @@ use C4::Auth; use C4::Dates qw/format_date format_date_in_iso/; use C4::Debug; use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/; +use C4::Acquisition qw/GetOrdersByBiblionumber/; my $input = new CGI; my $startdate = $input->param('from'); @@ -47,6 +48,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $booksellerid = $input->param('booksellerid') // ''; +my $basketno = $input->param('basketno') // ''; +if ($booksellerid && $basketno) { + $template->param( booksellerid => $booksellerid, basketno => $basketno ); +} + my ( $year, $month, $day ) = Today(); my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day); # Find yesterday for the default shelf pull start and end dates @@ -160,6 +167,15 @@ while ( my $data = $sth->fetchrow_hashref ) { ); } +{ + for my $rd ( @reservedata ) { + $rd->{biblionumber} || next; + my $pcnt = CountPendingOrdersByBiblionumber( $rd->{biblionumber} ); + $pcnt || next; + $rd->{pendingorders} = $pcnt; + } +} + $template->param( ratio_atleast1 => $ratio_atleast1, todaysdate => format_date($todaysdate), @@ -170,3 +186,17 @@ $template->param( ); output_html_with_http_headers $input, $cookie, $template->output; + +sub CountPendingOrdersByBiblionumber { + my $biblionumber = shift; + my @orders = GetOrdersByBiblionumber( $biblionumber ); + scalar(@orders) || return(0); + my $cnt=0; for my $order ( @orders ) { + defined($order->{datecancellationprinted}) && $order->{datecancellationprinted} && next; + my $onum = $order->{quantity} // 0; + my $rnum = $order->{quantityreceived} // 0; + $rnum >= $onum && next; + $cnt+=$onum; $cnt-=$rnum; + } + $cnt; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc index 46f8400..4111546 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-add-to-basket.inc @@ -17,6 +17,7 @@
  • From a new (empty) record
  • From an external source
  • From a staged file
  • + [% IF ( CAN_user_circulate ) %]
  • From titles w/ highest hold ratios
  • [% END %] [% ELSE %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt index d55382e..17c7ced 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt @@ -76,7 +76,8 @@

    [% reserveloo.location %]

    [% reserveloo.itype %]

    [% reserveloo.listcall %]

    - [% IF ( reserveloo.thisratio_atleast1 ) %]

    [% reserveloo.ratiocalc %] to order

    [% END %] + [% IF ( reserveloo.thisratio_atleast1 ) %]

    [% IF ( CAN_user_acquisition && basketno && booksellerid ) %][% END %][% reserveloo.ratiocalc %] to order[% IF ( CAN_user_acquisition && basketno && booksellerid ) %][% END %] + [% IF ( reserveloo.pendingorders ) %]
    [% reserveloo.pendingorders %] pending[% END %]

    [% END %] [% END %] @@ -108,6 +109,10 @@
    +[% IF ( CAN_user_acquisition && basketno && booksellerid ) %] + + +[% END %]
    -- 1.7.10.4