View | Details | Raw Unified | Return to bug 10424
Collapse All | Expand All

(-)a/C4/Acquisition.pm (+139 lines)
Lines 72-77 BEGIN { Link Here
72
        &CloseInvoice
72
        &CloseInvoice
73
        &ReopenInvoice
73
        &ReopenInvoice
74
        &DelInvoice
74
        &DelInvoice
75
        &GetReceivedorder
75
76
76
        &GetItemnumbersFromOrder
77
        &GetItemnumbersFromOrder
77
78
Lines 2061-2066 sub GetHistory { Link Here
2061
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2062
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2062
}
2063
}
2063
2064
2065
=head3 GetReceivedorder
2066
2067
    $orderrec_loop = GetReceivedorder( %params );
2068
2069
Returns an arrayref of received orders
2070
2071
params:
2072
    title
2073
    author
2074
    name
2075
    datereceivedfrom
2076
    datereceivedto
2077
    basket                  - search both basket name and number
2078
    ordernumber             - search by ordernumber
2079
2080
returns:
2081
    $order_loop is a reference to an array of hashrefs that each look like this:
2082
            {
2083
                'author'           => 'Twain, Mark',
2084
                'basketno'         => '1',
2085
                'biblionumber'     => '215',
2086
                'datereceived'     => 'MM/DD/YYYY'
2087
                'name'             => '',
2088
                'ordernumber'      => '1',
2089
                'quantity'         => 1,
2090
                'quantityreceived' => undef,
2091
                'title'            => 'The Adventures of Huckleberry Finn'
2092
            }
2093
2094
=cut
2095
2096
sub GetReceivedorder {
2097
    croak "No search params" unless @_;
2098
    my %params = @_;
2099
    my $title = $params{title};
2100
    my $author = $params{author};
2101
    my $isbn   = $params{isbn};
2102
    my $ean    = $params{ean};
2103
    my $name = $params{name};
2104
    my $datereceivedfrom = $params{datereceivedfrom};
2105
    my $datereceivedto = $params{datereceivedto};
2106
    my $basket = $params{basket};
2107
    my $order = $params{ordernumber};
2108
2109
    my $query ="
2110
        SELECT
2111
            biblio.title,
2112
            biblio.author,
2113
            biblioitems.isbn,
2114
            biblioitems.ean,
2115
            aqorders.basketno,
2116
            aqbasket.basketname,
2117
            aqbooksellers.name,
2118
            aqbasket.creationdate,
2119
            aqorders.datereceived,
2120
            aqorders.quantity,
2121
            aqorders.quantityreceived,
2122
            aqorders.ecost,
2123
            aqorders.ordernumber,
2124
            aqorders.invoiceid,
2125
            aqinvoices.invoicenumber,
2126
            aqbooksellers.id as id,
2127
            aqorders.biblionumber
2128
        FROM aqorders
2129
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2130
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2131
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2132
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2133
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2134
2135
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2136
    if ( C4::Context->preference("IndependentBranches") );
2137
2138
    $query .= " WHERE (aqorders.datereceived IS NOT NULL) ";
2139
2140
    my @query_params  = ();
2141
2142
    if ( $title ) {
2143
        $query .= " AND biblio.title LIKE ? ";
2144
        $title =~ s/\s+/%/g;
2145
        push @query_params, "%$title%";
2146
    }
2147
2148
    if ( $author ) {
2149
        $query .= " AND biblio.author LIKE ? ";
2150
        push @query_params, "%$author%";
2151
    }
2152
2153
    if ( $isbn ) {
2154
        $query .= " AND biblioitems.isbn LIKE ? ";
2155
        push @query_params, "%$isbn%";
2156
    }
2157
    if ( defined $ean and $ean ) {
2158
        $query .= " AND biblioitems.ean = ? ";
2159
        push @query_params, "$ean";
2160
    }
2161
    if ( $name ) {
2162
        $query .= " AND aqbooksellers.name LIKE ? ";
2163
        push @query_params, "%$name%";
2164
    }
2165
    if ( $datereceivedfrom ) {
2166
        $query .= " AND aqorders.datereceived >= ? ";
2167
        push @query_params, $datereceivedfrom;
2168
    }
2169
2170
    if ( $datereceivedto ) {
2171
        $query .= " AND aqorders.datereceived <= ? ";
2172
        push @query_params, $datereceivedto;
2173
    }
2174
2175
    if ($basket) {
2176
        if ($basket =~ m/^\d+$/) {
2177
            $query .= " AND aqorders.basketno = ? ";
2178
            push @query_params, $basket;
2179
        } else {
2180
            $query .= " AND aqbasket.basketname LIKE ? ";
2181
            push @query_params, "%$basket%";
2182
        }
2183
    }
2184
2185
    if ($order =~ m/^\d+$/) {
2186
            $query .= " AND aqorders.ordernumber = ? ";
2187
            push @query_params, $order;
2188
        }
2189
2190
    if ( C4::Context->preference("IndependentBranches") ) {
2191
        my $userenv = C4::Context->userenv;
2192
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2193
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2194
            push @query_params, $userenv->{branch};
2195
        }
2196
    }
