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

(-)a/C4/Acquisition.pm (-7 / +348 lines)
Lines 60-65 BEGIN { Link Here
60
        &GetParcels &GetParcel
60
        &GetParcels &GetParcel
61
        &GetContracts &GetContract
61
        &GetContracts &GetContract
62
62
63
        &GetInvoices
64
        &GetInvoice
65
        &GetInvoiceDetails
66
        &AddInvoice
67
        &ModInvoice
68
        &CloseInvoice
69
        &ReopenInvoice
70
63
        &GetItemnumbersFromOrder
71
        &GetItemnumbersFromOrder
64
    );
72
    );
65
}
73
}
Lines 1068-1074 C<$ordernumber>. Link Here
1068
sub ModReceiveOrder {
1076
sub ModReceiveOrder {
1069
    my (
1077
    my (
1070
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1078
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1071
        $invoiceno, $freight, $rrp, $budget_id, $datereceived
1079
        $invoiceid, $rrp, $budget_id, $datereceived
1072
    )
1080
    )
1073
    = @_;
1081
    = @_;
1074
    my $dbh = C4::Context->dbh;
1082
    my $dbh = C4::Context->dbh;
Lines 1097-1110 sub ModReceiveOrder { Link Here
1097
            UPDATE aqorders
1105
            UPDATE aqorders
1098
            SET quantityreceived=?
1106
            SET quantityreceived=?
1099
                , datereceived=?
1107
                , datereceived=?
1100
                , booksellerinvoicenumber=?
1108
                , invoiceid=?
1101
                , unitprice=?
1109
                , unitprice=?
1102
                , freight=?
1103
                , rrp=?
1110
                , rrp=?
1104
                , quantity=?
1111
                , quantity=?
1105
            WHERE biblionumber=? AND ordernumber=?");
1112
            WHERE biblionumber=? AND ordernumber=?");
1106
1113
1107
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
1114
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$quantrec,$biblionumber,$ordernumber);
1108
        $sth->finish;
1115
        $sth->finish;
1109
1116
1110
        # create a new order for the remaining items, and set its bookfund.
1117
        # create a new order for the remaining items, and set its bookfund.
Lines 1116-1125 sub ModReceiveOrder { Link Here
1116
        my $newOrder = NewOrder($order);
1123
        my $newOrder = NewOrder($order);
1117
} else {
1124
} else {
1118
        $sth=$dbh->prepare("update aqorders
1125
        $sth=$dbh->prepare("update aqorders
1119
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1126
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1120
                                unitprice=?,freight=?,rrp=?
1127
                                unitprice=?,rrp=?
1121
                            where biblionumber=? and ordernumber=?");
1128
                            where biblionumber=? and ordernumber=?");
1122
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1129
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1123
        $sth->finish;
1130
        $sth->finish;
1124
    }
1131
    }
1125
    return $datereceived;
1132
    return $datereceived;
Lines 1745-1750 sub GetContract { Link Here
1745
    return $result;
1752
    return $result;
1746
}
1753
}
1747
1754
1755
=head3 GetInvoices
1756
1757
    my @invoices = GetInvoices(
1758
        invoicenumber => $invoicenumber,
1759
        suppliername => $suppliername,
1760
        shipmentdatefrom => $shipmentdatefrom, # ISO format
1761
        shipmentdateto => $shipmentdateto, # ISO format
1762
        billingdatefrom => $billingdatefrom, # ISO format
1763
        billingdateto => $billingdateto, # ISO format
1764
        isbneanissn => $isbn_or_ean_or_issn,
1765
        title => $title,
1766
        author => $author,
1767
        publisher => $publisher,
1768
        publicationyear => $publicationyear,
1769
        branchcode => $branchcode,
1770
        order_by => $order_by
1771
    );
1772
1773
Return a list of invoices that match all given criteria.
1774
1775
$order_by is "column_name (asc|desc)", where column_name is any of
1776
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
1777
'shipmentcost', 'shipmentcost_budgetid'.
1778
1779
asc is the default if omitted
1780
1781
=cut
1782
1783
sub GetInvoices {
1784
    my %args = @_;
1785
1786
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
1787
        closedate shipmentcost shipmentcost_budgetid);
1788
1789
    my $dbh = C4::Context->dbh;
1790
    my $query = qq{
1791
        SELECT invoices.*, aqbooksellers.name AS suppliername,
1792
          COUNT(
1793
            DISTINCT IF(
1794
              aqorders.datereceived IS NOT NULL,
1795
              aqorders.biblionumber,
1796
              NULL
1797
            )
1798
          ) AS receivedbiblios,
1799
          SUM(aqorders.quantityreceived) AS receiveditems
1800
        FROM invoices
1801
          LEFT JOIN aqbooksellers ON aqbooksellers.id = invoices.booksellerid
1802
          LEFT JOIN aqorders ON aqorders.invoiceid = invoices.invoiceid
1803
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1804
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
1805
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
1806
    };
1807
1808
    my @bind_args;
1809
    my @bind_strs;
1810
    if($args{invoicenumber}) {
1811
        push @bind_strs, " invoices.invoicenumber LIKE ? ";
1812
        push @bind_args, "%$args{invoicenumber}%";
1813
    }
1814
    if($args{suppliername}) {
1815
        push @bind_strs, " aqbooksellers.name LIKE ? ";
1816
        push @bind_args, "%$args{suppliername}%";
1817
    }
1818
    if($args{shipmentdatefrom}) {
1819
        push @bind_strs, " invoices.shipementdate >= ? ";
1820
        push @bind_args, $args{shipementdatefrom};
1821
    }
1822
    if($args{shipmentdateto}) {
1823
        push @bind_strs, " invoices.shipementdate <= ? ";
1824
        push @bind_args, $args{shipementdateto};
1825
    }
1826
    if($args{billingdatefrom}) {
1827
        push @bind_strs, " invoices.billingdate >= ? ";
1828
        push @bind_args, $args{billingdatefrom};
1829
    }
1830
    if($args{billingdateto}) {
1831
        push @bind_strs, " invoices.billingdate <= ? ";
1832
        push @bind_args, $args{billingdateto};
1833
    }
1834
    if($args{isbneanissn}) {
1835
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
1836
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
1837
    }
1838
    if($args{title}) {
1839
        push @bind_strs, " biblio.title LIKE ? ";
1840
        push @bind_args, $args{title};
1841
    }
1842
    if($args{author}) {
1843
        push @bind_strs, " biblio.author LIKE ? ";
1844
        push @bind_args, $args{author};
1845
    }
1846
    if($args{publisher}) {
1847
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
1848
        push @bind_args, $args{publisher};
1849
    }
1850
    if($args{publicationyear}) {
1851
        push @bind_strs, " biblioitems.publicationyear = ? ";
1852
        push @bind_args, $args{publicationyear};
1853
    }
1854
    if($args{branchcode}) {
1855
        push @bind_strs, " aqorders.branchcode = ? ";
1856
        push @bind_args, $args{branchcode};
1857
    }
1858
1859
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
1860
    $query .= " GROUP BY invoices.invoiceid ";
1861
1862
    if($args{order_by}) {
1863
        my ($column, $direction) = split / /, $args{order_by};
1864
        if(grep /^$column$/, @columns) {
1865
            $direction ||= 'ASC';
1866
            $query .= " ORDER BY $column $direction";
1867
        }
1868
    }
1869
1870
    my $sth = $dbh->prepare($query);
1871
    $sth->execute(@bind_args);
1872
1873
    my $results = $sth->fetchall_arrayref({});
1874
    return @$results;
1875
}
1876
1877
=head3 GetInvoice
1878
1879
    my $invoice = GetInvoice($invoiceid);
1880
1881
Get informations about invoice with given $invoiceid
1882
1883
Return a hash filled with invoices.* fields
1884
1885
=cut
1886
1887
sub GetInvoice {
1888
    my ($invoiceid) = @_;
1889
    my $invoice;
1890
1891
    return unless $invoiceid;
1892
1893
    my $dbh = C4::Context->dbh;
1894
    my $query = qq{
1895
        SELECT *
1896
        FROM invoices
1897
        WHERE invoiceid = ?
1898
    };
1899
    my $sth = $dbh->prepare($query);
1900
    $sth->execute($invoiceid);
1901
1902
    $invoice = $sth->fetchrow_hashref;
1903
    return $invoice;
1904
}
1905
1906
=head3 GetInvoiceDetails
1907
1908
    my $invoice = GetInvoiceDetails($invoiceid)
1909
1910
Return informations about an invoice + the list of related order lines
1911
1912
Orders informations are in $invoice->{orders} (array ref)
1913
1914
=cut
1915
1916
sub GetInvoiceDetails {
1917
    my ($invoiceid) = @_;
1918
    my $invoice;
1919
1920
    return unless $invoiceid;
1921
1922
    my $dbh = C4::Context->dbh;
1923
    my $query = qq{
1924
        SELECT invoices.*, aqbooksellers.name AS suppliername
1925
        FROM invoices
1926
          LEFT JOIN aqbooksellers ON invoices.booksellerid = aqbooksellers.id
1927
        WHERE invoiceid = ?
1928
    };
1929
    my $sth = $dbh->prepare($query);
1930
    $sth->execute($invoiceid);
1931
1932
    $invoice = $sth->fetchrow_hashref;
1933
1934
    $query = qq{
1935
        SELECT aqorders.*, biblio.*
1936
        FROM aqorders
1937
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1938
        WHERE invoiceid = ?
1939
    };
1940
    $sth = $dbh->prepare($query);
1941
    $sth->execute($invoiceid);
1942
    $invoice->{orders} = $sth->fetchall_arrayref({});
1943
1944
    return $invoice;
1945
}
1946
1947
=head3 AddInvoice
1948
1949
    my $invoiceid = AddInvoice(
1950
        invoicenumber => $invoicenumber,
1951
        booksellerid => $booksellerid,
1952
        shipmentdate => $shipmentdate,
1953
        billingdate => $billingdate,
1954
        closedate => $closedate,
1955
        shipmentcost => $shipmentcost,
1956
        shipmentcost_budgetid => $shipmentcost_budgetid
1957
    );
1958
1959
Create a new invoice and return its id or undef if it fails.
1960
1961
=cut
1962
1963
sub AddInvoice {
1964
    my %invoice = @_;
1965
1966
    return unless(%invoice and $invoice{invoicenumber});
1967
1968
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
1969
        closedate shipmentcost shipmentcost_budgetid);
1970
1971
    my @set_strs;
1972
    my @set_args;
1973
    foreach my $key (keys %invoice) {
1974
        if(0 < grep(/^$key$/, @columns)) {
1975
            push @set_strs, "$key = ?";
1976
            push @set_args, ($invoice{$key} || undef);
1977
        }
1978
    }
1979
1980
    my $rv;
1981
    if(@set_args > 0) {
1982
        my $dbh = C4::Context->dbh;
1983
        my $query = "INSERT INTO invoices SET ";
1984
        $query .= join (",", @set_strs);
1985
        my $sth = $dbh->prepare($query);
1986
        $rv = $sth->execute(@set_args);
1987
        if($rv) {
1988
            $rv = $dbh->last_insert_id(undef, undef, 'invoices', undef);
1989
        }
1990
    }
1991
    return $rv;
1992
}
1993
1994
=head3 ModInvoice
1995
1996
    ModInvoice(
1997
        invoiceid => $invoiceid,    # Mandatory
1998
        invoicenumber => $invoicenumber,
1999
        booksellerid => $booksellerid,
2000
        shipmentdate => $shipmentdate,
2001
        billingdate => $billingdate,
2002
        closedate => $closedate,
2003
        shipmentcost => $shipmentcost,
2004
        shipmentcost_budgetid => $shipmentcost_budgetid
2005
    );
