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

(-)a/C4/Acquisition.pm (-15 / +391 lines)
Lines 62-67 BEGIN { Link Here
62
        &GetParcels &GetParcel
62
        &GetParcels &GetParcel
63
        &GetContracts &GetContract
63
        &GetContracts &GetContract
64
64
65
        &GetInvoices
66
        &GetInvoice
67
        &GetInvoiceDetails
68
        &AddInvoice
69
        &ModInvoice
70
        &DelInvoice
71
        &CloseInvoice
72
        &ReopenInvoice
73
65
        &GetItemnumbersFromOrder
74
        &GetItemnumbersFromOrder
66
75
67
        &AddClaim
76
        &AddClaim
Lines 1138-1144 C<$ordernumber>. Link Here
1138
sub ModReceiveOrder {
1147
sub ModReceiveOrder {
1139
    my (
1148
    my (
1140
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1149
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1141
        $invoiceno, $freight, $rrp, $budget_id, $datereceived
1150
        $invoiceid, $rrp, $budget_id, $datereceived
1142
    )
1151
    )
1143
    = @_;
1152
    = @_;
1144
    my $dbh = C4::Context->dbh;
1153
    my $dbh = C4::Context->dbh;
Lines 1164-1177 sub ModReceiveOrder { Link Here
1164
            UPDATE aqorders
1173
            UPDATE aqorders
1165
            SET quantityreceived=?
1174
            SET quantityreceived=?
1166
                , datereceived=?
1175
                , datereceived=?
1167
                , booksellerinvoicenumber=?
1176
                , invoiceid=?
1168
                , unitprice=?
1177
                , unitprice=?
1169
                , freight=?
1170
                , rrp=?
1178
                , rrp=?
1171
                , quantity=?
1179
                , quantity=?
1172
            WHERE biblionumber=? AND ordernumber=?");
1180
            WHERE biblionumber=? AND ordernumber=?");
1173
1181
1174
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
1182
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$quantrec,$biblionumber,$ordernumber);
1175
        $sth->finish;
1183
        $sth->finish;
1176
1184
1177
        # create a new order for the remaining items, and set its bookfund.
1185
        # create a new order for the remaining items, and set its bookfund.
Lines 1183-1192 sub ModReceiveOrder { Link Here
1183
        my $newOrder = NewOrder($order);
1191
        my $newOrder = NewOrder($order);
1184
} else {
1192
} else {
1185
        $sth=$dbh->prepare("update aqorders
1193
        $sth=$dbh->prepare("update aqorders
1186
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1194
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1187
                                unitprice=?,freight=?,rrp=?
1195
                                unitprice=?,rrp=?
1188
                            where biblionumber=? and ordernumber=?");
1196
                            where biblionumber=? and ordernumber=?");
1189
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1197
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1190
        $sth->finish;
1198
        $sth->finish;
1191
    }
1199
    }
1192
    return $datereceived;
1200
    return $datereceived;
Lines 1341-1349 sub GetParcel { Link Here
1341
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1349
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1342
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1350
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1343
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1351
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1352
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1344
        WHERE
1353
        WHERE
1345
            aqbasket.booksellerid = ?
1354
            aqbasket.booksellerid = ?
1346
            AND aqorders.booksellerinvoicenumber LIKE ?
1355
            AND aqinvoices.invoicenumber LIKE ?
1347
            AND aqorders.datereceived = ? ";
1356
            AND aqorders.datereceived = ? ";
1348
1357
1349
    my @query_params = ( $supplierid, $code, $datereceived );
1358
    my @query_params = ( $supplierid, $code, $datereceived );
Lines 1416-1433 sub GetParcels { Link Here
1416
    my $dbh    = C4::Context->dbh;
1425
    my $dbh    = C4::Context->dbh;
1417
    my @query_params = ();
1426
    my @query_params = ();
1418
    my $strsth ="
1427
    my $strsth ="
1419
        SELECT  aqorders.booksellerinvoicenumber,
1428
        SELECT  aqinvoices.invoicenumber,
1420
                datereceived,purchaseordernumber,
1429
                datereceived,purchaseordernumber,
1421
                count(DISTINCT biblionumber) AS biblio,
1430
                count(DISTINCT biblionumber) AS biblio,
1422
                sum(quantity) AS itemsexpected,
1431
                sum(quantity) AS itemsexpected,
1423
                sum(quantityreceived) AS itemsreceived
1432
                sum(quantityreceived) AS itemsreceived
1424
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1433
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1434
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1425
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1435
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1426
    ";
1436
    ";
1427
    push @query_params, $bookseller;
1437
    push @query_params, $bookseller;
1428
1438
1429
    if ( defined $code ) {
1439
    if ( defined $code ) {
1430
        $strsth .= ' and aqorders.booksellerinvoicenumber like ? ';
1440
        $strsth .= ' and aqinvoices.invoicenumber like ? ';
1431
        # add a % to the end of the code to allow stemming.
1441
        # add a % to the end of the code to allow stemming.
1432
        push @query_params, "$code%";
1442
        push @query_params, "$code%";
1433
    }
1443
    }
Lines 1442-1448 sub GetParcels { Link Here
1442
        push @query_params, $dateto;
1452
        push @query_params, $dateto;
1443
    }
1453
    }
1444
1454
1445
    $strsth .= "group by aqorders.booksellerinvoicenumber,datereceived ";
1455
    $strsth .= "group by aqinvoices.invoicenumber,datereceived ";
1446
1456
1447
    # can't use a placeholder to place this column name.
1457
    # can't use a placeholder to place this column name.
1448
    # but, we could probably be checking to make sure it is a column that will be fetched.
1458
    # but, we could probably be checking to make sure it is a column that will be fetched.
Lines 1657-1663 sub GetHistory { Link Here
1657
            aqorders.quantityreceived,
1667
            aqorders.quantityreceived,
1658
            aqorders.ecost,
1668
            aqorders.ecost,
1659
            aqorders.ordernumber,
1669
            aqorders.ordernumber,
1660
            aqorders.booksellerinvoicenumber as invoicenumber,
1670
            aqinvoices.invoicenumber,
1661
            aqbooksellers.id as id,
1671
            aqbooksellers.id as id,
1662
            aqorders.biblionumber
1672
            aqorders.biblionumber
1663
        FROM aqorders
1673
        FROM aqorders
Lines 1665-1671 sub GetHistory { Link Here
1665
    LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1675
    LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1666
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1676
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1667
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1677
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1668
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1678
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
1679
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
1669
1680
1670
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1681
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1671
    if ( C4::Context->preference("IndependantBranches") );
1682
    if ( C4::Context->preference("IndependantBranches") );
Lines 1716-1723 sub GetHistory { Link Here
1716
    }
1727
    }
1717
1728
1718
    if ($booksellerinvoicenumber) {
1729
    if ($booksellerinvoicenumber) {
1719
        $query .= " AND (aqorders.booksellerinvoicenumber LIKE ? OR aqbasket.booksellerinvoicenumber LIKE ?)";
1730
        $query .= " AND aqinvoices.invoicenumber LIKE ? ";
1720
        push @query_params, "%$booksellerinvoicenumber%", "%$booksellerinvoicenumber%";
1731
        push @query_params, "%$booksellerinvoicenumber%";
1721
    }
1732
    }
1722
1733
1723
    if ( C4::Context->preference("IndependantBranches") ) {
1734
    if ( C4::Context->preference("IndependantBranches") ) {
Lines 1858-1864 sub AddClaim { Link Here
1858
        ";
1869
        ";
1859
    my $sth = $dbh->prepare($query);
1870
    my $sth = $dbh->prepare($query);
1860
    $sth->execute($ordernumber);
1871
    $sth->execute($ordernumber);
1872
}
1873
1874
=head3 GetInvoices
1875
1876
    my @invoices = GetInvoices(
1877
        invoicenumber => $invoicenumber,
1878
        suppliername => $suppliername,
1879
        shipmentdatefrom => $shipmentdatefrom, # ISO format
1880
        shipmentdateto => $shipmentdateto, # ISO format
1881
        billingdatefrom => $billingdatefrom, # ISO format
1882
        billingdateto => $billingdateto, # ISO format
1883
        isbneanissn => $isbn_or_ean_or_issn,
1884
        title => $title,
1885
        invoicenote => $invoicenote
1886
        author => $author,
1887
        publisher => $publisher,
1888
        publicationyear => $publicationyear,
1889
        branchcode => $branchcode,
1890
        order_by => $order_by
1891
    );
1892
1893
Return a list of invoices that match all given criteria.
1894
1895
$order_by is "column_name (asc|desc)", where column_name is any of
1896
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
1897
'shipmentcost', 'shipmentcost_budgetid'.
1898
1899
asc is the default if omitted
1900
1901
=cut
1902
1903
sub GetInvoices {
1904
    my %args = @_;
1905
1906
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
1907
        closedate shipmentcost shipmentcost_budgetid invoicenote);
1908
1909
    my $dbh = C4::Context->dbh;
1910
    my $query = qq{
1911
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername,
1912
          COUNT(
1913
            DISTINCT IF(
1914
              aqorders.datereceived IS NOT NULL,
1915
              aqorders.biblionumber,
1916
              NULL
1917
            )
1918
          ) AS receivedbiblios,
1919
          SUM(aqorders.quantityreceived) AS receiveditems
1920
        FROM aqinvoices
1921
          LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
1922
          LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid
1923
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1924
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
1925
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
1926
    };
1927
1928
    my @bind_args;
1929
    my @bind_strs;
1930
    if($args{supplierid}) {
1931
        push @bind_strs, " aqinvoices.booksellerid = ? ";
1932
        push @bind_args, $args{supplierid};
1933
    }
1934
    if($args{invoicenumber}) {
1935
        push @bind_strs, " aqinvoices.invoicenumber LIKE ? ";
1936
        push @bind_args, "%$args{invoicenumber}%";
1937
    }
1938
    if($args{invoicenote}) {
1939
        push @bind_strs, " aqinvoices.invoicenote LIKE ? ";
1940
        push @bind_args, "%$args{invoicenote}%";
1941
    }
1942
    if($args{suppliername}) {
1943
        push @bind_strs, " aqbooksellers.name LIKE ? ";
1944
        push @bind_args, "%$args{suppliername}%";
1945
    }
1946
    if($args{shipmentdatefrom}) {
1947
        push @bind_strs, " aqinvoices.shipementdate >= ? ";
1948
        push @bind_args, $args{shipementdatefrom};
1949
    }
1950
    if($args{shipmentdateto}) {
1951
        push @bind_strs, " aqinvoices.shipementdate <= ? ";
1952
        push @bind_args, $args{shipementdateto};
1953
    }
1954
    if($args{billingdatefrom}) {
1955
        push @bind_strs, " aqinvoices.billingdate >= ? ";
1956
        push @bind_args, $args{billingdatefrom};
1957
    }
1958
    if($args{billingdateto}) {
1959
        push @bind_strs, " aqinvoices.billingdate <= ? ";
1960
        push @bind_args, $args{billingdateto};
1961
    }
1962
    if($args{isbneanissn}) {
1963
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
1964
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
1965
    }
1966
    if($args{title}) {
1967
        push @bind_strs, " biblio.title LIKE ? ";
1968
        push @bind_args, $args{title};
1969
    }
1970
    if($args{author}) {
1971
        push @bind_strs, " biblio.author LIKE ? ";
1972
        push @bind_args, $args{author};
1973
    }
1974
    if($args{publisher}) {
1975
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
1976
        push @bind_args, $args{publisher};
1977
    }
1978
    if($args{publicationyear}) {
1979
        push @bind_strs, " biblioitems.publicationyear = ? ";
1980
        push @bind_args, $args{publicationyear};
1981
    }
1982
    if($args{branchcode}) {
1983
        push @bind_strs, " aqorders.branchcode = ? ";
1984
        push @bind_args, $args{branchcode};
1985
    }
1986
1987
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
1988
    $query .= " GROUP BY aqinvoices.invoiceid ";
1989
1990
    if($args{order_by}) {
1991
        my ($column, $direction) = split / /, $args{order_by};
1992
        if(grep /^$column$/, @columns) {
1993
            $direction ||= 'ASC';
1994
            $query .= " ORDER BY $column $direction";
1995
        }
1996
    }
1997
1998
    my $sth = $dbh->prepare($query);
1999
    $sth->execute(@bind_args);
2000
2001
    my $results = $sth->fetchall_arrayref({});
2002
    return @$results;
2003
}
2004
2005
=head3 GetInvoice
2006
2007
    my $invoice = GetInvoice($invoiceid);
2008
2009
Get informations about invoice with given $invoiceid
2010
2011
Return a hash filled with aqinvoices.* fields
2012
2013
=cut
2014
2015
sub GetInvoice {
2016
    my ($invoiceid) = @_;
2017
    my $invoice;
2018
2019
    return unless $invoiceid;
2020
2021
    my $dbh = C4::Context->dbh;
2022
    my $query = qq{
2023
        SELECT *
2024
        FROM aqinvoices
2025
        WHERE invoiceid = ?
2026
    };
2027
    my $sth = $dbh->prepare($query);
2028
    $sth->execute($invoiceid);
2029
2030
    $invoice = $sth->fetchrow_hashref;
2031
    return $invoice;
2032
}
2033
2034
=head3 GetInvoiceDetails
2035
2036
    my $invoice = GetInvoiceDetails($invoiceid)
2037
2038
Return informations about an invoice + the list of related order lines
2039
2040
Orders informations are in $invoice->{orders} (array ref)
2041
2042
=cut
2043
2044
sub GetInvoiceDetails {
2045
    my ($invoiceid) = @_;
2046
    my $invoice;
2047
2048
    return unless $invoiceid;
2049
2050
    my $dbh = C4::Context->dbh;
2051
    my $query = qq{
2052
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername
2053
        FROM aqinvoices
2054
          LEFT JOIN aqbooksellers ON aqinvoices.booksellerid = aqbooksellers.id
2055
        WHERE invoiceid = ?
2056
    };
2057
    my $sth = $dbh->prepare($query);
2058
    $sth->execute($invoiceid);
2059
2060
    $invoice = $sth->fetchrow_hashref;
2061
2062
    $query = qq{
2063
        SELECT aqorders.*, biblio.*
2064
        FROM aqorders
2065
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2066
        WHERE invoiceid = ?
2067
    };
2068
    $sth = $dbh->prepare($query);
2069
    $sth->execute($invoiceid);
2070
    $invoice->{orders} = $sth->fetchall_arrayref({});
2071
    $invoice->{orders} ||= []; # force an empty arrayref if fetchall_arrayref fails
1861
2072
2073
    return $invoice;
2074
}
2075
2076
=head3 AddInvoice
2077
2078
    my $invoiceid = AddInvoice(
2079
        invoicenumber => $invoicenumber,
2080
        booksellerid => $booksellerid,
2081
        shipmentdate => $shipmentdate,
2082
        billingdate => $billingdate,
2083
        closedate => $closedate,
2084
        shipmentcost => $shipmentcost,
2085
        shipmentcost_budgetid => $shipmentcost_budgetid
2086
    );
2087
2088
Create a new invoice and return its id or undef if it fails.
2089
2090
=cut
2091
2092
sub AddInvoice {
2093
    my %invoice = @_;
2094
2095
    return unless(%invoice and $invoice{invoicenumber});
2096
2097
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2098
        closedate shipmentcost shipmentcost_budgetid invoicenote);
2099
2100
    my @set_strs;
2101
    my @set_args;
2102
    foreach my $key (keys %invoice) {
2103
        if(0 < grep(/^$key$/, @columns)) {
2104
            push @set_strs, "$key = ?";
2105
            push @set_args, ($invoice{$key} || undef);
2106
        }
2107
    }
2108
2109
    my $rv;
2110
    if(@set_args > 0) {
2111
        my $dbh = C4::Context->dbh;
2112
        my $query = "INSERT INTO aqinvoices SET ";
2113
        $query .= join (",", @set_strs);
2114
        my $sth = $dbh->prepare($query);
2115
        $rv = $sth->execute(@set_args);
2116
        if($rv) {
2117
            $rv = $dbh->last_insert_id(undef, undef, 'aqinvoices', undef);
2118
        }
2119
    }
2120
    return $rv;
2121
}
2122
2123
=head3 ModInvoice
2124
2125
    ModInvoice(
2126
        invoiceid => $invoiceid,    # Mandatory
2127
        invoicenumber => $invoicenumber,
2128
        booksellerid => $booksellerid,
2129
        shipmentdate => $shipmentdate,
2130
        billingdate => $billingdate,
2131
        closedate => $closedate,
2132
        shipmentcost => $shipmentcost,
2133
        shipmentcost_budgetid => $shipmentcost_budgetid
2134
    );
2135
2136
Modify an invoice, invoiceid is mandatory.
2137
2138
Return undef if it fails.
2139
2140
=cut
2141
2142
sub ModInvoice {
2143
    my %invoice = @_;
2144
2145
    return unless(%invoice and $invoice{invoiceid});
2146
2147
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2148
        closedate shipmentcost shipmentcost_budgetid invoicenote);
2149
2150
    my @set_strs;
2151
    my @set_args;
2152
    foreach my $key (keys %invoice) {
2153
        if(0 < grep(/^$key$/, @columns)) {
2154
            push @set_strs, "$key = ?";
2155
            push @set_args, ($invoice{$key} || undef);
2156
        }
2157
    }
2158
2159
    my $dbh = C4::Context->dbh;
2160
    my $query = "UPDATE aqinvoices SET ";
2161
    $query .= join(",", @set_strs);
2162
    $query .= " WHERE invoiceid = ?";
2163
2164
    my $sth = $dbh->prepare($query);
2165
    $sth->execute(@set_args, $invoice{invoiceid});
2166
}
2167
2168
=head3 DelInvoice
2169
2170
    DelInvoice($invoiceid);
2171
2172
Delete an invoice.
2173
2174
=cut
2175
2176
sub DelInvoice {
2177
    my ($invoiceid) = @_;
2178
2179
    return unless $invoiceid;
2180
2181
    my $dbh = C4::Context->dbh;
2182
    my $query = qq{
2183
        Delete from aqinvoices
2184
        WHERE invoiceid = ?
2185
    };
2186
    my $sth = $dbh->prepare($query);
2187
    $sth->execute($invoiceid);
2188
}
2189
2190
=head3 CloseInvoice
2191
2192
    CloseInvoice($invoiceid);
2193
2194
Close an invoice.
2195
2196
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2197
2198
=cut
2199
2200
sub CloseInvoice {
2201
    my ($invoiceid) = @_;
2202
2203
    return unless $invoiceid;
2204
2205
    my $dbh = C4::Context->dbh;
2206
    my $query = qq{
2207
        UPDATE aqinvoices
2208
        SET closedate = CAST(NOW() AS DATE)
2209
        WHERE invoiceid = ?
2210
    };
2211
    my $sth = $dbh->prepare($query);
2212
    $sth->execute($invoiceid);
2213
}
2214
2215
=head3 ReopenInvoice
2216
2217
    ReopenInvoice($invoiceid);
2218
2219
Reopen an invoice
2220
2221
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2222
2223
=cut
2224
2225
sub ReopenInvoice {
2226
    my ($invoiceid) = @_;
2227
2228
    return unless $invoiceid;
2229
2230
    my $dbh = C4::Context->dbh;
2231
    my $query = qq{
2232
        UPDATE aqinvoices
2233
        SET closedate = NULL
2234
        WHERE invoiceid = ?
2235
    };
2236
    my $sth = $dbh->prepare($query);
2237
    $sth->execute($invoiceid);
1862
}
2238
}
1863
2239
1864
1;
2240
1;
(-)a/C4/Bookseller.pm (-3 / +2 lines)
Lines 64-75 sub GetBookSeller { Link Here
64
    my $searchstring = shift;
64
    my $searchstring = shift;
65
    $searchstring = q{%} . $searchstring . q{%};
65
    $searchstring = q{%} . $searchstring . q{%};
66
    my $query =
66
    my $query =
67
'select aqbooksellers.*, count(*) as basketcount from aqbooksellers left join aqbasket '
67
'select aqbooksellers.*, count(*) as basketcount from aqbooksellers left join aqbasket on aqbasket.booksellerid = aqbooksellers.id left join aqinvoices on aqbooksellers.id = aqinvoices.booksellerid where name like ? or basketname like ? or invoicenumber like ? group by aqbooksellers.id order by name';
68
      . 'on aqbasket.booksellerid = aqbooksellers.id where name like ? group by aqbooksellers.id order by name';
69
68
70
    my $dbh           = C4::Context->dbh;
69
    my $dbh           = C4::Context->dbh;
71
    my $sth           = $dbh->prepare($query);
70
    my $sth           = $dbh->prepare($query);
72
    $sth->execute($searchstring);
71
    $sth->execute($searchstring, $searchstring, $searchstring);
73
    my $resultset_ref = $sth->fetchall_arrayref( {} );
72
    my $resultset_ref = $sth->fetchall_arrayref( {} );
74
    return @{$resultset_ref};
73
    return @{$resultset_ref};
75
}
74
}
(-)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/addorderiso2709.pl (-2 lines)
Lines 190-202 if ($op eq ""){ Link Here
190
        # 3rd add order
190
        # 3rd add order
191
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
191
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
192
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
192
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
193
        my ($invoice);
194
        # get quantity in the MARC record (1 if none)
193
        # get quantity in the MARC record (1 if none)
195
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
194
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
196
        my %orderinfo = (
195
        my %orderinfo = (
197
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
196
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
198
            "quantity", $quantity, "branchcode", $branch, 
197
            "quantity", $quantity, "branchcode", $branch, 
199
            "booksellerinvoicenumber", $invoice, 
200
            "budget_id", $budget_id, "uncertainprice", 1,
198
            "budget_id", $budget_id, "uncertainprice", 1,
201
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
199
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
202
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
200
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
(-)a/acqui/finishreceive.pl (-6 / +6 lines)
Lines 45-58 my $origquantityrec=$input->param('origquantityrec'); Link Here
45
my $quantityrec=$input->param('quantityrec');
45
my $quantityrec=$input->param('quantityrec');
46
my $quantity=$input->param('quantity');
46
my $quantity=$input->param('quantity');
47
my $unitprice=$input->param('cost');
47
my $unitprice=$input->param('cost');
48
my $invoiceno=$input->param('invoice');
48
my $invoiceid = $input->param('invoiceid');
49
my $datereceived=$input->param('datereceived');
49
my $invoice = GetInvoice($invoiceid);
50
my $invoiceno = $invoice->{invoicenumber};
51
my $datereceived= $invoice->{shipmentdate};
50
my $replacement=$input->param('rrp');
52
my $replacement=$input->param('rrp');
51
my $gst=$input->param('gst');
53
my $gst=$input->param('gst');
52
my $freight=$input->param('freight');
53
my $booksellerid = $input->param('booksellerid');
54
my $booksellerid = $input->param('booksellerid');
54
my $cnt=0;
55
my $cnt=0;
55
my $error_url_str;
56
my $ecost = $input->param('ecost');
56
my $ecost = $input->param('ecost');
57
my $note = $input->param("note");
57
my $note = $input->param("note");
58
58
Lines 96-107 if ($quantityrec > $origquantityrec ) { Link Here
96
    }
96
    }
97
    
97
    
98
    # save the quantity received.
98
    # save the quantity received.
99
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived);
99
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoice->{invoiceid},$replacement,undef,$datereceived);
100
}
100
}
101
101
102
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
102
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
103
103
104
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&booksellerid=$booksellerid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
104
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
105
105
106
################################ End of script ################################
106
################################ End of script ################################
107
107
(-)a/acqui/invoice.pl (+214 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 $invoicenote = $input->param('invoicenote');
71
    my $shipment_budget_id = $input->param('shipment_budget_id');
72
    ModInvoice(
73
        invoiceid => $invoiceid,
74
        shipmentdate   => C4::Dates->new($shipmentdate)->output("iso"),
75
        billingdate   => C4::Dates->new($billingdate)->output("iso"),
76
        shipmentcost  => $shipmentcost,
77
  invoicenote => $invoicenote,
78
        shipmentcost_budgetid => $shipment_budget_id
79
    );
80
    $template->param(modified => 1);
81
}
82
83
my $details = GetInvoiceDetails($invoiceid);
84
my $bookseller = GetBookSellerFromId($details->{booksellerid});
85
my @orders_loop = ();
86
my $orders = $details->{'orders'};
87
my $qty_total;
88
my @books_loop;
89
my @book_foot_loop;
90
my %foot;
91
my $total_quantity = 0;
92
my $total_rrp = 0;
93
my $total_est = 0;
94
foreach my $order (@$orders) {
95
    my $line = get_infos( $order, $bookseller);
96
97
    $total_quantity += $$line{quantity};
98
    $total_rrp += $order->{quantity} * $order->{rrp};
99
    $total_est += $order->{quantity} * $order->{'ecost'};
100
101
    my %row = (%$order, %$line);
102
    push @orders_loop, \%row;
103
}
104
105
my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
106
my $discount = $bookseller->{'discount'} ? ($bookseller->{discount} / 100) : 0;
107
my $total_est_gste;
108
my $total_est_gsti;
109
my $total_rrp_gsti; # RRP Total, GST included
110
my $total_rrp_gste; # RRP Total, GST excluded
111
my $gist_est;
112
my $gist_rrp;
113
if ($gist){
114
    # if we have GST
115
    if ( $bookseller->{'listincgst'} ) {
116
        # if prices already includes GST
117
118
        # we know $total_rrp_gsti
119
        $total_rrp_gsti = $total_rrp;
120
        # and can reverse compute other values
121
        $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 );
122
123
        $gist_rrp       = $total_rrp_gsti - $total_rrp_gste;
124
        $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount );
125
        $total_est_gsti = $total_est;
126
    } else {
127
        # if prices does not include GST
128
129
        # then we use the common way to compute other values
130
        $total_rrp_gste = $total_rrp;
131
        $gist_rrp       = $total_rrp_gste * $gist;
132
        $total_rrp_gsti = $total_rrp_gste + $gist_rrp;
133
        $total_est_gste = $total_est;
134
        $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount );
135
   }
136
   $gist_est = $gist_rrp - ( $gist_rrp * $discount );
137
} else {
138
    $total_rrp_gsti = $total_rrp;
139
    $total_est_gsti = $total_est;
140
}
141
my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost};
142
143
my $format = "%.2f";
144
$template->param(
145
    total_rrp_gste => sprintf($format, $total_rrp_gste),
146
    total_rrp_gsti => sprintf($format, $total_rrp_gsti),
147
    total_est_gste => sprintf($format, $total_est_gste),
148
    total_est_gsti => sprintf($format, $total_est_gsti),
149
    gist_rrp => sprintf($format, $gist_rrp),
150
    gist_est => sprintf($format, $gist_est),
151
    total_gsti_shipment => sprintf($format, $total_gsti_shipment),
152
    gist => sprintf($format, $gist * 100),
153
);
154
155
my $budgets = GetBudgets();
156
my @budgets_loop;
157
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
158
foreach (@$budgets) {
159
    my %line = %{ $_ };
160
    if($shipmentcost_budgetid and $_->{'budget_id'} == $shipmentcost_budgetid) {
161
        $line{'selected'} = 1;
162
    }
163
    push @budgets_loop, \%line;
164
}
165
166
$template->param(
167
    invoiceid        => $details->{'invoiceid'},
168
    invoicenumber    => $details->{'invoicenumber'},
169
    suppliername     => $details->{'suppliername'},
170
    supplierid       => $details->{'booksellerid'},
171
    datereceived     => $details->{'datereceived'},
172
    shipmentdate     => $details->{'shipmentdate'},
173
    billingdate      => $details->{'billingdate'},
174
    invoiceclosedate => $details->{'closedate'},
175
    shipmentcost     => sprintf($format, $details->{'shipmentcost'} || 0),
176
    invoicenote      => $details->{'invoicenote'},
177
    orders_loop      => \@orders_loop,
178
    total_quantity   => $total_quantity,
179
    invoiceincgst    => $bookseller->{invoiceincgst},
180
    currency         => $bookseller->{listprice},
181
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
182
    budgets_loop     => \@budgets_loop,
183
);
184
185
sub get_infos {
186
    my $order = shift;
187
    my $bookseller = shift;
188
    my $qty = $order->{'quantity'} || 0;
189
    if ( !defined $order->{quantityreceived} ) {
190
        $order->{quantityreceived} = 0;
191
    }
192
    my $budget = GetBudget( $order->{'budget_id'} );
193
194
    my %line = %{ $order };
195
    $line{order_received} = ( $qty == $order->{'quantityreceived'} );
196
    $line{budget_name}    = $budget->{budget_name};
197
    $line{total} = $qty * $order->{ecost};
198
199
    if ( $line{uncertainprice} ) {
200
        $line{rrp} .= ' (Uncertain)';
201
    }
202
    if ( $line{'title'} ) {
203
        my $volume      = $order->{'volume'};
204
        my $seriestitle = $order->{'seriestitle'};
205
        $line{'title'} .= " / $seriestitle" if $seriestitle;
206
        $line{'title'} .= " / $volume"      if $volume;
207
    } else {
208
        $line{'title'} = "Deleted bibliographic notice, can't find title.";
209
    }
210
211
    return \%line;
212
}
213
214
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/invoices.pl (+154 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 $invoicenote   = $input->param('invoicenote');
52
my $supplier        = $input->param('supplier');
53
my $billingdatefrom = $input->param('billingdatefrom');
54
my $billingdateto   = $input->param('billingdateto');
55
my $isbneanissn     = $input->param('isbneanissn');
56
my $title           = $input->param('title');
57
my $author          = $input->param('author');
58
my $publisher       = $input->param('publisher');
59
my $publicationyear = $input->param('publicationyear');
60
my $branch          = $input->param('branch');
61
my $op              = $input->param('op');
62
63
my @results_loop = ();
64
if($op and $op eq "do_search") {
65
    my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso");
66
    my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso");
67
    my @invoices = GetInvoices(
68
        invoicenumber => $invoicenumber,
69
        invoicenote => $invoicenote,
70
        suppliername => $supplier,
71
        billingdatefrom => $billingdatefrom_iso,
72
        billingdateto => $billingdateto_iso,
73
        isbneanissn => $isbneanissn,
74
        title => $title,
75
        author => $author,
76
        publisher => $publisher,
77
        publicationyear => $publicationyear,
78
        branchcode => $branch
79
    );
80
    foreach (@invoices) {
81
        my %row = (
82
            invoiceid       => $_->{invoiceid},
83
            billingdate     => $_->{billingdate},
84
            invoicenumber   => $_->{invoicenumber},
85
            invoicenote   => $_->{invoicenote},
86
            suppliername    => $_->{suppliername},
87
            receivedbiblios => $_->{receivedbiblios},
88
            receiveditems   => $_->{receiveditems},
89
            subscriptionid  => $_->{subscriptionid},
90
            closedate => $_->{closedate},
91
        );
92
        push @results_loop, \%row;
93
    }
94
}
95
96
97
# Build suppliers list
98
my @suppliers = GetBookSeller(undef);
99
my @suppliers_loop = ();
100
my $suppliername;
101
foreach (@suppliers) {
102
    my $selected = 0;
103
    if ($supplier && $supplier == $_->{'id'}) {
104
        $selected = 1;
105
        $suppliername = $_->{'name'};
106
    }
107
    my %row = (
108
        suppliername => $_->{'name'},
109
        supplierid   => $_->{'id'},
110
        selected     => $selected,
111
    );
112
    push @suppliers_loop, \%row;
113
}
114
115
# Build branches list
116
my $branches = GetBranches();
117
my @branches_loop = ();
118
my $branchname;
119
foreach (sort keys %$branches) {
120
    my $selected = 0;
121
    if ($branch && $branch eq $_) {
122
        $selected = 1;
123
        $branchname = $branches->{$_}->{'branchname'};
124
    }
125
    my %row = (
126
        branchcode => $_,
127
        branchname => $branches->{$_}->{'branchname'},
128
        selected   => $selected,
129
    );
130
    push @branches_loop, \%row;
131
}
132
133
$template->param(
134
    do_search       => ($op and $op eq "do_search") ? 1 : 0,
135
    results_loop    => \@results_loop,
136
    invoicenumber   => $invoicenumber,
137
    invoicenote   => $invoicenote,
138
    supplier        => $supplier,
139
    suppliername    => $suppliername,
140
    billingdatefrom => $billingdatefrom,
141
    billingdateto   => $billingdateto,
142
    isbneanissn     => $isbneanissn,
143
    title           => $title,
144
    author          => $author,
145
    publisher       => $publisher,
146
    publicationyear => $publicationyear,
147
    branch          => $branch,
148
    branchname      => $branchname,
149
    suppliers_loop  => \@suppliers_loop,
150
    branches_loop   => \@branches_loop,
151
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
152
);
153
154
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 166-172 if ( $count == 1 ) { Link Here
166
        unitprice             => @$results[0]->{'unitprice'},
164
        unitprice             => @$results[0]->{'unitprice'},
167
        memberfirstname       => $member->{firstname} || "",
165
        memberfirstname       => $member->{firstname} || "",
168
        membersurname         => $member->{surname} || "",
166
        membersurname         => $member->{surname} || "",
169
        invoice               => $invoice,
167
        invoiceid             => $invoice->{invoiceid},
168
        invoice               => $invoice->{invoicenumber},
170
        datereceived          => $datereceived->output(),
169
        datereceived          => $datereceived->output(),
171
        datereceived_iso      => $datereceived->output('iso'),
170
        datereceived_iso      => $datereceived->output('iso'),
172
        notes                 => $order->{notes},
171
        notes                 => $order->{notes},
Lines 180-186 else { Link Here
180
    for ( my $i = 0 ; $i < $count ; $i++ ) {
179
    for ( my $i = 0 ; $i < $count ; $i++ ) {
181
        my %line = %{ @$results[$i] };
180
        my %line = %{ @$results[$i] };
182
181
183
        $line{invoice}      = $invoice;
182
        $line{invoice}      = $invoice->{invoicenumber};
184
        $line{datereceived} = $datereceived->output();
183
        $line{datereceived} = $datereceived->output();
185
        $line{freight}      = $freight;
184
        $line{freight}      = $freight;
186
        $line{gst}          = $gst;
185
        $line{gst}          = $gst;
Lines 192-202 else { Link Here
192
191
193
    $template->param(
192
    $template->param(
194
        loop         => \@loop,
193
        loop         => \@loop,
195
        booksellerid   => $booksellerid,
194
        booksellerid => $booksellerid,
195
        invoiceid    => $invoice->{invoiceid},
196
    );
196
    );
197
}
197
}
198
my $op = $input->param('op');
198
my $op = $input->param('op');
199
if ($op eq 'edit'){
199
if ($op and $op eq 'edit'){
200
    $template->param(edit   =>   1);
200
    $template->param(edit   =>   1);
201
}
201
}
202
output_html_with_http_headers $input, $cookie, $template->output;
202
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/parcel.pl (-139 / +125 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;
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');
79
my $code            = $input->param('code');
85
my @rcv_err         = $input->param('error');
80
my @rcv_err         = $input->param('error');
86
my @rcv_err_barcode = $input->param('error_bc');
81
my @rcv_err_barcode = $input->param('error_bc');
Lines 90-105 my $resultsperpage = $input->param('resultsperpage'); Link Here
90
$resultsperpage = 20 unless ($resultsperpage);
85
$resultsperpage = 20 unless ($resultsperpage);
91
$startfrom=0 unless ($startfrom);
86
$startfrom=0 unless ($startfrom);
92
87
93
if($input->param('format') eq "json"){
88
my $format = $input->param('format') || '';
89
if($format eq "json"){
94
    my ($template, $loggedinuser, $cookie)
90
    my ($template, $loggedinuser, $cookie)
95
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
91
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
96
                 query => $input,
92
                 query => $input,
97
				 type => "intranet",
93
                 type => "intranet",
98
                 authnotrequired => 0,
94
                 authnotrequired => 0,
99
                 flagsrequired => {acquisition => 'order_receive'},
95
                 flagsrequired => {acquisition => 'order_receive'},
100
                 debug => 1,
96
                 debug => 1,
101
    });
97
    });
102
       
98
103
    my @datas;
99
    my @datas;
104
    my $search   = $input->param('search') || '';
100
    my $search   = $input->param('search') || '';
105
    my $supplier = $input->param('booksellerid') || '';
101
    my $supplier = $input->param('booksellerid') || '';
Lines 110-116 if($input->param('format') eq "json"){ Link Here
110
    foreach my $order (@$orders){
106
    foreach my $order (@$orders){
111
        if($order->{quantityreceived} < $order->{quantity}){
107
        if($order->{quantityreceived} < $order->{quantity}){
112
            my $data = {};
108
            my $data = {};
113
            
109
114
            $data->{basketno} = $order->{basketno};
110
            $data->{basketno} = $order->{basketno};
115
            $data->{ordernumber} = $order->{ordernumber};
111
            $data->{ordernumber} = $order->{ordernumber};
116
            $data->{title} = $order->{title};
112
            $data->{title} = $order->{title};
Lines 118-131 if($input->param('format') eq "json"){ Link Here
118
            $data->{isbn} = $order->{isbn};
114
            $data->{isbn} = $order->{isbn};
119
            $data->{booksellerid} = $order->{booksellerid};
115
            $data->{booksellerid} = $order->{booksellerid};
120
            $data->{biblionumber} = $order->{biblionumber};
116
            $data->{biblionumber} = $order->{biblionumber};
121
            $data->{freight} = $order->{freight};
122
            $data->{quantity} = $order->{quantity};
117
            $data->{quantity} = $order->{quantity};
123
            $data->{ecost} = $order->{ecost};
118
            $data->{ecost} = $order->{ecost};
124
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
119
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
125
            push @datas, $data;
120
            push @datas, $data;
126
        }
121
        }
127
    }
122
    }
128
    
123
129
    my $json_text = to_json(\@datas);
124
    my $json_text = to_json(\@datas);
130
    $template->param(return => $json_text);
125
    $template->param(return => $json_text);
131
    output_html_with_http_headers $input, $cookie, $template->output;
126
    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)
130
my ($template, $loggedinuser, $cookie)
136
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
131
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
137
                 query => $input,
132
                 query => $input,
138
				 type => "intranet",
133
                 type => "intranet",
139
                 authnotrequired => 0,
134
                 authnotrequired => 0,
140
                 flagsrequired => {acquisition => 'order_receive'},
135
                 flagsrequired => {acquisition => 'order_receive'},
141
                 debug => 1,
136
                 debug => 1,
Lines 155-164 if( scalar(@rcv_err) ) { Link Here
155
}
150
}
156
151
157
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
152
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
158
my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso'));
153
my @parcelitems   = @{ $invoice->{orders} };
159
my $countlines    = scalar @parcelitems;
154
my $countlines    = scalar @parcelitems;
160
my $totalprice    = 0;
155
my $totalprice    = 0;
161
my $totalfreight  = 0;
162
my $totalquantity = 0;
156
my $totalquantity = 0;
163
my $total;
157
my $total;
164
my $tototal;
158
my $tototal;
Lines 166-180 my @loop_received = (); Link Here
166
160
167
for (my $i = 0 ; $i < $countlines ; $i++) {
161
for (my $i = 0 ; $i < $countlines ; $i++) {
168
162
169
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
163
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};
170
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
171
    $parcelitems[$i]->{'unitprice'} += 0;
164
    $parcelitems[$i]->{'unitprice'} += 0;
172
    my %line;
165
    my %line;
173
    %line          = %{ $parcelitems[$i] };
166
    %line          = %{ $parcelitems[$i] };
174
    $line{invoice} = $invoice;
167
    $line{invoice} = $invoice->{invoicenumber};
175
    $line{gst}     = $gst;
168
    $line{gst}     = $gst;
176
    $line{total} = sprintf($cfstr, $total);
169
    $line{total} = sprintf($cfstr, $total);
177
    $line{booksellerid} = $booksellerid;
170
    $line{booksellerid} = $invoice->{booksellerid};
178
    push @loop_received, \%line;
171
    push @loop_received, \%line;
179
    $totalprice += $parcelitems[$i]->{'unitprice'};
172
    $totalprice += $parcelitems[$i]->{'unitprice'};
180
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
173
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
Lines 184-327 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
184
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
177
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
185
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
178
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
186
179
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'};
180
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
195
    $tototal       += $total;
181
    $tototal       += $total;
196
}
182
}
197
183
198
my $pendingorders = GetPendingOrders($booksellerid);
184
if(!defined $invoice->{closedate}) {
199
my $countpendings = scalar @$pendingorders;
185
    my $pendingorders = GetPendingOrders($booksellerid);
200
186
    my $countpendings = scalar @$pendingorders;
201
# pending orders totals
187
202
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
188
    # pending orders totals
203
my $ordergrandtotal;
189
    my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
204
my @loop_orders = ();
190
    my $ordergrandtotal;
205
for (my $i = 0 ; $i < $countpendings ; $i++) {
191
    my @loop_orders = ();
206
    my %line;
192
    for (my $i = 0 ; $i < $countpendings ; $i++) {
207
    %line = %{$pendingorders->[$i]};
193
        my %line;
208
   
194
        %line = %{$pendingorders->[$i]};
209
    $line{quantity}+=0;
195
210
    $line{quantityreceived}+=0;
196
        $line{quantity}+=0;
211
    $line{unitprice}+=0;
197
        $line{quantityreceived}+=0;
212
    $totalPunitprice += $line{unitprice};
198
        $line{unitprice}+=0;
213
    $totalPquantity +=$line{quantity};
199
        $totalPunitprice += $line{unitprice};
214
    $totalPqtyrcvd +=$line{quantityreceived};
200
        $totalPquantity +=$line{quantity};
215
    $totalPecost += $line{ecost};
201
        $totalPqtyrcvd +=$line{quantityreceived};
216
    $line{ecost} = sprintf("%.2f",$line{ecost});
202
        $totalPecost += $line{ecost};
217
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
203
        $line{ecost} = sprintf("%.2f",$line{ecost});
218
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
204
        $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
219
    $line{invoice} = $invoice;
205
        $line{unitprice} = sprintf("%.2f",$line{unitprice});
220
    $line{gst} = $gst;
206
        $line{invoice} = $invoice;
221
    $line{total} = $total;
207
        $line{gst} = $gst;
222
    $line{booksellerid} = $booksellerid;
208
        $line{total} = $total;
223
    $ordergrandtotal += $line{ecost} * $line{quantity};
209
        $line{booksellerid} = $booksellerid;
224
    
210
        $ordergrandtotal += $line{ecost} * $line{quantity};
225
    my $biblionumber = $line{'biblionumber'};
211
226
    my $countbiblio = CountBiblioInOrders($biblionumber);
212
        my $biblionumber = $line{'biblionumber'};
227
    my $ordernumber = $line{'ordernumber'};
213
        my $countbiblio = CountBiblioInOrders($biblionumber);
228
    my @subscriptions = GetSubscriptionsId ($biblionumber);
214
        my $ordernumber = $line{'ordernumber'};
229
    my $itemcount = GetItemsCount($biblionumber);
215
        my @subscriptions = GetSubscriptionsId ($biblionumber);
230
    my $holds  = GetHolds ($biblionumber);
216
        my $itemcount = GetItemsCount($biblionumber);
231
    my @items = GetItemnumbersFromOrder( $ordernumber );
217
        my $holds  = GetHolds ($biblionumber);
232
    my $itemholds;
218
        my @items = GetItemnumbersFromOrder( $ordernumber );
233
    foreach my $item (@items){
219
        my $itemholds;
234
        my $nb = GetItemHolds($biblionumber, $item);
220
        foreach my $item (@items){
235
        if ($nb){
221
            my $nb = GetItemHolds($biblionumber, $item);
236
            $itemholds += $nb;
222
            if ($nb){
223
                $itemholds += $nb;
224
            }
237
        }
225
        }
238
    }
239
226
240
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
227
        my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
241
    $line{suggestionid}         = $suggestion->{suggestionid};
228
        $line{suggestionid}         = $suggestion->{suggestionid};
242
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
229
        $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
243
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
230
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
231
232
        # 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
233
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
234
        $line{items}                = ($itemcount) - (scalar @items);
235
        $line{left_item}            = 1 if $line{items} >= 1;
236
        $line{left_biblio}          = 1 if $countbiblio > 1;
237
        $line{biblios}              = $countbiblio - 1;
238
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
239
        $line{subscriptions}        = scalar @subscriptions;
240
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
241
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
242
        $line{holds}                = $holds;
243
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
244
245
246
        push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
247
    }
244
248
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
249
    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
250
263
my $count = $countpendings;
251
    if ($count>$resultsperpage){
252
        my $displaynext=0;
253
        my $displayprev=$startfrom;
254
        if(($count - ($startfrom+$resultsperpage)) > 0 ) {
255
            $displaynext = 1;
256
        }
264
257
265
if ($count>$resultsperpage){
258
        my @numbers = ();
266
    my $displaynext=0;
259
        for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
267
    my $displayprev=$startfrom;
260
                my $highlight=0;
268
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
261
                ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
269
        $displaynext = 1;
262
                push @numbers, { number => $i,
270
    }
263
                    highlight => $highlight ,
264
                    startfrom => ($i-1)*$resultsperpage};
265
        }
271
266
272
    my @numbers = ();
267
        my $from = $startfrom*$resultsperpage+1;
273
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
268
        my $to;
274
            my $highlight=0;
269
        if($count < (($startfrom+1)*$resultsperpage)){
275
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
270
            $to = $count;
276
            push @numbers, { number => $i,
271
        } else {
277
                highlight => $highlight ,
272
            $to = (($startfrom+1)*$resultsperpage);
278
                startfrom => ($i-1)*$resultsperpage};
273
        }
274
        $template->param(numbers=>\@numbers,
275
                         displaynext=>$displaynext,
276
                         displayprev=>$displayprev,
277
                         nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
278
                         prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
279
                        );
279
    }
280
    }
280
281
281
    my $from = $startfrom*$resultsperpage+1;
282
    $template->param(
282
    my $to;
283
        countpending => $countpendings,
283
    if($count < (($startfrom+1)*$resultsperpage)){
284
        loop_orders  => \@loop_orders,
284
        $to = $count;
285
        ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
285
    } else {
286
        totalPunitprice => sprintf("%.2f", $totalPunitprice),
286
        $to = (($startfrom+1)*$resultsperpage);
287
        totalPquantity  => $totalPquantity,
287
    }
288
        totalPqtyrcvd   => $totalPqtyrcvd,
288
    $template->param(numbers=>\@numbers,
289
        totalPecost     => sprintf("%.2f", $totalPecost),
289
                     displaynext=>$displaynext,
290
    );
290
                     displayprev=>$displayprev,
291
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
292
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
293
                    );
294
}
291
}
295
292
296
#$totalfreight=$freight;
297
$tototal = $tototal + $freight;
298
293
299
$template->param(
294
$template->param(
300
    invoice               => $invoice,
295
    invoiceid             => $invoice->{invoiceid},
301
    datereceived          => $datereceived->output('iso'),
296
    invoice               => $invoice->{invoicenumber},
302
    invoicedatereceived   => $datereceived->output('iso'),
297
    invoiceclosedate      => $invoice->{closedate},
303
    formatteddatereceived => $datereceived->output(),
298
    datereceived          => $invoice->{'shipmentdate'},
299
    invoicedatereceived   => $invoice->{'billingdate'},
300
    formatteddatereceived => $invoice->{'shipmentdate'},
304
    name                  => $bookseller->{'name'},
301
    name                  => $bookseller->{'name'},
305
    booksellerid            => $booksellerid,
302
    booksellerid          => $bookseller->{id},
306
    gst                   => $gst,
303
    gst                   => $gst,
307
    freight               => $freight,
308
    invoice               => $invoice,
309
    countreceived         => $countlines,
304
    countreceived         => $countlines,
310
    loop_received         => \@loop_received,
305
    loop_received         => \@loop_received,
311
    countpending          => $countpendings,
312
    loop_orders           => \@loop_orders,
313
    totalprice            => sprintf($cfstr, $totalprice),
306
    totalprice            => sprintf($cfstr, $totalprice),
314
    totalfreight          => $totalfreight,
315
    totalquantity         => $totalquantity,
307
    totalquantity         => $totalquantity,
316
    tototal               => sprintf($cfstr, $tototal),
308
    tototal               => sprintf($cfstr, $tototal),
317
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
318
    gst                   => $gst,
309
    gst                   => $gst,
319
    grandtot              => sprintf($cfstr, $tototal + $gst),
310
    grandtot              => sprintf($cfstr, $tototal + $gst),
320
    totalPunitprice       => sprintf("%.2f", $totalPunitprice),
321
    totalPquantity        => $totalPquantity,
322
    totalPqtyrcvd         => $totalPqtyrcvd,
323
    totalPecost           => sprintf("%.2f", $totalPecost),
324
    resultsperpage        => $resultsperpage,
311
    resultsperpage        => $resultsperpage,
325
);
312
);
326
output_html_with_http_headers $input, $cookie, $template->output;
313
output_html_with_http_headers $input, $cookie, $template->output;
327
 