2197
    $query .= " ORDER BY id";
2198
2199
    my $dbh = C4::Context->dbh;
2200
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params );
2201
}
2202
2064
=head2 GetRecentAcqui
2203
=head2 GetRecentAcqui
2065
2204
2066
  $results = GetRecentAcqui($days);
2205
  $results = GetRecentAcqui($days);
(-)a/acqui/receivedorders.pl (+109 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2013 Amit Gupta(amitddng135@gmail.com)
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
=head1 NAME
21
22
receivedorders.pl
23
24
=head1 DESCRIPTION
25
26
this script offer a interface to search among order.
27
28
=head1 CGI PARAMETERS
29
30
=over 4
31
32
=item title
33
if the script has to filter the results on title.
34
35
=item author
36
if the script has to filter the results on author.
37
38
=item name
39
if the script has to filter the results on supplier.
40
41
=item datereceivedfrom
42
to filter on started date.
43
44
=item datereceivedto
45
to filter on ended date.
46
47
=back
48
49
=cut
50
51
use strict;
52
use warnings;
53
use CGI;
54
use C4::Auth;    # get_template_and_user
55
use C4::Output;
56
use C4::Acquisition qw/GetReceivedorder/;
57
use C4::Dates;
58
use C4::Debug;
59
60
my $input = new CGI();
61
my $title                   = $input->param('title');
62
my $ordernumber             = $input->param('ordernumber');
63
my $author                  = $input->param('author');
64
my $isbn                    = $input->param('isbn');
65
my $name                    = $input->param('name' );
66
my $ean                     = $input->param('ean');
67
my $basket                  = $input->param( 'basket' );
68
my $do_search               = $input->param('do_search') || 0;
69
my $from                    = C4::Dates->new($input->param('from'));
70
my $to                      = C4::Dates->new($input->param('to'));
71
72
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
73
    {
74
        template_name   => "acqui/receivedorders.tmpl",
75
        query           => $input,
76
        type            => "intranet",
77
        authnotrequired => 0,
78
        flagsrequired   => { acquisition => '*' },
79
        debug           => 1,
80
    }
81
);
82
83
my ( $from_iso, $to_iso, $d );
84
if ( $d = $input->param('from') ) {
85
    $from_iso = C4::Dates->new($d)->output('iso');
86
}
87
if ( $d = $input->param('iso') ) {
88
    $to_iso = C4::Dates->new($d)->output('iso');
89
}
90
91
my $orderrec_loop;
92
93
if ($do_search) {
94
    $orderrec_loop = GetReceivedorder(
95
        title => $title,
96
        author => $author,
97
        isbn   => $isbn,
98
        ean   => $ean,
99
        name => $name,
100
        datereceivedfrom => $from_iso,
101
        datereceivedto => $to_iso,
102
        basket => $basket,
103
        ordernumber => $ordernumber,
104
    );
105
}
106
107
$template->param( orderrec_loop => $orderrec_loop,);
108
109
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc (+1 lines)
Lines 2-7 Link Here
2
	<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>
2
	<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>
3
	[% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% ELSE %][% END %]
3
	[% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% ELSE %][% END %]
4
    <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
4
    <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
5
    <li><a href="/cgi-bin/koha/acqui/receivedorders.pl">Received orders</a></li>
5
    [% IF ( CAN_user_acquisition_budget_manage ) %]
6
    [% IF ( CAN_user_acquisition_budget_manage ) %]
6
    <li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a></li>
7
    <li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a></li>
7
    <li><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></li>
8
    <li><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/receivedorders.tt (-1 / +110 lines)