2006
2007
Modify an invoice, invoiceid is mandatory.
2008
2009
Return undef if it fails.
2010
2011
=cut
2012
2013
sub ModInvoice {
2014
    my %invoice = @_;
2015
2016
    return unless(%invoice and $invoice{invoiceid});
2017
2018
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2019
        closedate shipmentcost shipmentcost_budgetid);
2020
2021
    my @set_strs;
2022
    my @set_args;
2023
    foreach my $key (keys %invoice) {
2024
        if(0 < grep(/^$key$/, @columns)) {
2025
            push @set_strs, "$key = ?";
2026
            push @set_args, ($invoice{$key} || undef);
2027
        }
2028
    }
2029
2030
    my $dbh = C4::Context->dbh;
2031
    my $query = "UPDATE invoices SET ";
2032
    $query .= join(",", @set_strs);
2033
    $query .= " WHERE invoiceid = ?";
2034
2035
    my $sth = $dbh->prepare($query);
2036
    $sth->execute(@set_args, $invoice{invoiceid});
2037
}
2038
2039
=head3 CloseInvoice
2040
2041
    CloseInvoice($invoiceid);
2042
2043
Close an invoice.
2044
2045
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2046
2047
=cut
2048
2049
sub CloseInvoice {
2050
    my ($invoiceid) = @_;
2051
2052
    return unless $invoiceid;
2053
2054
    my $dbh = C4::Context->dbh;
2055
    my $query = qq{
2056
        UPDATE invoices
2057
        SET closedate = CAST(NOW() AS DATE)
2058
        WHERE invoiceid = ?
2059
    };
2060
    my $sth = $dbh->prepare($query);
2061
    $sth->execute($invoiceid);
2062
}
2063
2064
=head3 ReopenInvoice
2065
2066
    ReopenInvoice($invoiceid);
2067
2068
Reopen an invoice
2069
2070
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2071
2072
=cut
2073
2074
sub ReopenInvoice {
2075
    my ($invoiceid) = @_;
2076
2077
    return unless $invoiceid;
2078
2079
    my $dbh = C4::Context->dbh;
2080
    my $query = qq{
2081
        UPDATE invoices
2082
        SET closedate = NULL
2083
        WHERE invoiceid = ?
2084
    };
2085
    my $sth = $dbh->prepare($query);
2086
    $sth->execute($invoiceid);
2087
}
2088
1748
1;
2089
1;
1749
__END__
2090
__END__
1750
2091
(-)a/C4/Budgets.pm (-2 / +22 lines)
Lines 309-317 sub GetBudgetSpent { Link Here
309
            quantityreceived > 0 AND
309
            quantityreceived > 0 AND
310
            datecancellationprinted IS NULL
310
            datecancellationprinted IS NULL
311
    |);
311
    |);
312
313
	$sth->execute($budget_id);
312
	$sth->execute($budget_id);
314
	my $sum =  $sth->fetchrow_array;
313
	my $sum =  $sth->fetchrow_array;
314
315
    $sth = $dbh->prepare(qq|
316
        SELECT SUM(shipmentcost) AS sum
317
        FROM invoices
318
        WHERE shipmentcost_budgetid = ?
319
          AND closedate IS NOT NULL
320
    |);
321
    $sth->execute($budget_id);
322
    my ($shipmentcost_sum) = $sth->fetchrow_array;
323
    $sum += $shipmentcost_sum;
324
315
	return $sum;
325
	return $sum;
316
}
326
}
317
327
Lines 325-333 sub GetBudgetOrdered { Link Here
325
            quantityreceived = 0 AND
335
            quantityreceived = 0 AND
326
            datecancellationprinted IS NULL
336
            datecancellationprinted IS NULL
327
    |);
337
    |);
328
329
	$sth->execute($budget_id);
338
	$sth->execute($budget_id);
330
	my $sum =  $sth->fetchrow_array;
339
	my $sum =  $sth->fetchrow_array;
340
341
    $sth = $dbh->prepare(qq|
342
        SELECT SUM(shipmentcost) AS sum
343
        FROM invoices
344
        WHERE shipmentcost_budgetid = ?
345
          AND closedate IS NULL
346
    |);
347
    $sth->execute($budget_id);
348
    my ($shipmentcost_sum) = $sth->fetchrow_array;
349
    $sum += $shipmentcost_sum;
350
331
	return $sum;
351
	return $sum;
332
}
352
}
333
353
(-)a/acqui/finishreceive.pl (-6 / +6 lines)
Lines 43-56 my $origquantityrec=$input->param('origquantityrec'); Link Here
43
my $quantityrec=$input->param('quantityrec');
43
my $quantityrec=$input->param('quantityrec');
44
my $quantity=$input->param('quantity');
44
my $quantity=$input->param('quantity');
45
my $unitprice=$input->param('cost');
45
my $unitprice=$input->param('cost');
46
my $invoiceno=$input->param('invoice');
46
my $invoiceid = $input->param('invoiceid');
47
my $datereceived=$input->param('datereceived');
47
my $invoice = GetInvoice($invoiceid);
48
my $invoiceno = $invoice->{invoicenumber};
49
my $datereceived= $invoice->{shipmentdate};
48
my $replacement=$input->param('rrp');
50
my $replacement=$input->param('rrp');
49
my $gst=$input->param('gst');
51
my $gst=$input->param('gst');
50
my $freight=$input->param('freight');
51
my $supplierid = $input->param('supplierid');
52
my $supplierid = $input->param('supplierid');
52
my $cnt=0;
53
my $cnt=0;
53
my $error_url_str;
54
my $ecost = $input->param('ecost');
54
my $ecost = $input->param('ecost');
55
my $note = $input->param("note");
55
my $note = $input->param("note");
56
56
Lines 111-117 if ($quantityrec > $origquantityrec ) { Link Here
111
    
111
    
112
    # save the quantity received.
112
    # save the quantity received.
113
	if( $quantityrec > 0 ) {
113
	if( $quantityrec > 0 ) {
114
    	$datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived);
114
    	$datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoice->{invoiceid},$replacement,undef,$datereceived);
115
	}
115
	}
116
}
116
}
117
    print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
117
    print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
(-)a/acqui/invoice.pl (+211 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
invoice.pl
22
23
=head1 DESCRIPTION
24
25
Invoice details
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
use C4::Acquisition;
36
use C4::Bookseller qw/GetBookSellerFromId/;
37
use C4::Budgets;
38
39
my $input = new CGI;
40
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
41
    template_name   => 'acqui/invoice.tmpl',
42
    query           => $input,
43
    type            => 'intranet',
44
    authnotrequired => 0,
45
    flagsrequired   => { 'acquisition' => '*' },
46
    debug           => 1,
47
} );
48
49
my $invoiceid = $input->param('invoiceid');
50
my $op = $input->param('op');
51
52
if($op && $op eq 'close') {
53
    CloseInvoice($invoiceid);
54
    my $referer = $input->param('referer');
55
    if($referer) {
56
        print $input->redirect($referer);
57
        exit 0;
58
    }
59
}elsif($op && $op eq 'reopen') {
60
    ReopenInvoice($invoiceid);
61
    my $referer = $input->param('referer');
62
    if($referer) {
63
        print $input->redirect($referer);
64
        exit 0;
65
    }
66
}elsif($op && $op eq 'mod') {
67
    my $shipmentdate = $input->param('shipmentdate');
68
    my $billingdate = $input->param('billingdate');
69
    my $shipmentcost = $input->param('shipmentcost');
70
    my $shipment_budget_id = $input->param('shipment_budget_id');
71
    ModInvoice(
72
        invoiceid => $invoiceid,
73
        shipmentdate   => C4::Dates->new($shipmentdate)->output("iso"),
74
        billingdate   => C4::Dates->new($billingdate)->output("iso"),
75
        shipmentcost  => $shipmentcost,
76
        shipmentcost_budgetid => $shipment_budget_id
77
    );
78
    $template->param(modified => 1);
79
}
80
81
my $details = GetInvoiceDetails($invoiceid);
82
my $bookseller = GetBookSellerFromId($details->{booksellerid});
83
my @orders_loop = ();
84
my $orders = $details->{'orders'};
85
my $qty_total;
86
my @books_loop;
87
my @book_foot_loop;
88
my %foot;
89
my $total_quantity = 0;
90
my $total_rrp = 0;
91
my $total_est = 0;
92
foreach my $order (@$orders) {
93
    my $line = get_infos( $order, $bookseller);
94
95
    $total_quantity += $$line{quantity};
96
    $total_rrp += $order->{quantity} * $order->{rrp};
97
    $total_est += $order->{quantity} * $order->{'ecost'};
98
99
    my %row = (%$order, %$line);
100
    push @orders_loop, \%row;
101
}
102
103
my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
104
my $discount = $bookseller->{'discount'} ? ($bookseller->{discount} / 100) : 0;
105
my $total_est_gste;
106
my $total_est_gsti;
107
my $total_rrp_gsti; # RRP Total, GST included
108
my $total_rrp_gste; # RRP Total, GST excluded
109
my $gist_est;
110
my $gist_rrp;
111
if ($gist){
112
    # if we have GST
113
    if ( $bookseller->{'listincgst'} ) {
114
        # if prices already includes GST
115
116
        # we know $total_rrp_gsti
117
        $total_rrp_gsti = $total_rrp;
118
        # and can reverse compute other values
119
        $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 );
120
121
        $gist_rrp       = $total_rrp_gsti - $total_rrp_gste;
122
        $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount );
123
        $total_est_gsti = $total_est;
124
    } else {
125
        # if prices does not include GST
126
127
        # then we use the common way to compute other values
128
        $total_rrp_gste = $total_rrp;
129
        $gist_rrp       = $total_rrp_gste * $gist;
130
        $total_rrp_gsti = $total_rrp_gste + $gist_rrp;
131
        $total_est_gste = $total_est;
132
        $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount );
133
   }
134
   $gist_est = $gist_rrp - ( $gist_rrp * $discount );
135
} else {
136
    $total_rrp_gsti = $total_rrp;
137
    $total_est_gsti = $total_est;
138
}
139
my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost};
140
141
my $format = "%.2f";
142
$template->param(
143
    total_rrp_gste => sprintf($format, $total_rrp_gste),
144
    total_rrp_gsti => sprintf($format, $total_rrp_gsti),
145
    total_est_gste => sprintf($format, $total_est_gste),
146
    total_est_gsti => sprintf($format, $total_est_gsti),
147
    gist_rrp => sprintf($format, $gist_rrp),
148
    gist_est => sprintf($format, $gist_est),
149
    total_gsti_shipment => sprintf($format, $total_gsti_shipment),
150
    gist => sprintf($format, $gist * 100),
151
);
152
153
my $budgets = GetBudgets();
154
my @budgets_loop;
155
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
156
foreach (@$budgets) {
157
    my %line = %{ $_ };
158
    if($shipmentcost_budgetid and $_->{'budget_id'} == $shipmentcost_budgetid) {
159
        $line{'selected'} = 1;
160
    }
161
    push @budgets_loop, \%line;
162
}
163
164
$template->param(
165
    invoiceid        => $details->{'invoiceid'},
166
    invoicenumber    => $details->{'invoicenumber'},
167
    suppliername     => $details->{'suppliername'},
168
    supplierid       => $details->{'booksellerid'},
169
    datereceived     => $details->{'datereceived'},
170
    shipmentdate     => C4::Dates->new($details->{'shipmentdate'}, "iso")->output(),
171
    billingdate      => C4::Dates->new($details->{'billingdate'}, "iso")->output(),
172
    invoiceclosedate => $details->{'closedate'},
173
    shipmentcost     => sprintf($format, $details->{'shipmentcost'}),
174
    orders_loop      => \@orders_loop,
175
    total_quantity   => $total_quantity,
176
    invoiceincgst    => $bookseller->{invoiceincgst},
177
    currency         => $bookseller->{listprice},
178
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
179
    budgets_loop     => \@budgets_loop,
180
);
181
182
sub get_infos {
183
    my $order = shift;
184
    my $bookseller = shift;
185
    my $qty = $order->{'quantity'} || 0;
186
    if ( !defined $order->{quantityreceived} ) {
187
        $order->{quantityreceived} = 0;
188
    }
189
    my $budget = GetBudget( $order->{'budget_id'} );
190
191
    my %line = %{ $order };
192
    $line{order_received} = ( $qty == $order->{'quantityreceived'} );
193
    $line{budget_name}    = $budget->{budget_name};
194
    $line{total} = $qty * $order->{ecost};
195
196
    if ( $line{uncertainprice} ) {
197
        $line{rrp} .= ' (Uncertain)';
198
    }
199
    if ( $line{'title'} ) {
200
        my $volume      = $order->{'volume'};
201
        my $seriestitle = $order->{'seriestitle'};
202
        $line{'title'} .= " / $seriestitle" if $seriestitle;
203
        $line{'title'} .= " / $volume"      if $volume;
204
    } else {
205
        $line{'title'} = "Deleted bibliographic notice, can't find title.";
206
    }
207
208
    return \%line;
209
}
210
211
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/invoices.pl (+152 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
invoices.pl
22
23
=head1 DESCRIPTION
24
25
Search for invoices
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
36
use C4::Acquisition;
37
use C4::Bookseller qw/GetBookSeller/;
38
use C4::Branch;
39
40
my $input = new CGI;
41
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
42
    template_name   => 'acqui/invoices.tmpl',
43
    query           => $input,
44
    type            => 'intranet',
45
    authnotrequired => 0,
46
    flagsrequired   => { 'acquisition' => '*' },
47
    debug           => 1,
48
} );
49
50
my $invoicenumber   = $input->param('invoicenumber');
51
my $supplier        = $input->param('supplier');
52
my $billingdatefrom = $input->param('billingdatefrom');
53
my $billingdateto   = $input->param('billingdateto');
54
my $isbneanissn     = $input->param('isbneanissn');
55
my $title           = $input->param('title');
56
my $author          = $input->param('author');
57
my $publisher       = $input->param('publisher');
58
my $publicationyear = $input->param('publicationyear');
59
my $branch          = $input->param('branch');
60
my $op              = $input->param('op');
61
62
my @results_loop = ();
63
if($op and $op eq "do_search") {
64
    my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso");
65
    my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso");
66
    my @invoices = GetInvoices(
67
        invoicenumber => $invoicenumber,
68
        suppliername => $supplier,
69
        billingdatefrom => $billingdatefrom_iso,
70
        billingdateto => $billingdateto_iso,
71
        isbneanissn => $isbneanissn,
72
        title => $title,
73
        author => $author,
74
        publisher => $publisher,
75
        publicationyear => $publicationyear,
76
        branchcode => $branch
77
    );
78
    foreach (@invoices) {
79
        my $billingdate = C4::Dates->new($_->{billingdate}, 'iso');
80
        my $closedate = C4::Dates->new($_->{closedate}, 'iso');
81
        my %row = (
82
            invoiceid       => $_->{invoiceid},
83
            billingdate     => $billingdate->output(),
84
            invoicenumber   => $_->{'invoicenumber'},
85
            suppliername    => $_->{'suppliername'},
86
            receivedbiblios => $_->{'receivedbiblios'},
87
            receiveditems   => $_->{'receiveditems'},
88
            subscriptionid  => $_->{subscriptionid},
89
            closedate => $closedate->output(),
90
        );
91
        push @results_loop, \%row;
92
    }
93
}
94
95
96
# Build suppliers list
97
my @suppliers = GetBookSeller(undef);
98
my @suppliers_loop = ();
99
my $suppliername;
100
foreach (@suppliers) {
101
    my $selected = 0;
102
    if ($supplier && $supplier == $_->{'id'}) {
103
        $selected = 1;
104
        $suppliername = $_->{'name'};
105
    }
106
    my %row = (
107
        suppliername => $_->{'name'},
108
        supplierid   => $_->{'id'},
109
        selected     => $selected,
110
    );
111
    push @suppliers_loop, \%row;
112
}
113
114
# Build branches list
115
my $branches = GetBranches();
116
my @branches_loop = ();
117
my $branchname;
118
foreach (sort keys %$branches) {
119
    my $selected = 0;
120
    if ($branch && $branch eq $_) {
121
        $selected = 1;
122
        $branchname = $branches->{$_}->{'branchname'};
123
    }
124
    my %row = (
125
        branchcode => $_,
126
        branchname => $branches->{$_}->{'branchname'},
127
        selected   => $selected,
128
    );
129
    push @branches_loop, \%row;
130
}
131
132
$template->param(
133
    do_search       => ($op and $op eq "do_search") ? 1 : 0,
134
    results_loop    => \@results_loop,
135
    invoicenumber   => $invoicenumber,
136
    supplier        => $supplier,
137
    suppliername    => $suppliername,
138
    billingdatefrom => $billingdatefrom,
139
    billingdateto   => $billingdateto,
140
    isbneanissn     => $isbneanissn,
141
    title           => $title,
142
    author          => $author,
143
    publisher       => $publisher,
144
    publicationyear => $publicationyear,
145
    branch          => $branch,
146
    branchname      => $branchname,
147
    suppliers_loop  => \@suppliers_loop,
148
    branches_loop   => \@branches_loop,
149
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
150
);
151
152
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/orderreceive.pl (-16 / +16 lines)
Lines 40-48 to know on what supplier this script has to display receive order. Link Here
40
40
41
=item receive
41
=item receive
42
42
43
=item invoice
43
=item invoiceid
44
44
45
the number of this invoice.
45
the id of this invoice.
46
46
47
=item freight
47
=item freight
48
48
Lines 61-67 The biblionumber of this order. Link Here
61
=cut
61
=cut
62
62
63
use strict;
63
use strict;
64
#use warnings; FIXME - Bug 2505
64
use warnings;
65
65
use CGI;
66
use CGI;
66
use C4::Context;
67
use C4::Context;
67
use C4::Koha;   # GetKohaAuthorisedValues GetItemTypes
68
use C4::Koha;   # GetKohaAuthorisedValues GetItemTypes
Lines 79-104 use C4::Biblio; Link Here
79
my $input      = new CGI;
80
my $input      = new CGI;
80
81
81
my $dbh          = C4::Context->dbh;
82
my $dbh          = C4::Context->dbh;
82
my $supplierid   = $input->param('supplierid');
83
my $invoiceid    = $input->param('invoiceid');
83
my $ordernumber       = $input->param('ordernumber');
84
my $invoice      = GetInvoice($invoiceid);
85
my $supplierid   = $invoice->{booksellerid};
86
my $freight      = $invoice->{shipmentcost};
87
my $datereceived = $invoice->{shipmentdate};
88
my $ordernumber  = $input->param('ordernumber');
84
my $search       = $input->param('receive');
89
my $search       = $input->param('receive');
85
my $invoice      = $input->param('invoice');
86
my $freight      = $input->param('freight');
87
my $datereceived = $input->param('datereceived');
88
89
90
90
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
91
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
91
92
92
my $bookseller = GetBookSellerFromId($supplierid);
93
my $bookseller = GetBookSellerFromId($supplierid);
93
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
94
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
94
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
95
my $results = SearchOrder($ordernumber,$search);
95
my $results = SearchOrder($ordernumber,$search);
96
96
97
98
my $count   = scalar @$results;
97
my $count   = scalar @$results;
99
my $order 	= GetOrder($ordernumber);
98
my $order 	= GetOrder($ordernumber);
100
99
101
102
my $date = @$results[0]->{'entrydate'};
100
my $date = @$results[0]->{'entrydate'};
103
101
104
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
102
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 155-161 if ( $count == 1 ) { Link Here
155
        rrp                   => @$results[0]->{'rrp'},
153
        rrp                   => @$results[0]->{'rrp'},
156
        ecost                 => @$results[0]->{'ecost'},
154
        ecost                 => @$results[0]->{'ecost'},
157
        unitprice             => @$results[0]->{'unitprice'},
155
        unitprice             => @$results[0]->{'unitprice'},
158
        invoice               => $invoice,
156
        invoiceid             => $invoice->{invoiceid},
157
        invoice               => $invoice->{invoicenumber},
159
        datereceived          => $datereceived->output(),
158
        datereceived          => $datereceived->output(),
160
        datereceived_iso          => $datereceived->output('iso'),
159
        datereceived_iso          => $datereceived->output('iso'),
161
        notes                       =>              $order->{notes}
160
        notes                       =>              $order->{notes}
Lines 166-172 else { Link Here
166
    for ( my $i = 0 ; $i < $count ; $i++ ) {
165
    for ( my $i = 0 ; $i < $count ; $i++ ) {
167
        my %line = %{ @$results[$i] };
166
        my %line = %{ @$results[$i] };
168
167
169
        $line{invoice}      = $invoice;
168
        $line{invoice}      = $invoice->{invoicenumber};
170
        $line{datereceived} = $datereceived->output();
169
        $line{datereceived} = $datereceived->output();
171
        $line{freight}      = $freight;
170
        $line{freight}      = $freight;
172
        $line{gst}          = $gst;
171
        $line{gst}          = $gst;
Lines 179-188 else { Link Here
179
    $template->param(
178
    $template->param(
180
        loop         => \@loop,
179
        loop         => \@loop,
181
        supplierid   => $supplierid,
180
        supplierid   => $supplierid,
181
        invoiceid    => $invoice->{invoiceid},
182
    );
182
    );
183
}
183
}
184
my $op = $input->param('op');
184
my $op = $input->param('op');
185
if ($op eq 'edit'){
185
if ($op and $op eq 'edit'){
186
    $template->param(edit   =>   1);
186
    $template->param(edit   =>   1);
187
}
187
}
188
output_html_with_http_headers $input, $cookie, $template->output;
188
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/parcel.pl (-132 / +119 lines)
Lines 42-49 To know the supplier this script has to show orders. Link Here
42
42
43
is the bookseller invoice number.
43
is the bookseller invoice number.
44
44
45
=item freight
46
47
45
48
=item gst
46
=item gst
49
47
Lines 57-63 To filter the results list on this given date. Link Here
57
=cut
55
=cut
58
56
59
use strict;
57
use strict;
60
#use warnings; FIXME - Bug 2505
58
use warnings;
59
61
use C4::Auth;
60
use C4::Auth;
62
use C4::Acquisition;
61
use C4::Acquisition;
63
use C4::Budgets;
62
use C4::Budgets;
Lines 70-85 use C4::Dates qw/format_date format_date_in_iso/; Link Here
70
use JSON;
69
use JSON;
71
70
72
my $input=new CGI;
71
my $input=new CGI;
73
my $supplierid=$input->param('supplierid');
72
74
my $bookseller=GetBookSellerFromId($supplierid);
73
my $invoiceid = $input->param('invoiceid');
75
74
my $invoice = GetInvoiceDetails($invoiceid);
76
my $invoice=$input->param('invoice') || '';
75
my $supplierid = $invoice->{booksellerid};
77
my $freight=$input->param('freight');
76
my $bookseller = GetBookSellerFromId($supplierid);
78
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
77
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
79
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
78
my $datereceived = C4::Dates->new();
80
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
81
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
82
$datereceived = C4::Dates->new() unless $datereceived;
83
my $code            = $input->param('code');
79
my $code            = $input->param('code');
84
my @rcv_err         = $input->param('error');
80
my @rcv_err         = $input->param('error');
85
my @rcv_err_barcode = $input->param('error_bc');
81
my @rcv_err_barcode = $input->param('error_bc');
Lines 89-104 my $resultsperpage = $input->param('resultsperpage'); Link Here
89
$resultsperpage = 20 unless ($resultsperpage);
85
$resultsperpage = 20 unless ($resultsperpage);
90
$startfrom=0 unless ($startfrom);
86
$startfrom=0 unless ($startfrom);
91
87
92
if($input->param('format') eq "json"){
88
my $format = $input->param('format') || '';
89
if($format eq "json"){
93
    my ($template, $loggedinuser, $cookie)
90
    my ($template, $loggedinuser, $cookie)
94
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
91
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
95
                 query => $input,
92
                 query => $input,
96
				 type => "intranet",
93
                 type => "intranet",
97
                 authnotrequired => 0,
94
                 authnotrequired => 0,
98
                 flagsrequired => {acquisition => 'order_receive'},
95
                 flagsrequired => {acquisition => 'order_receive'},
99
                 debug => 1,
96
                 debug => 1,
100
    });
97
    });
101
       
98
102
    my @datas;
99
    my @datas;
103
    my $search   = $input->param('search') || '';
100
    my $search   = $input->param('search') || '';
104
    my $supplier = $input->param('supplierid') || '';
101
    my $supplier = $input->param('supplierid') || '';
Lines 109-115 if($input->param('format') eq "json"){ Link Here
109
    foreach my $order (@$orders){
106
    foreach my $order (@$orders){
110
        if($order->{quantityreceived} < $order->{quantity}){
107
        if($order->{quantityreceived} < $order->{quantity}){
111
            my $data = {};
108
            my $data = {};
112
            
109
113
            $data->{basketno} = $order->{basketno};
110
            $data->{basketno} = $order->{basketno};
114
            $data->{ordernumber} = $order->{ordernumber};
111
            $data->{ordernumber} = $order->{ordernumber};
115
            $data->{title} = $order->{title};
112
            $data->{title} = $order->{title};
Lines 117-130 if($input->param('format') eq "json"){ Link Here
117
            $data->{isbn} = $order->{isbn};
114
            $data->{isbn} = $order->{isbn};
118
            $data->{booksellerid} = $order->{booksellerid};
115
            $data->{booksellerid} = $order->{booksellerid};
119
            $data->{biblionumber} = $order->{biblionumber};
116
            $data->{biblionumber} = $order->{biblionumber};
120
            $data->{freight} = $order->{freight};
121
            $data->{quantity} = $order->{quantity};
117
            $data->{quantity} = $order->{quantity};
122
            $data->{ecost} = $order->{ecost};
118
            $data->{ecost} = $order->{ecost};
123
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
119
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
124
            push @datas, $data;
120
            push @datas, $data;
125
        }
121
        }
126
    }
122
    }
127
    
123
128
    my $json_text = to_json(\@datas);
124
    my $json_text = to_json(\@datas);
129
    $template->param(return => $json_text);
125
    $template->param(return => $json_text);
130
    output_html_with_http_headers $input, $cookie, $template->output;
126
    output_html_with_http_headers $input, $cookie, $template->output;
Lines 134-140 if($input->param('format') eq "json"){ Link Here
134
my ($template, $loggedinuser, $cookie)
130
my ($template, $loggedinuser, $cookie)
135
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
131
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
136
                 query => $input,
132
                 query => $input,
137
				 type => "intranet",
133
                 type => "intranet",
138
                 authnotrequired => 0,
134
                 authnotrequired => 0,
139
                 flagsrequired => {acquisition => 'order_receive'},
135
                 flagsrequired => {acquisition => 'order_receive'},
140
                 debug => 1,
136
                 debug => 1,
Lines 154-163 if( scalar(@rcv_err) ) { Link Here
154
}
150
}
155
151
156
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
152
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
157
my @parcelitems   = GetParcel($supplierid, $invoice, $datereceived->output('iso'));
153
my @parcelitems   = @{ $invoice->{orders} };
158
my $countlines    = scalar @parcelitems;
154
my $countlines    = scalar @parcelitems;
159
my $totalprice    = 0;
155
my $totalprice    = 0;
160
my $totalfreight  = 0;
161
my $totalquantity = 0;
156
my $totalquantity = 0;
162
my $total;
157
my $total;
163
my $tototal;
158
my $tototal;
Lines 165-316 my @loop_received = (); Link Here
165
160
166
for (my $i = 0 ; $i < $countlines ; $i++) {
161
for (my $i = 0 ; $i < $countlines ; $i++) {
167
162
168
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
163
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};
169
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
170
    $parcelitems[$i]->{'unitprice'} += 0;
164
    $parcelitems[$i]->{'unitprice'} += 0;
171
    my %line;
165
    my %line;
172
    %line          = %{ $parcelitems[$i] };
166
    %line          = %{ $parcelitems[$i] };
173
    $line{invoice} = $invoice;
167
    $line{invoice} = $invoice->{invoicenumber};
174
    $line{gst}     = $gst;
168
    $line{gst}     = $gst;
175
    $line{total} = sprintf($cfstr, $total);
169
    $line{total} = sprintf($cfstr, $total);
176
    $line{supplierid} = $supplierid;
170
    $line{supplierid} = $invoice->{booksellerid};
177
    push @loop_received, \%line;
171
    push @loop_received, \%line;
178
    $totalprice += $parcelitems[$i]->{'unitprice'};
172
    $totalprice += $parcelitems[$i]->{'unitprice'};
179
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
173
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
180
174
181
    #double FIXME - totalfreight is redefined later.
182
183
# FIXME - each order in a  parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget..
184
    if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
185
        warn "FREIGHT CHARGE MISMATCH!!";
186
    }
187
    $totalfreight = $parcelitems[$i]->{'freight'};
188
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
175
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
189
    $tototal       += $total;
176
    $tototal       += $total;
190
}
177
}
191
178
192
my $pendingorders = GetPendingOrders($supplierid);
179
if(!defined $invoice->{closedate}) {
193
my $countpendings = scalar @$pendingorders;
180
    my $pendingorders = GetPendingOrders($supplierid);
194
181
    my $countpendings = scalar @$pendingorders;
195
# pending orders totals
182
196
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
183
    # pending orders totals
197
my $ordergrandtotal;
184
    my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
198
my @loop_orders = ();
185
    my $ordergrandtotal;
199
for (my $i = 0 ; $i < $countpendings ; $i++) {
186
    my @loop_orders = ();
200
    my %line;
187
    for (my $i = 0 ; $i < $countpendings ; $i++) {
201
    %line = %{$pendingorders->[$i]};
188
        my %line;
202
   
189
        %line = %{$pendingorders->[$i]};
203
    $line{quantity}+=0;
190
       
204
    $line{quantityreceived}+=0;
191
        $line{quantity}+=0;
205
    $line{unitprice}+=0;
192
        $line{quantityreceived}+=0;
206
    $totalPunitprice += $line{unitprice};
193
        $line{unitprice}+=0;
207
    $totalPquantity +=$line{quantity};
194
        $totalPunitprice += $line{unitprice};
208
    $totalPqtyrcvd +=$line{quantityreceived};
195
        $totalPquantity +=$line{quantity};
209
    $totalPecost += $line{ecost};
196
        $totalPqtyrcvd +=$line{quantityreceived};
210
    $line{ecost} = sprintf("%.2f",$line{ecost});
197
        $totalPecost += $line{ecost};
211
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
198
        $line{ecost} = sprintf("%.2f",$line{ecost});
212
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
199
        $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
213
    $line{invoice} = $invoice;
200
        $line{unitprice} = sprintf("%.2f",$line{unitprice});
214
    $line{gst} = $gst;
201
        $line{invoice} = $invoice;
215
    $line{total} = $total;
202
        $line{gst} = $gst;
216
    $line{supplierid} = $supplierid;
203
        $line{total} = $total;
217
    $ordergrandtotal += $line{ecost} * $line{quantity};
204
        $line{supplierid} = $supplierid;
218
    
205
        $ordergrandtotal += $line{ecost} * $line{quantity};
219
    my $biblionumber = $line{'biblionumber'};
206
        
220
    my $countbiblio = CountBiblioInOrders($biblionumber);
207
        my $biblionumber = $line{'biblionumber'};
221
    my $ordernumber = $line{'ordernumber'};
208
        my $countbiblio = CountBiblioInOrders($biblionumber);
222
    my @subscriptions = GetSubscriptionsId ($biblionumber);
209
        my $ordernumber = $line{'ordernumber'};
223
    my $itemcount = GetItemsCount($biblionumber);
210
        my @subscriptions = GetSubscriptionsId ($biblionumber);
224
    my $holds  = GetHolds ($biblionumber);
211
        my $itemcount = GetItemsCount($biblionumber);
225
    my @items = GetItemnumbersFromOrder( $ordernumber );
212
        my $holds  = GetHolds ($biblionumber);
226
    my $itemholds;
213
        my @items = GetItemnumbersFromOrder( $ordernumber );
227
    foreach my $item (@items){
214
        my $itemholds;
228
        my $nb = GetItemHolds($biblionumber, $item);
215
        foreach my $item (@items){
229
        if ($nb){
216
            my $nb = GetItemHolds($biblionumber, $item);
230
            $itemholds += $nb;
217
            if ($nb){
218
                $itemholds += $nb;
219
            }
231
        }
220
        }
221
        
222
        # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
223
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
224
        $line{items}                = ($itemcount) - (scalar @items);
225
        $line{left_item}            = 1 if $line{items} >= 1;
226
        $line{left_biblio}          = 1 if $countbiblio > 1;
227
        $line{biblios}              = $countbiblio - 1;
228
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
229
        $line{subscriptions}        = scalar @subscriptions;
230
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
231
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
232
        $line{holds}                = $holds;
233
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
234
        
235
        
236
        push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
232
    }
237
    }
233
    
234
    # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
235
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
236
    $line{items}                = ($itemcount) - (scalar @items);
237
    $line{left_item}            = 1 if $line{items} >= 1;
238
    $line{left_biblio}          = 1 if $countbiblio > 1;
239
    $line{biblios}              = $countbiblio - 1;
240
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
241
    $line{subscriptions}        = scalar @subscriptions;
242
    $line{left_holds}           = 1 if $holds >= 1;
243
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
244
    $line{holds}                = $holds;
245
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
246
    
247
    
248
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
249
}
250
$freight = $totalfreight unless $freight;
251
238
252
my $count = $countpendings;
239
    my $count = $countpendings;
253
240
254
if ($count>$resultsperpage){
241
    if ($count>$resultsperpage){
255
    my $displaynext=0;
242
        my $displaynext=0;
256
    my $displayprev=$startfrom;
243
        my $displayprev=$startfrom;
257
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
244
        if(($count - ($startfrom+$resultsperpage)) > 0 ) {
258
        $displaynext = 1;
245
            $displaynext = 1;
259
    }
246
        }
260
247
261
    my @numbers = ();
248
        my @numbers = ();
262
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
249
        for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
263
            my $highlight=0;
250
                my $highlight=0;
264
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
251
                ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
265
            push @numbers, { number => $i,
252
                push @numbers, { number => $i,
266
                highlight => $highlight ,
253
                    highlight => $highlight ,
267
                startfrom => ($i-1)*$resultsperpage};
254
                    startfrom => ($i-1)*$resultsperpage};
268
    }
255
        }
269
256
270
    my $from = $startfrom*$resultsperpage+1;
257
        my $from = $startfrom*$resultsperpage+1;
271
    my $to;
258
        my $to;
272
    if($count < (($startfrom+1)*$resultsperpage)){
259
        if($count < (($startfrom+1)*$resultsperpage)){
273
        $to = $count;
260
            $to = $count;
274
    } else {
261
        } else {
275
        $to = (($startfrom+1)*$resultsperpage);
262
            $to = (($startfrom+1)*$resultsperpage);
263
        }
264
        $template->param(numbers=>\@numbers,
265
                         displaynext=>$displaynext,
266
                         displayprev=>$displayprev,
267
                         nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
268
                         prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
269
                        );
276
    }
270
    }
