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

(-)a/C4/Acquisition.pm (-7 / +347 lines)
Lines 61-66 BEGIN { Link Here
61
        &GetParcels &GetParcel
61
        &GetParcels &GetParcel
62
        &GetContracts &GetContract
62
        &GetContracts &GetContract
63
63
64
        &GetInvoices
65
        &GetInvoice
66
        &GetInvoiceDetails
67
        &AddInvoice
68
        &ModInvoice
69
        &CloseInvoice
70
        &ReopenInvoice
71
64
        &GetItemnumbersFromOrder
72
        &GetItemnumbersFromOrder
65
73
66
        &AddClaim
74
        &AddClaim
Lines 1103-1109 C<$ordernumber>. Link Here
1103
sub ModReceiveOrder {
1111
sub ModReceiveOrder {
1104
    my (
1112
    my (
1105
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1113
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1106
        $invoiceno, $freight, $rrp, $budget_id, $datereceived
1114
        $invoiceid, $rrp, $budget_id, $datereceived
1107
    )
1115
    )
1108
    = @_;
1116
    = @_;
1109
    my $dbh = C4::Context->dbh;
1117
    my $dbh = C4::Context->dbh;
Lines 1129-1142 sub ModReceiveOrder { Link Here
1129
            UPDATE aqorders
1137
            UPDATE aqorders
1130
            SET quantityreceived=?
1138
            SET quantityreceived=?
1131
                , datereceived=?
1139
                , datereceived=?
1132
                , booksellerinvoicenumber=?
1140
                , invoiceid=?
1133
                , unitprice=?
1141
                , unitprice=?
1134
                , freight=?
1135
                , rrp=?
1142
                , rrp=?
1136
                , quantity=?
1143
                , quantity=?
1137
            WHERE biblionumber=? AND ordernumber=?");
1144
            WHERE biblionumber=? AND ordernumber=?");
1138
1145
1139
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
1146
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$quantrec,$biblionumber,$ordernumber);
1140
        $sth->finish;
1147
        $sth->finish;
1141
1148
1142
        # create a new order for the remaining items, and set its bookfund.
1149
        # create a new order for the remaining items, and set its bookfund.
Lines 1148-1157 sub ModReceiveOrder { Link Here
1148
        my $newOrder = NewOrder($order);
1155
        my $newOrder = NewOrder($order);
1149
} else {
1156
} else {
1150
        $sth=$dbh->prepare("update aqorders
1157
        $sth=$dbh->prepare("update aqorders
1151
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1158
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1152
                                unitprice=?,freight=?,rrp=?
1159
                                unitprice=?,rrp=?
1153
                            where biblionumber=? and ordernumber=?");
1160
                            where biblionumber=? and ordernumber=?");
1154
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1161
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1155
        $sth->finish;
1162
        $sth->finish;
1156
    }
1163
    }
1157
    return $datereceived;
1164
    return $datereceived;
Lines 1801-1807 sub AddClaim { Link Here
1801
        ";
1808
        ";
1802
    my $sth = $dbh->prepare($query);
1809
    my $sth = $dbh->prepare($query);
1803
    $sth->execute($ordernumber);
1810
    $sth->execute($ordernumber);
1811
}
1812
1813
=head3 GetInvoices
1814
1815
    my @invoices = GetInvoices(
1816
        invoicenumber => $invoicenumber,
1817
        suppliername => $suppliername,
1818
        shipmentdatefrom => $shipmentdatefrom, # ISO format
1819
        shipmentdateto => $shipmentdateto, # ISO format
1820
        billingdatefrom => $billingdatefrom, # ISO format
1821
        billingdateto => $billingdateto, # ISO format
1822
        isbneanissn => $isbn_or_ean_or_issn,
1823
        title => $title,
1824
        author => $author,
1825
        publisher => $publisher,
1826
        publicationyear => $publicationyear,
1827
        branchcode => $branchcode,
1828
        order_by => $order_by
1829
    );
1830
1831
Return a list of invoices that match all given criteria.
1832
1833
$order_by is "column_name (asc|desc)", where column_name is any of
1834
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
1835
'shipmentcost', 'shipmentcost_budgetid'.
1836
1837
asc is the default if omitted
1838
1839
=cut
1840
1841
sub GetInvoices {
1842
    my %args = @_;
1843
1844
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
1845
        closedate shipmentcost shipmentcost_budgetid);
1846
1847
    my $dbh = C4::Context->dbh;
1848
    my $query = qq{
1849
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername,
1850
          COUNT(
1851
            DISTINCT IF(
1852
              aqorders.datereceived IS NOT NULL,
1853
              aqorders.biblionumber,
1854
              NULL
1855
            )
1856
          ) AS receivedbiblios,
1857
          SUM(aqorders.quantityreceived) AS receiveditems
1858
        FROM aqinvoices
1859
          LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
1860
          LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid
1861
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1862
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
1863
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
1864
    };
1865
1866
    my @bind_args;
1867
    my @bind_strs;
1868
    if($args{invoicenumber}) {
1869
        push @bind_strs, " aqinvoices.invoicenumber LIKE ? ";
1870
        push @bind_args, "%$args{invoicenumber}%";
1871
    }
1872
    if($args{suppliername}) {
1873
        push @bind_strs, " aqbooksellers.name LIKE ? ";
1874
        push @bind_args, "%$args{suppliername}%";
1875
    }
1876
    if($args{shipmentdatefrom}) {
1877
        push @bind_strs, " aqinvoices.shipementdate >= ? ";
1878
        push @bind_args, $args{shipementdatefrom};
1879
    }
1880
    if($args{shipmentdateto}) {
1881
        push @bind_strs, " aqinvoices.shipementdate <= ? ";
1882
        push @bind_args, $args{shipementdateto};
1883
    }
1884
    if($args{billingdatefrom}) {
1885
        push @bind_strs, " aqinvoices.billingdate >= ? ";
1886
        push @bind_args, $args{billingdatefrom};
1887
    }
1888
    if($args{billingdateto}) {
1889
        push @bind_strs, " aqinvoices.billingdate <= ? ";
1890
        push @bind_args, $args{billingdateto};
1891
    }
1892
    if($args{isbneanissn}) {
1893
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
1894
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
1895
    }
1896
    if($args{title}) {
1897
        push @bind_strs, " biblio.title LIKE ? ";
1898
        push @bind_args, $args{title};
1899
    }
1900
    if($args{author}) {
1901
        push @bind_strs, " biblio.author LIKE ? ";
1902
        push @bind_args, $args{author};
1903
    }
1904
    if($args{publisher}) {
1905
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
1906
        push @bind_args, $args{publisher};
1907
    }
1908
    if($args{publicationyear}) {
1909
        push @bind_strs, " biblioitems.publicationyear = ? ";
1910
        push @bind_args, $args{publicationyear};
1911
    }
1912
    if($args{branchcode}) {
1913
        push @bind_strs, " aqorders.branchcode = ? ";
1914
        push @bind_args, $args{branchcode};
1915
    }
1916
1917
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
1918
    $query .= " GROUP BY aqinvoices.invoiceid ";
1919
1920
    if($args{order_by}) {
1921
        my ($column, $direction) = split / /, $args{order_by};
1922
        if(grep /^$column$/, @columns) {
1923
            $direction ||= 'ASC';
1924
            $query .= " ORDER BY $column $direction";
1925
        }
1926
    }
1927
1928
    my $sth = $dbh->prepare($query);
1929
    $sth->execute(@bind_args);
1930
1931
    my $results = $sth->fetchall_arrayref({});
1932
    return @$results;
1933
}
1934
1935
=head3 GetInvoice
1936
1937
    my $invoice = GetInvoice($invoiceid);
1938
1939
Get informations about invoice with given $invoiceid
1940
1941
Return a hash filled with aqinvoices.* fields
1942
1943
=cut
1944
1945
sub GetInvoice {
1946
    my ($invoiceid) = @_;
1947
    my $invoice;
1948
1949
    return unless $invoiceid;
1950
1951
    my $dbh = C4::Context->dbh;
1952
    my $query = qq{
1953
        SELECT *
1954
        FROM aqinvoices
1955
        WHERE invoiceid = ?
1956
    };
1957
    my $sth = $dbh->prepare($query);
1958
    $sth->execute($invoiceid);
1959
1960
    $invoice = $sth->fetchrow_hashref;
1961
    return $invoice;
1962
}
1963
1964
=head3 GetInvoiceDetails
1965
1966
    my $invoice = GetInvoiceDetails($invoiceid)
1967
1968
Return informations about an invoice + the list of related order lines
1969
1970
Orders informations are in $invoice->{orders} (array ref)
1971
1972
=cut
1973
1974
sub GetInvoiceDetails {
1975
    my ($invoiceid) = @_;
1976
    my $invoice;
1977
1978
    return unless $invoiceid;
1979
1980
    my $dbh = C4::Context->dbh;
1981
    my $query = qq{
1982
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername
1983
        FROM aqinvoices
1984
          LEFT JOIN aqbooksellers ON aqinvoices.booksellerid = aqbooksellers.id
1985
        WHERE invoiceid = ?
1986
    };
1987
    my $sth = $dbh->prepare($query);
1988
    $sth->execute($invoiceid);
1989
1990
    $invoice = $sth->fetchrow_hashref;
1804
1991
1992
    $query = qq{
1993
        SELECT aqorders.*, biblio.*
1994
        FROM aqorders
1995
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1996
        WHERE invoiceid = ?
1997
    };
1998
    $sth = $dbh->prepare($query);
1999
    $sth->execute($invoiceid);
2000
    $invoice->{orders} = $sth->fetchall_arrayref({});
2001
2002
    return $invoice;
2003
}
2004
2005
=head3 AddInvoice
2006
2007
    my $invoiceid = AddInvoice(
2008
        invoicenumber => $invoicenumber,
2009
        booksellerid => $booksellerid,
2010
        shipmentdate => $shipmentdate,
2011
        billingdate => $billingdate,
2012
        closedate => $closedate,
2013
        shipmentcost => $shipmentcost,
2014
        shipmentcost_budgetid => $shipmentcost_budgetid
2015
    );
2016
2017
Create a new invoice and return its id or undef if it fails.
2018
2019
=cut
2020
2021
sub AddInvoice {
2022
    my %invoice = @_;
2023
2024
    return unless(%invoice and $invoice{invoicenumber});
2025
2026
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2027
        closedate shipmentcost shipmentcost_budgetid);
2028
2029
    my @set_strs;
2030
    my @set_args;
2031
    foreach my $key (keys %invoice) {
2032
        if(0 < grep(/^$key$/, @columns)) {
2033
            push @set_strs, "$key = ?";
2034
            push @set_args, ($invoice{$key} || undef);
2035
        }
2036
    }
2037
2038
    my $rv;
2039
    if(@set_args > 0) {
2040
        my $dbh = C4::Context->dbh;
2041
        my $query = "INSERT INTO aqinvoices SET ";
2042
        $query .= join (",", @set_strs);
2043
        my $sth = $dbh->prepare($query);
2044
        $rv = $sth->execute(@set_args);
2045
        if($rv) {
2046
            $rv = $dbh->last_insert_id(undef, undef, 'aqinvoices', undef);
2047
        }
2048
    }
2049
    return $rv;
2050
}
2051
2052
=head3 ModInvoice
2053
2054
    ModInvoice(
2055
        invoiceid => $invoiceid,    # Mandatory
2056
        invoicenumber => $invoicenumber,
2057
        booksellerid => $booksellerid,
2058
        shipmentdate => $shipmentdate,
2059
        billingdate => $billingdate,
2060
        closedate => $closedate,
2061
        shipmentcost => $shipmentcost,
2062
        shipmentcost_budgetid => $shipmentcost_budgetid
2063
    );
2064
2065
Modify an invoice, invoiceid is mandatory.
2066
2067
Return undef if it fails.
2068
2069
=cut
2070
2071
sub ModInvoice {
2072
    my %invoice = @_;
2073
2074
    return unless(%invoice and $invoice{invoiceid});
2075
2076
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2077
        closedate shipmentcost shipmentcost_budgetid);
2078
2079
    my @set_strs;
2080
    my @set_args;
2081
    foreach my $key (keys %invoice) {
2082
        if(0 < grep(/^$key$/, @columns)) {
2083
            push @set_strs, "$key = ?";
2084
            push @set_args, ($invoice{$key} || undef);
2085
        }
2086
    }
2087
2088
    my $dbh = C4::Context->dbh;
2089
    my $query = "UPDATE aqinvoices SET ";
2090
    $query .= join(",", @set_strs);
2091
    $query .= " WHERE invoiceid = ?";
2092
2093
    my $sth = $dbh->prepare($query);
2094
    $sth->execute(@set_args, $invoice{invoiceid});
2095
}
2096
2097
=head3 CloseInvoice
2098
2099
    CloseInvoice($invoiceid);
2100
2101
Close an invoice.
2102
2103
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2104
2105
=cut
2106
2107
sub CloseInvoice {
2108
    my ($invoiceid) = @_;
2109
2110
    return unless $invoiceid;
2111
2112
    my $dbh = C4::Context->dbh;
2113
    my $query = qq{
2114
        UPDATE aqinvoices
2115
        SET closedate = CAST(NOW() AS DATE)
2116
        WHERE invoiceid = ?
2117
    };
2118
    my $sth = $dbh->prepare($query);
2119
    $sth->execute($invoiceid);
2120
}
2121
2122
=head3 ReopenInvoice
2123
2124
    ReopenInvoice($invoiceid);
2125
2126
Reopen an invoice
2127
2128
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2129
2130
=cut
2131
2132
sub ReopenInvoice {
2133
    my ($invoiceid) = @_;
2134
2135
    return unless $invoiceid;
2136
2137
    my $dbh = C4::Context->dbh;
2138
    my $query = qq{
2139
        UPDATE aqinvoices
2140
        SET closedate = NULL
2141
        WHERE invoiceid = ?
2142
    };
2143
    my $sth = $dbh->prepare($query);
2144
    $sth->execute($invoiceid);
1805
}
2145
}
1806
2146
1807
1;
2147
1;
(-)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 aqinvoices
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 aqinvoices
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 94-105 if ($quantityrec > $origquantityrec ) { Link Here
94
    }
