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 $booksellerid = $input->param('booksellerid');
52
my $booksellerid = $input->param('booksellerid');
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&booksellerid=$booksellerid&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 (-17 / +17 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 81-106 use C4::Suggestions; Link Here
81
my $input      = new CGI;
82
my $input      = new CGI;
82
83
83
my $dbh          = C4::Context->dbh;
84
my $dbh          = C4::Context->dbh;
84
my $booksellerid   = $input->param('booksellerid');
85
my $invoiceid    = $input->param('invoiceid');
85
my $ordernumber       = $input->param('ordernumber');
86
my $invoice      = GetInvoice($invoiceid);
87
my $booksellerid   = $invoice->{booksellerid};
88
my $freight      = $invoice->{shipmentcost};
89
my $datereceived = $invoice->{shipmentdate};
90
my $ordernumber  = $input->param('ordernumber');
86
my $search       = $input->param('receive');
91
my $search       = $input->param('receive');
87
my $invoice      = $input->param('invoice');
88
my $freight      = $input->param('freight');
89
my $datereceived = $input->param('datereceived');
90
91
92
92
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
93
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
93
94
94
my $bookseller = GetBookSellerFromId($booksellerid);
95
my $bookseller = GetBookSellerFromId($booksellerid);
95
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
96
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
96
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
97
my $results = SearchOrder($ordernumber,$search);
97
my $results = SearchOrder($ordernumber,$search);
98
98
99
100
my $count   = scalar @$results;
99
my $count   = scalar @$results;
101
my $order 	= GetOrder($ordernumber);
100
my $order 	= GetOrder($ordernumber);
102
101
103
104
my $date = @$results[0]->{'entrydate'};
102
my $date = @$results[0]->{'entrydate'};
105
103
106
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
104
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 167-173 if ( $count == 1 ) { Link Here
167
        unitprice             => @$results[0]->{'unitprice'},
165
        unitprice             => @$results[0]->{'unitprice'},
168
        memberfirstname       => $member->{firstname} || "",
166
        memberfirstname       => $member->{firstname} || "",
169
        membersurname         => $member->{surname} || "",
167
        membersurname         => $member->{surname} || "",
170
        invoice               => $invoice,
168
        invoiceid             => $invoice->{invoiceid},
169
        invoice               => $invoice->{invoicenumber},
171
        datereceived          => $datereceived->output(),
170
        datereceived          => $datereceived->output(),
172
        datereceived_iso      => $datereceived->output('iso'),
171
        datereceived_iso      => $datereceived->output('iso'),
173
        notes                 => $order->{notes},
172
        notes                 => $order->{notes},
Lines 181-187 else { Link Here
181
    for ( my $i = 0 ; $i < $count ; $i++ ) {
180
    for ( my $i = 0 ; $i < $count ; $i++ ) {
182
        my %line = %{ @$results[$i] };
181
        my %line = %{ @$results[$i] };
183
182
184
        $line{invoice}      = $invoice;
183
        $line{invoice}      = $invoice->{invoicenumber};
185
        $line{datereceived} = $datereceived->output();
184
        $line{datereceived} = $datereceived->output();
186
        $line{freight}      = $freight;
185
        $line{freight}      = $freight;
187
        $line{gst}          = $gst;
186
        $line{gst}          = $gst;
Lines 193-203 else { Link Here
193
192
194
    $template->param(
193
    $template->param(
195
        loop         => \@loop,
194
        loop         => \@loop,
196
        booksellerid   => $booksellerid,
195
        booksellerid => $booksellerid,
196
        invoiceid    => $invoice->{invoiceid},
197
    );
197
    );
198
}
198
}
199
my $op = $input->param('op');
199
my $op = $input->param('op');
200
if ($op eq 'edit'){
200
if ($op and $op eq 'edit'){
201
    $template->param(edit   =>   1);
201
    $template->param(edit   =>   1);
202
}
202
}
203
output_html_with_http_headers $input, $cookie, $template->output;
203
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/parcel.pl (-136 / +123 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 71-86 use C4::Suggestions; Link Here
71
use JSON;
70
use JSON;
72
71
73
my $input=new CGI;
72
my $input=new CGI;
74
my $booksellerid=$input->param('booksellerid');
73
75
my $bookseller=GetBookSellerFromId($booksellerid);
74
my $invoiceid = $input->param('invoiceid');
76
75
my $invoice = GetInvoiceDetails($invoiceid);
77
my $invoice=$input->param('invoice') || '';
76
my $booksellerid = $invoice->{booksellerid};
78
my $freight=$input->param('freight');
77
my $bookseller = GetBookSellerFromId($booksellerid);
79
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
78
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
80
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
79
my $datereceived = C4::Dates->new();
81
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
82
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
83
$datereceived = C4::Dates->new() unless $datereceived;
84
my $code            = $input->param('code');
80
my $code            = $input->param('code');
85
my @rcv_err         = $input->param('error');
81
my @rcv_err         = $input->param('error');
86
my @rcv_err_barcode = $input->param('error_bc');
82
my @rcv_err_barcode = $input->param('error_bc');
Lines 90-105 my $resultsperpage = $input->param('resultsperpage'); Link Here
90
$resultsperpage = 20 unless ($resultsperpage);
86
$resultsperpage = 20 unless ($resultsperpage);
91
$startfrom=0 unless ($startfrom);
87
$startfrom=0 unless ($startfrom);
92
88
93
if($input->param('format') eq "json"){
89
my $format = $input->param('format') || '';
90
if($format eq "json"){
94
    my ($template, $loggedinuser, $cookie)
91
    my ($template, $loggedinuser, $cookie)
95
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
92
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
96
                 query => $input,
93
                 query => $input,
97
				 type => "intranet",
94
                 type => "intranet",
98
                 authnotrequired => 0,
95
                 authnotrequired => 0,
99
                 flagsrequired => {acquisition => 'order_receive'},
96
                 flagsrequired => {acquisition => 'order_receive'},
100
                 debug => 1,
97
                 debug => 1,
101
    });
98
    });
102
       
99
103
    my @datas;
100
    my @datas;
104
    my $search   = $input->param('search') || '';
101
    my $search   = $input->param('search') || '';
105
    my $supplier = $input->param('booksellerid') || '';
102
    my $supplier = $input->param('booksellerid') || '';
Lines 110-116 if($input->param('format') eq "json"){ Link Here
110
    foreach my $order (@$orders){
107
    foreach my $order (@$orders){
111
        if($order->{quantityreceived} < $order->{quantity}){
108
        if($order->{quantityreceived} < $order->{quantity}){
112
            my $data = {};
109
            my $data = {};
113
            
110
114
            $data->{basketno} = $order->{basketno};
111
            $data->{basketno} = $order->{basketno};
115
            $data->{ordernumber} = $order->{ordernumber};
112
            $data->{ordernumber} = $order->{ordernumber};
116
            $data->{title} = $order->{title};
113
            $data->{title} = $order->{title};
Lines 118-131 if($input->param('format') eq "json"){ Link Here
118
            $data->{isbn} = $order->{isbn};
115
            $data->{isbn} = $order->{isbn};
119
            $data->{booksellerid} = $order->{booksellerid};
116
            $data->{booksellerid} = $order->{booksellerid};
120
            $data->{biblionumber} = $order->{biblionumber};
117
            $data->{biblionumber} = $order->{biblionumber};
121
            $data->{freight} = $order->{freight};
122
            $data->{quantity} = $order->{quantity};
118
            $data->{quantity} = $order->{quantity};
123
            $data->{ecost} = $order->{ecost};
119
            $data->{ecost} = $order->{ecost};
124
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
120
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
125
            push @datas, $data;
121
            push @datas, $data;
126
        }
122
        }
127
    }
123
    }
128
    
124
129
    my $json_text = to_json(\@datas);
125
    my $json_text = to_json(\@datas);
130
    $template->param(return => $json_text);
126
    $template->param(return => $json_text);
131
    output_html_with_http_headers $input, $cookie, $template->output;
127
    output_html_with_http_headers $input, $cookie, $template->output;
Lines 135-141 if($input->param('format') eq "json"){ Link Here
135
my ($template, $loggedinuser, $cookie)
131
my ($template, $loggedinuser, $cookie)
136
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
132
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
137
                 query => $input,
133
                 query => $input,
138
				 type => "intranet",
134
                 type => "intranet",
139
                 authnotrequired => 0,
135
                 authnotrequired => 0,
140
                 flagsrequired => {acquisition => 'order_receive'},
136
                 flagsrequired => {acquisition => 'order_receive'},
141
                 debug => 1,
137
                 debug => 1,
Lines 155-164 if( scalar(@rcv_err) ) { Link Here
155
}
151
}
156
152
157
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
153
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
158
my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso'));
154
my @parcelitems   = @{ $invoice->{orders} };
159
my $countlines    = scalar @parcelitems;
155
my $countlines    = scalar @parcelitems;
160
my $totalprice    = 0;
156
my $totalprice    = 0;
161
my $totalfreight  = 0;
162
my $totalquantity = 0;
157
my $totalquantity = 0;
163
my $total;
158
my $total;
164
my $tototal;
159
my $tototal;
Lines 166-180 my @loop_received = (); Link Here
166
161
167
for (my $i = 0 ; $i < $countlines ; $i++) {
162
for (my $i = 0 ; $i < $countlines ; $i++) {
168
163
169
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
164
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};
170
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
171
    $parcelitems[$i]->{'unitprice'} += 0;
165
    $parcelitems[$i]->{'unitprice'} += 0;
172
    my %line;
166
    my %line;
173
    %line          = %{ $parcelitems[$i] };
167
    %line          = %{ $parcelitems[$i] };
174
    $line{invoice} = $invoice;
168
    $line{invoice} = $invoice->{invoicenumber};
175
    $line{gst}     = $gst;
169
    $line{gst}     = $gst;
176
    $line{total} = sprintf($cfstr, $total);
170
    $line{total} = sprintf($cfstr, $total);
177
    $line{booksellerid} = $booksellerid;
171
    $line{booksellerid} = $invoice->{booksellerid};
178
    push @loop_received, \%line;
172
    push @loop_received, \%line;
179
    $totalprice += $parcelitems[$i]->{'unitprice'};
173
    $totalprice += $parcelitems[$i]->{'unitprice'};
180
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
174
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
Lines 184-327 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
184
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
178
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
185
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
179
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
186
180
187
    #double FIXME - totalfreight is redefined later.
188
189
# 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..
190
    if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
191
        warn "FREIGHT CHARGE MISMATCH!!";
192
    }
193
    $totalfreight = $parcelitems[$i]->{'freight'};
194
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
181
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
195
    $tototal       += $total;
182
    $tototal       += $total;
196
}
183
}
197
184
198
my $pendingorders = GetPendingOrders($booksellerid);
185
if(!defined $invoice->{closedate}) {
199
my $countpendings = scalar @$pendingorders;
186
    my $pendingorders = GetPendingOrders($booksellerid);
200
187
    my $countpendings = scalar @$pendingorders;
201
# pending orders totals
188
202
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
189
    # pending orders totals
203
my $ordergrandtotal;
190
    my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
204
my @loop_orders = ();
191
    my $ordergrandtotal;
205
for (my $i = 0 ; $i < $countpendings ; $i++) {
192
    my @loop_orders = ();
206
    my %line;
193
    for (my $i = 0 ; $i < $countpendings ; $i++) {
207
    %line = %{$pendingorders->[$i]};
194
        my %line;
208
   
195
        %line = %{$pendingorders->[$i]};
209
    $line{quantity}+=0;
196
210
    $line{quantityreceived}+=0;
197
        $line{quantity}+=0;
211
    $line{unitprice}+=0;
198
        $line{quantityreceived}+=0;
212
    $totalPunitprice += $line{unitprice};
199
        $line{unitprice}+=0;
213
    $totalPquantity +=$line{quantity};
200
        $totalPunitprice += $line{unitprice};
214
    $totalPqtyrcvd +=$line{quantityreceived};
201
        $totalPquantity +=$line{quantity};
215
    $totalPecost += $line{ecost};
202
        $totalPqtyrcvd +=$line{quantityreceived};
216
    $line{ecost} = sprintf("%.2f",$line{ecost});
203
        $totalPecost += $line{ecost};
217
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
204
        $line{ecost} = sprintf("%.2f",$line{ecost});
218
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
205
        $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
219
    $line{invoice} = $invoice;
206
        $line{unitprice} = sprintf("%.2f",$line{unitprice});
220
    $line{gst} = $gst;
207
        $line{invoice} = $invoice;
221
    $line{total} = $total;
208
        $line{gst} = $gst;
222
    $line{booksellerid} = $booksellerid;
209
        $line{total} = $total;
223
    $ordergrandtotal += $line{ecost} * $line{quantity};
210
        $line{booksellerid} = $booksellerid;
224
    
211
        $ordergrandtotal += $line{ecost} * $line{quantity};
225
    my $biblionumber = $line{'biblionumber'};
212
226
    my $countbiblio = CountBiblioInOrders($biblionumber);
213
        my $biblionumber = $line{'biblionumber'};
227
    my $ordernumber = $line{'ordernumber'};
214
        my $countbiblio = CountBiblioInOrders($biblionumber);
228
    my @subscriptions = GetSubscriptionsId ($biblionumber);
215
        my $ordernumber = $line{'ordernumber'};
229
    my $itemcount = GetItemsCount($biblionumber);
216
        my @subscriptions = GetSubscriptionsId ($biblionumber);
230
    my $holds  = GetHolds ($biblionumber);
217
        my $itemcount = GetItemsCount($biblionumber);
231
    my @items = GetItemnumbersFromOrder( $ordernumber );
218
        my $holds  = GetHolds ($biblionumber);
232
    my $itemholds;
219
        my @items = GetItemnumbersFromOrder( $ordernumber );
233
    foreach my $item (@items){
220
        my $itemholds;
234
        my $nb = GetItemHolds($biblionumber, $item);
221
        foreach my $item (@items){
235
        if ($nb){
222
            my $nb = GetItemHolds($biblionumber, $item);
236
            $itemholds += $nb;
223
            if ($nb){
224
                $itemholds += $nb;
225
            }
237
        }
226
        }
238
    }
239
227
240
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
228
        my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
241
    $line{suggestionid}         = $suggestion->{suggestionid};
229
        $line{suggestionid}         = $suggestion->{suggestionid};
242
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
230
        $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
243
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
231
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
232
233
        # 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
234
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
235
        $line{items}                = ($itemcount) - (scalar @items);
236
        $line{left_item}            = 1 if $line{items} >= 1;
237
        $line{left_biblio}          = 1 if $countbiblio > 1;
238
        $line{biblios}              = $countbiblio - 1;
239
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
240
        $line{subscriptions}        = scalar @subscriptions;
241
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
242
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
243
        $line{holds}                = $holds;
244
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
245
        
246
        
247
        push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
248
    }
244
249
245
    # 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
250
    my $count = $countpendings;
246
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
247
    $line{items}                = ($itemcount) - (scalar @items);
248
    $line{left_item}            = 1 if $line{items} >= 1;
249
    $line{left_biblio}          = 1 if $countbiblio > 1;
250
    $line{biblios}              = $countbiblio - 1;
251
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
252
    $line{subscriptions}        = scalar @subscriptions;
253
    $line{left_holds}           = 1 if $holds >= 1;
254
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
255
    $line{holds}                = $holds;
256
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
257
    
258
    
259
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
260
}
261
$freight = $totalfreight unless $freight;
262
251
263
my $count = $countpendings;
252
    if ($count>$resultsperpage){
253
        my $displaynext=0;
254
        my $displayprev=$startfrom;
255
        if(($count - ($startfrom+$resultsperpage)) > 0 ) {
256
            $displaynext = 1;
257
        }
264
258
265
if ($count>$resultsperpage){
259
        my @numbers = ();
266
    my $displaynext=0;
260
        for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
267
    my $displayprev=$startfrom;
261
                my $highlight=0;
268
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
262
                ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
269
        $displaynext = 1;
263
                push @numbers, { number => $i,
270
    }
264
                    highlight => $highlight ,
265
                    startfrom => ($i-1)*$resultsperpage};
266
        }
271
267
272
    my @numbers = ();
268
        my $from = $startfrom*$resultsperpage+1;
273
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
269
        my $to;
274
            my $highlight=0;
270
        if($count < (($startfrom+1)*$resultsperpage)){
275
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
271
            $to = $count;
276
            push @numbers, { number => $i,
272
        } else {
277
                highlight => $highlight ,
273
            $to = (($startfrom+1)*$resultsperpage);
278
                startfrom => ($i-1)*$resultsperpage};
274
        }
275
        $template->param(numbers=>\@numbers,
276
                         displaynext=>$displaynext,
277
                         displayprev=>$displayprev,
278
                         nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
279
                         prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
280
                        );
279
    }
281
    }
280
282
281
    my $from = $startfrom*$resultsperpage+1;
283
    $template->param(
282
    my $to;
284
        countpending => $countpendings,
283
    if($count < (($startfrom+1)*$resultsperpage)){
285
        loop_orders  => \@loop_orders,
284
        $to = $count;
286
        ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
285
    } else {
287
        totalPunitprice => sprintf("%.2f", $totalPunitprice),
286
        $to = (($startfrom+1)*$resultsperpage);
288
        totalPquantity  => $totalPquantity,
287
    }
289
        totalPqtyrcvd   => $totalPqtyrcvd,
288
    $template->param(numbers=>\@numbers,
290
        totalPecost     => sprintf("%.2f", $totalPecost),
289
                     displaynext=>$displaynext,
291
    );
290
                     displayprev=>$displayprev,
291
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
292
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
293
                    );
294
}
292
}
295
293
296
#$totalfreight=$freight;
297
$tototal = $tototal + $freight;
298
294
299
$template->param(
295
$template->param(
300
    invoice               => $invoice,
296
    invoiceid             => $invoice->{invoiceid},
297
    invoice               => $invoice->{invoicenumber},
298
    invoiceclosedate      => $invoice->{closedate},
301
    datereceived          => $datereceived->output('iso'),
299
    datereceived          => $datereceived->output('iso'),
302
    invoicedatereceived   => $datereceived->output('iso'),
300
    invoicedatereceived   => $datereceived->output('iso'),
303
    formatteddatereceived => $datereceived->output(),
301
    formatteddatereceived => $datereceived->output(),
304
    name                  => $bookseller->{'name'},
302
    name                  => $bookseller->{'name'},
305
    booksellerid            => $booksellerid,
303
    booksellerid          => $bookseller->{id},
306
    gst                   => $gst,
304
    gst                   => $gst,
307
    freight               => $freight,
308
    invoice               => $invoice,
309
    countreceived         => $countlines,
305
    countreceived         => $countlines,
310
    loop_received         => \@loop_received,
306
    loop_received         => \@loop_received,
311
    countpending          => $countpendings,
312
    loop_orders           => \@loop_orders,
313
    totalprice            => sprintf($cfstr, $totalprice),
307
    totalprice            => sprintf($cfstr, $totalprice),
314
    totalfreight          => $totalfreight,
315
    totalquantity         => $totalquantity,
308
    totalquantity         => $totalquantity,
316
    tototal               => sprintf($cfstr, $tototal),
309
    tototal               => sprintf($cfstr, $tototal),
317
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
318
    gst                   => $gst,
310
    gst                   => $gst,
319
    grandtot              => sprintf($cfstr, $tototal + $gst),
311
    grandtot              => sprintf($cfstr, $tototal + $gst),
320
    totalPunitprice       => sprintf("%.2f", $totalPunitprice),
321
    totalPquantity        => $totalPquantity,
322
    totalPqtyrcvd         => $totalPqtyrcvd,
323
    totalPecost           => sprintf("%.2f", $totalPecost),
324
    resultsperpage        => $resultsperpage,
312
    resultsperpage        => $resultsperpage,
325
);
313
);
326
output_html_with_http_headers $input, $cookie, $template->output;
314
output_html_with_http_headers $input, $cookie, $template->output;
327
 
