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

(-)a/C4/Acquisition.pm (+139 lines)
Lines 71-76 BEGIN { Link Here
71
        &ModInvoice
71
        &ModInvoice
72
        &CloseInvoice
72
        &CloseInvoice
73
        &ReopenInvoice
73
        &ReopenInvoice
74
        &GetReceivedorder
74
75
75
        &GetItemnumbersFromOrder
76
        &GetItemnumbersFromOrder
76
77
Lines 2148-2153 sub GetHistory { Link Here
2148
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2149
    return \@order_loop, $total_qty, $total_price, $total_qtyreceived;
2149
}
2150
}
2150
2151
2152
=head3 GetReceivedorder
2153
2154
    $orderrec_loop = GetReceivedorder( %params );
2155
2156
Returns an arrayref of received orders
2157
2158
params:
2159
    title
2160
    author
2161
    name
2162
    datereceivedfrom
2163
    datereceivedto
2164
    basket                  - search both basket name and number
2165
    ordernumber             - search by ordernumber
2166
2167
returns:
2168
    $order_loop is a reference to an array of hashrefs that each look like this:
2169
            {
2170
                'author'           => 'Twain, Mark',
2171
                'basketno'         => '1',
2172
                'biblionumber'     => '215',
2173
                'datereceived'     => 'MM/DD/YYYY'
2174
                'name'             => '',
2175
                'ordernumber'      => '1',
2176
                'quantity'         => 1,
2177
                'quantityreceived' => undef,
2178
                'title'            => 'The Adventures of Huckleberry Finn'
2179
            }
2180
2181
=cut
2182
2183
sub GetReceivedorder {
2184
    croak "No search params" unless @_;
2185
    my %params = @_;
2186
    my $title = $params{title};
2187
    my $author = $params{author};
2188
    my $isbn   = $params{isbn};
2189
    my $ean    = $params{ean};
2190
    my $name = $params{name};
2191
    my $datereceivedfrom = $params{datereceivedfrom};
2192
    my $datereceivedto = $params{datereceivedto};
2193
    my $basket = $params{basket};
2194
    my $order = $params{ordernumber};
2195
2196
    my $query ="
2197
        SELECT
2198
            biblio.title,
2199
            biblio.author,
2200
            biblioitems.isbn,
2201
            biblioitems.ean,
2202
            aqorders.basketno,
2203
            aqbasket.basketname,
2204
            aqbooksellers.name,
2205
            aqbasket.creationdate,
2206
            aqorders.datereceived,
2207
            aqorders.quantity,
2208
            aqorders.quantityreceived,
2209
            aqorders.ecost,
2210
            aqorders.ordernumber,
2211
            aqorders.invoiceid,
2212
            aqinvoices.invoicenumber,
2213
            aqbooksellers.id as id,
2214
            aqorders.biblionumber
2215
        FROM aqorders
2216
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2217
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2218
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2219
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2220
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2221
2222
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2223
    if ( C4::Context->preference("IndependentBranches") );
2224
2225
    $query .= " WHERE (aqorders.datereceived IS NOT NULL) ";
2226
2227
    my @query_params  = ();
2228
2229
    if ( $title ) {
2230
        $query .= " AND biblio.title LIKE ? ";
2231
        $title =~ s/\s+/%/g;
2232
        push @query_params, "%$title%";
2233
    }
2234
2235
    if ( $author ) {
2236
        $query .= " AND biblio.author LIKE ? ";
2237
        push @query_params, "%$author%";
2238
    }
2239
2240
    if ( $isbn ) {
2241
        $query .= " AND biblioitems.isbn LIKE ? ";
2242
        push @query_params, "%$isbn%";
2243
    }
2244
    if ( defined $ean and $ean ) {
2245
        $query .= " AND biblioitems.ean = ? ";
2246
        push @query_params, "$ean";
2247
    }
2248
    if ( $name ) {
2249
        $query .= " AND aqbooksellers.name LIKE ? ";
2250
        push @query_params, "%$name%";
2251
    }
2252
    if ( $datereceivedfrom ) {
2253
        $query .= " AND aqorders.datereceived >= ? ";
2254
        push @query_params, $datereceivedfrom;
2255
    }
2256
2257
    if ( $datereceivedto ) {
2258
        $query .= " AND aqorders.datereceived <= ? ";
2259
        push @query_params, $datereceivedto;
2260
    }
2261
2262
    if ($basket) {
2263
        if ($basket =~ m/^\d+$/) {
2264
            $query .= " AND aqorders.basketno = ? ";
2265
            push @query_params, $basket;
2266
        } else {
2267
            $query .= " AND aqbasket.basketname LIKE ? ";
2268
            push @query_params, "%$basket%";
2269
        }
2270
    }
2271
2272
    if ($order =~ m/^\d+$/) {
2273
            $query .= " AND aqorders.ordernumber = ? ";
2274
            push @query_params, $order;
2275
        }
2276
2277
    if ( C4::Context->preference("IndependentBranches") ) {
2278
        my $userenv = C4::Context->userenv;
2279
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2280
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2281
            push @query_params, $userenv->{branch};
2282
        }
2283
    }
2284
    $query .= " ORDER BY id";
2285
2286
    my $dbh = C4::Context->dbh;
2287
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params );
2288
}
2289
2151
=head2 GetRecentAcqui
2290
=head2 GetRecentAcqui
2152
2291
2153
  $results = GetRecentAcqui($days);
2292
  $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