277
    $template->param(numbers=>\@numbers,
271
278
                     displaynext=>$displaynext,
272
    $template->param(
279
                     displayprev=>$displayprev,
273
        countpending => $countpendings,
280
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
274
        loop_orders  => \@loop_orders,
281
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
275
        ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
282
                    );
276
        totalPunitprice => sprintf("%.2f", $totalPunitprice),
277
        totalPquantity  => $totalPquantity,
278
        totalPqtyrcvd   => $totalPqtyrcvd,
279
        totalPecost     => sprintf("%.2f", $totalPecost),
280
    );
283
}
281
}
284
282
285
#$totalfreight=$freight;
286
$tototal = $tototal + $freight;
287
283
288
$template->param(
284
$template->param(
289
    invoice               => $invoice,
285
    invoiceid             => $invoice->{invoiceid},
286
    invoice               => $invoice->{invoicenumber},
287
    invoiceclosedate      => $invoice->{closedate},
290
    datereceived          => $datereceived->output('iso'),
288
    datereceived          => $datereceived->output('iso'),
291
    invoicedatereceived   => $datereceived->output('iso'),
289
    invoicedatereceived   => $datereceived->output('iso'),
292
    formatteddatereceived => $datereceived->output(),
290
    formatteddatereceived => $datereceived->output(),
293
    name                  => $bookseller->{'name'},
291
    name                  => $bookseller->{'name'},
294
    supplierid            => $supplierid,
292
    supplierid            => $bookseller->{id},
295
    gst                   => $gst,
293
    gst                   => $gst,
296
    freight               => $freight,
297
    invoice               => $invoice,
298
    countreceived         => $countlines,
294
    countreceived         => $countlines,
299
    loop_received         => \@loop_received,
295
    loop_received         => \@loop_received,
300
    countpending          => $countpendings,
301
    loop_orders           => \@loop_orders,
302
    totalprice            => sprintf($cfstr, $totalprice),
296
    totalprice            => sprintf($cfstr, $totalprice),
303
    totalfreight          => $totalfreight,
304
    totalquantity         => $totalquantity,
297
    totalquantity         => $totalquantity,
305
    tototal               => sprintf($cfstr, $tototal),
298
    tototal               => sprintf($cfstr, $tototal),
306
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
307
    gst                   => $gst,
299
    gst                   => $gst,
308
    grandtot              => sprintf($cfstr, $tototal + $gst),
300
    grandtot              => sprintf($cfstr, $tototal + $gst),
309
    totalPunitprice       => sprintf("%.2f", $totalPunitprice),
310
    totalPquantity        => $totalPquantity,
311
    totalPqtyrcvd         => $totalPqtyrcvd,
312
    totalPecost           => sprintf("%.2f", $totalPecost),
313
    resultsperpage        => $resultsperpage,
301
    resultsperpage        => $resultsperpage,
314
);
302
);
315
output_html_with_http_headers $input, $cookie, $template->output;
303
output_html_with_http_headers $input, $cookie, $template->output;
316
 