(-)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 => $booksellerid,
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($booksellerid);
120
my $bookseller = GetBookSellerFromId($booksellerid);
100
my @parcels = GetParcels( $booksellerid, $order, $code, $datefrom, $dateto );
121
my @parcels = GetInvoices(
122
    supplierid => $booksellerid,
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
    booksellerid             => $booksellerid,
167
    booksellerid             => $booksellerid,
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 (+192 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
9
[% INCLUDE 'datatables-strings.inc' %]
10
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
11
<script type="text/javascript">
12
//<![CDATA[
13
    $(document).ready(function() {
14
        $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
15
            bInfo: false,
16
            bPaginate: false,
17
            bFilter: false,
18
        }));
19
        Calendar.setup({
20
            inputField: "shipmentdate",
21
            ifFormat: "[% DHTMLcalendar_dateformat %]",
22
            button: "shipmentdateCalendar"
23
        });
24
        Calendar.setup({
25
            inputField: "billingdate",
26
            ifFormat: "[% DHTMLcalendar_dateformat %]",
27
            button: "billingdateCalendar"
28
        });
29
    });
30
//]]>
31
</script>
32
</head>
33
34
<body>
35
[% INCLUDE 'header.inc' %]
36
[% INCLUDE 'acquisitions-search.inc' %]
37
38
<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>
39
40
<div id="doc3" class="yui-t2">
41
42
<div id="bd">
43
  <div id="yui-main">