Line 0 Link Here
0
- 
1
[% USE KohaDates %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Acquisitions &rsaquo; [% IF ( orderrec_loop ) %] Received orders &rsaquo; Search results[% ELSE %]Search received orders[% END %]</title>
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
8
[% INCLUDE 'datatables-strings.inc' %]
9
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
10
<script type="text/javascript">
11
$(document).ready(function() {
12
    var orderrecsearch = $("#orderrecsearch").dataTable($.extend(true, {}, dataTablesDefaults, {
13
    "sPaginationType": "four_button"
14
    } ) );
15
});
16
</script>
17
</head>
18
<body id="acq_recsearch" class="acq">
19
[% INCLUDE 'header.inc' %]
20
[% INCLUDE 'acquisitions-search.inc' %]
21
22
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; [% IF ( orderrec_loop ) %]<a href="/cgi-bin/koha/acqui/receivedorders.pl">Search received orders</a> &rsaquo; Search results[% ELSE %]Search received orders[% END %]</div>
23
24
<div id="doc3" class="yui-t2">
25
<div id="bd">
26
<div id="yui-main">
27
<div class="yui-b">
28
    [% UNLESS ( orderrec_loop ) %]<form action="/cgi-bin/koha/acqui/receivedorders.pl" method="post">
29
        <fieldset class="rows">
30
        <legend>Search received orders</legend>
31
        <ol>
32
            <li><label for="ordernumber">Order: </label> <input type="text" name="ordernumber" id="ordernumber" value="[% ordernumber %]" /></li>
33
            <li><label for="basket">Basket: </label> <input type="text" name="basket" id="basket" value="[% basket %]" /></li>
34
            <li><label for="title">Title: </label> <input type="text" name="title" id="title" value="[% title %]" /></li>
35
            <li><label for="author">Author: </label> <input type="text" name="author" id="author" value="[% author %]" /></li>
36
            <li><label for="isbn">ISBN: </label> <input type="text" name="isbn" id="isbn" value="[% isbn %]" /></li>
37
            [% IF (UNIMARC) %]
38
                <li><label for="ean">EAN: </label> <input type="text" name="ean" id="ean" value="[% ean %]" /></li>
39
            [% END %]
40
            <li><label for="name">Vendor: </label> <input type="text" name="name" id="name" value="[% name %]" /></li>
41
            <li><label for="from">Received from: </label>
42
            <input type="text" size="10" id="from" name="from" value="[% from_placed_on %]" class="datepickerfrom" />
43
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
44
            </li>
45
            <li><label for="to">Receive to: </label>
46
            <input type="text" size="10" id="to" name="to" value="[% to_placed_on %]" class="datepickerto" />
47
                    <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
48
            </li>
49
        </ol>
50
        </fieldset>
51
        <input type="hidden" name="do_search" value="1" />
52
        <fieldset class="action"><input type="submit" value="Search" /></fieldset>
53
        </form>
54
    [% END %]
55
    [% IF ( orderrec_loop ) %]<h1>Received orders search result</h1>
56
        <div id="acqui_recsearch">
57
        <table id="orderrecsearch">
58
        <thead>
59
        <tr>
60
            <th>Basket</th>
61
            <th>Invoice number</th>
62
            <th>Order number</th>
63
            <th>Summary</th>
64
            <th>Vendor</th>
65
            <th>Placed on</th>
66
            <th>Received on</th>
67
            <th>Quantity ordered</th>
68
            <th>Quantity received</th>
69
            <th>Unit price</th>
70
        </tr>
71
        </thead>
72
        <tbody>
73
        [% FOREACH ordersrec_loo IN orderrec_loop %]
74
        <tr>
75
            <td>[% ordersrec_loo.basketname %] (<a href="basket.pl?basketno=[% ordersrec_loo.basketno %]">[% ordersrec_loo.basketno %]</a>)</td>
76
            <td>
77
                [% IF  ordersrec_loo.invoicenumber  %]
78
                    <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% ordersrec_loo.invoiceid %]">[% ordersrec_loo.invoicenumber %]</a>
79
                [% ELSE %]
80
                    &nbsp;
81
                [% END %]
82
            </td>
83
            <td>[% ordersrec_loo.ordernumber %]</td>
84
            <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% ordersrec_loo.biblionumber %]">[% ordersrec_loo.title |html %]</a>
85
                <br />[% ordersrec_loo.author %] <br /> [% ordersrec_loo.isbn %]
86
            </td>
87
            <td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% ordersrec_loo.id %]">[% ordersrec_loo.name %]</a></td>
88
            <td>[% ordersrec_loo.creationdate | $KohaDates %]</td>
89
            <td>
90
                [% IF ordersrec_loo.datereceived %]
91
                    [% ordersrec_loo.datereceived | $KohaDates %]
92
                [% END %]
93
            </td>
94
            <td>[% ordersrec_loo.quantity %]</td>
95
            <td>[% ordersrec_loo.quantityreceived %]</td>
96
            <td>[% ordersrec_loo.ecost %]</td>
97
        </tr>
98
        [% END %]
99
        </tbody>
100
        </table>
101
        </div>
102
        [% ELSE %]
103
        [% END %]
104
</div>
105
</div>
106
<div class="yui-b">
107
[% INCLUDE 'acquisitions-menu.inc' %]
108
</div>
109
</div>
110
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 10424