(-)a/acqui/parcels.pl (-13 / +48 lines)
Lines 44-52 To know the supplier this script has to show orders. Link Here
44
sort list of order by 'orderby'.
44
sort list of order by 'orderby'.
45
Orderby can be equals to
45
Orderby can be equals to
46
    * datereceived desc (default value)
46
    * datereceived desc (default value)
47
    * aqorders.booksellerinvoicenumber
47
    * invoicenumber
48
    * datereceived
48
    * datereceived
49
    * aqorders.booksellerinvoicenumber desc
49
    * invoicenumber desc
50
50
51
=item filter
51
=item filter
52
52
Lines 77-89 use C4::Acquisition; Link Here
77
use C4::Bookseller qw/ GetBookSellerFromId /;
77
use C4::Bookseller qw/ GetBookSellerFromId /;
78
78
79
my $input          = CGI->new;
79
my $input          = CGI->new;
80
my $booksellerid     = $input->param('booksellerid');
80
my $booksellerid   = $input->param('booksellerid');
81
my $order          = $input->param('orderby') || 'datereceived desc';
81
my $order          = $input->param('orderby') || 'datereceived desc';
82
my $startfrom      = $input->param('startfrom');
82
my $startfrom      = $input->param('startfrom');
83
my $code           = $input->param('filter');
83
my $code           = $input->param('filter');
84
my $invoicenote    = $input->param('notefilter');
84
my $datefrom       = $input->param('datefrom');
85
my $datefrom       = $input->param('datefrom');
85
my $dateto         = $input->param('dateto');
86
my $dateto         = $input->param('dateto');
86
my $resultsperpage = $input->param('resultsperpage');
87
my $resultsperpage = $input->param('resultsperpage');
88
my $op             = $input->param('op');
87
$resultsperpage ||= 20;
89
$resultsperpage ||= 20;
88
90
89
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
91
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 96-103 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
96
    }