44
    <div class="yui-b">
45
      [% IF ( modified ) %]
46
        <div class="dialog">
47
          <p>Invoice has been modified</p>
48
        </div>
49
      [% END %]
50
      <h1>Invoice: [% invoicenumber %]</h1>
51
52
      <p>Supplier: [% suppliername %]</p>
53
      <form action="" method="post">
54
        <label for="shipmentdate">Shipment date:</label>
55
        [% IF (shipmentdate) %]
56
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" readonly="readonly" />
57
        [% ELSE %]
58
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" readonly="readonly" />
59
        [% END %]
60
        <img id="shipmentdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
61
        <p></p>
62
        <label for="billingdate">Billing date:</label>
63
        [% IF (billingdate) %]
64
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
65
        [% ELSE %]
66
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
67
        [% END %]
68
        <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
69
        <p></p>
70
        <label for="shipmentcost">Shipment cost:</label>
71
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
72
        <label for="shipment_budget_id">Budget:</label>
73
        <select id="shipment_budget_id" name="shipment_budget_id">
74
            <option value="">No budget</option>
75
          [% FOREACH budget IN budgets_loop %]
76
            [% IF ( budget.selected ) %]
77
              <option selected="selected" value="[% budget.budget_id %]">
78
            [% ELSE %]
79
              <option value="[% budget.budget_id %]">
