@@ -, +, @@ --- C4/Acquisition.pm | 139 ++++++++++++++++++++ acqui/receivedorders.pl | 109 +++++++++++++++ .../prog/en/includes/acquisitions-menu.inc | 1 + .../prog/en/modules/acqui/receivedorders.tt | 110 ++++++++++++++++ 4 files changed, 359 insertions(+) create mode 100755 acqui/receivedorders.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/acqui/receivedorders.tt --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -72,6 +72,7 @@ BEGIN { &CloseInvoice &ReopenInvoice &DelInvoice + &GetReceivedorder &GetItemnumbersFromOrder @@ -2130,6 +2131,144 @@ sub GetHistory { return \@order_loop, $total_qty, $total_price, $total_qtyreceived; } +=head3 GetReceivedorder + + $orderrec_loop = GetReceivedorder( %params ); + +Returns an arrayref of received orders + +params: + title + author + name + datereceivedfrom + datereceivedto + basket - search both basket name and number + ordernumber - search by ordernumber + +returns: + $order_loop is a reference to an array of hashrefs that each look like this: + { + 'author' => 'Twain, Mark', + 'basketno' => '1', + 'biblionumber' => '215', + 'datereceived' => 'MM/DD/YYYY' + 'name' => '', + 'ordernumber' => '1', + 'quantity' => 1, + 'quantityreceived' => undef, + 'title' => 'The Adventures of Huckleberry Finn' + } + +=cut + +sub GetReceivedorder { + croak "No search params" unless @_; + my %params = @_; + my $title = $params{title}; + my $author = $params{author}; + my $isbn = $params{isbn}; + my $ean = $params{ean}; + my $name = $params{name}; + my $datereceivedfrom = $params{datereceivedfrom}; + my $datereceivedto = $params{datereceivedto}; + my $basket = $params{basket}; + my $order = $params{ordernumber}; + + my $query =" + SELECT + biblio.title, + biblio.author, + biblioitems.isbn, + biblioitems.ean, + aqorders.basketno, + aqbasket.basketname, + aqbooksellers.name, + aqbasket.creationdate, + aqorders.datereceived, + aqorders.quantity, + aqorders.quantityreceived, + aqorders.ecost, + aqorders.ordernumber, + aqorders.invoiceid, + aqinvoices.invoicenumber, + aqbooksellers.id as id, + aqorders.biblionumber + FROM aqorders + LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno + LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id + LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber + LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber + LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid"; + + $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber" + if ( C4::Context->preference("IndependentBranches") ); + + $query .= " WHERE (aqorders.datereceived IS NOT NULL) "; + + my @query_params = (); + + if ( $title ) { + $query .= " AND biblio.title LIKE ? "; + $title =~ s/\s+/%/g; + push @query_params, "%$title%"; + } + + if ( $author ) { + $query .= " AND biblio.author LIKE ? "; + push @query_params, "%$author%"; + } + + if ( $isbn ) { + $query .= " AND biblioitems.isbn LIKE ? "; + push @query_params, "%$isbn%"; + } + if ( defined $ean and $ean ) { + $query .= " AND biblioitems.ean = ? "; + push @query_params, "$ean"; + } + if ( $name ) { + $query .= " AND aqbooksellers.name LIKE ? "; + push @query_params, "%$name%"; + } + if ( $datereceivedfrom ) { + $query .= " AND aqorders.datereceived >= ? "; + push @query_params, $datereceivedfrom; + } + + if ( $datereceivedto ) { + $query .= " AND aqorders.datereceived <= ? "; + push @query_params, $datereceivedto; + } + + if ($basket) { + if ($basket =~ m/^\d+$/) { + $query .= " AND aqorders.basketno = ? "; + push @query_params, $basket; + } else { + $query .= " AND aqbasket.basketname LIKE ? "; + push @query_params, "%$basket%"; + } + } + + if ($order =~ m/^\d+$/) { + $query .= " AND aqorders.ordernumber = ? "; + push @query_params, $order; + } + + if ( C4::Context->preference("IndependentBranches") ) { + my $userenv = C4::Context->userenv; + if ( $userenv && ($userenv->{flags} || 0) != 1 ) { + $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) "; + push @query_params, $userenv->{branch}; + } + } + $query .= " ORDER BY id"; + + my $dbh = C4::Context->dbh; + return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params ); +} + =head2 GetRecentAcqui $results = GetRecentAcqui($days); --- a/acqui/receivedorders.pl +++ a/acqui/receivedorders.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Copyright (C) 2013 Amit Gupta (amitddng135@gmail.com) +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +=head1 NAME + +receivedorders.pl + +=head1 DESCRIPTION + +this script offer a interface to search among order. + +=head1 CGI PARAMETERS + +=over 4 + +=item title +if the script has to filter the results on title. + +=item author +if the script has to filter the results on author. + +=item name +if the script has to filter the results on supplier. + +=item datereceivedfrom +to filter on started date. + +=item datereceivedto +to filter on ended date. + +=back + +=cut + +use strict; +use warnings; +use CGI; +use C4::Auth; # get_template_and_user +use C4::Output; +use C4::Acquisition qw/GetReceivedorder/; +use C4::Dates; +use C4::Debug; + +my $input = new CGI(); +my $title = $input->param('title'); +my $ordernumber = $input->param('ordernumber'); +my $author = $input->param('author'); +my $isbn = $input->param('isbn'); +my $name = $input->param('name' ); +my $ean = $input->param('ean'); +my $basket = $input->param( 'basket' ); +my $do_search = $input->param('do_search') || 0; +my $from = C4::Dates->new($input->param('from')); +my $to = C4::Dates->new($input->param('to')); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "acqui/receivedorders.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { acquisition => '*' }, + debug => 1, + } +); + +my ( $from_iso, $to_iso, $d ); +if ( $d = $input->param('from') ) { + $from_iso = C4::Dates->new($d)->output('iso'); +} +if ( $d = $input->param('iso') ) { + $to_iso = C4::Dates->new($d)->output('iso'); +} + +my $orderrec_loop; + +if ($do_search) { + $orderrec_loop = GetReceivedorder( + title => $title, + author => $author, + isbn => $isbn, + ean => $ean, + name => $name, + datereceivedfrom => $from_iso, + datereceivedto => $to_iso, + basket => $basket, + ordernumber => $ordernumber, + ); +} + +$template->param( orderrec_loop => $orderrec_loop,); + +output_html_with_http_headers $input, $cookie, $template->output; --- a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc @@ -2,6 +2,7 @@
  • Late orders
  • [% IF ( suggestion ) %]
  • Suggestions
  • [% ELSE %][% END %]
  • Invoices
  • +
  • Received orders
  • [% IF ( CAN_user_acquisition_budget_manage ) %]
  • Budgets
  • Funds
  • --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/receivedorders.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/receivedorders.tt @@ -0,0 +1,110 @@ +[% USE KohaDates %] +[% INCLUDE 'doc-head-open.inc' %] +Koha › Acquisitions › [% IF ( orderrec_loop ) %] Received orders › Search results[% ELSE %]Search received orders[% END %] + +[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'calendar.inc' %] + +[% INCLUDE 'datatables-strings.inc' %] + + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'acquisitions-search.inc' %] + + + +
    +
    +
    +
    + [% UNLESS ( orderrec_loop ) %]
    +
    + Search received orders +
      +
    1. +
    2. +
    3. +
    4. +
    5. + [% IF (UNIMARC) %] +
    6. + [% END %] +
    7. +
    8. + +
      [% INCLUDE 'date-format.inc' %]
      +
    9. +
    10. + +
      [% INCLUDE 'date-format.inc' %]
      +
    11. +
    +
    + +
    +
    + [% END %] + [% IF ( orderrec_loop ) %]

    Received orders search result

    +
    + + + + + + + + + + + + + + + + + [% FOREACH ordersrec_loo IN orderrec_loop %] + + + + + + + + + + + + + [% END %] + +
    BasketInvoice numberOrder numberSummaryVendorPlaced onReceived onQuantity orderedQuantity receivedUnit price
    [% ordersrec_loo.basketname %] ([% ordersrec_loo.basketno %]) + [% IF ordersrec_loo.invoicenumber %] + [% ordersrec_loo.invoicenumber %] + [% ELSE %] +   + [% END %] + [% ordersrec_loo.ordernumber %][% ordersrec_loo.title |html %] +
    [% ordersrec_loo.author %]
    [% ordersrec_loo.isbn %] +
    [% ordersrec_loo.name %][% ordersrec_loo.creationdate | $KohaDates %] + [% IF ordersrec_loo.datereceived %] + [% ordersrec_loo.datereceived | $KohaDates %] + [% END %] + [% ordersrec_loo.quantity %][% ordersrec_loo.quantityreceived %][% ordersrec_loo.ecost %]
    +
    + [% ELSE %] + [% END %] +
    +
    +
    +[% INCLUDE 'acquisitions-menu.inc' %] +
    +
    +[% INCLUDE 'intranet-bottom.inc' %] --