98
    }
97
);
99
);
98
100
101
if($op and $op eq 'new') {
102
    my $invoicenumber = $input->param('invoice');
103
    my $billingdate = $input->param('billingdate');
104
    my $shipmentdate = $input->param('shipmentdate');
105
    $invoicenote = $input->param('invoicenote');
106
    my $invoiceid = AddInvoice(
107
        invoicenumber => $invoicenumber,
108
        booksellerid => $booksellerid,
109
      invoicenote => $invoicenote,
110
        billingdate => C4::Dates->new($billingdate)->output('iso'),
111
        shipmentdate => C4::Dates->new($shipmentdate)->output('iso')
112
    );
113
    if(defined $invoiceid) {
114
        # Successful 'Add'
115
        print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
116
        exit 0;
117
    } else {
118
        $template->param(error_failed_to_create_invoice => 1);
119
    }
120
} elsif($op eq 'delete') {
121
    my $invoiceid = $input->param('invoiceid');
122
    DelInvoice($invoiceid);
123
}
124
99
my $bookseller = GetBookSellerFromId($booksellerid);
125
my $bookseller = GetBookSellerFromId($booksellerid);
100
my @parcels = GetParcels( $booksellerid, $order, $code, $datefrom, $dateto );
126
my @parcels = GetInvoices(
127
    supplierid => $booksellerid,
128
    invoicenumber => $code,
129
    invoicenote => $invoicenote,
130
    shipmentdatefrom => $datefrom,
131
    shipmentdateto => $dateto,
132
    order_by => $order
133
);
101
my $count_parcels = @parcels;
134
my $count_parcels = @parcels;
102
135
103
# multi page display gestion
136
# multi page display gestion
Lines 114-127 for my $i ( $startfrom .. $last_row) { Link Here
114
147
115
    push @{$loopres},
148
    push @{$loopres},
116
      { number           => $i + 1,
149
      { number           => $i + 1,
117
        code             => $p->{booksellerinvoicenumber},
150
        invoiceid        => $p->{invoiceid},
118
        nullcode         => $p->{booksellerinvoicenumber} eq 'NULL',
151
        code             => $p->{invoicenumber},
119
        emptycode        => $p->{booksellerinvoicenumber} eq q{},
152
        nullcode         => $p->{invoicenumber} eq 'NULL',
120
        raw_datereceived => $p->{datereceived},
153
        emptycode        => $p->{invoicenumber} eq q{},
121
        datereceived     => format_date( $p->{datereceived} ),
154
        raw_datereceived => $p->{shipmentdate},
122
        bibcount         => $p->{biblio},
155
    invoicenote      => $p->{invoicenote},
123
        reccount         => $p->{itemsreceived},
156
        datereceived     => format_date( $p->{shipmentdate} ),
124
        itemcount        => $p->{itemsexpected},
157
        bibcount         => $p->{receivedbiblios} || 0,
158
        reccount         => $p->{receiveditems} || 0,
159
        itemcount        => $p->{itemsexpected} || 0,
125
      };
160
      };
126
}
161
}
127
if ($count_parcels) {
162
if ($count_parcels) {
Lines 135-141 $template->param( Link Here
135
    resultsperpage           => $resultsperpage,
170
    resultsperpage           => $resultsperpage,
136
    name                     => $bookseller->{'name'},
171
    name                     => $bookseller->{'name'},
137
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
172
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
138
    datereceived_today       => C4::Dates->new()->output(),
173
    today       => C4::Dates->new()->output(),
139
    booksellerid             => $booksellerid,
174
    booksellerid             => $booksellerid,
140
    GST                      => C4::Context->preference('gist'),
175
    GST                      => C4::Context->preference('gist'),
141
);
176
);
(-)a/acqui/spent.pl (-12 / +35 lines)
Lines 60-69 SELECT Link Here
60
    aqbasket.booksellerid,
60
    aqbasket.booksellerid,
61
    itype,
61
    itype,
62
    title,
62
    title,
63
    aqorders.booksellerinvoicenumber,
63
    aqorders.invoiceid,
64
    aqinvoices.invoicenumber,
64
    quantityreceived,
65
    quantityreceived,
65
    unitprice,
66
    unitprice,
66
    freight,
67
    datereceived,
67
    datereceived,
68
    aqorders.biblionumber
68
    aqorders.biblionumber
69
FROM (aqorders, aqbasket)
69
FROM (aqorders, aqbasket)
Lines 73-78 LEFT JOIN biblio ON Link Here
73
    biblio.biblionumber=aqorders.biblionumber
73
    biblio.biblionumber=aqorders.biblionumber
74
LEFT JOIN aqorders_items ON
74
LEFT JOIN aqorders_items ON
75
    aqorders.ordernumber=aqorders_items.ordernumber
75
    aqorders.ordernumber=aqorders_items.ordernumber
76
LEFT JOIN aqinvoices ON
77
    aqorders.invoiceid = aqinvoices.invoiceid
76
WHERE
78
WHERE
77
    aqorders.basketno=aqbasket.basketno AND
79
    aqorders.basketno=aqbasket.basketno AND
78
    budget_id=? AND
80
    budget_id=? AND
Lines 85-111 $sth->execute($bookfund); Link Here
85
if ( $sth->err ) {
87
if ( $sth->err ) {
86
    die "An error occurred fetching records: " . $sth->errstr;
88
    die "An error occurred fetching records: " . $sth->errstr;
87
}
89
}
88
my $total = 0;
90
my $subtotal = 0;
89
my $toggle;
91
my $toggle;
90
my @spent;
92
my @spent;
91
while ( my $data = $sth->fetchrow_hashref ) {
93
while ( my $data = $sth->fetchrow_hashref ) {
92
    my $recv = $data->{'quantityreceived'};
94
    my $recv = $data->{'quantityreceived'};
93
    if ( $recv > 0 ) {
95
    if ( $recv > 0 ) {
94
        my $subtotal = $recv * ( $data->{'unitprice'} + $data->{'freight'} );
96
        my $rowtotal = $recv * $data->{'unitprice'};
95
        $data->{'subtotal'}  = sprintf( "%.2f", $subtotal );
97
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
96
        $data->{'freight'}   = sprintf( "%.2f", $data->{'freight'} );
97
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
98
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
98
        $total += $subtotal;
99
        $subtotal += $rowtotal;
99
        push @spent, $data;
100
        push @spent, $data;
100
    }
101
    }
101
102
102
}
103
}
103
$total = sprintf( "%.2f", $total );
104
104
105
$template->{VARS}->{'fund'}  = $bookfund;
105
my $total = $subtotal;
106
$template->{VARS}->{'spent'} = \@spent;
106
$query = qq{
107
$template->{VARS}->{'total'} = $total;
107
    SELECT invoicenumber, shipmentcost
108
$template->{VARS}->{'fund_code'} = $fund_code;
108
    FROM aqinvoices
109
    WHERE shipmentcost_budgetid = ?
110
};
111
$sth = $dbh->prepare($query);
112
$sth->execute($bookfund);
113
my @shipmentcosts;
114
while (my $data = $sth->fetchrow_hashref) {
115
    push @shipmentcosts, {
116
        shipmentcost => sprintf("%.2f", $data->{shipmentcost}),
117
        invoicenumber => $data->{invoicenumber}
118
    };
119
    $total += $data->{shipmentcost};
120
}
109
$sth->finish;
121
$sth->finish;
110
122
123
$total = sprintf( "%.2f", $total );
124
125
$template->param(
126
    fund => $bookfund,
127
    spent => \@spent,
128
    subtotal => $subtotal,
129
    shipmentcosts => \@shipmentcosts,
130
    total => $total,
131
    fund_code => $fund_code
132
);
133
111
output_html_with_http_headers $input, $cookie, $template->output;
134
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/catalogue/moredetail.pl (-3 / +5 lines)
Lines 141-157 foreach my $item (@items){ Link Here
141
    }
141
    }