80
            [% END %]
81
              [% budget.budget_name %]
82
            </option>
83
          [% END %]
84
        </select>
85
        <input type="hidden" name="op" value="mod" />
86
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
87
        <fieldset class="action">
88
            <input type="submit" value="Save">
89
        </fieldset>
90
      </form>
91
      <p>Status:
92
        [% IF ( invoiceclosedate ) %]
93
          Closed on [% invoiceclosedate | $KohaDates %].
94
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
95
            Reopen
96
          </a>
97
        [% ELSE %]
98
          Open.
99
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
100
            Close
101
          </a>
102
        [% END %]
103
      </p>
104
      <p>
105
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
106
      </p>
107
      <h2>Invoice details</h2>
108
      [% IF orders_loop.size %]
109
          <table id="orderst">
110
            <thead>
111
              <tr>
112
                <th>Summary</th>
113
                <th>Publisher</th>
114
                <th>Branch</th>
115
                <th>RRP</th>
116
                <th>Est.</th>
117
                <th>Qty.</th>
118
                <th>Total</th>
119
                <th>Fund</th>
120
              </tr>
121
            </thead>
122
            <tbody>
123
              [% FOREACH order IN orders_loop %]
124
                <tr>
125
                  <td><p>[% order.title %]
126
                    [% IF ( order.author ) %]