(-)a/acqui/parcels.pl (-10 / +38 lines)
Lines 84-89 my $code = $input->param('filter'); Link Here
84
my $datefrom       = $input->param('datefrom');
84
my $datefrom       = $input->param('datefrom');
85
my $dateto         = $input->param('dateto');
85
my $dateto         = $input->param('dateto');
86
my $resultsperpage = $input->param('resultsperpage');
86
my $resultsperpage = $input->param('resultsperpage');
87
my $op             = $input->param('op');
87
$resultsperpage ||= 20;
88
$resultsperpage ||= 20;
88
89
89
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
90
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 96-103 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
96
    }
97
    }
97
);
98
);
98
99
100
if($op and $op eq 'new') {
101
    my $invoicenumber = $input->param('invoice');
102
    my $shipmentdate = $input->param('shipmentdate');
103
    if($shipmentdate) {
104
        $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
105
    }
106
    my $invoiceid = AddInvoice(
107
        invoicenumber => $invoicenumber,
108
        booksellerid => $supplierid,
109
        shipmentdate => $shipmentdate,
110
    );
111
    if(defined $invoiceid) {
112
        # Successful 'Add'
113
        print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
114
        exit 0;
115
    } else {
116
        $template->param(error_failed_to_create_invoice => 1);
117
    }
118
}
119
99
my $bookseller = GetBookSellerFromId($supplierid);
120
my $bookseller = GetBookSellerFromId($supplierid);
100
my @parcels = GetParcels( $supplierid, $order, $code, $datefrom, $dateto );
121
my @parcels = GetInvoices(
122
    supplierid => $supplierid,
123
    invoicenumber => $code,
124
    shipmentdatefrom => $datefrom,
125
    shipmentdateto => $dateto,
126
    order_by => $order
127
);
101
my $count_parcels = @parcels;
128
my $count_parcels = @parcels;
102
129
103
# multi page display gestion
130
# multi page display gestion
Lines 114-127 for my $i ( $startfrom .. $last_row) { Link Here
114
141
115
    push @{$loopres},
142
    push @{$loopres},
116
      { number           => $i + 1,
143
      { number           => $i + 1,
117
        code             => $p->{booksellerinvoicenumber},
144
        invoiceid        => $p->{invoiceid},
118
        nullcode         => $p->{booksellerinvoicenumber} eq 'NULL',
145
        code             => $p->{invoicenumber},
119
        emptycode        => $p->{booksellerinvoicenumber} eq q{},
146
        nullcode         => $p->{invoicenumber} eq 'NULL',
120
        raw_datereceived => $p->{datereceived},
147
        emptycode        => $p->{invoicenumber} eq q{},
121
        datereceived     => format_date( $p->{datereceived} ),
148
        raw_datereceived => $p->{shipmentdate},
122
        bibcount         => $p->{biblio},
149
        datereceived     => format_date( $p->{shipmentdate} ),
123
        reccount         => $p->{itemsreceived},
150
        bibcount         => $p->{receivedbiblios} || 0,
124
        itemcount        => $p->{itemsexpected},
151
        reccount         => $p->{receiveditems} || 0,
152
        itemcount        => $p->{itemsexpected} || 0,
125
      };
153
      };
126
}
154
}
127
if ($count_parcels) {
155
if ($count_parcels) {
Lines 135-141 $template->param( Link Here
135
    resultsperpage           => $resultsperpage,
163
    resultsperpage           => $resultsperpage,
136
    name                     => $bookseller->{'name'},
164
    name                     => $bookseller->{'name'},
137
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
165
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
138
    datereceived_today       => C4::Dates->new()->output(),
166
    shipmentdate_today       => C4::Dates->new()->output(),
139
    supplierid               => $supplierid,
167
    supplierid               => $supplierid,
140
    GST                      => C4::Context->preference('gist'),
168
    GST                      => C4::Context->preference('gist'),
141
);
169
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc (+1 lines)
Lines 1-6 Link Here
1
<ul>
1
<ul>
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
    [% IF ( CAN_user_acquisition_budget_manage ) %]
5
    [% IF ( CAN_user_acquisition_budget_manage ) %]
5
	<li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets &amp; Funds</a></li>
6
	<li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets &amp; Funds</a></li>
6
    [% END %]
7
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (+172 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
6
<script type="text/javascript">
7
//<![CDATA[
8
    $(document).ready(function() {
9
        $("#orderst").tablesorter({widgets : ['zebra']});
10
        Calendar.setup({
11
            inputField: "shipmentdate",
12
            ifFormat: "[% DHTMLcalendar_dateformat %]",
13
            button: "shipmentdateCalendar"
14
        });
15
        Calendar.setup({
16
            inputField: "billingdate",
17
            ifFormat: "[% DHTMLcalendar_dateformat %]",
18
            button: "billingdateCalendar"
19
        });
20
    });
21
//]]>
22
</script>
23
</head>
24
25
<body>
26
[% INCLUDE 'header.inc' %]
27
[% INCLUDE 'acquisitions-search.inc' %]
28
29
<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; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">[% invoicenumber %]</a></div>
30
31
<div id="doc3" class="yui-t2">
32
33
<div id="bd">
34
  <div id="yui-main">
35
    <div class="yui-b">
36
      [% IF ( modified ) %]
37
        <div class="dialog">
38
          <p>Invoice has been modified</p>
39
        </div>
40
      [% END %]
41
      <h1>Invoice: [% invoicenumber %]</h1>
42
43
      <p>Supplier: [% suppliername %]</p>
44
      <form action="" method="post">
45
        <label for="shipmentdate">Shipment date:</label>
46
        <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate %]" readonly="readonly" />
47
        <img id="shipmentdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
48
        <p></p>
49
        <label for="billingdate">Billing date:</label>
50
        <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate %]" readonly="readonly" />
51
        <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
52
        <p></p>
53
        <label for="shipmentcost">Shipment cost:</label>
54
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
55
        <label for="shipment_budget_id">Budget:</label>
56
        <select id="shipment_budget_id" name="shipment_budget_id">
57
            <option value="">No budget</option>
58
          [% FOREACH budget IN budgets_loop %]
59
            [% IF ( budget.selected ) %]
60
              <option selected="selected" value="[% budget.budget_id %]">
61
            [% ELSE %]
62
              <option value="[% budget.budget_id %]">
63
            [% END %]
64
              [% budget.budget_name %]
65
            </option>
66
          [% END %]
67
        </select>
68
        <input type="hidden" name="op" value="mod" />
69
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
70
        <fieldset class="action">
71
            <input type="submit" value="Save">
72
        </fieldset>
73
      </form>
74
      <p>Status:
75
        [% IF ( invoiceclosedate ) %]
76
          Closed on [% invoiceclosedate %].
77
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
78
            Reopen
79
          </a>
80
        [% ELSE %]
81
          Open.
82
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
83
            Close
84
          </a>
85
        [% END %]
86
      </p>
87
      <p>
88
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
89
      </p>
90
      <h2>Invoice details</h2>
91
      <table id="orderst">
92
        <thead>
93
          <tr>
94
            <th>Summary</th>
95
            <th>Publisher</th>
96
            <th>Branch</th>
97
            <th>RRP</th>
98
            <th>Est.</th>
99
            <th>Qty.</th>
100
            <th>Total</th>
101
            <th>Fund</th>
102
          </tr>
103
        </thead>
104
        <tbody>
105
          [% FOREACH order IN orders_loop %]
106
            <tr>
107
              <td><p>[% order.title %]
108
                [% IF ( order.author ) %]
109
                  <br /><em>by</em> [% order.author %]
110
                [% END %]
111
              </p></td>
112
              <td>
113
                [% IF ( order.publishercode ) %]
114
                  <p>[% order.publishercode %]
115
                    [% IF ( order.publicationyear ) %]
116
                      - [% order.publicationyear %]
117
                    [% END %]
118
                  </p>
119
                [% END %]
120
              </td>
121
              <td><p>[% order.branchcode %]</p></td>
122
              <td>[% order.rrp %]</td>
123
              <td>[% order.ecost %]</td>
124
              <td class="number">[% order.quantity %]</td>
125
              <td>[% order.total %]</td>
126
              <td>[% order.budget_name %]</td>
127
            </tr>
128
          [% END %]
129
        </tbody>
130
        <tfoot>
131
            <tr>
132
                <th colspan="3">Total Tax Exc.</th>
133
                <th>[% total_rrp_gste %]</th>
134
                <th>&nbsp;</th>
135
                <th>[% total_quantity %]</th>
136
                <th>[% total_est_gste %]</th>
137
                <th>&nbsp;</th>
138
            </tr>
139
            <tr>
140
                <th colspan='3'>Tax ([% gist %]%)</th>
141
                <th>[% gist_rrp %]</th>
142
                <th>&nbsp;</th>
143
                <th>&nbsp;</th>
144
                <th>[% gist_est %]</th>
145
                <th>&nbsp;</th>
146
            </tr>
147
            <tr>
148
                <th colspan='3'>Total Tax Inc. ([% currency %])</th>
149
                <th>[% total_rrp_gsti %]</th>
150
                <th>&nbsp;</th>
151
                <th>[% total_quantity %]</th>
152
                <th>[% total_est_gsti %]</th>
153
                <th>&nbsp;</th>
154
            </tr>
155
            <tr>
156
                <th colspan="3">Total + Shipment cost ([% currency %])</th>
157
                <th>&nbsp;</th>
158
                <th>&nbsp;</th>
159
                <th>[% total_quantity %]</th>
160
                <th>[% total_gsti_shipment %]</th>
161
                <th>&nbsp;</th>
162
            </tr>
163
        </tfoot>
164
      </table>
165
166
    </div>
167
  </div>
168
  <div class="yui-b">
169
    [% INCLUDE 'acquisitions-menu.inc' %]
170
  </div>
171
</div>
172
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+217 lines)
Line 0 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoices</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
5
[% INCLUDE 'calendar.inc' %]
6
<script type="text/javascript">
7
//<![CDATA[
8
$(document).ready(function() {
9
    Calendar.setup({
10
        inputField: "billingdatefrom",
11
        ifFormat: "[% DHTMLcalendar_dateformat %]",
12
        button: "billingdatefromCalendar"
13
    });
14
    Calendar.setup({
15
        inputField: "billingdateto",
16
        ifFormat: "[% DHTMLcalendar_dateformat %]",
17
        button: "billingdatetoCalendar"
18
    });
19
    $("#resultst").tablesorter({
20
        widgets : ['zebra'],
21
        headers: {
22
            6: { sorter: false },
23
        }
24
    });
25
});
26
//]]>
27
</script>
28
</head>
29
30
<body>
31
[% INCLUDE 'header.inc' %]
32
[% INCLUDE 'acquisitions-search.inc' %]
33
34
<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; Invoices</div>
35
36
<div id="doc3" class="yui-t2">
37
38
<div id="bd">
39
  <div id="yui-main">
