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

(-)a/C4/Acquisition.pm (+139 lines)
Lines 77-82 BEGIN { Link Here
77
        &ReopenInvoice
77
        &ReopenInvoice
78
        &DelInvoice
78
        &DelInvoice
79
        &MergeInvoices
79
        &MergeInvoices
80
        &GetReceivedorder
80
81
81
        &GetItemnumbersFromOrder
82
        &GetItemnumbersFromOrder
82
83
Lines 2338-2343 sub GetHistory { Link Here
2338
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params );
2339
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params );
2339
}
2340
}
2340
2341
2342
=head3 GetReceivedorder
2343
2344
    $orderrec_loop = GetReceivedorder( %params );
2345
2346
Returns an arrayref of received orders
2347
2348
params:
2349
    title
2350
    author
2351
    name
2352
    datereceivedfrom
2353
    datereceivedto
2354
    basket                  - search both basket name and number
2355
    ordernumber             - search by ordernumber
2356
2357
returns:
2358
    $order_loop is a reference to an array of hashrefs that each look like this:
2359
            {
2360
                'author'           => 'Twain, Mark',
2361
                'basketno'         => '1',
2362
                'biblionumber'     => '215',
2363
                'datereceived'     => 'MM/DD/YYYY'
2364
                'name'             => '',
2365
                'ordernumber'      => '1',
2366
                'quantity'         => 1,
2367
                'quantityreceived' => undef,
2368
                'title'            => 'The Adventures of Huckleberry Finn'
2369
            }
2370
2371
=cut
2372
2373
sub GetReceivedorder {
2374
    croak "No search params" unless @_;
2375
    my %params = @_;
2376
    my $title = $params{title};
2377
    my $author = $params{author};
2378
    my $isbn   = $params{isbn};
2379
    my $ean    = $params{ean};
2380
    my $name = $params{name};
2381
    my $datereceivedfrom = $params{datereceivedfrom};
2382
    my $datereceivedto = $params{datereceivedto};
2383
    my $basket = $params{basket};
2384
    my $order = $params{ordernumber};
2385
2386
    my $query ="
2387
        SELECT
2388
            biblio.title,
2389
            biblio.author,
2390
            biblioitems.isbn,
2391
            biblioitems.ean,
2392
            aqorders.basketno,
2393
            aqbasket.basketname,
2394
            aqbooksellers.name,
2395
            aqbasket.creationdate,
2396
            aqorders.datereceived,
2397
            aqorders.quantity,
2398
            aqorders.quantityreceived,
2399
            aqorders.ecost,
2400
            aqorders.ordernumber,
2401
            aqorders.invoiceid,
2402
            aqinvoices.invoicenumber,
2403
            aqbooksellers.id as id,
2404
            aqorders.biblionumber
2405
        FROM aqorders
2406
        LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno
2407
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
2408
        LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
2409
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
2410
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
2411
2412
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
2413
    if ( C4::Context->preference("IndependentBranches") );
2414
2415
    $query .= " WHERE (aqorders.datereceived IS NOT NULL) ";
2416
2417
    my @query_params  = ();
2418
2419
    if ( $title ) {
2420
        $query .= " AND biblio.title LIKE ? ";
2421
        $title =~ s/\s+/%/g;
2422
        push @query_params, "%$title%";
2423
    }
2424
2425
    if ( $author ) {
2426
        $query .= " AND biblio.author LIKE ? ";
2427
        push @query_params, "%$author%";
2428
    }
2429
2430
    if ( $isbn ) {
2431
        $query .= " AND biblioitems.isbn LIKE ? ";
2432
        push @query_params, "%$isbn%";
2433
    }
2434
    if ( defined $ean and $ean ) {
2435
        $query .= " AND biblioitems.ean = ? ";
2436
        push @query_params, "$ean";
2437
    }
2438
    if ( $name ) {
2439
        $query .= " AND aqbooksellers.name LIKE ? ";
2440
        push @query_params, "%$name%";
2441
    }
2442
    if ( $datereceivedfrom ) {
2443
        $query .= " AND aqorders.datereceived >= ? ";
2444
        push @query_params, $datereceivedfrom;
2445
    }
2446
2447
    if ( $datereceivedto ) {
2448
        $query .= " AND aqorders.datereceived <= ? ";
2449
        push @query_params, $datereceivedto;
2450
    }
2451
2452
    if ($basket) {
2453
        if ($basket =~ m/^\d+$/) {
2454
            $query .= " AND aqorders.basketno = ? ";
2455
            push @query_params, $basket;
2456
        } else {
2457
            $query .= " AND aqbasket.basketname LIKE ? ";
2458
            push @query_params, "%$basket%";
2459
        }
2460
    }
2461
2462
    if ($order =~ m/^\d+$/) {
2463
            $query .= " AND aqorders.ordernumber = ? ";
2464
            push @query_params, $order;
2465
        }
2466
2467
    if ( C4::Context->preference("IndependentBranches") ) {
2468
        my $userenv = C4::Context->userenv;
2469
        if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
2470
            $query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
2471
            push @query_params, $userenv->{branch};
2472
        }
2473
    }
2474
    $query .= " ORDER BY id";
2475
2476
    my $dbh = C4::Context->dbh;
2477
    return $dbh->selectall_arrayref( $query, { Slice => {} }, @query_params );
2478
}
2479
2341
=head2 GetRecentAcqui
2480
=head2 GetRecentAcqui
2342
2481
2343
  $results = GetRecentAcqui($days);
2482
  $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