94
    }
95
    
95
    
96
    # save the quantity received.
96
    # save the quantity received.
97
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived);
97
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoice->{invoiceid},$replacement,undef,$datereceived);
98
}
98
}
99
99
100
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
100
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
101
101
102
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&supplierid=$supplierid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
102
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
103
103
104
################################ End of script ################################
104
################################ End of script ################################
105
105
(-)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     => $details->{'shipmentdate'},
171
    billingdate      => $details->{'billingdate'},
172
    invoiceclosedate => $details->{'closedate'},
173
    shipmentcost     => sprintf($format, $details->{'shipmentcost'} || 0),
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 (+150 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 %row = (
80
            invoiceid       => $_->{invoiceid},
81
            billingdate     => $_->{billingdate},
82
            invoicenumber   => $_->{invoicenumber},
83
            suppliername    => $_->{suppliername},
84
            receivedbiblios => $_->{receivedbiblios},
85
            receiveditems   => $_->{receiveditems},
86
            subscriptionid  => $_->{subscriptionid},
87
            closedate => $_->{closedate},
88
        );
89
        push @results_loop, \%row;
90
    }
91
}
92
93
94
# Build suppliers list
95
my @suppliers = GetBookSeller(undef);
96
my @suppliers_loop = ();
97
my $suppliername;
98
foreach (@suppliers) {
99
    my $selected = 0;
100
    if ($supplier && $supplier == $_->{'id'}) {
101
        $selected = 1;
102
        $suppliername = $_->{'name'};
103
    }
104
    my %row = (
105
        suppliername => $_->{'name'},
106
        supplierid   => $_->{'id'},
107
        selected     => $selected,
108
    );
109
    push @suppliers_loop, \%row;
110
}
111
112
# Build branches list
113
my $branches = GetBranches();
114
my @branches_loop = ();
115
my $branchname;
116
foreach (sort keys %$branches) {
117
    my $selected = 0;
118
    if ($branch && $branch eq $_) {
119
        $selected = 1;
120
        $branchname = $branches->{$_}->{'branchname'};
121
    }
122
    my %row = (
123
        branchcode => $_,
124
        branchname => $branches->{$_}->{'branchname'},
125
        selected   => $selected,
126
    );
127
    push @branches_loop, \%row;
128
}
129
130
$template->param(
131
    do_search       => ($op and $op eq "do_search") ? 1 : 0,
132
    results_loop    => \@results_loop,
133
    invoicenumber   => $invoicenumber,
134
    supplier        => $supplier,
135
    suppliername    => $suppliername,
136
    billingdatefrom => $billingdatefrom,
137
    billingdateto   => $billingdateto,
138
    isbneanissn     => $isbneanissn,
139
    title           => $title,
140
    author          => $author,
141
    publisher       => $publisher,
142
    publicationyear => $publicationyear,
143
    branch          => $branch,
144
    branchname      => $branchname,
145
    suppliers_loop  => \@suppliers_loop,
146
    branches_loop   => \@branches_loop,
147
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
148
);
149
150
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 80-105 use C4::Biblio; Link Here
80
my $input      = new CGI;
81
my $input      = new CGI;
81
82
82
my $dbh          = C4::Context->dbh;
83
my $dbh          = C4::Context->dbh;
83
my $supplierid   = $input->param('supplierid');
84
my $invoiceid    = $input->param('invoiceid');
84
my $ordernumber       = $input->param('ordernumber');
85
my $invoice      = GetInvoice($invoiceid);
86
my $supplierid   = $invoice->{booksellerid};
87
my $freight      = $invoice->{shipmentcost};
88
my $datereceived = $invoice->{shipmentdate};
89
my $ordernumber  = $input->param('ordernumber');
85
my $search       = $input->param('receive');
90
my $search       = $input->param('receive');
86
my $invoice      = $input->param('invoice');
87
my $freight      = $input->param('freight');
88
my $datereceived = $input->param('datereceived');
89
90
91
91
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
92
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
92
93
93
my $bookseller = GetBookSellerFromId($supplierid);
94
my $bookseller = GetBookSellerFromId($supplierid);
94
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
95
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
95
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
96
my $results = SearchOrder($ordernumber,$search);
96
my $results = SearchOrder($ordernumber,$search);
97
97
98
99
my $count   = scalar @$results;
98
my $count   = scalar @$results;
100
my $order 	= GetOrder($ordernumber);
99
my $order 	= GetOrder($ordernumber);
101
100
102
103
my $date = @$results[0]->{'entrydate'};
101
my $date = @$results[0]->{'entrydate'};
104
102
105
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
103
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 164-170 if ( $count == 1 ) { Link Here
164
        unitprice             => @$results[0]->{'unitprice'},
162
        unitprice             => @$results[0]->{'unitprice'},
165
        memberfirstname       => $member->{firstname} || "",
163
        memberfirstname       => $member->{firstname} || "",
166
        membersurname         => $member->{surname} || "",
164
        membersurname         => $member->{surname} || "",
167
        invoice               => $invoice,
165
        invoiceid             => $invoice->{invoiceid},
166
        invoice               => $invoice->{invoicenumber},
168
        datereceived          => $datereceived->output(),
167
        datereceived          => $datereceived->output(),
169
        datereceived_iso      => $datereceived->output('iso'),
168
        datereceived_iso      => $datereceived->output('iso'),
170
        notes                 => $order->{notes}
169
        notes                 => $order->{notes}
Lines 175-181 else { Link Here
175
    for ( my $i = 0 ; $i < $count ; $i++ ) {
174
    for ( my $i = 0 ; $i < $count ; $i++ ) {
176
        my %line = %{ @$results[$i] };
175
        my %line = %{ @$results[$i] };
177
176
178
        $line{invoice}      = $invoice;
177
        $line{invoice}      = $invoice->{invoicenumber};
179
        $line{datereceived} = $datereceived->output();
178
        $line{datereceived} = $datereceived->output();
180
        $line{freight}      = $freight;
179
        $line{freight}      = $freight;
181
        $line{gst}          = $gst;
180
        $line{gst}          = $gst;
Lines 188-197 else { Link Here
188
    $template->param(
187
    $template->param(
189
        loop         => \@loop,
188
        loop         => \@loop,
190
        supplierid   => $supplierid,
189
        supplierid   => $supplierid,
190
        invoiceid    => $invoice->{invoiceid},
191
    );
191
    );
192
}
192
}
193
my $op = $input->param('op');
193
my $op = $input->param('op');
194
if ($op eq 'edit'){
194
if ($op and $op eq 'edit'){
195
    $template->param(edit   =>   1);
195
    $template->param(edit   =>   1);
196
}
196
}
197
output_html_with_http_headers $input, $cookie, $template->output;
197
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 (+182 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'calendar.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
8
<script type="text/javascript">
9
//<![CDATA[
10
    $(document).ready(function() {
11
        $("#orderst").tablesorter({widgets : ['zebra']});
12
        Calendar.setup({
13
            inputField: "shipmentdate",
14
            ifFormat: "[% DHTMLcalendar_dateformat %]",
15
            button: "shipmentdateCalendar"
16
        });
17
        Calendar.setup({
18
            inputField: "billingdate",
19
            ifFormat: "[% DHTMLcalendar_dateformat %]",
20
            button: "billingdateCalendar"
21
        });
22
    });
23
//]]>
24
</script>
25
</head>
26
27
<body>
28
[% INCLUDE 'header.inc' %]
29
[% INCLUDE 'acquisitions-search.inc' %]
30
31
<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>
32
33
<div id="doc3" class="yui-t2">
34
35
<div id="bd">
36
  <div id="yui-main">
37
    <div class="yui-b">
38
      [% IF ( modified ) %]
39
        <div class="dialog">
40
          <p>Invoice has been modified</p>
41
        </div>
42
      [% END %]
43
      <h1>Invoice: [% invoicenumber %]</h1>
44
45
      <p>Supplier: [% suppliername %]</p>
46
      <form action="" method="post">
47
        <label for="shipmentdate">Shipment date:</label>
48
        [% IF (shipmentdate) %]
49
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" readonly="readonly" />
50
        [% ELSE %]
51
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" readonly="readonly" />
52
        [% END %]
53
        <img id="shipmentdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
54
        <p></p>
55
        <label for="billingdate">Billing date:</label>
56
        [% IF (billingdate) %]
57
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
58
        [% ELSE %]
59
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
60
        [% END %]
61
        <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
62
        <p></p>
63
        <label for="shipmentcost">Shipment cost:</label>
64
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
65
        <label for="shipment_budget_id">Budget:</label>
66
        <select id="shipment_budget_id" name="shipment_budget_id">
67
            <option value="">No budget</option>
68
          [% FOREACH budget IN budgets_loop %]
69
            [% IF ( budget.selected ) %]
70
              <option selected="selected" value="[% budget.budget_id %]">
71
            [% ELSE %]
72
              <option value="[% budget.budget_id %]">
73
            [% END %]
74
              [% budget.budget_name %]
75
            </option>
76
          [% END %]
77
        </select>
78
        <input type="hidden" name="op" value="mod" />
79
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
80
        <fieldset class="action">
81
            <input type="submit" value="Save">
82
        </fieldset>
83
      </form>
84
      <p>Status:
85
        [% IF ( invoiceclosedate ) %]
86
          Closed on [% invoiceclosedate | $KohaDates %].
87
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
88
            Reopen
89
          </a>
90
        [% ELSE %]
91
          Open.
92
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
93
            Close
94
          </a>
95
        [% END %]
96
      </p>
97
      <p>
98
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
99
      </p>
100
      <h2>Invoice details</h2>
101
      <table id="orderst">
102
        <thead>
103
          <tr>
104
            <th>Summary</th>
105
            <th>Publisher</th>
106
            <th>Branch</th>
107
            <th>RRP</th>
108
            <th>Est.</th>
109
            <th>Qty.</th>
110
            <th>Total</th>
111
            <th>Fund</th>
112
          </tr>
113
        </thead>
114
        <tbody>
115
          [% FOREACH order IN orders_loop %]
116
            <tr>
117
              <td><p>[% order.title %]
118
                [% IF ( order.author ) %]
119
                  <br /><em>by</em> [% order.author %]
120
                [% END %]
121
              </p></td>
122
              <td>
123
                [% IF ( order.publishercode ) %]
124
                  <p>[% order.publishercode %]
125
                    [% IF ( order.publicationyear ) %]
126
                      - [% order.publicationyear %]
127
                    [% END %]
128
                  </p>
129
                [% END %]
130
              </td>
131
              <td><p>[% order.branchcode %]</p></td>
132
              <td>[% order.rrp %]</td>
133
              <td>[% order.ecost %]</td>
134
              <td class="number">[% order.quantity %]</td>
135
              <td>[% order.total %]</td>
136
              <td>[% order.budget_name %]</td>
137
            </tr>
138
          [% END %]
139
        </tbody>
140
        <tfoot>
141
            <tr>
142
                <th colspan="3">Total Tax Exc.</th>
143
                <th>[% total_rrp_gste %]</th>
144
                <th>&nbsp;</th>
145
                <th>[% total_quantity %]</th>
146
                <th>[% total_est_gste %]</th>
147
                <th>&nbsp;</th>
148
            </tr>
149
            <tr>
150
                <th colspan='3'>Tax ([% gist %]%)</th>
151
                <th>[% gist_rrp %]</th>
152
                <th>&nbsp;</th>
153
                <th>&nbsp;</th>
154
                <th>[% gist_est %]</th>
155
                <th>&nbsp;</th>
156
            </tr>
157
            <tr>
158
                <th colspan='3'>Total Tax Inc. ([% currency %])</th>
159
                <th>[% total_rrp_gsti %]</th>
160
                <th>&nbsp;</th>
161
                <th>[% total_quantity %]</th>
162
                <th>[% total_est_gsti %]</th>
163
                <th>&nbsp;</th>
164
            </tr>
165
            <tr>
166
                <th colspan="3">Total + Shipment cost ([% currency %])</th>
167
                <th>&nbsp;</th>
168
                <th>&nbsp;</th>
169
                <th>[% total_quantity %]</th>
170
                <th>[% total_gsti_shipment %]</th>
171
                <th>&nbsp;</th>
172
            </tr>
173
        </tfoot>
174
      </table>
175
176
    </div>
177
  </div>
178
  <div class="yui-b">
179
    [% INCLUDE 'acquisitions-menu.inc' %]
180
  </div>
181
</div>
182
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+223 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoices</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
7
[% INCLUDE 'calendar.inc' %]
8
<script type="text/javascript">
9
//<![CDATA[
10
$(document).ready(function() {
11
    Calendar.setup({
12
        inputField: "billingdatefrom",
13
        ifFormat: "[% DHTMLcalendar_dateformat %]",
14
        button: "billingdatefromCalendar"
15
    });
16
    Calendar.setup({
17
        inputField: "billingdateto",
18
        ifFormat: "[% DHTMLcalendar_dateformat %]",
19
        button: "billingdatetoCalendar"
20
    });
21
    $("#resultst").tablesorter({
22
        widgets : ['zebra'],
23
        headers: {
24
            6: { sorter: false },
25
        }
26
    });
27
});
28
//]]>
29
</script>
30
</head>
31
32
<body>
33
[% INCLUDE 'header.inc' %]
34
[% INCLUDE 'acquisitions-search.inc' %]
35
36
<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>
37
38
<div id="doc3" class="yui-t2">
39
40
<div id="bd">
41
  <div id="yui-main">
42
    <div class="yui-b">
43
      <h1>Invoices</h1>
44
      [% IF ( do_search ) %]
45
        [% IF ( results_loop ) %]
46
          <table id="resultst">
47
            <thead>
48
              <tr>
49
                <th>Invoice no.</th>
50
                <th>Vendor</th>
51
                <th>Billing date</th>
52
                <th>Received biblios</th>
53
                <th>Received items</th>
54
                <th>Status</th>
55
                <th>&nbsp;</th>
56
              </tr>
57
            </thead>
58
            <tbody>
59
              [% FOREACH result IN results_loop %]
60
                <tr>
61
                  <td>[% result.invoicenumber %]</td>
62
                  <td>[% result.suppliername %]</td>
63
                  <td>
64
                    [% IF (result.billingdate) %]
65
                      [% result.billingdate | $KohaDates %]
66
                    [% END %]
67
                  </td>
68
                  <td>[% result.receivedbiblios %]</td>
69
                  <td>[% result.receiveditems %]</td>
70
                  <td>
71
                    [% IF ( result.closedate ) %]
72
                      Closed on [% result.closedate | $KohaDates %]
73
                    [% ELSE %]
74
                      Open
75
                    [% END %]
76
                  </td>
77
                  <td>
78
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
79
                    [% IF ( result.closedate ) %]
80
                      <a href="invoice.pl?op=reopen&invoiceid=[% result.invoiceid %]">Reopen</a>
81
                    [% ELSE %]
82
                      <a href="invoice.pl?op=close&invoiceid=[% result.invoiceid %]">Close</a>
83
                    [% END %]
84
                  </td>
85
                </tr>
86
              [% END %]
87
            </tbody>
88
          </table>
89
        [% ELSE %]
90
          <p>Sorry, but there is no results for your search.</p>
91
          <p>Search was:
92
            <ul>
93
              [% IF ( invoicenumber ) %]
94
                <li>Invoice no.: [% invoicenumber %]</li>
95
              [% END %]
96
              [% IF ( supplier ) %]
97
                <li>Vendor: [% suppliername %]</li>
98
              [% END %]
99
              [% IF ( billingdatefrom ) %]
100
                <li>Billing date:
101
                [% IF ( billingdateto ) %]
102
                  From [% billingdatefrom %]
103
                  To [% billingdateto %]
104
                [% ELSE %]
105
                  All since [% billingdatefrom %]
106
                [% END %]
107
                </li>
108
              [% ELSE %]
109
                [% IF ( billingdateto ) %]
110
                  <li>Billing date:
111
                    All until [% billingdateto %]
112
                  </li>
113
                [% END %]
114
              [% END %]
115
              [% IF ( isbneanissn ) %]
116
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
117
              [% END %]
118
              [% IF ( title ) %]
119
                <li>Title: [% title %]</li>
120
              [% END %]
121
              [% IF ( author ) %]
122
                <li>Author: [% author %]</li>
123
              [% END %]
124
              [% IF ( publisher ) %]
125
                <li>Publisher: [% publisher %]</li>
126
              [% END %]
127
              [% IF ( publicationyear ) %]
128
                <li>Publication year: [% publicationyear %]</li>
129
              [% END %]
130
              [% IF ( branch ) %]
131
                <li>Branch: [% branchname %]</li>
132
              [% END %]
133
            </ul>
134
          </p>
135
        [% END %]<!-- results_loop -->
136
      [% ELSE %]
137
        <p>Please fill in the form to the left to make a search.</p>
138
      [% END %]<!-- do_search -->
139
    </div>
140
  </div>
141
  <div class="yui-b">
142
    <form action="" method="get">
143
      <fieldset class="brief">
144
        <h3>Search filters</h3>
145
        <ol>
146
          <li>
147
            <label for="invoicenumber">Invoice no:</label>
148
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
149
          </li>
150
          <li>
151
            <label for="supplier">Supplier:</label>
152
            <select id="supplier" name="supplier">
153
              <option value="">All</option>
154
              [% FOREACH supplier IN suppliers_loop %]
155
                [% IF ( supplier.selected ) %]
156
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
157
                [% ELSE %]
158
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
159
                [% END %]
160
              [% END %]
161
            </select>
162
          </li>
163
          <li>
164
            <fieldset class="brief">
165
              <legend>Billing date</legend>
166
              <ol>
167
                <li>
168
                  <label for="billingdatefrom">From:</label>
169
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" />
170
                  <img id="billingdatefromCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
171
                </li>
172
                <li>
173
                  <label for="billingdateto">To:</label>
174
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" />
175
                  <img id="billingdatetoCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
176
                </li>
177
              </ol>
178
            </fieldset>
179
          </li>
180
          <li>
181
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
182
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
183
          </li>
184
          <li>
185
            <label for="title">Title:</label>
186
            <input type="text" id="title" name="title" value="[% title %]" />
187
          </li>
188
          <li>
189
            <label for="author">Author:</label>
190
            <input type="text" id="author" name="author" value="[% author %]" />
191
          </li>
192
          <li>
193
            <label for="publisher">Publisher:</label>
194
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
195
          </li>
196
          <li>
197
            <label for="publicationyear">Publication year:</label>
198
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
199
          </li>
200
          <li>
201
            <label for="branch">Branch:</label>
202
            <select id="branch" name="branch">
203
              <option value="">All</option>
204
              [% FOREACH branch IN branches_loop %]
205
                [% IF ( branch.selected ) %]
206
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
207
                [% ELSE %]
208
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
209
                [% END %]
210
              [% END %]
211
            </select>
212
          </li>
213
        </ol>
214
        <fieldset class="action">
215
          <input type="submit" value="Search" />
216
        </fieldset>
217
      </fieldset>
218
      <input type="hidden" name="op" id="op" value="do_search" />
219
    </form>
220
    [% INCLUDE 'acquisitions-menu.inc' %]
221
  </div>
222
</div>
223
[% 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 130-141 Link Here
130
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
130
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
131
        [% END %]</li></ol>
131
        [% END %]</li></ol>
132
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
132
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
133
        <input type="hidden" name="invoice" value="[% invoice %]" />
134
    </fieldset>
133
    </fieldset>
135
134
136
</div>
135
</div>
137
</div><div class="yui-g"><fieldset class="action">
136
</div><div class="yui-g"><fieldset class="action">
138
        <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>
137
        <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>
139
</fieldset></div>    </form>
138
</fieldset></div>    </form>
140
[% ELSE %]
139
[% ELSE %]
141
<div id="acqui_acquire_orderlist">
140
<div id="acqui_acquire_orderlist">
Lines 152-158 Link Here
152
        <tr>
151
        <tr>
153
            <td>[% loo.basketno %]</td>
152
            <td>[% loo.basketno %]</td>
154
            <td>[% loo.isbn %]</td>
153
            <td>[% loo.isbn %]</td>
155
         <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>
154
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
156
            <td>[% loo.author %]</td>
155
            <td>[% loo.author %]</td>
157
            <td>[% loo.quantity %]</td>
156
            <td>[% loo.quantity %]</td>
158
            <td>[% loo.quantityreceived %]</td>
157
            <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.basketno %],[% 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.basketno %],[% 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