40
    <div class="yui-b">
41
      <h1>Invoices</h1>
42
      [% IF ( do_search ) %]
43
        [% IF ( results_loop ) %]
44
          <table id="resultst">
45
            <thead>
46
              <tr>
47
                <th>Invoice no.</th>
48
                <th>Vendor</th>
49
                <th>Billing date</th>
50
                <th>Received biblios</th>
51
                <th>Received items</th>
52
                <th>Status</th>
53
                <th>&nbsp;</th>
54
              </tr>
55
            </thead>
56
            <tbody>
57
              [% FOREACH result IN results_loop %]
58
                <tr>
59
                  <td>[% result.invoicenumber %]</td>
60
                  <td>[% result.suppliername %]</td>
61
                  <td>[% result.billingdate %]</td>
62
                  <td>[% result.receivedbiblios %]</td>
63
                  <td>[% result.receiveditems %]</td>
64
                  <td>
65
                    [% IF ( result.closedate ) %]
66
                      Closed on [% result.closedate %]
67
                    [% ELSE %]
68
                      Open
69
                    [% END %]
70
                  </td>
71
                  <td>
72
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
73
                    [% IF ( result.closedate ) %]
74
                      <a href="invoice.pl?op=reopen&invoiceid=[% result.invoiceid %]">Reopen</a>
75
                    [% ELSE %]
76
                      <a href="invoice.pl?op=close&invoiceid=[% result.invoiceid %]">Close</a>
77
                    [% END %]
78
                  </td>
79
                </tr>
80
              [% END %]