142
142
143
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
143
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
144
    my $basket = GetBasket( $order->{'basketno'} );
145
    $item->{'booksellerid'}            = $basket->{'booksellerid'};
146
    $item->{'ordernumber'}             = $order->{'ordernumber'};
144
    $item->{'ordernumber'}             = $order->{'ordernumber'};
147
    $item->{'basketno'}                = $order->{'basketno'};
145
    $item->{'basketno'}                = $order->{'basketno'};
148
    $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
149
    $item->{'orderdate'}               = $order->{'entrydate'};
146
    $item->{'orderdate'}               = $order->{'entrydate'};
150
    if ($item->{'basketno'}){
147
    if ($item->{'basketno'}){
151
	    my $basket = GetBasket($item->{'basketno'});
148
	    my $basket = GetBasket($item->{'basketno'});
152
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
149
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
153
	    $item->{'vendor'} = $bookseller->{'name'};
150
	    $item->{'vendor'} = $bookseller->{'name'};
154
    }
151
    }
152
    $item->{'invoiceid'}               = $order->{'invoiceid'};
153
    if($item->{invoiceid}) {
154
        my $invoice = GetInvoice($item->{invoiceid});
155
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
156
    }
155
    $item->{'datereceived'}            = $order->{'datereceived'};
157
    $item->{'datereceived'}            = $order->{'datereceived'};