127
                      <br /><em>by</em> [% order.author %]
128
                    [% END %]
129
                  </p></td>
130
                  <td>
131
                    [% IF ( order.publishercode ) %]
132
                      <p>[% order.publishercode %]
133
                        [% IF ( order.publicationyear ) %]
134
                          - [% order.publicationyear %]
135
                        [% END %]
136
                      </p>
137
                    [% END %]
138
                  </td>
139
                  <td><p>[% order.branchcode %]</p></td>
140
                  <td>[% order.rrp %]</td>
141
                  <td>[% order.ecost %]</td>
142
                  <td class="number">[% order.quantity %]</td>
143
                  <td>[% order.total %]</td>
144
                  <td>[% order.budget_name %]</td>
145
                </tr>
146
              [% END %]
147
            </tbody>
148
            <tfoot>
149
                <tr>
150
                    <th colspan="3">Total Tax Exc.</th>
151
                    <th>[% total_rrp_gste %]</th>
152
                    <th>&nbsp;</th>
153
                    <th>[% total_quantity %]</th>
154
                    <th>[% total_est_gste %]</th>
155
                    <th>&nbsp;</th>
156
                </tr>
157
                <tr>
158
                    <th colspan='3'>Tax ([% gist %]%)</th>
159
                    <th>[% gist_rrp %]</th>
