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 2130-2135 sub GetHistory { Link Here
2130
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2131
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2131
}
2132
}
2132
2133
2134
=head3 GetReceivedorder
2135
2136
    $orderrec_loop = GetReceivedorder( %params );
2137
2138
Returns an arrayref of received orders
2139
2140
params:
2141
    title
2142
    author
2143
    name
2144
    datereceivedfrom
2145
    datereceivedto
2146
    basket                  - search both basket name and number
2147
    ordernumber             - search by ordernumber
2148
2149
returns:
2150
    $order_loop is a reference to an array of hashrefs that each look like this:
2151
            {
2152
                'author'           => 'Twain, Mark',
2153
                'basketno'         => '1',
2154
                'biblionumber'     => '215',
2155
                'datereceived'     => 'MM/DD/YYYY'
2156
                'name'             => '',
2157
                'ordernumber'      => '1',
2158
                'quantity'         => 1,
2159
                'quantityreceived' => undef,
2160
                'title'            => 'The Adventures of Huckleberry Finn'
2161
            }
2162
2163
=cut
2164
2165
sub GetReceivedorder {
2166
    croak "No search params" unless @_;
2167
    my %params = @_;
2168
    my $title = $params{title};
2169
    my $author = $params{author};
2170
    my $isbn   = $params{isbn};
2171
    my $ean    = $params{ean};
2172
    my $name = $params{name};
2173
    my $datereceivedfrom = $params{datereceivedfrom};
2174
    my $datereceivedto = $params{datereceivedto};
2175
    my $basket = $params{basket};
2176
    my $order = $params{ordernumber};
2177
2178
    my $query ="
2179
        SELECT
2180
            biblio.title,
2181
            biblio.author,
2182
            biblioitems.isbn,
2183
            biblioitems.ean,
2184
            aqorders.basketno,
2185
            aqbasket.basketname,
2186
            aqbooksellers.name,
2187
            aqbasket.creationdate,
2188
            aqorders.datereceived,
2189
            aqorders.quantity,
2190
            aqorders.quantityreceived,
2191
            aqorders.ecost,
2192
            aqorders.ordernumber,
2193
            aqorders.invoiceid,
2194
            aqinvoices.invoicenumber,
2195
            aqbooksellers.id as id,
2196
            aqorders.biblionumber
2197
        FROM aqorders
2198
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2199
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2200
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2201
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2202
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2203
2204
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2205
    if ( C4::Context->preference("IndependentBranches") );
2206
2207
    $query .= " WHERE (aqorders.datereceived IS NOT NULL) ";
2208
2209
    my @query_params  = ();
2210
2211
    if ( $title ) {
2212
        $query .= " AND biblio.title LIKE ? ";
2213
        $title =~ s/\s+/%/g;
2214
        push @query_params, "%$title%";
2215
    }
2216
2217
    if ( $author ) {
2218
        $query .= " AND biblio.author LIKE ? ";
2219
        push @query_params, "%$author%";
2220
    }
2221
2222
    if ( $isbn ) {
2223
        $query .= " AND biblioitems.isbn LIKE ? ";
2224
        push @query_params, "%$isbn%";
2225
    }
2226
    if ( defined $ean and $ean ) {
2227
        $query .= " AND biblioitems.ean = ? ";
2228
        push @query_params, "$ean";
2229
    }
2230
    if ( $name ) {
2231
        $query .= " AND aqbooksellers.name LIKE ? ";
2232
        push @query_params, "%$name%";
2233
    }
2234
    if ( $datereceivedfrom ) {
2235
        $query .= " AND aqorders.datereceived >= ? ";
2236
        push @query_params, $datereceivedfrom;
2237
    }
2238
2239
    if ( $datereceivedto ) {
2240
        $query .= " AND aqorders.datereceived <= ? ";
2241
        push @query_params, $datereceivedto;
2242
    }
2243
2244
    if ($basket) {
2245
        if ($basket =~ m/^\d+$/) {
2246
            $query .= " AND aqorders.basketno = ? ";
2247
            push @query_params, $basket;
2248
        } else {
2249
            $query .= " AND aqbasket.basketname LIKE ? ";
2250
            push @query_params, "%$basket%";
2251
        }
2252
    }
2253
2254
    if ($order =~ m/^\d+$/) {
2255
            $query .= " AND aqorders.ordernumber = ? ";
2256
            push @query_params, $order;
2257
        }
2258
2259
    if ( C4::Context->preference("IndependentBranches") ) {
2260
        my $userenv = C4::Context->userenv;
2261
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2262
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2263
            push @query_params, $userenv->{branch};
2264
        }
2265
    }
2266
    $query .= " ORDER BY id";
2267
2268
    my $dbh = C4::Context->dbh;
2269
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params );
2270
}
2271
2133
=head2 GetRecentAcqui
2272
=head2 GetRecentAcqui
2134
2273
2135
  $results = GetRecentAcqui($days);
2274
  $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 (C) 2013 Amit Gupta (amitddng135@gmail.com)
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
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