156
158
157
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
159
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
(-)a/installer/data/mysql/kohastructure.sql (-2 / +24 lines)
Lines 2715-2721 CREATE TABLE `aqorders` ( Link Here
2715
  `listprice` decimal(28,6) default NULL,
2715
  `listprice` decimal(28,6) default NULL,
2716
  `totalamount` decimal(28,6) default NULL,
2716
  `totalamount` decimal(28,6) default NULL,
2717
  `datereceived` date default NULL,
2717
  `datereceived` date default NULL,
2718
  `booksellerinvoicenumber` mediumtext,
2718
  invoiceid int(11) default NULL,
2719
  `freight` decimal(28,6) default NULL,
2719
  `freight` decimal(28,6) default NULL,
2720
  `unitprice` decimal(28,6) default NULL,
2720
  `unitprice` decimal(28,6) default NULL,
2721
  `quantityreceived` smallint(6) NOT NULL default 0,
2721
  `quantityreceived` smallint(6) NOT NULL default 0,
Lines 2747-2753 CREATE TABLE `aqorders` ( Link Here
2747
  KEY `biblionumber` (`biblionumber`),
2747
  KEY `biblionumber` (`biblionumber`),
2748
  KEY `budget_id` (`budget_id`),
2748
  KEY `budget_id` (`budget_id`),
2749
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2749
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2750
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2750
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2751
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
2751
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2752
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2752
2753
2753
2754
Lines 2764-2769 CREATE TABLE `aqorders_items` ( Link Here
2764
  KEY `ordernumber` (`ordernumber`)
2765
  KEY `ordernumber` (`ordernumber`)
2765
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2766
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2766
2767
2768
2769
--
2770
-- Table structure for table aqinvoices
2771
--
2772
2773
DROP TABLE IF EXISTS aqinvoices;
2774
CREATE TABLE aqinvoices (
2775
  invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
2776
  invoicenumber mediumtext NOT NULL,    -- Name of invoice
2777
  booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
2778
  shipmentdate date default NULL,   -- date of shipment
2779
  billingdate date default NULL,    -- date of billing
2780
  closedate date default NULL,  -- invoice close date, NULL means the invoice is open
2781
  shipmentcost decimal(28,6) default NULL,  -- shipment cost
2782
  shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
2783
  PRIMARY KEY (invoiceid),
2784
  CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
2785
  CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
2786
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2787
2788
2767
--
2789
--
2768
-- Table structure for table `fieldmapping`
2790
-- Table structure for table `fieldmapping`
2769
--
2791
--
(-)a/installer/data/mysql/updatedatabase.pl (+62 lines)
Lines 5146-5151 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5146
    SetVersion($DBversion);
5146
    SetVersion($DBversion);
5147
}
5147
}
5148
5148
5149
5150
5151
$DBversion = "3.08.01.XXX";
5152
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5153
    $dbh->do("
5154
        CREATE TABLE aqinvoices (
5155
          invoiceid int(11) NOT NULL AUTO_INCREMENT,
5156
          invoicenumber mediumtext NOT NULL,
5157
          booksellerid int(11) NOT NULL,
5158
          shipmentdate date default NULL,
5159
          billingdate date default NULL,
5160
          closedate date default NULL,
5161
          shipmentcost decimal(28,6) default NULL,
5162
          shipmentcost_budgetid int(11) default NULL,
5163
          invoicenote varchar(255),
5164
          PRIMARY KEY (invoiceid),
5165
          CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5166
          CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5167
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5168
    ");
5169
5170
    # Fill this new table with existing invoices
5171
    my $sth = $dbh->prepare("
5172
        SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid
5173
        FROM aqorders
5174
          LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5175
        WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5176
          AND aqorders.booksellerinvoicenumber != ''
5177
        GROUP BY aqorders.booksellerinvoicenumber
5178
    ");
5179
    $sth->execute;
5180
    my $results = $sth->fetchall_arrayref({});
5181
    $sth = $dbh->prepare("
5182
        INSERT INTO aqinvoices (invoicenumber, booksellerid) VALUES (?,?)
5183
    ");
5184
    foreach(@$results) {
5185
        $sth->execute($_->{'invoicenumber'}, $_->{'booksellerid'});
5186
    }
5187
5188
    # Add the column in aqorders, fill it with correct value
5189
    # and then drop booksellerinvoicenumber column
5190
    $dbh->do("
5191
        ALTER TABLE aqorders
5192
        ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5193
        ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5194
    ");
5195
5196
    $dbh->do("
5197
        UPDATE aqorders, aqinvoices
5198
        SET aqorders.invoiceid = aqinvoices.invoiceid
5199
        WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5200
    ");
5201
5202
    $dbh->do("
5203
        ALTER TABLE aqorders
5204
        DROP COLUMN booksellerinvoicenumber
5205
    ");
5206
5207
    print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5208
    SetVersion ($DBversion);
5209
}
5210
5149
=head1 FUNCTIONS
5211
=head1 FUNCTIONS
5150
5212
5151
=head2 DropAllForeignKeys($table)
5213
=head2 DropAllForeignKeys($table)
(-)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/histsearch.tt (-1 / +5 lines)
Lines 89-95 Link Here
89
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
89
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
90
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
90
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
91
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
91
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
92
					<td>[% suggestions_loo.datereceived | $KohaDates %]</td>
92
                    <td>
93
                        [% IF suggestions_loo.datereceived %]
94
                            [% suggestions_loo.datereceived | $KohaDates %]
95
                        [% END %]
96
                    </td>
93
					<td>[% suggestions_loo.quantity %]</td>
97
					<td>[% suggestions_loo.quantity %]</td>
94
					<td>[% suggestions_loo.ecost %]</td>
98
					<td>[% suggestions_loo.ecost %]</td>
95
				</tr>
99
				</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (+195 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="invoicenote">Invoice note</label>
55
        <input type="text" size="20" id="invoicenote" name="invoicenote" value="[% invoicenote %]"/>
56
   <p></p>
57
        <label for="shipmentdate">Shipment date:</label>
58
        [% IF (shipmentdate) %]
59
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" readonly="readonly" />
60
        [% ELSE %]
61
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" readonly="readonly" />
62
        [% END %]
63
        <img id="shipmentdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
64
        <p></p>
65
        <label for="billingdate">Billing date:</label>
66
        [% IF (billingdate) %]
67
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
68
        [% ELSE %]
69
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
70
        [% END %]
71
        <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
72
        <p></p>
73
        <label for="shipmentcost">Shipment cost:</label>
74
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
75
        <label for="shipment_budget_id">Budget:</label>
76
        <select id="shipment_budget_id" name="shipment_budget_id">
77
            <option value="">No budget</option>
78
          [% FOREACH budget IN budgets_loop %]
79
            [% IF ( budget.selected ) %]
80
              <option selected="selected" value="[% budget.budget_id %]">
81
            [% ELSE %]
82
              <option value="[% budget.budget_id %]">
83
            [% END %]
84
              [% budget.budget_name %]
85
            </option>
86
          [% END %]
87
        </select>
88
        <input type="hidden" name="op" value="mod" />
89
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
90
        <fieldset class="action">
91
            <input type="submit" value="Save">
92
        </fieldset>
93
      </form>
94
      <p>Status:
95
        [% IF ( invoiceclosedate ) %]
96
          Closed on [% invoiceclosedate | $KohaDates %].
97
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
98
            Reopen
99
          </a>
100
        [% ELSE %]
101
          Open.
102
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
103
            Close
104
          </a>
105
        [% END %]
106
      </p>
107
      <p>
108
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
109
      </p>
110
      <h2>Invoice details</h2>
111
      [% IF orders_loop.size %]
112
          <table id="orderst">
113
            <thead>
114
              <tr>
115
                <th>Summary</th>
116
                <th>Publisher</th>
117
                <th>Branch</th>
118
                <th>RRP</th>
119
                <th>Est.</th>
120
                <th>Qty.</th>
121
                <th>Total</th>
122
                <th>Fund</th>
123
              </tr>
124
            </thead>
125
            <tbody>
126
              [% FOREACH order IN orders_loop %]
127
                <tr>
128
                  <td><p>[% order.title %]
129
                    [% IF ( order.author ) %]
130
                      <br /><em>by</em> [% order.author %]
131
                    [% END %]
132
                  </p></td>
133
                  <td>
134
                    [% IF ( order.publishercode ) %]
135
                      <p>[% order.publishercode %]
136
                        [% IF ( order.publicationyear ) %]
137
                          - [% order.publicationyear %]
138
                        [% END %]
139
                      </p>
140
                    [% END %]
141
                  </td>
142
                  <td><p>[% order.branchcode %]</p></td>
143
                  <td>[% order.rrp %]</td>
144
                  <td>[% order.ecost %]</td>
145
                  <td class="number">[% order.quantity %]</td>
146
                  <td>[% order.total %]</td>
147
                  <td>[% order.budget_name %]</td>
148
                </tr>
149
              [% END %]
150
            </tbody>
151
            <tfoot>
152
                <tr>
153
                    <th colspan="3">Total Tax Exc.</th>
154
                    <th>[% total_rrp_gste %]</th>
155
                    <th>&nbsp;</th>
156
                    <th>[% total_quantity %]</th>
157
                    <th>[% total_est_gste %]</th>
158
                    <th>&nbsp;</th>
159
                </tr>
160
                <tr>
161
                    <th colspan='3'>Tax ([% gist %]%)</th>
162
                    <th>[% gist_rrp %]</th>
163
                    <th>&nbsp;</th>
164
                    <th>&nbsp;</th>
165
                    <th>[% gist_est %]</th>
166
                    <th>&nbsp;</th>
167
                </tr>
168
                <tr>
169
                    <th colspan='3'>Total Tax Inc. ([% currency %])</th>
170
                    <th>[% total_rrp_gsti %]</th>
171
                    <th>&nbsp;</th>
172
                    <th>[% total_quantity %]</th>
173
                    <th>[% total_est_gsti %]</th>
174
                    <th>&nbsp;</th>
175
                </tr>
176
                <tr>
177
                    <th colspan="3">Total + Shipment cost ([% currency %])</th>
178
                    <th>&nbsp;</th>
179
                    <th>&nbsp;</th>
180
                    <th>[% total_quantity %]</th>
181
                    <th>[% total_gsti_shipment %]</th>
182
                    <th>&nbsp;</th>
183
                </tr>
184
            </tfoot>
185
          </table>
186
        [% ELSE %]
187
            <p>No orders yet</p>
188
        [% END %]
189
    </div>
190
  </div>
191
  <div class="yui-b">
192
    [% INCLUDE 'acquisitions-menu.inc' %]
193
  </div>
194
</div>
195
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+237 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>Invoice note</th>
56
                <th>Vendor</th>
57
                <th>Billing date</th>
58
                <th>Received biblios</th>
59
                <th>Received items</th>
60
                <th>Status</th>
61
                <th>Actions</th>
62
              </tr>
63
            </thead>
64
            <tbody>
65
              [% FOREACH result IN results_loop %]
66
                <tr>
67
                  <td>[% result.invoicenumber %]</td>
68
                  <td>[% result.invoicenote %]</td>
69
                  <td>[% result.suppliername %]</td>
70
                  <td>
71
                    [% IF (result.billingdate) %]
72
                      [% result.billingdate | $KohaDates %]
73
                    [% END %]
74
                  </td>
75
                  <td>[% result.receivedbiblios %]</td>
76
                  <td>[% result.receiveditems %]</td>
77
                  <td>
78
                    [% IF ( result.closedate ) %]
79
                      Closed on [% result.closedate | $KohaDates %]
80
                    [% ELSE %]
81
                      Open
82
                    [% END %]
83
                  </td>
84
                  <td>
85
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
86
                    [% IF ( result.closedate ) %]
87
                      <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>
88
                    [% ELSE %]
89
                      <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>
90
                    [% END %]
91
                  </td>
92
                </tr>
93
              [% END %]
94
            </tbody>
95
          </table>
96
        [% ELSE %]
97
          <p>Sorry, but there is no results for your search.</p>
98
          <p>Search was:
99
            <ul>
100
              [% IF ( invoicenumber ) %]
101
                <li>Invoice no.: [% invoicenumber %]</li>
102
              [% END %]
103
              [% IF ( invoicenote ) %]
104
                <li>Invoice note: [% invoicenote %]</li>
105
              [% END %]
106
              [% IF ( supplier ) %]
107
                <li>Vendor: [% suppliername %]</li>
108
              [% END %]
109
              [% IF ( billingdatefrom ) %]
110
                <li>Billing date:
111
                [% IF ( billingdateto ) %]
112
                  From [% billingdatefrom %]
113
                  To [% billingdateto %]
114
                [% ELSE %]
115
                  All since [% billingdatefrom %]
116
                [% END %]
117
                </li>
118
              [% ELSE %]
119
                [% IF ( billingdateto ) %]
120
                  <li>Billing date:
121
                    All until [% billingdateto %]
122
                  </li>
123
                [% END %]
124
              [% END %]
125
              [% IF ( isbneanissn ) %]
126
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
127
              [% END %]
128
              [% IF ( title ) %]
129
                <li>Title: [% title %]</li>
130
              [% END %]
131
              [% IF ( author ) %]
132
                <li>Author: [% author %]</li>
133
              [% END %]
134
              [% IF ( publisher ) %]
135
                <li>Publisher: [% publisher %]</li>
136
              [% END %]
137
              [% IF ( publicationyear ) %]
138
                <li>Publication year: [% publicationyear %]</li>
139
              [% END %]
140
              [% IF ( branch ) %]
141
                <li>Branch: [% branchname %]</li>
142
              [% END %]
143
            </ul>
144
          </p>
145
        [% END %]<!-- results_loop -->
146
      [% ELSE %]
147
        <p>Please fill in the form to the left to make a search.</p>
148
      [% END %]<!-- do_search -->
149
    </div>
150
  </div>
151
  <div class="yui-b">
152
    <form action="" method="get">
153
      <fieldset class="brief">
154
        <h3>Search filters</h3>
155
        <ol>
156
          <li>
157
            <label for="invoicenumber">Invoice no:</label>
158
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
159
          </li>
160
      <li>
161
            <label for="invoicenote">Invoice note:</label>
162
            <input type="text" id="invoicenote" name="invoicenote" value="[% invoicenote %]" />
163
          </li>
164
          <li>
165
            <label for="supplier">Supplier:</label>
166
            <select id="supplier" name="supplier">
167
              <option value="">All</option>
168
              [% FOREACH supplier IN suppliers_loop %]
169
                [% IF ( supplier.selected ) %]
170
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
171
                [% ELSE %]
172
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
173
                [% END %]
174
              [% END %]
175
            </select>
176
          </li>
177
          <li>
178
            <fieldset class="brief">
179
              <legend>Billing date</legend>
180
              <ol>
181
                <li>
182
                  <label for="billingdatefrom">From:</label>
183
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" />
184
                  <img id="billingdatefromCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
185
                </li>
186
                <li>
187
                  <label for="billingdateto">To:</label>
188
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" />
189
                  <img id="billingdatetoCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
190
                </li>
191
              </ol>
192
            </fieldset>
193
          </li>
194
          <li>
195
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
196
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
197
          </li>
198
          <li>
199
            <label for="title">Title:</label>
200
            <input type="text" id="title" name="title" value="[% title %]" />
201
          </li>
202
          <li>
203
            <label for="author">Author:</label>
204
            <input type="text" id="author" name="author" value="[% author %]" />
205
          </li>
206
          <li>
207
            <label for="publisher">Publisher:</label>
208
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
209
          </li>
210
          <li>
211
            <label for="publicationyear">Publication year:</label>
212
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
213
          </li>
214
          <li>
215
            <label for="branch">Branch:</label>
216
            <select id="branch" name="branch">
217
              <option value="">All</option>
218
              [% FOREACH branch IN branches_loop %]
219
                [% IF ( branch.selected ) %]
220
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
221
                [% ELSE %]
222
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
223
                [% END %]
224
              [% END %]
225
            </select>
226
          </li>
227
        </ol>
228
        <fieldset class="action">
229
          <input type="submit" value="Search" />
230
        </fieldset>
231
      </fieldset>
232
      <input type="hidden" name="op" id="op" value="do_search" />
233
    </form>
234
    [% INCLUDE 'acquisitions-menu.inc' %]
235
  </div>
236
</div>
237
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-5 / +4 lines)
Lines 129-139 Link Here
129
        </fieldset>
129
        </fieldset>
130
    [% END %][%# IF (AcqCreateItemReceiving) %]
130
    [% END %][%# IF (AcqCreateItemReceiving) %]
131
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
131
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
132
    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
132
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
133
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
133
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
134
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
134
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
135
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
135
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
136
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
136
    <input type="hidden" name="freight" value="[% freight %]" />
137
    <input type="hidden" name="gst" value="[% gst %]" />
137
    <input type="hidden" name="gst" value="[% gst %]" />
138
	</div>
138
	</div>
139
	<div class="yui-u">
139
	<div class="yui-u">
Lines 185-197 Link Here
185
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
185
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
186
        [% END %]</li></ol>
186
        [% END %]</li></ol>
187
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
187
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
188
        <input type="hidden" name="invoice" value="[% invoice %]" />
189
    </fieldset>
188
    </fieldset>
190
189
191
</div>
190
  </div>
192
</div><div class="yui-g"><fieldset class="action">
191
</div><div class="yui-g"><fieldset class="action">
193
        <input type="submit"  value="Save" />
192
        <input type="submit"  value="Save" />
194
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
193
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Cancel</a>
195
</fieldset></div>    </form>
194
</fieldset></div>    </form>
196
[% ELSE %]
195
[% ELSE %]
197
<div id="acqui_acquire_orderlist">
196
<div id="acqui_acquire_orderlist">
Lines 208-214 Link Here
208
        <tr>
207
        <tr>
209
            <td>[% loo.basketno %]</td>
208
            <td>[% loo.basketno %]</td>
210
            <td>[% loo.isbn %]</td>
209
            <td>[% loo.isbn %]</td>
211
         <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>
210
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
212
            <td>[% loo.author %]</td>
211
            <td>[% loo.author %]</td>
213
            <td>[% loo.quantity %]</td>
212
            <td>[% loo.quantity %]</td>
214
            <td>[% loo.quantityreceived %]</td>
213
            <td>[% loo.quantityreceived %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-252 / +261 lines)
Lines 152-274 Link Here
152
//]]>
152
//]]>
153
</script>
153
</script>
154
154
155
155
</head>
156
</head>
156
<body id="acq_parcel" class="acq">
157
<body id="acq_parcel" class="acq">
157
[% INCLUDE 'header.inc' %]
158
  [% INCLUDE 'header.inc' %]
158
[% INCLUDE 'acquisitions-search.inc' %]
159
  [% INCLUDE 'acquisitions-search.inc' %]
159
160
  
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 ) %]
161
  <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 ) %]
161
            Receipt Summary for <i>[% name %]</i> [% IF ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
162
    Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
162
        [% ELSE %]
163
    [% ELSE %]
163
            Receive orders from [% name %]
164
    Receive orders from [% name %]
164
        [% END %]</div>
165
    [% END %]</div>
165
166
  
166
<div id="doc3" class="yui-t2">
167
  <div id="doc3" class="yui-t2">
167
168
    
168
   <div id="bd">
169
    <div id="bd">
169
	<div id="yui-main">
170
      <div id="yui-main">
170
	<div class="yui-b">
171
	<div class="yui-b">
171
	[% IF ( receive_error ) %]
172
	  [% IF ( receive_error ) %]
172
	<div class="dialog alert">
173
	  <div class="dialog alert">
173
	<h3>Error adding items:</h3>
174
	    <h3>Error adding items:</h3>
174
	<ul>
175
	    <ul>
175
	[% FOREACH error_loo IN error_loop %]
176
	      [% FOREACH error_loo IN error_loop %]
176
		<li>[% error_loo.error_param %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
177
	      <li>[% error_loo.error_param %][% IF ( error_loo.error_duplicate_barcode ) %]Duplicate Barcode[% END %] <!-- todo: other error conditions come here. --></li>
177
	[% END %]
178
	      [% END %]
178
	</ul>
179
	    </ul>
179
	</div>
180
	  </div>
180
	[% END %]
181
	  [% END %]
181
    <h1>
182
	  <h1>
182
        [% IF ( datereceived ) %]
183
            [% IF ( datereceived ) %]
183
            Receipt Summary for <i>[% name %]</i> [% IF ( invoice ) %] <i> [ [% invoice %] ] </i>[% END %] on <i>[% formatteddatereceived %]</i>
184
            Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %] <i> [ [% invoice %] ] </i>[% END %] on <i>[% formatteddatereceived %]</i>
184
        [% ELSE %]
185
            [% ELSE %]
185
            Receive orders from [% name %]
186
            Receive orders from [% name %]
186
        [% END %]
187
            [% END %]
187
    </h1>
188
	  </h1>
188
189
	  
189
    [% IF ( success_delorder ) %]
190
	  [% IF ( success_delorder ) %]
190
    <div class="dialog message">The order has been successfully canceled.</div>
191
	  <div class="dialog message">The order has been successfully canceled.</div>
191
    [% ELSE %]
192
	  [% ELSE %]
192
	[% IF ( error_delitem ) %]
193
	  [% IF ( error_delitem ) %]
193
	    <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
194
	  <div class="dialog alert">The order has been canceled, although one or more items could not have been deleted.</div>
194
	[% END %]
195
	  [% END %]
195
	[% IF ( error_delbiblio ) %]
196
	  [% IF ( error_delbiblio ) %]
196
	    <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
197
	  <div class="dialog alert">The order has been canceled, although the record has not been deleted.</div>
197
	[% END %]
198
	  [% END %]
198
    [% END %]
199
	  [% END %]
199
200
	  
200
<div id="acqui_receive_summary">
201
	  <div id="acqui_receive_summary">
201
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
202
	    <p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
202
	<!-- TODO: Add date picker, change rcv date. -->
203
	    <p><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">Go to invoice details</a></p>
203
</div>
204
	  </div>
204
<div id="acqui_receive_search">
205
	  [% UNLESS (invoiceclosedate) %]
205
    <h3>Pending Orders</h3>
206
	  <div id="acqui_receive_search">
206
207
            <h3>Pending Orders</h3>
207
 [% IF ( loop_orders ) %]<table id="pendingt">
208
	    
208
    <thead>
209
	    [% IF ( loop_orders ) %]<table id="pendingt">
209
        <tr>
210
              <thead>
210
            <th>Basket</th>
211
		<tr>
211
            <th>Order Line</th>
212
		  <th>Basket</th>
212
            <th>Summary</th>
213
		  <th>Order line</th>
213
    	    <th>View Record</th>
214
		  <th>Summary</th>
214
            <th>Quantity</th>
215
		  <th>View record</th>
215
            <th>Unit cost</th>
216
		  <th>Quantity</th>
216
            <th>Order cost</th>
217
		  <th>Unit cost</th>
217
            <th>&nbsp;</th>
218
		  <th>Order cost</th>
218
            <th>&nbsp;</th>
219
		  <th>&nbsp;</th>
219
        </tr>
220
		  <th>&nbsp;</th>
220
    </thead>
221
		</tr>
221
		<tfoot>
222
	      </thead>
222
            <tr><td colspan="4" class="total">TOTAL</td>
223
	      <tfoot>
223
                <td> [% totalPquantity %] </td>
224
		<tr><td colspan="4" class="total">TOTAL</td>
224
				<td>&nbsp;</td>
225
		  <td> [% totalPquantity %] </td>
225
                <td>[% ordergrandtotal %]</td>
226
		  <td>&nbsp;</td>
226
				<td>&nbsp;</td>
227
                  <td>[% ordergrandtotal %]</td>
227
				<td>&nbsp;</td>
228
                  <td>&nbsp;</td>
228
            </tr>
229
                  <td>&nbsp;</td>
229
		</tfoot>
230
                </tr>
230
    <tbody class="filterclass">
231
              </tfoot>
231
        [% FOREACH loop_order IN loop_orders %]
232
              <tbody class="filterclass">
232
	[% UNLESS ( loop.odd ) %]
233
		[% FOREACH loop_order IN loop_orders %]
233
            <tr class="highlight">
234
		[% UNLESS ( loop.odd ) %]
234
        [% ELSE %]
235
                <tr class="highlight">
235
            <tr>
236
		  [% ELSE %]
236
        [% END %]
237
                <tr>
237
                <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
238
		  [% END %]
238
                <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.booksellerid %]">[% loop_order.ordernumber %]</a></td>
239
                  <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
239
                <td class="summaryfilterclass">
240
                  <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.booksellerid %]">[% loop_order.ordernumber %]</a></td>
240
                  <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
241
                  <td class="summaryfilterclass">
241
                [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
242
                    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
242
                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
243
                    [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
243
                [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
244
                    [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
244
                [% IF ( loop_order.suggestionid ) %]
245
                    [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
246
                    [% IF ( loop_order.suggestionid ) %]
245
                    <br/>
247
                    <br/>
246
                    Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
248
                    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 %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
249
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
248
                [% END %]
250
                    [% END %]
249
                <br />
251
                    <br />
250
                [% IF ( loop_order.notes ) %]
252
                    [% IF ( loop_order.notes ) %]
251
                    <p class="ordernote"><strong>Note: </strong>[% loop_order.notes|html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Change note</a>]</p>
253
                    <p class="ordernote"><strong>Note: </strong>[% loop_order.notes|html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Change note</a>]</p>
252
                [% ELSE %]
254
                    [% ELSE %]
253
                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Add note</a>]
255
                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Add note</a>]
254
                [% END %]
256
                    [% END %]
255
                </td>
257
                  </td>
256
                <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>
258
                  <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>
257
                <td>[% loop_order.quantity %]</td>
259
                  <td>[% loop_order.quantity %]</td>
258
                <td>[% loop_order.ecost %]</td>
260
                  <td>[% loop_order.ecost %]</td>
259
                <td>[% loop_order.ordertotal %]</td>
261
                  <td>[% loop_order.ordertotal %]</td>
260
				<td>
262
                  <td>
261
				    <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>
263
                    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
262
				    
264
		    
263
				</td>
265
                  </td>
264
				<td>
266
                  <td>
265
				    [% IF ( loop_order.left_holds_on_order ) %]
267
                    [% IF ( loop_order.left_holds_on_order ) %]
266
                    <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>
268
                    <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>
267
                    [% ELSE %]
269
                    [% ELSE %]
268
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
270
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
269
                    [% END %]
271
                    [% END %]
270
                    [% IF ( loop_order.can_del_bib ) %]
272
                    [% IF ( loop_order.can_del_bib ) %]
271
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
273
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
272
                    [% ELSE %]
274
                    [% ELSE %]
273
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
275
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
274
                    [% END %]
276
                    [% END %]
Lines 284-439 Link Here
284
                    [% IF ( loop_order.left_holds ) %]
286
                    [% IF ( loop_order.left_holds ) %]
285
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
287
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
286
                    [% END %]
288
                    [% END %]
287
				</td>
289
                  </td>
288
            </tr>
290
                </tr>
289
        [% END %]
290
    </tbody>
291
     </table>[% ELSE %]There are no pending orders.[% END %]
292
   <div id="resultnumber">
293
	<!-- Row of numbers corresponding to search result pages -->
294
	[% IF ( displayprev ) %]
295
		<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>
296
	[% END %]
297
	[% FOREACH number IN numbers %]
298
		[% IF ( number.highlight ) %]
299
		<span class="current">[% number.number %]</span>
300
		[% ELSE %]
301
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% number.startfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
302
		[% END %]
291
		[% END %]
303
	[% END %]
292
              </tbody>
304
	[% IF ( displaynext ) %]
293
            </table>
305
		<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>
294
	    [% ELSE %]There are no pending orders.[% END %]
306
	[% END %]
295
	    <div id="resultnumber">
296
              <!-- Row of numbers corresponding to search result pages -->
297
              [% IF ( displayprev ) %]
298
              <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% prevstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
299
              [% END %]
300
              [% FOREACH number IN numbers %]
301
              [% IF ( number.highlight ) %]
302
              <span class="current">[% number.number %]</span>
303
              [% ELSE %]
304
              <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% number.startfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
305
              [% END %]
306
              [% END %]
307
              [% IF ( displaynext ) %]
308
              <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% nextstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
309
              [% END %]
310
            </div>
311
	  </div>
312
	  [% ELSE %]
313
	  <p>
314
            Invoice is close, so you can't receive orders.
315
            <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
316
	  </p>
317
	  [% END %]
318
	  <div id="acqui_receive_receivelist">
319
	    <h3>Already received</h3>
320
	    
321
	    [% IF ( loop_received ) %]
322
	    <form action="/cgi-bin/koha/acqui/parcel.pl" method="get" name="orderform">
323
	      <table id="receivedt">
324
		<thead>
325
		  <tr>
326
		    <th>Basket</th>
327
		    <th>Order line</th>
328
		    <th>Summary</th>
329
		    <th>View record</th>
330
		    <th>Quantity</th>  
331
		    <th>Est cost</th>
332
		    <th>Actual cost</th>
333
		    <th>TOTAL</th>
334
		  </tr>
335
		</thead>
336
		<tfoot>
337
		  <tr>
338
		    <td colspan="4" class="total">SUBTOTAL</td>
339
		    <td colspan="2">&nbsp;</td>
340
		    <td>[% totalprice %]</td>
341
		    <td>[% tototal %]</td>
342
		  </tr>
343
		  
344
		  [% IF ( totalfreight ) %]
345
		  <tr>
346
		    <td colspan="6">&nbsp;
347
		    </td>
348
		    <td>Shipping</td>
349
		    <td>[% totalfreight %]</td>
350
	    	  </tr> 
351
		  [% END %]
352
		  [% IF ( gst ) %]
353
		  <tr>
354
		    <td colspan="6">
355
		      <p class="message">
356
			<b>HELP</b><br />
357
			The total at the bottom of the page should be within a few cents of the total for the invoice.
358
		      </p>
359
		    </td>
360
		    <td><b>Tax rate</b></td>
361
		    <td>[% gst %]</td>
362
	    	  </tr> 
363
		  [% END %]
364
		  <tr>
365
		    <td colspan="4" class="total">TOTAL</td>
366
		    <td>[% totalquantity %]</td>
367
		    <td colspan="2">&nbsp;</td>
368
		    <td>[% grandtot %]</td>
369
		  </tr>
370
		</tfoot>
371
		<tbody class="filterclass">
372
		  [% FOREACH loop_receive IN loop_received %]
373
		  [% UNLESS ( loop.odd ) %]
374
		  <tr class="highlight">
375
		    [% ELSE %]
376
		  <tr>
377
		    [% END %]
378
                    <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_receive.basketno %]">[% loop_receive.basketno %]</a></td>
379
                    <td><a href="neworderempty.pl?ordernumber=[% loop_receive.ordernumber %]&amp;booksellerid=[% booksellerid %]">[% loop_receive.ordernumber %]</a></td>
380
                    <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_receive.biblionumber %]">[% loop_receive.title |html %]</a>
381
                      [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %]
382
                      [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %]
383
                      [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %]
384
                      [% IF ( loop_receive.suggestionid ) %]
385
                      <br/>
386
                      Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %]
387
                      (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]&amp;op=show">suggestion #[% loop_receive.suggestionid %]</a>)
388
                      [% END %]
389
                    </td>
390
                    <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
391
                    <td>[% loop_receive.quantityreceived %]</td>
392
                    <td>[% loop_receive.ecost %]</td>
393
                    <td>[% loop_receive.unitprice %]</td>
394
                    <td>[% loop_receive.total %]</td>
395
		  </tr>
396
		  [% END %]
397
		</tbody>
398
	      </table>
399
	    </form>
400
	    [% ELSE %]There are no received orders.[% END %]
401
	  </div>
402
	  
403
	  <!--<form action="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid %]" method="post">-->
404
	  <form action="parcels.pl?booksellerid=[% booksellerid %]" method="post">
405
	    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
406
	    <fieldset class="action">
407
              <input type="submit" value="Finish receiving" />
408
	    </fieldset>
409
	  </form>
410
	  
307
	</div>
411
	</div>
308
</div>
412
      </div>
309
<div id="acqui_receive_receivelist">
413
      <div class="yui-b">
310
    <h3>Already Received</h3>
414
	<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" onsubmit="return filter();">
311
415
          <fieldset class="brief">
312
   [% IF ( loop_received ) %]
416
	    
313
   <form action="/cgi-bin/koha/acqui/parcel.pl" method="get" name="orderform">
314
    <table id="receivedt">
315
        <thead>
316
	    <tr>
317
		<th>Basket</th>
318
		<th>Order Line</th>
319
		<th>Summary</th>
320
		<th>View Record</th>
321
		<th>Quantity</th>  
322
		<th>Est cost</th>
323
		<th>Actual cost</th>
324
		<th>TOTAL</th>
325
	    </tr>
326
	</thead>
327
<tfoot>
328
	    <tr>
329
		<td colspan="4" class="total">SUBTOTAL</td>
330
		<td colspan="2">&nbsp;</td>
331
		<td>[% totalprice %]</td>
332
		<td>[% tototal %]</td>
333
	    </tr>
334
	      
335
	      [% IF ( totalfreight ) %]
336
		    <tr>
337
			<td colspan="6">&nbsp;
338
		</td>
339
			    <td>Shipping</td>
340
		<td>[% totalfreight %]</td>
341
	    	</tr> 
342
	    [% END %]
343
	      [% IF ( gst ) %]
344
		    <tr>
345
			<td colspan="6">
346
		<p class="message">
347
			    <b>HELP</b><br />
348
		    The total at the bottom of the page should be within a few cents of the total for the invoice.
349
		</p>
350
		</td>
351
			    <td><b>Tax rate</b></td>
352
		<td>[% gst %]</td>
353
	    	</tr> 
354
	    [% END %]
355
	    <tr>
356
	    <td colspan="4" class="total">TOTAL</td>
357
		<td>[% totalquantity %]</td>
358
		<td colspan="2">&nbsp;</td>
359
		<td>[% grandtot %]</td>
360
	    </tr>
361
    </tfoot>
362
	<tbody class="filterclass">
363
	    [% FOREACH loop_receive IN loop_received %]
364
        [% UNLESS ( loop.odd ) %]
365
            <tr class="highlight">
366
        [% ELSE %]
367
            <tr>
368
        [% END %]
369
                <td><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_receive.basketno %]">[% loop_receive.basketno %]</a></td>
370
                <td><a href="neworderempty.pl?ordernumber=[% loop_receive.ordernumber %]&amp;booksellerid=[% booksellerid %]">[% loop_receive.ordernumber %]</a></td>
371
                <td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_receive.biblionumber %]">[% loop_receive.title |html %]</a>
372
                [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %]
373
                [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %]
374
                [% IF ( loop_receive.publishercode ) %]<br />Publisher :[% loop_receive.publishercode %][% END %]
375
                [% IF ( loop_receive.suggestionid ) %]
376
                    <br/>
377
                    Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %]
378
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]&amp;op=show">suggestion #[% loop_receive.suggestionid %]</a>)
379
                [% END %]
380
                </td>
381
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
382
                <td>[% loop_receive.quantityreceived %]</td>
383
                <td>[% loop_receive.ecost %]</td>
384
                <td>[% loop_receive.unitprice %]</td>
385
                <td>[% loop_receive.total %]</td>
386
            </tr>
387
	    [% END %]
388
	</tbody>
389
    </table>
390
    </form>
391
	[% ELSE %]There are no received orders.[% END %]
392
</div>
393
394
<!--<form action="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid %]" method="post">-->
395
<form action="parcels.pl?booksellerid=[% booksellerid %]" method="post">
396
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
397
    <fieldset class="action">
398
        <input type="submit" value="Finish receiving" />
399
    </fieldset>
400
</form>
401
402
</div>
403
</div>
404
<div class="yui-b">
405
<form action="/cgi-bin/koha/acqui/parcel.pl" id="filterform" onsubmit="return filter();">
406
        <fieldset class="brief">
407
408
            <h4>Filter</h4>
417
            <h4>Filter</h4>
409
418
	    
410
	    <ol>
419
	    <ol>
411
420
	      
412
		<li>
421
	      <li>
413
		    <label for="summaryfilter">ISBN, author or title :</label>
422
		<label for="summaryfilter">ISBN, author or title :</label>
414
		    <input type="text" name="summaryfilter" id="summaryfilter" />
423
		<input type="text" name="summaryfilter" id="summaryfilter" />
415
		</li>
424
	      </li>
416
425
	      
417
		<li>
426
	      <li>
418
		    <label for="basketfilter">Basket :</label>
427
		<label for="basketfilter">Basket :</label>
419
		    <input type="text" name="basketfilter" id="basketfilter" />
428
		<input type="text" name="basketfilter" id="basketfilter" />
420
		</li>
429
	      </li>
421
430
	      
422
		<li>
431
	      <li>
423
		    <label for="orderfilter">Order Line :</label>
432
		<label for="orderfilter">Order line :</label>
424
		    <input type="text" name="orderfilter" id="orderfilter" />
433
		<input type="text" name="orderfilter" id="orderfilter" />
425
		</li>
434
	      </li>
426
	    </ol>
435
	    </ol>
427
		<fieldset class="action">
436
	    <fieldset class="action">
428
		    <input type="submit" value="Filter" />
437
	      <input type="submit" value="Filter" />
429
		    <a href="#" onclick="clearFilters();">Clear</a>
438
	      <a href="#" onclick="clearFilters();">Clear</a>
430
		</fieldset>
439
	    </fieldset>
431
440
	    
432
441
	    
433
        </fieldset>
442
          </fieldset>
434
    </form>
443
	</form>
435
[% INCLUDE 'acquisitions-menu.inc' %]
444
	[% INCLUDE 'acquisitions-menu.inc' %]
436
</div>
445
      </div>
437
</div>
446
    </div>
438
[% INCLUDE 'intranet-bottom.inc' %]
447
    [% INCLUDE 'intranet-bottom.inc' %]
439
 
448
    
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-28 / +57 lines)
Lines 2-7 Link Here
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Receive shipment from vendor [% name %]</title>
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Receive shipment from vendor [% name %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'calendar.inc' %]
4
[% INCLUDE 'calendar.inc' %]
5
<script language="JavaScript" type="text/javascript">
6
//<![CDATA[
7
    $(document).ready(function() {
8
  Calendar.setup({
9
    inputField : "shipmentdate",
10
    ifFormat : "[% DHTMLcalendar_dateformat %]",
11
    button : "shipmentdate_button"
12
  });
13
  Calendar.setup({
14
    inputField: "billingdate",
15
    ifFormat: "[% DHTMLcalendar_dateformat %]",
16
    button: "billingdateCalendar"
17
  });
18
});
19
  //]]>