160
                    <th>&nbsp;</th>
161
                    <th>&nbsp;</th>
162
                    <th>[% gist_est %]</th>
163
                    <th>&nbsp;</th>
164
                </tr>
165
                <tr>
166
                    <th colspan='3'>Total Tax Inc. ([% currency %])</th>
167
                    <th>[% total_rrp_gsti %]</th>
168
                    <th>&nbsp;</th>
169
                    <th>[% total_quantity %]</th>
170
                    <th>[% total_est_gsti %]</th>
171
                    <th>&nbsp;</th>
172
                </tr>
173
                <tr>
174
                    <th colspan="3">Total + Shipment cost ([% currency %])</th>
175
                    <th>&nbsp;</th>
176
                    <th>&nbsp;</th>
177
                    <th>[% total_quantity %]</th>
178
                    <th>[% total_gsti_shipment %]</th>
179
                    <th>&nbsp;</th>
180
                </tr>
181
            </tfoot>
182
          </table>
183
        [% ELSE %]
184
            <p>No orders yet</p>
185
        [% END %]
186
    </div>
187
  </div>
188
  <div class="yui-b">
189
    [% INCLUDE 'acquisitions-menu.inc' %]
190
  </div>
191
</div>
192
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+228 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoices</title>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'doc-head-close.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
8
[% INCLUDE 'datatables-strings.inc' %]
9
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
10
[% INCLUDE 'calendar.inc' %]
11
<script type="text/javascript">
12
//<![CDATA[
13
$(document).ready(function() {
14
    Calendar.setup({
15
        inputField: "billingdatefrom",
16
        ifFormat: "[% DHTMLcalendar_dateformat %]",
17
        button: "billingdatefromCalendar"
18
    });
19
    Calendar.setup({
20
        inputField: "billingdateto",
21
        ifFormat: "[% DHTMLcalendar_dateformat %]",
22
        button: "billingdatetoCalendar"
23
    });
24
    $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
25
        bInfo: false,
26
        bPaginate: false,
27
        bFilter: false,
28
        aoColumnDefs: [
29
            { "bSortable": false, "aTargets": [6] }
30
        ]
31
    }));
32
});
33
//]]>
34
</script>
35
</head>
36
37
<body>
38
[% INCLUDE 'header.inc' %]
39
[% INCLUDE 'acquisitions-search.inc' %]
40
41
<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>
42
43
<div id="doc3" class="yui-t2">
44
45
<div id="bd">
46
  <div id="yui-main">
47
    <div class="yui-b">
48
      <h1>Invoices</h1>
49
      [% IF ( do_search ) %]
50
        [% IF ( results_loop ) %]
51
          <table id="resultst">
52
            <thead>
53
              <tr>
54
                <th>Invoice no.</th>
55
                <th>Vendor</th>
56
                <th>Billing date</th>
57
                <th>Received biblios</th>
58
                <th>Received items</th>
59
                <th>Status</th>
60
                <th>&nbsp;</th>
61
              </tr>
62
            </thead>
63
            <tbody>
64
              [% FOREACH result IN results_loop %]
65
                <tr>
66
                  <td>[% result.invoicenumber %]</td>
67
                  <td>[% result.suppliername %]</td>
68
                  <td>
69
                    [% IF (result.billingdate) %]
70
                      [% result.billingdate | $KohaDates %]
71
                    [% END %]
72
                  </td>
73
                  <td>[% result.receivedbiblios %]</td>
74
                  <td>[% result.receiveditems %]</td>
75
                  <td>
76
                    [% IF ( result.closedate ) %]
77
                      Closed on [% result.closedate | $KohaDates %]
78
                    [% ELSE %]
79
                      Open
80
                    [% END %]
81
                  </td>
82
                  <td>
83
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
84
                    [% IF ( result.closedate ) %]