81
            </tbody>
82
          </table>
83
        [% ELSE %]
84
          <p>Sorry, but there is no results for your search.</p>
85
          <p>Search was:
86
            <ul>
87
              [% IF ( invoicenumber ) %]
88
                <li>Invoice no.: [% invoicenumber %]</li>
89
              [% END %]
90
              [% IF ( supplier ) %]
91
                <li>Vendor: [% suppliername %]</li>
92
              [% END %]
93
              [% IF ( billingdatefrom ) %]
94
                <li>Billing date:
95
                [% IF ( billingdateto ) %]
96
                  From [% billingdatefrom %]
97
                  To [% billingdateto %]
98
                [% ELSE %]
99
                  All since [% billingdatefrom %]
100
                [% END %]
101
                </li>
102
              [% ELSE %]
103
                [% IF ( billingdateto ) %]
104
                  <li>Billing date:
105
                    All until [% billingdateto %]
106
                  </li>
107
                [% END %]
108
              [% END %]
109
              [% IF ( isbneanissn ) %]
110
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
111
              [% END %]
112
              [% IF ( title ) %]
113
                <li>Title: [% title %]</li>
114
              [% END %]
115
              [% IF ( author ) %]
116
                <li>Author: [% author %]</li>
117
              [% END %]
118
              [% IF ( publisher ) %]
119
                <li>Publisher: [% publisher %]</li>
120
              [% END %]
121
              [% IF ( publicationyear ) %]
122
                <li>Publication year: [% publicationyear %]</li>
123
              [% END %]
124
              [% IF ( branch ) %]
125
                <li>Branch: [% branchname %]</li>
126
              [% END %]
127
            </ul>
128
          </p>
129
        [% END %]<!-- results_loop -->
130
      [% ELSE %]
131
        <p>Please fill in the form to the left to make a search.</p>
132
      [% END %]<!-- do_search -->
133
    </div>
134
  </div>
135
  <div class="yui-b">
136
    <form action="" method="get">
137
      <fieldset class="brief">
138
        <h3>Search filters</h3>
139
        <ol>
140
          <li>
141
            <label for="invoicenumber">Invoice no:</label>
142
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
143
          </li>
144
          <li>
145
            <label for="supplier">Supplier:</label>
146
            <select id="supplier" name="supplier">
147
              <option value="">All</option>
148
              [% FOREACH supplier IN suppliers_loop %]
149
                [% IF ( supplier.selected ) %]
150
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
151
                [% ELSE %]
152
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
153
                [% END %]
154
              [% END %]
155
            </select>
156
          </li>
157
          <li>
158
            <fieldset class="brief">
159
              <legend>Billing date</legend>
160
              <ol>
161
                <li>
162
                  <label for="billingdatefrom">From:</label>
163
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" />
164
                  <img id="billingdatefromCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
165
                </li>
166
                <li>
167
                  <label for="billingdateto">To:</label>
168
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" />
169
                  <img id="billingdatetoCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
170
                </li>
171
              </ol>
172
            </fieldset>
173
          </li>
174
          <li>
175
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
176
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
177
          </li>
178
          <li>
179
            <label for="title">Title:</label>
180
            <input type="text" id="title" name="title" value="[% title %]" />
181
          </li>
182
          <li>
183
            <label for="author">Author:</label>
184
            <input type="text" id="author" name="author" value="[% author %]" />
185
          </li>
186
          <li>
187
            <label for="publisher">Publisher:</label>
188
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
189
          </li>
190
          <li>
191
            <label for="publicationyear">Publication year:</label>
192
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
193
          </li>
194
          <li>
195
            <label for="branch">Branch:</label>
196
            <select id="branch" name="branch">
197
              <option value="">All</option>
198
              [% FOREACH branch IN branches_loop %]
199
                [% IF ( branch.selected ) %]
200
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
201
                [% ELSE %]
202
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
203
                [% END %]
204
              [% END %]
205
            </select>
206
          </li>
207
        </ol>
208
        <fieldset class="action">
209
          <input type="submit" value="Search" />
210
        </fieldset>
211
      </fieldset>
212
      <input type="hidden" name="op" id="op" value="do_search" />
213
    </form>
214
    [% INCLUDE 'acquisitions-menu.inc' %]
215
  </div>
216
</div>
217
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +3 lines)
Lines 78-88 Link Here
78
    </fieldset>
78
    </fieldset>
79
    [% END %] <!-- items -->
79
    [% END %] <!-- items -->
80
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
80
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
81
    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
81
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
82
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
82
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
83
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
83
    <input type="hidden" name="supplierid" value="[% supplierid %]" />
84
    <input type="hidden" name="supplierid" value="[% supplierid %]" />
84
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
85
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
85
    <input type="hidden" name="freight" value="[% freight %]" />
86
    <input type="hidden" name="gst" value="[% gst %]" />
86
    <input type="hidden" name="gst" value="[% gst %]" />
87
	</div>
87
	</div>
88
	<div class="yui-u">
88
	<div class="yui-u">
Lines 128-139 Link Here
128
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
128
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
129
        [% END %]</li></ol>
129
        [% END %]</li></ol>
130
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
130
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
131
        <input type="hidden" name="invoice" value="[% invoice %]" />
132
    </fieldset>
131
    </fieldset>
133
132
134
</div>
133
</div>
135
</div><div class="yui-g"><fieldset class="action">
134
</div><div class="yui-g"><fieldset class="action">
136
        <input type="button"  value="Save" onclick="javascript:if(check_additem()) { this.form.submit(); } else { alert( _('Duplicate barcodes detected.  Please correct the errors and resubmit.') ); return false };" /> <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?supplierid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
135
        <input type="button"  value="Save" onclick="javascript:if(check_additem()) { this.form.submit(); } else { alert( _('Duplicate barcodes detected.  Please correct the errors and resubmit.') ); return false };" /> <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Cancel</a>
137
</fieldset></div>    </form>
136
</fieldset></div>    </form>
138
[% ELSE %]
137
[% ELSE %]
139
<div id="acqui_acquire_orderlist">
138
<div id="acqui_acquire_orderlist">
Lines 150-156 Link Here
150
        <tr>
149
        <tr>
151
            <td>[% loo.basketno %]</td>
150
            <td>[% loo.basketno %]</td>
152
            <td>[% loo.isbn %]</td>
151
            <td>[% loo.isbn %]</td>
153
         <td><a href="orderreceive.pl?datereceived=[% loo.datereceived %]&amp;receive=[% loo.ordernumber %]&amp;biblio=[% loo.biblionumber %]&amp;invoice=[% loo.invoice %]&amp;freight=[% loo.freight %]&amp;gst=[% loo.gst %]&amp;id=[% loo.id %]">[% loo.title |html %]</a></td>
152
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
154
            <td>[% loo.author %]</td>
153
            <td>[% loo.author %]</td>
155
            <td>[% loo.quantity %]</td>
154
            <td>[% loo.quantity %]</td>
156
            <td>[% loo.quantityreceived %]</td>
155
            <td>[% loo.quantityreceived %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-97 / +111 lines)
Lines 157-167 Link Here
157
[% INCLUDE 'header.inc' %]
157
[% INCLUDE 'header.inc' %]
158
[% INCLUDE 'acquisitions-search.inc' %]
158
[% INCLUDE 'acquisitions-search.inc' %]
159
159
160
<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 ( datereceived ) %]
160
<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;
161
            Receipt Summary for <i>[% name %]</i> [% IF ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
161
    [% IF ( datereceived ) %]
162
        [% ELSE %]
162
        Receipt Summary for <i>[% name %]</i>
163
            Receive orders from [% name %]
163
        [% IF ( invoice ) %]
164
        [% END %]</div>
164
            <i>[ [% invoice %] ]</i>
165
        [% END %]
166
        on <i>[% formatteddatereceived %]</i>
167
    [% ELSE %]
168
        Receive orders from [% name %]
169
    [% END %]
170
</div>
165
171
166
<div id="doc3" class="yui-t2">
172
<div id="doc3" class="yui-t2">
167
173
Lines 199-300 Link Here
199
205
200
<div id="acqui_receive_summary">
206
<div id="acqui_receive_summary">
201
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
207
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
202
	<!-- TODO: Add date picker, change rcv date. -->
208
<p><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">Go to invoice details</a></p>
203
</div>
209
</div>
204
<div id="acqui_receive_search">
210
[% UNLESS (invoiceclosedate) %]
205
    <h3>Pending Orders</h3>
211
    <div id="acqui_receive_search">
206
212
        <h3>Pending Orders</h3>
207
 [% IF ( loop_orders ) %]<table id="pendingt">
213
208
    <thead>
214
     [% IF ( loop_orders ) %]<table id="pendingt">
209
        <tr>
215
        <thead>
210
            <th>Basket</th>
211
            <th>Order Line</th>
212
            <th>Summary</th>
213
    	    <th>View Record</th>
214
            <th>Quantity</th>
215
            <th>Unit cost</th>
216
            <th>Order cost</th>
217
            <th>&nbsp;</th>
218
            <th>&nbsp;</th>
219
        </tr>
220
    </thead>
221
		<tfoot>
222
            <tr><td colspan="4" class="total">TOTAL</td>
223
                <td> [% totalPquantity %] </td>
224
				<td>&nbsp;</td>
225
                <td>[% ordergrandtotal %]</td>
226
				<td>&nbsp;</td>
227
				<td>&nbsp;</td>
228
            </tr>
229
		</tfoot>
230
    <tbody class="filterclass">
231
        [% FOREACH loop_order IN loop_orders %]
232
	[% UNLESS ( loop.odd ) %]
233
            <tr class="highlight">
234
        [% ELSE %]
235
            <tr>
216
            <tr>
236
        [% END %]
217
                <th>Basket</th>
237
                <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
218
                <th>Order Line</th>
238
                <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.supplierid %]">[% loop_order.ordernumber %]</a></td>
219
                <th>Summary</th>
239
                <td class="summaryfilterclass">
220
                <th>View Record</th>
240
                  <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
221
                <th>Quantity</th>