20
</script>
21
5
</head>
22
</head>
6
<body id="acq_parcels" class="acq">
23
<body id="acq_parcels" class="acq">
7
[% INCLUDE 'header.inc' %]
24
[% INCLUDE 'header.inc' %]
Lines 14-20 Link Here
14
   <div id="bd">
31
   <div id="bd">
15
	<div id="yui-main">
32
	<div id="yui-main">
16
	<div class="yui-b">
33
	<div class="yui-b">
17
	
34
35
[% IF ( error_failed_to_create_invoice ) %]
36
    <div id="error" class="dialog error">
37
        <p>An error has occured. Invoice cannot be created.</p>
38
    </div>
39
[% END %]
18
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1>
40
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1>
19
41
20
[% IF ( count ) %]
42
[% IF ( count ) %]
Lines 27-35 Link Here
27
            <th>Line</th>
49
            <th>Line</th>
28
            <th>Date Received</th>
50
            <th>Date Received</th>
29
            <th>Invoice Number</th>
51
            <th>Invoice Number</th>
52
            <th>Invoice Note</th>
30
            <th>Item Count</th>
53
            <th>Item Count</th>
31
            <th>Biblio count</th>
54
            <th>Biblio count</th>
32
            <th>Items expected</th>
55
            <th>Items expected</th>