85
                      <a href="invoice.pl?op=reopen&invoiceid=[% result.invoiceid %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber %]%26supplier=[% supplier %]%26billingdatefrom=[% billingdatefrom %]%26billingdateto=[% billingdateto %]%26isbneanissn=[% isbneanissn %]%26title=[% title %]%26author=[% author %]%26publisher=[% publisher %]%26publicationyear=[% publicationyear %]%26branch=[% branch %]">Reopen</a>
86
                    [% ELSE %]
87
                      <a href="invoice.pl?op=close&invoiceid=[% result.invoiceid %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber %]%26supplier=[% supplier %]%26billingdatefrom=[% billingdatefrom %]%26billingdateto=[% billingdateto %]%26isbneanissn=[% isbneanissn %]%26title=[% title %]%26author=[% author %]%26publisher=[% publisher %]%26publicationyear=[% publicationyear %]%26branch=[% branch %]">Close</a>
88
                    [% END %]
89
                  </td>
90
                </tr>
91
              [% END %]
92
            </tbody>
93
          </table>
94
        [% ELSE %]
95
          <p>Sorry, but there is no results for your search.</p>
96
          <p>Search was:
97
            <ul>
98
              [% IF ( invoicenumber ) %]
99
                <li>Invoice no.: [% invoicenumber %]</li>
100
              [% END %]
101
              [% IF ( supplier ) %]
102
                <li>Vendor: [% suppliername %]</li>
103
              [% END %]
104
              [% IF ( billingdatefrom ) %]
105
                <li>Billing date:
106
                [% IF ( billingdateto ) %]
107
                  From [% billingdatefrom %]
108
                  To [% billingdateto %]
109
                [% ELSE %]
110
                  All since [% billingdatefrom %]
111
                [% END %]
112
                </li>
113
              [% ELSE %]
114
                [% IF ( billingdateto ) %]
115
                  <li>Billing date:
116
                    All until [% billingdateto %]
117
                  </li>
118
                [% END %]
119
              [% END %]
120
              [% IF ( isbneanissn ) %]
121
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
122
              [% END %]
123
              [% IF ( title ) %]
124
                <li>Title: [% title %]</li>
125
              [% END %]
126
              [% IF ( author ) %]
127
                <li>Author: [% author %]</li>
128
              [% END %]
129
              [% IF ( publisher ) %]
130
                <li>Publisher: [% publisher %]</li>
131
              [% END %]
132
              [% IF ( publicationyear ) %]
133
                <li>Publication year: [% publicationyear %]</li>
134
              [% END %]
135
              [% IF ( branch ) %]
136
                <li>Branch: [% branchname %]</li>
137
              [% END %]
138
            </ul>
139
          </p>
140
        [% END %]<!-- results_loop -->
141
      [% ELSE %]
142
        <p>Please fill in the form to the left to make a search.</p>
143
      [% END %]<!-- do_search -->
144
    </div>
145
  </div>
146
  <div class="yui-b">
147
    <form action="" method="get">
148
      <fieldset class="brief">
149
        <h3>Search filters</h3>
150
        <ol>
151
          <li>
152
            <label for="invoicenumber">Invoice no:</label>
153
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
154
          </li>
155
          <li>
156
            <label for="supplier">Supplier:</label>
157
            <select id="supplier" name="supplier">
158
              <option value="">All</option>
159
              [% FOREACH supplier IN suppliers_loop %]
160
                [% IF ( supplier.selected ) %]
161
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
162
                [% ELSE %]
163
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
164
                [% END %]
165
              [% END %]
166
            </select>
167
          </li>
168
          <li>
169
            <fieldset class="brief">
170
              <legend>Billing date</legend>
171
              <ol>
172
                <li>
173
                  <label for="billingdatefrom">From:</label>
174
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" />
175
                  <img id="billingdatefromCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
176
                </li>
177
                <li>
178
                  <label for="billingdateto">To:</label>
179
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" />
180
                  <img id="billingdatetoCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
181
                </li>
182
              </ol>
183
            </fieldset>
184
          </li>
185
          <li>
186
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
187
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
188
          </li>
189
          <li>
190
            <label for="title">Title:</label>
191
            <input type="text" id="title" name="title" value="[% title %]" />
192
          </li>
193
          <li>
194
            <label for="author">Author:</label>
195
            <input type="text" id="author" name="author" value="[% author %]" />
196
          </li>
197
          <li>
198
            <label for="publisher">Publisher:</label>
199
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
200
          </li>
201
          <li>
202
            <label for="publicationyear">Publication year:</label>
203
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
204
          </li>
205
          <li>
206
            <label for="branch">Branch:</label>
207
            <select id="branch" name="branch">
208
              <option value="">All</option>
209
              [% FOREACH branch IN branches_loop %]
210
                [% IF ( branch.selected ) %]
211
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
212
                [% ELSE %]
213
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
214
                [% END %]
215
              [% END %]
216
            </select>
217
          </li>
218
        </ol>
219
        <fieldset class="action">
220
          <input type="submit" value="Search" />
221
        </fieldset>
222
      </fieldset>
223
      <input type="hidden" name="op" id="op" value="do_search" />