241
                [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
222
                <th>Unit cost</th>
242
                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
223
                <th>Order cost</th>
243
                [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
224
                <th>&nbsp;</th>
244
                </td>
225
                <th>&nbsp;</th>
245
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
246
                <td>[% loop_order.quantity %]</td>
247
                <td>[% loop_order.ecost %]</td>
248
                <td>[% loop_order.ordertotal %]</td>
249
				<td>
250
				    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;supplierid=[% loop_order.supplierid %]">Receive</a>
251
				    
252
				</td>
253
				<td>
254
				    [% IF ( loop_order.left_holds_on_order ) %]
255
                    <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
256
                    [% ELSE %]
257
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
258
                    [% END %]
259
                    [% IF ( loop_order.can_del_bib ) %]
260
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
261
                    [% ELSE %]
262
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
263
                    [% END %]
264
                    [% IF ( loop_order.left_item ) %]
265
                    <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
266
                    [% END %]
267
                    [% IF ( loop_order.left_biblio ) %]
268
                    <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
269
                    [% END %]
270
                    [% IF ( loop_order.left_subscription ) %]
271
                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
272
                    [% END %]
273
                    [% IF ( loop_order.left_holds ) %]
274
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
275
                    [% END %]
276
				</td>
277
            </tr>
226
            </tr>
227
        </thead>
228
            <tfoot>
229
                <tr><td colspan="4" class="total">TOTAL</td>
230
                    <td> [% totalPquantity %] </td>
231
                    <td>&nbsp;</td>
232
                    <td>[% ordergrandtotal %]</td>
233
                    <td>&nbsp;</td>
234
                    <td>&nbsp;</td>
235
                </tr>
236
            </tfoot>
237
        <tbody class="filterclass">
238
            [% FOREACH loop_order IN loop_orders %]
239
        [% UNLESS ( loop.odd ) %]
240
                <tr class="highlight">
241
            [% ELSE %]
242
                <tr>
243
            [% END %]
244
                    <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
245
                    <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.supplierid %]">[% loop_order.ordernumber %]</a></td>
246
                    <td class="summaryfilterclass">
247
                      <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
248
                    [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
249
                    [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
250
                    [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
251
                    </td>
252
                    <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
253
                    <td>[% loop_order.quantity %]</td>
254
                    <td>[% loop_order.ecost %]</td>
255
                    <td>[% loop_order.ordertotal %]</td>
256
                    <td>
257
                        <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
258
                        
259
                    </td>
260
                    <td>
261
                        [% IF ( loop_order.left_holds_on_order ) %]
262
                        <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
263
                        [% ELSE %]
264
                        <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
265
                        [% END %]
266
                        [% IF ( loop_order.can_del_bib ) %]
267
                        <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
268
                        [% ELSE %]
269
                        <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
270
                        [% END %]
271
                        [% IF ( loop_order.left_item ) %]
272
                        <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
273
                        [% END %]
274
                        [% IF ( loop_order.left_biblio ) %]
275
                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
276
                        [% END %]
277
                        [% IF ( loop_order.left_subscription ) %]
278
                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
279
                        [% END %]
280
                        [% IF ( loop_order.left_holds ) %]
281
                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
282
                        [% END %]
283
                    </td>
284
                </tr>
285
            [% END %]
286
        </tbody>
287
         </table>[% ELSE %]There are no pending orders.[% END %]
288
       <div id="resultnumber">
289
        <!-- Row of numbers corresponding to search result pages -->
290
        [% IF ( displayprev ) %]
291
            <a href="parcel.pl?type=intra&amp;supplierid=[% supplierid %]&amp;startfrom=[% prevstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
278
        [% END %]
292
        [% END %]
279
    </tbody>
293
        [% FOREACH number IN numbers %]
280
     </table>[% ELSE %]There are no pending orders.[% END %]
294
            [% IF ( number.highlight ) %]
281
   <div id="resultnumber">
295
            <span class="current">[% number.number %]</span>
282
	<!-- Row of numbers corresponding to search result pages -->
296
            [% ELSE %]
283
	[% IF ( displayprev ) %]
297
            <a href="parcel.pl?type=intra&amp;supplierid=[% supplierid %]&amp;startfrom=[% number.startfrom %][% IF ( number.datereceived ) %]&amp;datereceived=[% number.datereceived %][% END %][% IF ( number.invoice ) %]&amp;invoice=[% number.invoice %][% END %][% IF ( number.resultsperpage ) %]&amp;resultsperpage=[% number.resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
284
		<a href="parcel.pl?type=intra&amp;supplierid=[% supplierid %]&amp;startfrom=[% prevstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
298
            [% END %]
285
	[% END %]
299
        [% END %]
286
	[% FOREACH number IN numbers %]
300
        [% IF ( displaynext ) %]
287
		[% IF ( number.highlight ) %]
301
            <a href="parcel.pl?type=intra&amp;supplierid=[% supplierid %]&amp;startfrom=[% nextstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
288
		<span class="current">[% number.number %]</span>
302
        [% END %]
289
		[% ELSE %]
303
        </div>
290
		<a href="parcel.pl?type=intra&amp;supplierid=[% supplierid %]&amp;startfrom=[% number.startfrom %][% IF ( number.datereceived ) %]&amp;datereceived=[% number.datereceived %][% END %][% IF ( number.invoice ) %]&amp;invoice=[% number.invoice %][% END %][% IF ( number.resultsperpage ) %]&amp;resultsperpage=[% number.resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
304
    </div>
291
		[% END %]
305
[% ELSE %]
292
	[% END %]
306
    <p>
293
	[% IF ( displaynext ) %]
307
        Invoice is close, so you can't receive orders.
294
		<a href="parcel.pl?type=intra&amp;supplierid=[% supplierid %]&amp;startfrom=[% nextstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
308
        <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
295
	[% END %]
309
    </p>
296
	</div>
310
[% END %]
297
</div>
311
298
<div id="acqui_receive_receivelist">
312
<div id="acqui_receive_receivelist">
299
    <h3>Already Received</h3>
313
    <h3>Already Received</h3>
300
314
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-25 / +24 lines)
Lines 14-20 Link Here
14
   <div id="bd">
14
   <div id="bd">
15
	<div id="yui-main">
15
	<div id="yui-main">
16
	<div class="yui-b">
16
	<div class="yui-b">
17
	
17
18
[% IF ( error_failed_to_create_invoice ) %]
19
    <div id="error" class="dialog error">
20
        <p>An error has occured. Invoice cannot be created.</p>
21
    </div>
22
[% END %]
18
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=[% supplierid %]">[% name %]</a></h1>
23
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=[% supplierid %]">[% name %]</a></h1>
19
24
20
[% IF ( count ) %]
25
[% IF ( count ) %]
Lines 42-52 Link Here
42
            [% searchresult.number %]
47
            [% searchresult.number %]
43
        </td>
48
        </td>
44
        <td>
49
        <td>
45
            <a href="/cgi-bin/koha/acqui/parcel.pl?type=intra&amp;supplierid=[% supplierid |url %]&amp;datereceived=[% searchresult.raw_datereceived |url %][% IF ( searchresult.code ) %]&amp;invoice=[% searchresult.code |url %][% END %]">
50
            [% searchresult.datereceived %]
46
                [% searchresult.datereceived %]</a>
47
        </td>
51
        </td>
48
        <td>
52
        <td>
49
            [% IF ( searchresult.code ) %][% searchresult.code %][% ELSE %]<acronym title="not available">n/a</acronym>[% END %]
53
            [% IF ( searchresult.code ) %]
54
                <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% searchresult.invoiceid %]">
55
                    [% searchresult.code %]
56
            </a>
57
            [% ELSE %]
58
                <acronym title="not available">n/a</acronym>
59
            [% END %]
50
        </td>
60
        </td>
51
        <td>
61
        <td>
52
            [% searchresult.reccount %] 
62
            [% searchresult.reccount %] 
Lines 81-87 Link Here
81
[% END %]
91
[% END %]
82
92
83
    <div id="parcels_new_parcel">
93
    <div id="parcels_new_parcel">
84
        <form method="get" action="parcel.pl">
94
        <form method="get" action="parcels.pl">
85
    <fieldset class="rows">
95
    <fieldset class="rows">
86
    <legend>Receive a new shipment</legend>
96
    <legend>Receive a new shipment</legend>
87
       <ol> <li>
97
       <ol> <li>
Lines 90-115 Link Here
90
            <input type="hidden" name="op" value="new" />
100
            <input type="hidden" name="op" value="new" />
91
			<input type="text" size="20" id="invoice" name="invoice" />
101
			<input type="text" size="20" id="invoice" name="invoice" />
92
        </li>
102
        </li>
93
		[% IF ( gst ) %]
103
         <li><label for="shipmentdate">Shipment date: </label>
94
        <li>
104
            <input type="text" id="shipmentdate" name="shipmentdate" maxlength="10" size="10" value="[% shipmentdate_today %]" />
95
            <label for="gst">GST:</label>
105
            <img src="[% themelang %]/lib/calendar/cal.gif" id="shipmentdate_button" alt="Show Calendar" />
96
            <input type="text" size="20" id="gst" name="gst" />
97
        </li>
98
		[% END %]
99
      <!--  // Removing freight input until shipping can be proplerly handled .
100
	  <li>
101
            <label for="freight">Shipping:</label>
102
            <input type="text" size="20" id="freight" name="freight" />
103
        </li> -->
104
         <li><label for="datereceived">Shipment date: </label>
105
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" />
106
            <img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
107
      <script language="JavaScript" type="text/javascript">
106
      <script language="JavaScript" type="text/javascript">
108
        Calendar.setup(
107
        Calendar.setup(
109
          {
108
          {
110
            inputField : "datereceived",
109
            inputField : "shipmentdate",
111
            ifFormat : "[% DHTMLcalendar_dateformat %]",
110
            ifFormat : "[% DHTMLcalendar_dateformat %]",
112
            button : "datereceived_button"          }
111
            button : "shipmentdate_button"
112
          }
113
        );
113
        );
114
      </script>
114
      </script>
115
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
115
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
Lines 131-139 Link Here
131
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
131
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
132
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
132
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
133
                <option value="aqorders.booksellerinvoicenumber">Invoice number</option>
133
                <option value="aqorders.booksellerinvoicenumber">Invoice number</option>
134
                <option value="datereceived"> Date Received</option>
134
                <option value="shipmentdate">Shipment date</option>
135
                <option value="datereceived desc"> Date Received reverse</option>
135
                <option value="datereceived desc">Shipment date reverse</option>
136
                <option value="aqorders.booksellerinvoicenumber desc"> Invoice number reverse</option>
136
                <option value="aqorders.booksellerinvoicenumber desc">Invoice number reverse</option>
137
                </select><br />
137
                </select><br />
138
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
138
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
139
                <option value="20">20</option>
139
                <option value="20">20</option>
140
- 

Return to bug 5339