56
            <th>Actions</th>
33
        </tr>
57
        </tr>
34
<!-- Actual Search Results -->
58
<!-- Actual Search Results -->
35
[% FOREACH searchresult IN searchresults %]
59
[% FOREACH searchresult IN searchresults %]
Lines 42-52 Link Here
42
            [% searchresult.number %]
66
            [% searchresult.number %]
43
        </td>
67
        </td>
44
        <td>
68
        <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 %]">
69
            [% searchresult.datereceived %]
46
                [% searchresult.datereceived %]</a>
70
        </td>
71
        <td>
72
            [% IF ( searchresult.code ) %]
73
                <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% searchresult.invoiceid %]">
74
                    [% searchresult.code %]
75
            </a>
76
            [% ELSE %]
77
                <acronym title="not available">n/a</acronym>
78
            [% END %]
47
        </td>
79
        </td>
48
        <td>
80
        <td>
49
            [% IF ( searchresult.code ) %][% searchresult.code %][% ELSE %]<acronym title="not available">n/a</acronym>[% END %]
81
            [% searchresult.invoicenote %]
50
        </td>
82
        </td>
51
        <td>
83
        <td>
52
            [% searchresult.reccount %] 
84
            [% searchresult.reccount %] 
Lines 57-62 Link Here
57
        <td>
89
        <td>
58
            [% searchresult.itemcount %]
90
            [% searchresult.itemcount %]
59
        </td>
91
        </td>
92
    <td>
93
     <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% searchresult.invoiceid %]">Edit</a> /
94
     <a href="/cgi-bin/koha/acqui/parcels.pl?op=delete&invoiceid=[% searchresult.invoiceid %]&booksellerid=[% booksellerid %]">Delete</a>
95
 </td>
60
    </tr>
96
    </tr>
61
[% END %]
97
[% END %]
62
</table>
98
</table>
Lines 81-87 Link Here
81
[% END %]
117
[% END %]
82
118
83
    <div id="parcels_new_parcel">
119
    <div id="parcels_new_parcel">
84
        <form method="get" action="parcel.pl">
120
        <form method="get" action="parcels.pl">
85
    <fieldset class="rows">
121
    <fieldset class="rows">
86
    <legend>Receive a new shipment</legend>
122
    <legend>Receive a new shipment</legend>
87
       <ol> <li>
123
       <ol> <li>
Lines 90-118 Link Here
90
            <input type="hidden" name="op" value="new" />
126
            <input type="hidden" name="op" value="new" />
91
			<input type="text" size="20" id="invoice" name="invoice" />
127
			<input type="text" size="20" id="invoice" name="invoice" />
92
        </li>
128
        </li>
93
		[% IF ( gst ) %]
129
  <li>
94
        <li>
130
           <label for="invoicenote">Invoice note</label>
95
            <label for="gst">GST:</label>
131
    <input type="text" size="20" id="invoicenote" name="invoicenote" />
96
            <input type="text" size="20" id="gst" name="gst" />
132
         </li>
97
        </li>
133
98
		[% END %]
134
         <li><label for="billingdate">Billing date:</label>
99
      <!--  // Removing freight input until shipping can be proplerly handled .
135
           <input type="text" size="10" id="billingdate" name="billingdate" value="[% today %]" readonly="readonly" />
100
	  <li>
136
           <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
101
            <label for="freight">Shipping:</label>
137
       </li>
102
            <input type="text" size="20" id="freight" name="freight" />
138
103
        </li> -->
139
104
         <li><label for="datereceived">Shipment date: </label>
140
         <li><label for="shipmentdate">Shipment date: </label>
105
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" />
141
            <input type="text" id="shipmentdate" name="shipmentdate" maxlength="10" size="10" value="[% today %]" />
106
            <img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
142
            <img src="[% themelang %]/lib/calendar/cal.gif" id="shipmentdate_button" alt="Show Calendar" />
107
      <script language="JavaScript" type="text/javascript">
143
         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
108
        Calendar.setup(
109
          {
110
            inputField : "datereceived",
111
            ifFormat : "[% DHTMLcalendar_dateformat %]",
112
            button : "datereceived_button"          }
113
        );
114
      </script>
115
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
116
		</ol>
144
		</ol>
117
    </fieldset>
145
    </fieldset>
118
            <fieldset class="action"><input type="submit" class="button" value="Next" /> <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">Cancel</a></fieldset>
146
            <fieldset class="action"><input type="submit" class="button" value="Next" /> <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">Cancel</a></fieldset>
Lines 127-132 Link Here
127
        <ol>
155
        <ol>
128
            <li> <input type="hidden" name="booksellerid" value="[% booksellerid %]" /></li>
156
            <li> <input type="hidden" name="booksellerid" value="[% booksellerid %]" /></li>
129
            <li><label for="filter">Invoice number:</label><input type="text" size="20" name="filter" value="[% filter %]" id="filter" /></li>
157
            <li><label for="filter">Invoice number:</label><input type="text" size="20" name="filter" value="[% filter %]" id="filter" /></li>
158
            <li><label for="notefilter">Invoice note:</label><input type="text" size="20" name="notefilter" value="[% notefilter %]" id="notefilter" /></li>
130
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
159
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
131
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
160
                <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">
161
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt (-21 / +19 lines)
Lines 47-59 Link Here
47
	    [% order.title %]
47
	    [% order.title %]
48
	</td>
48
	</td>
49
	<td class="cell">
49
	<td class="cell">
50
            <a href="/cgi-bin/koha/acqui/orderreceive.pl?ordernumber=[% order.ordernumber %]&amp;biblio=[% order.biblionumber %]&amp;invoice=[% order.booksellerinvoicenumber %]&amp;booksellerid=[% order.booksellerid %]&amp;catview=yes">[% order.ordernumber %]</a>
50
            <a href="/cgi-bin/koha/acqui/orderreceive.pl?ordernumber=[% order.ordernumber %]&amp;biblio=[% order.biblionumber %]&amp;invoiceid=[% order.invoiceid %]">[% order.ordernumber %]</a>
51
	</td>
51
	</td>
52
	<td class="cell">
52
	<td class="cell">
53
	    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.booksellerid %]">[% order.booksellerid %]</a>
53
	    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.booksellerid %]">[% order.booksellerid %]</a>
54
	</td>
54
	</td>
55
	<td class="cell">
55
	<td class="cell">
56
	    <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% order.booksellerinvoicenumber %]&amp;booksellerid=[% order.booksellerid %]&amp;datereceived=[% order.datereceived %]">[% order.booksellerinvoicenumber %]</a>
56
           <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid %]">[% order.invoicenumber %]</a>
57
	</td>
57
	</td>
58
	<td class="cell">
58
	<td class="cell">
59
	    [% order.itype %]
59
	    [% order.itype %]
Lines 65-101 Link Here
65
	    [% order.unitprice %]
65
	    [% order.unitprice %]
66
	</td>
66
	</td>
67
	<td class="cell" align="right">
67
	<td class="cell" align="right">
68
	    [% order.freight %]
69
	</td>
70
	<td class="cell" align="right">
71
	    [% order.entrydate | $KohaDates %]
68
	    [% order.entrydate | $KohaDates %]
72
	</td>
69
	</td>
73
	<td class="cell" align="right">
70
	<td class="cell" align="right">
74
	    [% order.datereceived | $KohaDates %]
71
	    [% order.datereceived | $KohaDates %]
75
	</td>
72
	</td>
76
	<td class="cell" align="right">
73
	<td class="cell" align="right">
77
	    [% order.subtotal %]
74
      [% order.rowtotal %]
78
	</td>
75
	</td>
79
    </tr>
76
    </tr>
80
[% END %]
77
[% END %]
81
    <tfoot>
78
    <tfoot>
82
        <tr valign="top">
79
        [% IF shipmentcosts.size %]
83
        <td> Total </td>
80
            <tr valign="top">
84
        <td> </td>
81
                <td colspan="9"> Sub total </td>
85
        <td> </td>
82
                <td align="right"> [% subtotal %] </td>
86
        <td> </td>
83
            </tr>
87
        <td> </td>
84
            [% FOREACH shipmentcost IN shipmentcosts %]
88
        <td> </td>
85
                <tr>
89
        <td> </td>
86
                    <td></td>
90
        <td> </td>
87
                    <td colspan="8">Shipment cost for invoice [% shipmentcost.invoicenumber %]</td>
91
	<td> </td>
88
                    <td class="total">[% shipmentcost.shipmentcost %]</td>
92
	<td> </td>
89
                </tr>
93
        <td align="right">
90
            [% END %]
94
		[% total %]
91
        [% END %]
95
	</td>
92
        <tr>
93
            <td colspan="9">TOTAL</td>
94
            <td class="total">[% total %]</td>
96
        </tr>
95
        </tr>
97
    </tfoot>
96
    </tfoot>
98
99
</table>
97
</table>
100
98
101
</div>
99
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-5 / +4 lines)
Lines 168-183 Link Here
168
168
169
            [% IF ITEM_DAT.dateaccessioned %]
169
            [% IF ITEM_DAT.dateaccessioned %]
170
                <li><span class="label">Accession date:</span>
170
                <li><span class="label">Accession date:</span>
171
                    [% IF ( CAN_user_acquisition_order_receive && ITEM_DAT.booksellerinvoicenumber ) %]
171
                    [% IF ( CAN_user_acquisition_order_receive && ITEM_DAT.invoiceid ) %]
172
                        <a href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% ITEM_DAT.booksellerid %]&amp;invoice=[% ITEM_DAT.booksellerinvoicenumber %]&amp;datereceived=[% ITEM_DAT.datereceived %]">[% ITEM_DAT.dateaccessioned | $KohaDates %]</a>
172
                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% ITEM_DAT.invoiceid %]">[% ITEM_DAT.dateaccessioned | $KohaDates %]</a>
173
                    [% ELSE %]
173
                    [% ELSE %]
174
                        [% ITEM_DAT.dateaccessioned | $KohaDates %]
174
                        [% ITEM_DAT.dateaccessioned | $KohaDates %]
175
                    [% END %]
175
                    [% END %]
176
                </li>
176
                </li>
177
            [% END %]
177
            [% END %]
178
            [% IF ( ITEM_DAT.booksellerinvoicenumber ) %]
178
            [% IF ( ITEM_DAT.invoicenumber ) %]
179
                <li><span class="label">Invoice number:</span>
179
                <li><span class="label">Invoice number:</span>
180
                    [% ITEM_DAT.booksellerinvoicenumber %]
180
                    [% ITEM_DAT.invoicenumber %]
181
                </li>
181
                </li>
182
            [% END %]
182
            [% END %]
183
183
184
- 

Return to bug 5339