224
    </form>
225
    [% INCLUDE 'acquisitions-menu.inc' %]
226
  </div>
227
</div>
228
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +3 lines)
Lines 91-101 Link Here
91
    </fieldset>
91
    </fieldset>
92
    [% END %] <!-- items -->
92
    [% END %] <!-- items -->
93
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
93
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
94
    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
94
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
95
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
95
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
96
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
96
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
97
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
97
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
98
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
98
    <input type="hidden" name="freight" value="[% freight %]" />
99
    <input type="hidden" name="gst" value="[% gst %]" />
99
    <input type="hidden" name="gst" value="[% gst %]" />
100
	</div>
100
	</div>
101
	<div class="yui-u">
101
	<div class="yui-u">
Lines 143-154 Link Here
143
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
143
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
144
        [% END %]</li></ol>
144
        [% END %]</li></ol>
145
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
145
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
146
        <input type="hidden" name="invoice" value="[% invoice %]" />
147
    </fieldset>
146
    </fieldset>
148
147
149
</div>
148
</div>
150
</div><div class="yui-g"><fieldset class="action">
149
</div><div class="yui-g"><fieldset class="action">
151
        <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?booksellerid=[% booksellerid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
150
        <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>
152
</fieldset></div>    </form>
151
</fieldset></div>    </form>
153
[% ELSE %]
152
[% ELSE %]
154
<div id="acqui_acquire_orderlist">
153
<div id="acqui_acquire_orderlist">
Lines 165-171 Link Here
165
        <tr>
164
        <tr>
166
            <td>[% loo.basketno %]</td>
165
            <td>[% loo.basketno %]</td>
167
            <td>[% loo.isbn %]</td>
166
            <td>[% loo.isbn %]</td>
168
         <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>
167
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
169
            <td>[% loo.author %]</td>
168
            <td>[% loo.author %]</td>
170
            <td>[% loo.quantity %]</td>
169
            <td>[% loo.quantity %]</td>
171
            <td>[% loo.quantityreceived %]</td>
170
            <td>[% loo.quantityreceived %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-102 / +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-305 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.booksellerid %]">[% 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
                [% IF ( loop_order.suggestionid ) %]
225
                <th>&nbsp;</th>
245
                    <br/>
246
                    Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
247
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]">suggestion #[% loop_order.suggestionid %]</a>)
248
                [% END %]
249
                </td>
250
                <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>
251
                <td>[% loop_order.quantity %]</td>
252
                <td>[% loop_order.ecost %]</td>
253
                <td>[% loop_order.ordertotal %]</td>
254
				<td>
255
				    <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;booksellerid=[% loop_order.booksellerid %]">Receive</a>
256
				    
257
				</td>
258
				<td>
259
				    [% IF ( loop_order.left_holds_on_order ) %]
260
                    <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>
261
                    [% ELSE %]
262
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
263
                    [% END %]
264
                    [% IF ( loop_order.can_del_bib ) %]
265
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
266
                    [% ELSE %]
267
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
268
                    [% END %]
269
                    [% IF ( loop_order.left_item ) %]
270
                    <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
271
                    [% END %]
272
                    [% IF ( loop_order.left_biblio ) %]
273
                    <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
274
                    [% END %]
275
                    [% IF ( loop_order.left_subscription ) %]
276
                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
277
                    [% END %]
278
                    [% IF ( loop_order.left_holds ) %]
279
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
280
                    [% END %]
281
				</td>
282
            </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.booksellerid %]">[% 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;booksellerid=[% booksellerid %]&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>
283
        [% END %]
292
        [% END %]
284
    </tbody>
293
        [% FOREACH number IN numbers %]
285
     </table>[% ELSE %]There are no pending orders.[% END %]
294
            [% IF ( number.highlight ) %]
286
   <div id="resultnumber">
295
            <span class="current">[% number.number %]</span>
287
	<!-- Row of numbers corresponding to search result pages -->
296
            [% ELSE %]
288
	[% IF ( displayprev ) %]
297
            <a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&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>
289
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&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 %]
290
	[% END %]
299
        [% END %]
291
	[% FOREACH number IN numbers %]
300
        [% IF ( displaynext ) %]
292
		[% IF ( number.highlight ) %]
301
            <a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&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>
293
		<span class="current">[% number.number %]</span>
302
        [% END %]
294
		[% ELSE %]
303
        </div>
295
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&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>
296
		[% END %]
305
[% ELSE %]
297
	[% END %]
306
    <p>
298
	[% IF ( displaynext ) %]
307
        Invoice is close, so you can't receive orders.
299
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&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>.
300
	[% END %]
309
    </p>
301
	</div>
310
[% END %]
302
</div>
311
303
<div id="acqui_receive_receivelist">
312
<div id="acqui_receive_receivelist">
304
    <h3>Already Received</h3>
313
    <h3>Already Received</h3>
305
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?booksellerid=[% booksellerid %]">[% name %]</a></h1>
23
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% 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;booksellerid=[% booksellerid |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