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

(-)a/C4/Acquisition.pm (-19 / +366 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
        &CloseInvoice
71
        &ReopenInvoice
72
65
        &GetItemnumbersFromOrder
73
        &GetItemnumbersFromOrder
66
74
67
        &AddClaim
75
        &AddClaim
Lines 1146-1160 sub GetCancelledOrders { Link Here
1146
=head3 ModReceiveOrder
1154
=head3 ModReceiveOrder
1147
1155
1148
  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
1156
  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
1149
    $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
1157
    $unitprice, $invoiceid, $biblioitemnumber,
1150
    $freight, $bookfund, $rrp);
1158
    $bookfund, $rrp, \@received_itemnumbers);
1151
1159
1152
Updates an order, to reflect the fact that it was received, at least
1160
Updates an order, to reflect the fact that it was received, at least
1153
in part. All arguments not mentioned below update the fields with the
1161
in part. All arguments not mentioned below update the fields with the
1154
same name in the aqorders table of the Koha database.
1162
same name in the aqorders table of the Koha database.
1155
1163
1156
If a partial order is received, splits the order into two.  The received
1164
If a partial order is received, splits the order into two.
1157
portion must have a booksellerinvoicenumber.
1158
1165
1159
Updates the order with bibilionumber C<$biblionumber> and ordernumber
1166
Updates the order with bibilionumber C<$biblionumber> and ordernumber
1160
C<$ordernumber>.
1167
C<$ordernumber>.
Lines 1165-1171 C<$ordernumber>. Link Here
1165
sub ModReceiveOrder {
1172
sub ModReceiveOrder {
1166
    my (
1173
    my (
1167
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1174
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1168
        $invoiceno, $freight, $rrp, $budget_id, $datereceived, $received_items
1175
        $invoiceid, $rrp, $budget_id, $datereceived, $received_items
1169
    )
1176
    )
1170
    = @_;
1177
    = @_;
1171
    my $dbh = C4::Context->dbh;
1178
    my $dbh = C4::Context->dbh;
Lines 1191-1204 sub ModReceiveOrder { Link Here
1191
            UPDATE aqorders
1198
            UPDATE aqorders
1192
            SET quantityreceived=?
1199
            SET quantityreceived=?
1193
                , datereceived=?
1200
                , datereceived=?
1194
                , booksellerinvoicenumber=?
1201
                , invoiceid=?
1195
                , unitprice=?
1202
                , unitprice=?
1196
                , freight=?
1197
                , rrp=?
1203
                , rrp=?
1198
                , quantity=?
1204
                , quantity=?
1199
            WHERE biblionumber=? AND ordernumber=?");
1205
            WHERE biblionumber=? AND ordernumber=?");
1200
1206
1201
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
1207
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$quantrec,$biblionumber,$ordernumber);
1202
        $sth->finish;
1208
        $sth->finish;
1203
1209
1204
        # create a new order for the remaining items, and set its bookfund.
1210
        # create a new order for the remaining items, and set its bookfund.
Lines 1222-1231 sub ModReceiveOrder { Link Here
1222
        }
1228
        }
1223
    } else {
1229
    } else {
1224
        $sth=$dbh->prepare("update aqorders
1230
        $sth=$dbh->prepare("update aqorders
1225
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1231
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1226
                                unitprice=?,freight=?,rrp=?
1232
                                unitprice=?,rrp=?
1227
                            where biblionumber=? and ordernumber=?");
1233
                            where biblionumber=? and ordernumber=?");
1228
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1234
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1229
        $sth->finish;
1235
        $sth->finish;
1230
    }
1236
    }
1231
    return $datereceived;
1237
    return $datereceived;
Lines 1384-1392 sub GetParcel { Link Here
1384
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1390
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1385
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1391
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1386
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1392
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1393
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1387
        WHERE
1394
        WHERE
1388
            aqbasket.booksellerid = ?
1395
            aqbasket.booksellerid = ?
1389
            AND aqorders.booksellerinvoicenumber LIKE ?
1396
            AND aqinvoices.invoicenumber LIKE ?
1390
            AND aqorders.datereceived = ? ";
1397
            AND aqorders.datereceived = ? ";
1391
1398
1392
    my @query_params = ( $supplierid, $code, $datereceived );
1399
    my @query_params = ( $supplierid, $code, $datereceived );
Lines 1459-1476 sub GetParcels { Link Here
1459
    my $dbh    = C4::Context->dbh;
1466
    my $dbh    = C4::Context->dbh;
1460
    my @query_params = ();
1467
    my @query_params = ();
1461
    my $strsth ="
1468
    my $strsth ="
1462
        SELECT  aqorders.booksellerinvoicenumber,
1469
        SELECT  aqinvoices.invoicenumber,
1463
                datereceived,purchaseordernumber,
1470
                datereceived,purchaseordernumber,
1464
                count(DISTINCT biblionumber) AS biblio,
1471
                count(DISTINCT biblionumber) AS biblio,
1465
                sum(quantity) AS itemsexpected,
1472
                sum(quantity) AS itemsexpected,
1466
                sum(quantityreceived) AS itemsreceived
1473
                sum(quantityreceived) AS itemsreceived
1467
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1474
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1475
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1468
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1476
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1469
    ";
1477
    ";
1470
    push @query_params, $bookseller;
1478
    push @query_params, $bookseller;
1471
1479
1472
    if ( defined $code ) {
1480
    if ( defined $code ) {
1473
        $strsth .= ' and aqorders.booksellerinvoicenumber like ? ';
1481
        $strsth .= ' and aqinvoices.invoicenumber like ? ';
1474
        # add a % to the end of the code to allow stemming.
1482
        # add a % to the end of the code to allow stemming.
1475
        push @query_params, "$code%";
1483
        push @query_params, "$code%";
1476
    }
1484
    }
Lines 1485-1491 sub GetParcels { Link Here
1485
        push @query_params, $dateto;
1493
        push @query_params, $dateto;
1486
    }
1494
    }
1487
1495
1488
    $strsth .= "group by aqorders.booksellerinvoicenumber,datereceived ";
1496
    $strsth .= "group by aqinvoices.invoicenumber,datereceived ";
1489
1497
1490
    # can't use a placeholder to place this column name.
1498
    # can't use a placeholder to place this column name.
1491
    # but, we could probably be checking to make sure it is a column that will be fetched.
1499
    # but, we could probably be checking to make sure it is a column that will be fetched.
Lines 1701-1707 sub GetHistory { Link Here
1701
            aqorders.quantityreceived,
1709
            aqorders.quantityreceived,
1702
            aqorders.ecost,
1710
            aqorders.ecost,
1703
            aqorders.ordernumber,
1711
            aqorders.ordernumber,
1704
            aqorders.booksellerinvoicenumber as invoicenumber,
1712
            aqinvoices.invoicenumber,
1705
            aqbooksellers.id as id,
1713
            aqbooksellers.id as id,
1706
            aqorders.biblionumber
1714
            aqorders.biblionumber
1707
        FROM aqorders
1715
        FROM aqorders
Lines 1709-1715 sub GetHistory { Link Here
1709
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1717
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1710
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1718
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1711
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1719
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1712
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1720
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
1721
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
1713
1722
1714
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1723
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1715
    if ( C4::Context->preference("IndependantBranches") );
1724
    if ( C4::Context->preference("IndependantBranches") );
Lines 1763-1770 sub GetHistory { Link Here
1763
    }
1772
    }
1764
1773
1765
    if ($booksellerinvoicenumber) {
1774
    if ($booksellerinvoicenumber) {
1766
        $query .= " AND (aqorders.booksellerinvoicenumber LIKE ? OR aqbasket.booksellerinvoicenumber LIKE ?)";
1775
        $query .= " AND aqinvoices.invoicenumber LIKE ? ";
1767
        push @query_params, "%$booksellerinvoicenumber%", "%$booksellerinvoicenumber%";
1776
        push @query_params, "%$booksellerinvoicenumber%";
1768
    }
1777
    }
1769
1778
1770
    if ( C4::Context->preference("IndependantBranches") ) {
1779
    if ( C4::Context->preference("IndependantBranches") ) {
Lines 1905-1911 sub AddClaim { Link Here
1905
        ";
1914
        ";
1906
    my $sth = $dbh->prepare($query);
1915
    my $sth = $dbh->prepare($query);
1907
    $sth->execute($ordernumber);
1916
    $sth->execute($ordernumber);
1917
}
1918
1919
=head3 GetInvoices
1920
1921
    my @invoices = GetInvoices(
1922
        invoicenumber => $invoicenumber,
1923
        suppliername => $suppliername,
1924
        shipmentdatefrom => $shipmentdatefrom, # ISO format
1925
        shipmentdateto => $shipmentdateto, # ISO format
1926
        billingdatefrom => $billingdatefrom, # ISO format
1927
        billingdateto => $billingdateto, # ISO format
1928
        isbneanissn => $isbn_or_ean_or_issn,
1929
        title => $title,
1930
        author => $author,
1931
        publisher => $publisher,
1932
        publicationyear => $publicationyear,
1933
        branchcode => $branchcode,
1934
        order_by => $order_by
1935
    );
1936
1937
Return a list of invoices that match all given criteria.
1938
1939
$order_by is "column_name (asc|desc)", where column_name is any of
1940
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
1941
'shipmentcost', 'shipmentcost_budgetid'.
1942
1943
asc is the default if omitted
1944
1945
=cut
1946
1947
sub GetInvoices {
1948
    my %args = @_;
1949
1950
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
1951
        closedate shipmentcost shipmentcost_budgetid);
1952
1953
    my $dbh = C4::Context->dbh;
1954
    my $query = qq{
1955
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername,
1956
          COUNT(
1957
            DISTINCT IF(
1958
              aqorders.datereceived IS NOT NULL,
1959
              aqorders.biblionumber,
1960
              NULL
1961
            )
1962
          ) AS receivedbiblios,
1963
          SUM(aqorders.quantityreceived) AS receiveditems
1964
        FROM aqinvoices
1965
          LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
1966
          LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid
1967
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1968
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
1969
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
1970
    };
1971
1972
    my @bind_args;
1973
    my @bind_strs;
1974
    if($args{supplierid}) {
1975
        push @bind_strs, " aqinvoices.booksellerid = ? ";
1976
        push @bind_args, $args{supplierid};
1977
    }
1978
    if($args{invoicenumber}) {
1979
        push @bind_strs, " aqinvoices.invoicenumber LIKE ? ";
1980
        push @bind_args, "%$args{invoicenumber}%";
1981
    }
1982
    if($args{suppliername}) {
1983
        push @bind_strs, " aqbooksellers.name LIKE ? ";
1984
        push @bind_args, "%$args{suppliername}%";
1985
    }
1986
    if($args{shipmentdatefrom}) {
1987
        push @bind_strs, " aqinvoices.shipementdate >= ? ";
1988
        push @bind_args, $args{shipementdatefrom};
1989
    }
1990
    if($args{shipmentdateto}) {
1991
        push @bind_strs, " aqinvoices.shipementdate <= ? ";
1992
        push @bind_args, $args{shipementdateto};
1993
    }
1994
    if($args{billingdatefrom}) {
1995
        push @bind_strs, " aqinvoices.billingdate >= ? ";
1996
        push @bind_args, $args{billingdatefrom};
1997
    }
1998
    if($args{billingdateto}) {
1999
        push @bind_strs, " aqinvoices.billingdate <= ? ";
2000
        push @bind_args, $args{billingdateto};
2001
    }
2002
    if($args{isbneanissn}) {
2003
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
2004
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
2005
    }
2006
    if($args{title}) {
2007
        push @bind_strs, " biblio.title LIKE ? ";
2008
        push @bind_args, $args{title};
2009
    }
2010
    if($args{author}) {
2011
        push @bind_strs, " biblio.author LIKE ? ";
2012
        push @bind_args, $args{author};
2013
    }
2014
    if($args{publisher}) {
2015
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
2016
        push @bind_args, $args{publisher};
2017
    }
2018
    if($args{publicationyear}) {
2019
        push @bind_strs, " biblioitems.publicationyear = ? ";
2020
        push @bind_args, $args{publicationyear};
2021
    }
2022
    if($args{branchcode}) {
2023
        push @bind_strs, " aqorders.branchcode = ? ";
2024
        push @bind_args, $args{branchcode};
2025
    }
2026
2027
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
2028
    $query .= " GROUP BY aqinvoices.invoiceid ";
2029
2030
    if($args{order_by}) {
2031
        my ($column, $direction) = split / /, $args{order_by};
2032
        if(grep /^$column$/, @columns) {
2033
            $direction ||= 'ASC';
2034
            $query .= " ORDER BY $column $direction";
2035
        }
2036
    }
1908
2037
2038
    my $sth = $dbh->prepare($query);
2039
    $sth->execute(@bind_args);
2040
2041
    my $results = $sth->fetchall_arrayref({});
2042
    return @$results;
2043
}
2044
2045
=head3 GetInvoice
2046
2047
    my $invoice = GetInvoice($invoiceid);
2048
2049
Get informations about invoice with given $invoiceid
2050
2051
Return a hash filled with aqinvoices.* fields
2052
2053
=cut
2054
2055
sub GetInvoice {
2056
    my ($invoiceid) = @_;
2057
    my $invoice;
2058
2059
    return unless $invoiceid;
2060
2061
    my $dbh = C4::Context->dbh;
2062
    my $query = qq{
2063
        SELECT *
2064
        FROM aqinvoices
2065
        WHERE invoiceid = ?
2066
    };
2067
    my $sth = $dbh->prepare($query);
2068
    $sth->execute($invoiceid);
2069
2070
    $invoice = $sth->fetchrow_hashref;
2071
    return $invoice;
2072
}
2073
2074
=head3 GetInvoiceDetails
2075
2076
    my $invoice = GetInvoiceDetails($invoiceid)
2077
2078
Return informations about an invoice + the list of related order lines
2079
2080
Orders informations are in $invoice->{orders} (array ref)
2081
2082
=cut
2083
2084
sub GetInvoiceDetails {
2085
    my ($invoiceid) = @_;
2086
    my $invoice;
2087
2088
    return unless $invoiceid;
2089
2090
    my $dbh = C4::Context->dbh;
2091
    my $query = qq{
2092
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername
2093
        FROM aqinvoices
2094
          LEFT JOIN aqbooksellers ON aqinvoices.booksellerid = aqbooksellers.id
2095
        WHERE invoiceid = ?
2096
    };
2097
    my $sth = $dbh->prepare($query);
2098
    $sth->execute($invoiceid);
2099
2100
    $invoice = $sth->fetchrow_hashref;
2101
2102
    $query = qq{
2103
        SELECT aqorders.*, biblio.*
2104
        FROM aqorders
2105
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2106
        WHERE invoiceid = ?
2107
    };
2108
    $sth = $dbh->prepare($query);
2109
    $sth->execute($invoiceid);
2110
    $invoice->{orders} = $sth->fetchall_arrayref({});
2111
    $invoice->{orders} ||= []; # force an empty arrayref if fetchall_arrayref fails
2112
2113
    return $invoice;
2114
}
2115
2116
=head3 AddInvoice
2117
2118
    my $invoiceid = AddInvoice(
2119
        invoicenumber => $invoicenumber,
2120
        booksellerid => $booksellerid,
2121
        shipmentdate => $shipmentdate,
2122
        billingdate => $billingdate,
2123
        closedate => $closedate,
2124
        shipmentcost => $shipmentcost,
2125
        shipmentcost_budgetid => $shipmentcost_budgetid
2126
    );
2127
2128
Create a new invoice and return its id or undef if it fails.
2129
2130
=cut
2131
2132
sub AddInvoice {
2133
    my %invoice = @_;
2134
2135
    return unless(%invoice and $invoice{invoicenumber});
2136
2137
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2138
        closedate shipmentcost shipmentcost_budgetid);
2139
2140
    my @set_strs;
2141
    my @set_args;
2142
    foreach my $key (keys %invoice) {
2143
        if(0 < grep(/^$key$/, @columns)) {
2144
            push @set_strs, "$key = ?";
2145
            push @set_args, ($invoice{$key} || undef);
2146
        }
2147
    }
2148
2149
    my $rv;
2150
    if(@set_args > 0) {
2151
        my $dbh = C4::Context->dbh;
2152
        my $query = "INSERT INTO aqinvoices SET ";
2153
        $query .= join (",", @set_strs);
2154
        my $sth = $dbh->prepare($query);
2155
        $rv = $sth->execute(@set_args);
2156
        if($rv) {
2157
            $rv = $dbh->last_insert_id(undef, undef, 'aqinvoices', undef);
2158
        }
2159
    }
2160
    return $rv;
2161
}
2162
2163
=head3 ModInvoice
2164
2165
    ModInvoice(
2166
        invoiceid => $invoiceid,    # Mandatory
2167
        invoicenumber => $invoicenumber,
2168
        booksellerid => $booksellerid,
2169
        shipmentdate => $shipmentdate,
2170
        billingdate => $billingdate,
2171
        closedate => $closedate,
2172
        shipmentcost => $shipmentcost,
2173
        shipmentcost_budgetid => $shipmentcost_budgetid
2174
    );
2175
2176
Modify an invoice, invoiceid is mandatory.
2177
2178
Return undef if it fails.
2179
2180
=cut
2181
2182
sub ModInvoice {
2183
    my %invoice = @_;
2184
2185
    return unless(%invoice and $invoice{invoiceid});
2186
2187
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2188
        closedate shipmentcost shipmentcost_budgetid);
2189
2190
    my @set_strs;
2191
    my @set_args;
2192
    foreach my $key (keys %invoice) {
2193
        if(0 < grep(/^$key$/, @columns)) {
2194
            push @set_strs, "$key = ?";
2195
            push @set_args, ($invoice{$key} || undef);
2196
        }
2197
    }
2198
2199
    my $dbh = C4::Context->dbh;
2200
    my $query = "UPDATE aqinvoices SET ";
2201
    $query .= join(",", @set_strs);
2202
    $query .= " WHERE invoiceid = ?";
2203
2204
    my $sth = $dbh->prepare($query);
2205
    $sth->execute(@set_args, $invoice{invoiceid});
2206
}
2207
2208
=head3 CloseInvoice
2209
2210
    CloseInvoice($invoiceid);
2211
2212
Close an invoice.
2213
2214
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2215
2216
=cut
2217
2218
sub CloseInvoice {
2219
    my ($invoiceid) = @_;
2220
2221
    return unless $invoiceid;
2222
2223
    my $dbh = C4::Context->dbh;
2224
    my $query = qq{
2225
        UPDATE aqinvoices
2226
        SET closedate = CAST(NOW() AS DATE)
2227
        WHERE invoiceid = ?
2228
    };
2229
    my $sth = $dbh->prepare($query);
2230
    $sth->execute($invoiceid);
2231
}
2232
2233
=head3 ReopenInvoice
2234
2235
    ReopenInvoice($invoiceid);
2236
2237
Reopen an invoice
2238
2239
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2240
2241
=cut
2242
2243
sub ReopenInvoice {
2244
    my ($invoiceid) = @_;
2245
2246
    return unless $invoiceid;
2247
2248
    my $dbh = C4::Context->dbh;
2249
    my $query = qq{
2250
        UPDATE aqinvoices
2251
        SET closedate = NULL
2252
        WHERE invoiceid = ?
2253
    };
2254
    my $sth = $dbh->prepare($query);
2255
    $sth->execute($invoiceid);
1909
}
2256
}
1910
2257
1911
1;
2258
1;
(-)a/C4/Budgets.pm (-2 / +22 lines)
Lines 309-317 sub GetBudgetSpent { Link Here
309
            quantityreceived > 0 AND
309
            quantityreceived > 0 AND
310
            datecancellationprinted IS NULL
310
            datecancellationprinted IS NULL
311
    |);
311
    |);
312
313
	$sth->execute($budget_id);
312
	$sth->execute($budget_id);
314
	my $sum =  $sth->fetchrow_array;
313
	my $sum =  $sth->fetchrow_array;
314
315
    $sth = $dbh->prepare(qq|
316
        SELECT SUM(shipmentcost) AS sum
317
        FROM aqinvoices
318
        WHERE shipmentcost_budgetid = ?
319
          AND closedate IS NOT NULL
320
    |);
321
    $sth->execute($budget_id);
322
    my ($shipmentcost_sum) = $sth->fetchrow_array;
323
    $sum += $shipmentcost_sum;
324
315
	return $sum;
325
	return $sum;
316
}
326
}
317
327
Lines 325-333 sub GetBudgetOrdered { Link Here
325
            quantityreceived = 0 AND
335
            quantityreceived = 0 AND
326
            datecancellationprinted IS NULL
336
            datecancellationprinted IS NULL
327
    |);
337
    |);
328
329
	$sth->execute($budget_id);
338
	$sth->execute($budget_id);
330
	my $sum =  $sth->fetchrow_array;
339
	my $sum =  $sth->fetchrow_array;
340
341
    $sth = $dbh->prepare(qq|
342
        SELECT SUM(shipmentcost) AS sum
343
        FROM aqinvoices
344
        WHERE shipmentcost_budgetid = ?
345
          AND closedate IS NULL
346
    |);
347
    $sth->execute($budget_id);
348
    my ($shipmentcost_sum) = $sth->fetchrow_array;
349
    $sum += $shipmentcost_sum;
350
331
	return $sum;
351
	return $sum;
332
}
352
}
333
353
(-)a/acqui/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 101-112 if ($quantityrec > $origquantityrec ) { Link Here
101
    }
101
    }
102
102
103
    # save the quantity received.
103
    # save the quantity received.
104
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived, \@received_items);
104
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoice->{invoiceid},$replacement,undef,$datereceived, \@received_items);
105
}
105
}
106
106
107
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
107
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
108
108
109
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&booksellerid=$booksellerid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
109
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
110
110
111
################################ End of script ################################
111
################################ End of script ################################
112
112
(-)a/acqui/invoice.pl (+211 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
invoice.pl
22
23
=head1 DESCRIPTION
24
25
Invoice details
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
use C4::Acquisition;
36
use C4::Bookseller qw/GetBookSellerFromId/;
37
use C4::Budgets;
38
39
my $input = new CGI;
40
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
41
    template_name   => 'acqui/invoice.tmpl',
42
    query           => $input,
43
    type            => 'intranet',
44
    authnotrequired => 0,
45
    flagsrequired   => { 'acquisition' => '*' },
46
    debug           => 1,
47
} );
48
49
my $invoiceid = $input->param('invoiceid');
50
my $op = $input->param('op');
51
52
if($op && $op eq 'close') {
53
    CloseInvoice($invoiceid);
54
    my $referer = $input->param('referer');
55
    if($referer) {
56
        print $input->redirect($referer);
57
        exit 0;
58
    }
59
}elsif($op && $op eq 'reopen') {
60
    ReopenInvoice($invoiceid);
61
    my $referer = $input->param('referer');
62
    if($referer) {
63
        print $input->redirect($referer);
64
        exit 0;
65
    }
66
}elsif($op && $op eq 'mod') {
67
    my $shipmentdate = $input->param('shipmentdate');
68
    my $billingdate = $input->param('billingdate');
69
    my $shipmentcost = $input->param('shipmentcost');
70
    my $shipment_budget_id = $input->param('shipment_budget_id');
71
    ModInvoice(
72
        invoiceid => $invoiceid,
73
        shipmentdate   => C4::Dates->new($shipmentdate)->output("iso"),
74
        billingdate   => C4::Dates->new($billingdate)->output("iso"),
75
        shipmentcost  => $shipmentcost,
76
        shipmentcost_budgetid => $shipment_budget_id
77
    );
78
    $template->param(modified => 1);
79
}
80
81
my $details = GetInvoiceDetails($invoiceid);
82
my $bookseller = GetBookSellerFromId($details->{booksellerid});
83
my @orders_loop = ();
84
my $orders = $details->{'orders'};
85
my $qty_total;
86
my @books_loop;
87
my @book_foot_loop;
88
my %foot;
89
my $total_quantity = 0;
90
my $total_rrp = 0;
91
my $total_est = 0;
92
foreach my $order (@$orders) {
93
    my $line = get_infos( $order, $bookseller);
94
95
    $total_quantity += $$line{quantity};
96
    $total_rrp += $order->{quantity} * $order->{rrp};
97
    $total_est += $order->{quantity} * $order->{'ecost'};
98
99
    my %row = (%$order, %$line);
100
    push @orders_loop, \%row;
101
}
102
103
my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
104
my $discount = $bookseller->{'discount'} ? ($bookseller->{discount} / 100) : 0;
105
my $total_est_gste;
106
my $total_est_gsti;
107
my $total_rrp_gsti; # RRP Total, GST included
108
my $total_rrp_gste; # RRP Total, GST excluded
109
my $gist_est;
110
my $gist_rrp;
111
if ($gist){
112
    # if we have GST
113
    if ( $bookseller->{'listincgst'} ) {
114
        # if prices already includes GST
115
116
        # we know $total_rrp_gsti
117
        $total_rrp_gsti = $total_rrp;
118
        # and can reverse compute other values
119
        $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 );
120
121
        $gist_rrp       = $total_rrp_gsti - $total_rrp_gste;
122
        $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount );
123
        $total_est_gsti = $total_est;
124
    } else {
125
        # if prices does not include GST
126
127
        # then we use the common way to compute other values
128
        $total_rrp_gste = $total_rrp;
129
        $gist_rrp       = $total_rrp_gste * $gist;
130
        $total_rrp_gsti = $total_rrp_gste + $gist_rrp;
131
        $total_est_gste = $total_est;
132
        $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount );
133
   }
134
   $gist_est = $gist_rrp - ( $gist_rrp * $discount );
135
} else {
136
    $total_rrp_gsti = $total_rrp;
137
    $total_est_gsti = $total_est;
138
}
139
my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost};
140
141
my $format = "%.2f";
142
$template->param(
143
    total_rrp_gste => sprintf($format, $total_rrp_gste),
144
    total_rrp_gsti => sprintf($format, $total_rrp_gsti),
145
    total_est_gste => sprintf($format, $total_est_gste),
146
    total_est_gsti => sprintf($format, $total_est_gsti),
147
    gist_rrp => sprintf($format, $gist_rrp),
148
    gist_est => sprintf($format, $gist_est),
149
    total_gsti_shipment => sprintf($format, $total_gsti_shipment),
150
    gist => sprintf($format, $gist * 100),
151
);
152
153
my $budgets = GetBudgets();
154
my @budgets_loop;
155
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
156
foreach (@$budgets) {
157
    my %line = %{ $_ };
158
    if($shipmentcost_budgetid and $_->{'budget_id'} == $shipmentcost_budgetid) {
159
        $line{'selected'} = 1;
160
    }
161
    push @budgets_loop, \%line;
162
}
163
164
$template->param(
165
    invoiceid        => $details->{'invoiceid'},
166
    invoicenumber    => $details->{'invoicenumber'},
167
    suppliername     => $details->{'suppliername'},
168
    supplierid       => $details->{'booksellerid'},
169
    datereceived     => $details->{'datereceived'},
170
    shipmentdate     => $details->{'shipmentdate'},
171
    billingdate      => $details->{'billingdate'},
172
    invoiceclosedate => $details->{'closedate'},
173
    shipmentcost     => sprintf($format, $details->{'shipmentcost'} || 0),
174
    orders_loop      => \@orders_loop,
175
    total_quantity   => $total_quantity,
176
    invoiceincgst    => $bookseller->{invoiceincgst},
177
    currency         => $bookseller->{listprice},
178
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
179
    budgets_loop     => \@budgets_loop,
180
);
181
182
sub get_infos {
183
    my $order = shift;
184
    my $bookseller = shift;
185
    my $qty = $order->{'quantity'} || 0;
186
    if ( !defined $order->{quantityreceived} ) {
187
        $order->{quantityreceived} = 0;
188
    }
189
    my $budget = GetBudget( $order->{'budget_id'} );
190
191
    my %line = %{ $order };
192
    $line{order_received} = ( $qty == $order->{'quantityreceived'} );
193
    $line{budget_name}    = $budget->{budget_name};
194
    $line{total} = $qty * $order->{ecost};
195
196
    if ( $line{uncertainprice} ) {
197
        $line{rrp} .= ' (Uncertain)';
198
    }
199
    if ( $line{'title'} ) {
200
        my $volume      = $order->{'volume'};
201
        my $seriestitle = $order->{'seriestitle'};
202
        $line{'title'} .= " / $seriestitle" if $seriestitle;
203
        $line{'title'} .= " / $volume"      if $volume;
204
    } else {
205
        $line{'title'} = "Deleted bibliographic notice, can't find title.";
206
    }
207
208
    return \%line;
209
}
210
211
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/invoices.pl (+150 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
invoices.pl
22
23
=head1 DESCRIPTION
24
25
Search for invoices
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
36
use C4::Acquisition;
37
use C4::Bookseller qw/GetBookSeller/;
38
use C4::Branch;
39
40
my $input = new CGI;
41
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
42
    template_name   => 'acqui/invoices.tmpl',
43
    query           => $input,
44
    type            => 'intranet',
45
    authnotrequired => 0,
46
    flagsrequired   => { 'acquisition' => '*' },
47
    debug           => 1,
48
} );
49
50
my $invoicenumber   = $input->param('invoicenumber');
51
my $supplier        = $input->param('supplier');
52
my $billingdatefrom = $input->param('billingdatefrom');
53
my $billingdateto   = $input->param('billingdateto');
54
my $isbneanissn     = $input->param('isbneanissn');
55
my $title           = $input->param('title');
56
my $author          = $input->param('author');
57
my $publisher       = $input->param('publisher');
58
my $publicationyear = $input->param('publicationyear');
59
my $branch          = $input->param('branch');
60
my $op              = $input->param('op');
61
62
my @results_loop = ();
63
if($op and $op eq "do_search") {
64
    my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso");
65
    my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso");
66
    my @invoices = GetInvoices(
67
        invoicenumber => $invoicenumber,
68
        suppliername => $supplier,
69
        billingdatefrom => $billingdatefrom_iso,
70
        billingdateto => $billingdateto_iso,
71
        isbneanissn => $isbneanissn,
72
        title => $title,
73
        author => $author,
74
        publisher => $publisher,
75
        publicationyear => $publicationyear,
76
        branchcode => $branch
77
    );
78
    foreach (@invoices) {
79
        my %row = (
80
            invoiceid       => $_->{invoiceid},
81
            billingdate     => $_->{billingdate},
82
            invoicenumber   => $_->{invoicenumber},
83
            suppliername    => $_->{suppliername},
84
            receivedbiblios => $_->{receivedbiblios},
85
            receiveditems   => $_->{receiveditems},
86
            subscriptionid  => $_->{subscriptionid},
87
            closedate => $_->{closedate},
88
        );
89
        push @results_loop, \%row;
90
    }
91
}
92
93
94
# Build suppliers list
95
my @suppliers = GetBookSeller(undef);
96
my @suppliers_loop = ();
97
my $suppliername;
98
foreach (@suppliers) {
99
    my $selected = 0;
100
    if ($supplier && $supplier == $_->{'id'}) {
101
        $selected = 1;
102
        $suppliername = $_->{'name'};
103
    }
104
    my %row = (
105
        suppliername => $_->{'name'},
106
        supplierid   => $_->{'id'},
107
        selected     => $selected,
108
    );
109
    push @suppliers_loop, \%row;
110
}
111
112
# Build branches list
113
my $branches = GetBranches();
114
my @branches_loop = ();
115
my $branchname;
116
foreach (sort keys %$branches) {
117
    my $selected = 0;
118
    if ($branch && $branch eq $_) {
119
        $selected = 1;
120
        $branchname = $branches->{$_}->{'branchname'};
121
    }
122
    my %row = (
123
        branchcode => $_,
124
        branchname => $branches->{$_}->{'branchname'},
125
        selected   => $selected,
126
    );
127
    push @branches_loop, \%row;
128
}
129
130
$template->param(
131
    do_search       => ($op and $op eq "do_search") ? 1 : 0,
132
    results_loop    => \@results_loop,
133
    invoicenumber   => $invoicenumber,
134
    supplier        => $supplier,
135
    suppliername    => $suppliername,
136
    billingdatefrom => $billingdatefrom,
137
    billingdateto   => $billingdateto,
138
    isbneanissn     => $isbneanissn,
139
    title           => $title,
140
    author          => $author,
141
    publisher       => $publisher,
142
    publicationyear => $publicationyear,
143
    branch          => $branch,
144
    branchname      => $branchname,
145
    suppliers_loop  => \@suppliers_loop,
146
    branches_loop   => \@branches_loop,
147
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
148
);
149
150
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/orderreceive.pl (-12 / +13 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 82-100 use C4::Suggestions; Link Here
82
my $input      = new CGI;
82
my $input      = new CGI;
83
83
84
my $dbh          = C4::Context->dbh;
84
my $dbh          = C4::Context->dbh;
85
my $booksellerid = $input->param('booksellerid');
85
my $invoiceid    = $input->param('invoiceid');
86
my $invoice      = GetInvoice($invoiceid);
87
my $booksellerid   = $invoice->{booksellerid};
88
my $freight      = $invoice->{shipmentcost};
89
my $datereceived = $invoice->{shipmentdate};
86
my $ordernumber  = $input->param('ordernumber');
90
my $ordernumber  = $input->param('ordernumber');
87
my $search       = $input->param('receive');
91
my $search       = $input->param('receive');
88
my $invoice      = $input->param('invoice');
89
my $freight      = $input->param('freight');
90
my $datereceived = $input->param('datereceived');
91
92
92
93
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
93
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
94
94
95
my $bookseller = GetBookSellerFromId($booksellerid);
95
my $bookseller = GetBookSellerFromId($booksellerid);
96
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
96
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
97
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
98
my $results = SearchOrder($ordernumber,$search);
97
my $results = SearchOrder($ordernumber,$search);
99
98
100
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
99
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 195-201 if ( $count == 1 ) { Link Here
195
        unitprice             => sprintf( "%.2f",$order->{'unitprice'}),
194
        unitprice             => sprintf( "%.2f",$order->{'unitprice'}),
196
        memberfirstname       => $member->{firstname} || "",
195
        memberfirstname       => $member->{firstname} || "",
197
        membersurname         => $member->{surname} || "",
196
        membersurname         => $member->{surname} || "",
198
        invoice               => $invoice,
197
        invoiceid             => $invoice->{invoiceid},
198
        invoice               => $invoice->{invoicenumber},
199
        datereceived          => $datereceived->output(),
199
        datereceived          => $datereceived->output(),
200
        datereceived_iso      => $datereceived->output('iso'),
200
        datereceived_iso      => $datereceived->output('iso'),
201
        notes                 => $order->{notes},
201
        notes                 => $order->{notes},
Lines 209-215 else { Link Here
209
    for ( my $i = 0 ; $i < $count ; $i++ ) {
209
    for ( my $i = 0 ; $i < $count ; $i++ ) {
210
        my %line = %{ @$results[$i] };
210
        my %line = %{ @$results[$i] };
211
211
212
        $line{invoice}      = $invoice;
212
        $line{invoice}      = $invoice->{invoicenumber};
213
        $line{datereceived} = $datereceived->output();
213
        $line{datereceived} = $datereceived->output();
214
        $line{freight}      = $freight;
214
        $line{freight}      = $freight;
215
        $line{gst}          = $gst;
215
        $line{gst}          = $gst;
Lines 221-227 else { Link Here
221
221
222
    $template->param(
222
    $template->param(
223
        loop         => \@loop,
223
        loop         => \@loop,
224
        booksellerid   => $booksellerid,
224
        booksellerid => $booksellerid,
225
        invoiceid    => $invoice->{invoiceid},
225
    );
226
    );
226
}
227
}
227
my $op = $input->param('op');
228
my $op = $input->param('op');
(-)a/acqui/parcel.pl (-136 / +123 lines)
Lines 42-49 To know the supplier this script has to show orders. Link Here
42
42
43
is the bookseller invoice number.
43
is the bookseller invoice number.
44
44
45
=item freight
46
47
45
48
=item gst
46
=item gst
49
47
Lines 57-63 To filter the results list on this given date. Link Here
57
=cut
55
=cut
58
56
59
use strict;
57
use strict;
60
#use warnings; FIXME - Bug 2505
58
use warnings;
59
61
use C4::Auth;
60
use C4::Auth;
62
use C4::Acquisition;
61
use C4::Acquisition;
63
use C4::Budgets;
62
use C4::Budgets;
Lines 71-86 use C4::Suggestions; Link Here
71
use JSON;
70
use JSON;
72
71
73
my $input=new CGI;
72
my $input=new CGI;
74
my $booksellerid=$input->param('booksellerid');
73
75
my $bookseller=GetBookSellerFromId($booksellerid);
74
my $invoiceid = $input->param('invoiceid');
76
75
my $invoice = GetInvoiceDetails($invoiceid);
77
my $invoice=$input->param('invoice') || '';
76
my $booksellerid = $invoice->{booksellerid};
78
my $freight=$input->param('freight');
77
my $bookseller = GetBookSellerFromId($booksellerid);
79
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
78
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
80
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
79
my $datereceived = C4::Dates->new();
81
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
82
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
83
$datereceived = C4::Dates->new() unless $datereceived;
84
my $code            = $input->param('code');
80
my $code            = $input->param('code');
85
my @rcv_err         = $input->param('error');
81
my @rcv_err         = $input->param('error');
86
my @rcv_err_barcode = $input->param('error_bc');
82
my @rcv_err_barcode = $input->param('error_bc');
Lines 90-105 my $resultsperpage = $input->param('resultsperpage'); Link Here
90
$resultsperpage = 20 unless ($resultsperpage);
86
$resultsperpage = 20 unless ($resultsperpage);
91
$startfrom=0 unless ($startfrom);
87
$startfrom=0 unless ($startfrom);
92
88
93
if($input->param('format') eq "json"){
89
my $format = $input->param('format') || '';
90
if($format eq "json"){
94
    my ($template, $loggedinuser, $cookie)
91
    my ($template, $loggedinuser, $cookie)
95
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
92
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
96
                 query => $input,
93
                 query => $input,
97
				 type => "intranet",
94
                 type => "intranet",
98
                 authnotrequired => 0,
95
                 authnotrequired => 0,
99
                 flagsrequired => {acquisition => 'order_receive'},
96
                 flagsrequired => {acquisition => 'order_receive'},
100
                 debug => 1,
97
                 debug => 1,
101
    });
98
    });
102
       
99
103
    my @datas;
100
    my @datas;
104
    my $search   = $input->param('search')     || '';
101
    my $search   = $input->param('search')     || '';
105
    my $ean      = $input->param('ean')        || '';
102
    my $ean      = $input->param('ean')        || '';
Lines 111-117 if($input->param('format') eq "json"){ Link Here
111
    foreach my $order (@$orders) {
108
    foreach my $order (@$orders) {
112
        if ( $order->{quantityreceived} < $order->{quantity} ) {
109
        if ( $order->{quantityreceived} < $order->{quantity} ) {
113
            my $data = {};
110
            my $data = {};
114
            
111
115
            $data->{basketno} = $order->{basketno};
112
            $data->{basketno} = $order->{basketno};
116
            $data->{ordernumber} = $order->{ordernumber};
113
            $data->{ordernumber} = $order->{ordernumber};
117
            $data->{title} = $order->{title};
114
            $data->{title} = $order->{title};
Lines 119-132 if($input->param('format') eq "json"){ Link Here
119
            $data->{isbn} = $order->{isbn};
116
            $data->{isbn} = $order->{isbn};
120
            $data->{booksellerid} = $order->{booksellerid};
117
            $data->{booksellerid} = $order->{booksellerid};
121
            $data->{biblionumber} = $order->{biblionumber};
118
            $data->{biblionumber} = $order->{biblionumber};
122
            $data->{freight} = $order->{freight};
123
            $data->{quantity} = $order->{quantity};
119
            $data->{quantity} = $order->{quantity};
124
            $data->{ecost} = $order->{ecost};
120
            $data->{ecost} = $order->{ecost};
125
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
121
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
126
            push @datas, $data;
122
            push @datas, $data;
127
        }
123
        }
128
    }
124
    }
129
    
125
130
    my $json_text = to_json(\@datas);
126
    my $json_text = to_json(\@datas);
131
    $template->param(return => $json_text);
127
    $template->param(return => $json_text);
132
    output_html_with_http_headers $input, $cookie, $template->output;
128
    output_html_with_http_headers $input, $cookie, $template->output;
Lines 136-142 if($input->param('format') eq "json"){ Link Here
136
my ($template, $loggedinuser, $cookie)
132
my ($template, $loggedinuser, $cookie)
137
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
133
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
138
                 query => $input,
134
                 query => $input,
139
				 type => "intranet",
135
                 type => "intranet",
140
                 authnotrequired => 0,
136
                 authnotrequired => 0,
141
                 flagsrequired => {acquisition => 'order_receive'},
137
                 flagsrequired => {acquisition => 'order_receive'},
142
                 debug => 1,
138
                 debug => 1,
Lines 156-165 if( scalar(@rcv_err) ) { Link Here
156
}
152
}
157
153
158
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
154
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
159
my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso'));
155
my @parcelitems   = @{ $invoice->{orders} };
160
my $countlines    = scalar @parcelitems;
156
my $countlines    = scalar @parcelitems;
161
my $totalprice    = 0;
157
my $totalprice    = 0;
162
my $totalfreight  = 0;
163
my $totalquantity = 0;
158
my $totalquantity = 0;
164
my $total;
159
my $total;
165
my $tototal;
160
my $tototal;
Lines 167-181 my @loop_received = (); Link Here
167
162
168
for (my $i = 0 ; $i < $countlines ; $i++) {
163
for (my $i = 0 ; $i < $countlines ; $i++) {
169
164
170
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
165
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};
171
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
172
    $parcelitems[$i]->{'unitprice'} += 0;
166
    $parcelitems[$i]->{'unitprice'} += 0;
173
    my %line;
167
    my %line;
174
    %line          = %{ $parcelitems[$i] };
168
    %line          = %{ $parcelitems[$i] };
175
    $line{invoice} = $invoice;
169
    $line{invoice} = $invoice->{invoicenumber};
176
    $line{gst}     = $gst;
170
    $line{gst}     = $gst;
177
    $line{total} = sprintf($cfstr, $total);
171
    $line{total} = sprintf($cfstr, $total);
178
    $line{booksellerid} = $booksellerid;
172
    $line{booksellerid} = $invoice->{booksellerid};
179
    push @loop_received, \%line;
173
    push @loop_received, \%line;
180
    $totalprice += $parcelitems[$i]->{'unitprice'};
174
    $totalprice += $parcelitems[$i]->{'unitprice'};
181
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
175
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
Lines 185-329 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
185
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
179
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
186
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
180
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
187
181
188
    #double FIXME - totalfreight is redefined later.
189
190
# 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..
191
    if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
192
        warn "FREIGHT CHARGE MISMATCH!!";
193
    }
194
    $totalfreight = $parcelitems[$i]->{'freight'};
195
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
182
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
196
    $tototal       += $total;
183
    $tototal       += $total;
197
}
184
}
198
185
199
my $pendingorders = GetPendingOrders($booksellerid);
186
if(!defined $invoice->{closedate}) {
200
my $countpendings = scalar @$pendingorders;
187
    my $pendingorders = GetPendingOrders($booksellerid);
201
188
    my $countpendings = scalar @$pendingorders;
202
# pending orders totals
189
203
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
190
    # pending orders totals
204
my $ordergrandtotal;
191
    my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
205
my @loop_orders = ();
192
    my $ordergrandtotal;
206
for (my $i = 0 ; $i < $countpendings ; $i++) {
193
    my @loop_orders = ();
207
    my %line;
194
    for (my $i = 0 ; $i < $countpendings ; $i++) {
208
    %line = %{$pendingorders->[$i]};
195
        my %line;
209
   
196
        %line = %{$pendingorders->[$i]};
210
    $line{quantity}+=0;
197
211
    $line{quantityreceived}+=0;
198
        $line{quantity}+=0;
212
    $line{unitprice}+=0;
199
        $line{quantityreceived}+=0;
213
    $totalPunitprice += $line{unitprice};
200
        $line{unitprice}+=0;
214
    $totalPquantity +=$line{quantity};
201
        $totalPunitprice += $line{unitprice};
215
    $totalPqtyrcvd +=$line{quantityreceived};
202
        $totalPquantity +=$line{quantity};
216
    $totalPecost += $line{ecost};
203
        $totalPqtyrcvd +=$line{quantityreceived};
217
    $line{ecost} = sprintf("%.2f",$line{ecost});
204
        $totalPecost += $line{ecost};
218
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
205
        $line{ecost} = sprintf("%.2f",$line{ecost});
219
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
206
        $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
220
    $line{invoice} = $invoice;
207
        $line{unitprice} = sprintf("%.2f",$line{unitprice});
221
    $line{gst} = $gst;
208
        $line{invoice} = $invoice;
222
    $line{total} = $total;
209
        $line{gst} = $gst;
223
    $line{booksellerid} = $booksellerid;
210
        $line{total} = $total;
224
    $ordergrandtotal += $line{ecost} * $line{quantity};
211
        $line{booksellerid} = $booksellerid;
225
    
212
        $ordergrandtotal += $line{ecost} * $line{quantity};
226
    my $biblionumber = $line{'biblionumber'};
213
227
    my $countbiblio = CountBiblioInOrders($biblionumber);
214
        my $biblionumber = $line{'biblionumber'};
228
    my $ordernumber = $line{'ordernumber'};
215
        my $countbiblio = CountBiblioInOrders($biblionumber);
229
    my @subscriptions = GetSubscriptionsId ($biblionumber);
216
        my $ordernumber = $line{'ordernumber'};
230
    my $itemcount = GetItemsCount($biblionumber);
217
        my @subscriptions = GetSubscriptionsId ($biblionumber);
231
    my $holds  = GetHolds ($biblionumber);
218
        my $itemcount = GetItemsCount($biblionumber);
232
    my @items = GetItemnumbersFromOrder( $ordernumber );
219
        my $holds  = GetHolds ($biblionumber);
233
    my $itemholds;
220
        my @items = GetItemnumbersFromOrder( $ordernumber );
234
    foreach my $item (@items){
221
        my $itemholds;
235
        my $nb = GetItemHolds($biblionumber, $item);
222
        foreach my $item (@items){
236
        if ($nb){
223
            my $nb = GetItemHolds($biblionumber, $item);
237
            $itemholds += $nb;
224
            if ($nb){
225
                $itemholds += $nb;
226
            }
238
        }
227
        }
239
    }
240
228
241
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
229
        my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
242
    $line{suggestionid}         = $suggestion->{suggestionid};
230
        $line{suggestionid}         = $suggestion->{suggestionid};
243
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
231
        $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
244
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
232
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
233
234
        # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
235
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
236
        $line{items}                = ($itemcount) - (scalar @items);
237
        $line{left_item}            = 1 if $line{items} >= 1;
238
        $line{left_biblio}          = 1 if $countbiblio > 1;
239
        $line{biblios}              = $countbiblio - 1;
240
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
241
        $line{subscriptions}        = scalar @subscriptions;
242
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
243
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
244
        $line{holds}                = $holds;
245
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
246
        
247
        
248
        push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
249
    }
245
250
246
    # 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
251
    my $count = $countpendings;
247
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
248
    $line{items}                = ($itemcount) - (scalar @items);
249
    $line{left_item}            = 1 if $line{items} >= 1;
250
    $line{left_biblio}          = 1 if $countbiblio > 1;
251
    $line{biblios}              = $countbiblio - 1;
252
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
253
    $line{subscriptions}        = scalar @subscriptions;
254
    $line{left_holds}           = 1 if $holds >= 1;
255
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
256
    $line{holds}                = $holds;
257
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
258
    
259
    
260
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
261
}
262
$freight = $totalfreight unless $freight;
263
252
264
my $count = $countpendings;
253
    if ($count>$resultsperpage){
254
        my $displaynext=0;
255
        my $displayprev=$startfrom;
256
        if(($count - ($startfrom+$resultsperpage)) > 0 ) {
257
            $displaynext = 1;
258
        }
265
259
266
if ($count>$resultsperpage){
260
        my @numbers = ();
267
    my $displaynext=0;
261
        for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
268
    my $displayprev=$startfrom;
262
                my $highlight=0;
269
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
263
                ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
270
        $displaynext = 1;
264
                push @numbers, { number => $i,
271
    }
265
                    highlight => $highlight ,
266
                    startfrom => ($i-1)*$resultsperpage};
267
        }
272
268
273
    my @numbers = ();
269
        my $from = $startfrom*$resultsperpage+1;
274
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
270
        my $to;
275
            my $highlight=0;
271
        if($count < (($startfrom+1)*$resultsperpage)){
276
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
272
            $to = $count;
277
            push @numbers, { number => $i,
273
        } else {
278
                highlight => $highlight ,
274
            $to = (($startfrom+1)*$resultsperpage);
279
                startfrom => ($i-1)*$resultsperpage};
275
        }
276
        $template->param(numbers=>\@numbers,
277
                         displaynext=>$displaynext,
278
                         displayprev=>$displayprev,
279
                         nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
280
                         prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
281
                        );
280
    }
282
    }
281
283
282
    my $from = $startfrom*$resultsperpage+1;
284
    $template->param(
283
    my $to;
285
        countpending => $countpendings,
284
    if($count < (($startfrom+1)*$resultsperpage)){
286
        loop_orders  => \@loop_orders,
285
        $to = $count;
287
        ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
286
    } else {
288
        totalPunitprice => sprintf("%.2f", $totalPunitprice),
287
        $to = (($startfrom+1)*$resultsperpage);
289
        totalPquantity  => $totalPquantity,
288
    }
290
        totalPqtyrcvd   => $totalPqtyrcvd,
289
    $template->param(numbers=>\@numbers,
291
        totalPecost     => sprintf("%.2f", $totalPecost),
290
                     displaynext=>$displaynext,
292
    );
291
                     displayprev=>$displayprev,
292
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
293
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
294
                    );
295
}
293
}
296
294
297
#$totalfreight=$freight;
298
$tototal = $tototal + $freight;
299
295
300
$template->param(
296
$template->param(
301
    invoice               => $invoice,
297
    invoiceid             => $invoice->{invoiceid},
298
    invoice               => $invoice->{invoicenumber},
299
    invoiceclosedate      => $invoice->{closedate},
302
    datereceived          => $datereceived->output('iso'),
300
    datereceived          => $datereceived->output('iso'),
303
    invoicedatereceived   => $datereceived->output('iso'),
301
    invoicedatereceived   => $datereceived->output('iso'),
304
    formatteddatereceived => $datereceived->output(),
302
    formatteddatereceived => $datereceived->output(),
305
    name                  => $bookseller->{'name'},
303
    name                  => $bookseller->{'name'},
306
    booksellerid            => $booksellerid,
304
    booksellerid          => $bookseller->{id},
307
    gst                   => $gst,
305
    gst                   => $gst,
308
    freight               => $freight,
309
    invoice               => $invoice,
310
    countreceived         => $countlines,
306
    countreceived         => $countlines,
311
    loop_received         => \@loop_received,
307
    loop_received         => \@loop_received,
312
    countpending          => $countpendings,
313
    loop_orders           => \@loop_orders,
314
    totalprice            => sprintf($cfstr, $totalprice),
308
    totalprice            => sprintf($cfstr, $totalprice),
315
    totalfreight          => $totalfreight,
316
    totalquantity         => $totalquantity,
309
    totalquantity         => $totalquantity,
317
    tototal               => sprintf($cfstr, $tototal),
310
    tototal               => sprintf($cfstr, $tototal),
318
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
319
    gst                   => $gst,
311
    gst                   => $gst,
320
    grandtot              => sprintf($cfstr, $tototal + $gst),
312
    grandtot              => sprintf($cfstr, $tototal + $gst),
321
    totalPunitprice       => sprintf("%.2f", $totalPunitprice),
322
    totalPquantity        => $totalPquantity,
323
    totalPqtyrcvd         => $totalPqtyrcvd,
324
    totalPecost           => sprintf("%.2f", $totalPecost),
325
    resultsperpage        => $resultsperpage,
313
    resultsperpage        => $resultsperpage,
326
    (uc(C4::Context->preference("marcflavour"))) => 1
314
    (uc(C4::Context->preference("marcflavour"))) => 1
327
);
315
);
328
output_html_with_http_headers $input, $cookie, $template->output;
316
output_html_with_http_headers $input, $cookie, $template->output;
329
 
(-)a/acqui/parcels.pl (-12 / +40 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 84-89 my $code = $input->param('filter'); Link Here
84
my $datefrom       = $input->param('datefrom');
84
my $datefrom       = $input->param('datefrom');
85
my $dateto         = $input->param('dateto');
85
my $dateto         = $input->param('dateto');
86
my $resultsperpage = $input->param('resultsperpage');
86
my $resultsperpage = $input->param('resultsperpage');
87
my $op             = $input->param('op');
87
$resultsperpage ||= 20;
88
$resultsperpage ||= 20;
88
89
89
our ( $template, $loggedinuser, $cookie ) = get_template_and_user(
90
our ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 96-103 our ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
96
    }
97
    }
97
);
98
);
98
99
100
if($op and $op eq 'new') {
101
    my $invoicenumber = $input->param('invoice');
102
    my $shipmentdate = $input->param('shipmentdate');
103
    if($shipmentdate) {
104
        $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
105
    }
106
    my $invoiceid = AddInvoice(
107
        invoicenumber => $invoicenumber,
108
        booksellerid => $booksellerid,
109
        shipmentdate => $shipmentdate,
110
    );
111
    if(defined $invoiceid) {
112
        # Successful 'Add'
113
        print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
114
        exit 0;
115
    } else {
116
        $template->param(error_failed_to_create_invoice => 1);
117
    }
118
}
119
99
my $bookseller = GetBookSellerFromId($booksellerid);
120
my $bookseller = GetBookSellerFromId($booksellerid);
100
my @parcels = GetParcels( $booksellerid, $order, $code, $datefrom, $dateto );
121
my @parcels = GetInvoices(
122
    supplierid => $booksellerid,
123
    invoicenumber => $code,
124
    shipmentdatefrom => $datefrom,
125
    shipmentdateto => $dateto,
126
    order_by => $order
127
);
101
my $count_parcels = @parcels;
128
my $count_parcels = @parcels;
102
129
103
# multi page display gestion
130
# multi page display gestion
Lines 114-127 for my $i ( $startfrom .. $last_row) { Link Here
114
141
115
    push @{$loopres},
142
    push @{$loopres},
116
      { number           => $i + 1,
143
      { number           => $i + 1,
117
        code             => $p->{booksellerinvoicenumber},
144
        invoiceid        => $p->{invoiceid},
118
        nullcode         => $p->{booksellerinvoicenumber} eq 'NULL',
145
        code             => $p->{invoicenumber},
119
        emptycode        => $p->{booksellerinvoicenumber} eq q{},
146
        nullcode         => $p->{invoicenumber} eq 'NULL',
120
        raw_datereceived => $p->{datereceived},
147
        emptycode        => $p->{invoicenumber} eq q{},
121
        datereceived     => format_date( $p->{datereceived} ),
148
        raw_datereceived => $p->{shipmentdate},
122
        bibcount         => $p->{biblio},
149
        datereceived     => format_date( $p->{shipmentdate} ),
123
        reccount         => $p->{itemsreceived},
150
        bibcount         => $p->{receivedbiblios} || 0,
124
        itemcount        => $p->{itemsexpected},
151
        reccount         => $p->{receiveditems} || 0,
152
        itemcount        => $p->{itemsexpected} || 0,
125
      };
153
      };
126
}
154
}
127
if ($count_parcels) {
155
if ($count_parcels) {
Lines 135-141 $template->param( Link Here
135
    resultsperpage           => $resultsperpage,
163
    resultsperpage           => $resultsperpage,
136
    name                     => $bookseller->{'name'},
164
    name                     => $bookseller->{'name'},
137
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
165
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
138
    datereceived_today       => C4::Dates->new()->output(),
166
    shipmentdate_today       => C4::Dates->new()->output(),
139
    booksellerid             => $booksellerid,
167
    booksellerid             => $booksellerid,
140
    GST                      => C4::Context->preference('gist'),
168
    GST                      => C4::Context->preference('gist'),
141
);
169
);
(-)a/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 143-159 foreach my $item (@items){ Link Here
143
    }
143
    }
144
144
145
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
145
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
146
    my $basket = GetBasket( $order->{'basketno'} );
147
    $item->{'booksellerid'}            = $basket->{'booksellerid'};
148
    $item->{'ordernumber'}             = $order->{'ordernumber'};
146
    $item->{'ordernumber'}             = $order->{'ordernumber'};
149
    $item->{'basketno'}                = $order->{'basketno'};
147
    $item->{'basketno'}                = $order->{'basketno'};
150
    $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
151
    $item->{'orderdate'}               = $order->{'entrydate'};
148
    $item->{'orderdate'}               = $order->{'entrydate'};
152
    if ($item->{'basketno'}){
149
    if ($item->{'basketno'}){
153
	    my $basket = GetBasket($item->{'basketno'});
150
	    my $basket = GetBasket($item->{'basketno'});
154
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
151
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
155
	    $item->{'vendor'} = $bookseller->{'name'};
152
	    $item->{'vendor'} = $bookseller->{'name'};
156
    }
153
    }
154
    $item->{'invoiceid'}               = $order->{'invoiceid'};
155
    if($item->{invoiceid}) {
156
        my $invoice = GetInvoice($item->{invoiceid});
157
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
158
    }
157
    $item->{'datereceived'}            = $order->{'datereceived'};
159
    $item->{'datereceived'}            = $order->{'datereceived'};
158
160
159
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
161
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
(-)a/installer/data/mysql/kohastructure.sql (-2 / +24 lines)
Lines 2723-2729 CREATE TABLE `aqorders` ( Link Here
2723
  `listprice` decimal(28,6) default NULL,
2723
  `listprice` decimal(28,6) default NULL,
2724
  `totalamount` decimal(28,6) default NULL,
2724
  `totalamount` decimal(28,6) default NULL,
2725
  `datereceived` date default NULL,
2725
  `datereceived` date default NULL,
2726
  `booksellerinvoicenumber` mediumtext,
2726
  invoiceid int(11) default NULL,
2727
  `freight` decimal(28,6) default NULL,
2727
  `freight` decimal(28,6) default NULL,
2728
  `unitprice` decimal(28,6) default NULL,
2728
  `unitprice` decimal(28,6) default NULL,
2729
  `quantityreceived` smallint(6) NOT NULL default 0,
2729
  `quantityreceived` smallint(6) NOT NULL default 0,
Lines 2755-2761 CREATE TABLE `aqorders` ( Link Here
2755
  KEY `biblionumber` (`biblionumber`),
2755
  KEY `biblionumber` (`biblionumber`),
2756
  KEY `budget_id` (`budget_id`),
2756
  KEY `budget_id` (`budget_id`),
2757
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2757
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2758
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2758
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2759
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
2759
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2760
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2760
2761
2761
2762
Lines 2772-2777 CREATE TABLE `aqorders_items` ( Link Here
2772
  KEY `ordernumber` (`ordernumber`)
2773
  KEY `ordernumber` (`ordernumber`)
2773
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2774
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2774
2775
2776
2777
--
2778
-- Table structure for table aqinvoices
2779
--
2780
2781
DROP TABLE IF EXISTS aqinvoices;
2782
CREATE TABLE aqinvoices (
2783
  invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
2784
  invoicenumber mediumtext NOT NULL,    -- Name of invoice
2785
  booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
2786
  shipmentdate date default NULL,   -- date of shipment
2787
  billingdate date default NULL,    -- date of billing
2788
  closedate date default NULL,  -- invoice close date, NULL means the invoice is open
2789
  shipmentcost decimal(28,6) default NULL,  -- shipment cost
2790
  shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
2791
  PRIMARY KEY (invoiceid),
2792
  CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
2793
  CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
2794
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2795
2796
2775
--
2797
--
2776
-- Table structure for table `fieldmapping`
2798
-- Table structure for table `fieldmapping`
2777
--
2799
--
(-)a/installer/data/mysql/updatedatabase.pl (+60 lines)
Lines 5392-5397 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5392
    SetVersion ($DBversion);
5392
    SetVersion ($DBversion);
5393
}
5393
}
5394
5394
5395
$DBversion = "XXX";
5396
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5397
    $dbh->do("
5398
        CREATE TABLE aqinvoices (
5399
          invoiceid int(11) NOT NULL AUTO_INCREMENT,
5400
          invoicenumber mediumtext NOT NULL,
5401
          booksellerid int(11) NOT NULL,
5402
          shipmentdate date default NULL,
5403
          billingdate date default NULL,
5404
          closedate date default NULL,
5405
          shipmentcost decimal(28,6) default NULL,
5406
          shipmentcost_budgetid int(11) default NULL,
5407
          PRIMARY KEY (invoiceid),
5408
          CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5409
          CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5410
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5411
    ");
5412
5413
    # Fill this new table with existing invoices
5414
    my $sth = $dbh->prepare("
5415
        SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid
5416
        FROM aqorders
5417
          LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5418
        WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5419
          AND aqorders.booksellerinvoicenumber != ''
5420
        GROUP BY aqorders.booksellerinvoicenumber
5421
    ");
5422
    $sth->execute;
5423
    my $results = $sth->fetchall_arrayref({});
5424
    $sth = $dbh->prepare("
5425
        INSERT INTO aqinvoices (invoicenumber, booksellerid) VALUES (?,?)
5426
    ");
5427
    foreach(@$results) {
5428
        $sth->execute($_->{'invoicenumber'}, $_->{'booksellerid'});
5429
    }
5430
5431
    # Add the column in aqorders, fill it with correct value
5432
    # and then drop booksellerinvoicenumber column
5433
    $dbh->do("
5434
        ALTER TABLE aqorders
5435
        ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5436
        ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5437
    ");
5438
5439
    $dbh->do("
5440
        UPDATE aqorders, aqinvoices
5441
        SET aqorders.invoiceid = aqinvoices.invoiceid
5442
        WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5443
    ");
5444
5445
    $dbh->do("
5446
        ALTER TABLE aqorders
5447
        DROP COLUMN booksellerinvoicenumber
5448
    ");
5449
5450
    print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5451
    SetVersion ($DBversion);
5452
}
5453
5454
5395
=head1 FUNCTIONS
5455
=head1 FUNCTIONS
5396
5456
5397
=head2 TableExists($table)
5457
=head2 TableExists($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</a></li>
6
    <li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a></li>
6
    <li><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></li>
7
    <li><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-1 / +5 lines)
Lines 115-121 Link Here
115
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
115
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
116
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
116
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
117
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
117
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
118
					<td>[% suggestions_loo.datereceived | $KohaDates %]</td>
118
                    <td>
119
                        [% IF suggestions_loo.datereceived %]
120
                            [% suggestions_loo.datereceived | $KohaDates %]
121
                        [% END %]
122
                    </td>
119
					<td>[% suggestions_loo.quantity %]</td>
123
					<td>[% suggestions_loo.quantity %]</td>
120
					<td>[% suggestions_loo.ecost %]</td>
124
					<td>[% suggestions_loo.ecost %]</td>
121
				</tr>
125
				</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (+192 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
9
[% INCLUDE 'datatables-strings.inc' %]
10
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
11
<script type="text/javascript">
12
//<![CDATA[
13
    $(document).ready(function() {
14
        $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
15
            bInfo: false,
16
            bPaginate: false,
17
            bFilter: false,
18
        }));
19
        Calendar.setup({
20
            inputField: "shipmentdate",
21
            ifFormat: "[% DHTMLcalendar_dateformat %]",
22
            button: "shipmentdateCalendar"
23
        });
24
        Calendar.setup({
25
            inputField: "billingdate",
26
            ifFormat: "[% DHTMLcalendar_dateformat %]",
27
            button: "billingdateCalendar"
28
        });
29
    });
30
//]]>
31
</script>
32
</head>
33
34
<body>
35
[% INCLUDE 'header.inc' %]
36
[% INCLUDE 'acquisitions-search.inc' %]
37
38
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">[% invoicenumber %]</a></div>
39
40
<div id="doc3" class="yui-t2">
41
42
<div id="bd">
43
  <div id="yui-main">
44
    <div class="yui-b">
45
      [% IF ( modified ) %]
46
        <div class="dialog">
47
          <p>Invoice has been modified</p>
48
        </div>
49
      [% END %]
50
      <h1>Invoice: [% invoicenumber %]</h1>
51
52
      <p>Supplier: [% suppliername %]</p>
53
      <form action="" method="post">
54
        <label for="shipmentdate">Shipment date:</label>
55
        [% IF (shipmentdate) %]
56
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" readonly="readonly" />
57
        [% ELSE %]
58
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" readonly="readonly" />
59
        [% END %]
60
        <img id="shipmentdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
61
        <p></p>
62
        <label for="billingdate">Billing date:</label>
63
        [% IF (billingdate) %]
64
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
65
        [% ELSE %]
66
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
67
        [% END %]
68
        <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
69
        <p></p>
70
        <label for="shipmentcost">Shipment cost:</label>
71
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
72
        <label for="shipment_budget_id">Budget:</label>
73
        <select id="shipment_budget_id" name="shipment_budget_id">
74
            <option value="">No budget</option>
75
          [% FOREACH budget IN budgets_loop %]
76
            [% IF ( budget.selected ) %]
77
              <option selected="selected" value="[% budget.budget_id %]">
78
            [% ELSE %]
79
              <option value="[% budget.budget_id %]">
80
            [% END %]
81
              [% budget.budget_name %]
82
            </option>
83
          [% END %]
84
        </select>
85
        <input type="hidden" name="op" value="mod" />
86
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
87
        <fieldset class="action">
88
            <input type="submit" value="Save">
89
        </fieldset>
90
      </form>
91
      <p>Status:
92
        [% IF ( invoiceclosedate ) %]
93
          Closed on [% invoiceclosedate | $KohaDates %].
94
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
95
            Reopen
96
          </a>
97
        [% ELSE %]
98
          Open.
99
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
100
            Close
101
          </a>
102
        [% END %]
103
      </p>
104
      <p>
105
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
106
      </p>
107
      <h2>Invoice details</h2>
108
      [% IF orders_loop.size %]
109
          <table id="orderst">
110
            <thead>
111
              <tr>
112
                <th>Summary</th>
113
                <th>Publisher</th>
114
                <th>Branch</th>
115
                <th>RRP</th>
116
                <th>Est.</th>
117
                <th>Qty.</th>
118
                <th>Total</th>
119
                <th>Fund</th>
120
              </tr>
121
            </thead>
122
            <tbody>
123
              [% FOREACH order IN orders_loop %]
124
                <tr>
125
                  <td><p>[% order.title %]
126
                    [% IF ( order.author ) %]
127
                      <br /><em>by</em> [% order.author %]
128
                    [% END %]
129
                  </p></td>
130
                  <td>
131
                    [% IF ( order.publishercode ) %]
132
                      <p>[% order.publishercode %]
133
                        [% IF ( order.publicationyear ) %]
134
                          - [% order.publicationyear %]
135
                        [% END %]
136
                      </p>
137
                    [% END %]
138
                  </td>
139
                  <td><p>[% order.branchcode %]</p></td>
140
                  <td>[% order.rrp %]</td>
141
                  <td>[% order.ecost %]</td>
142
                  <td class="number">[% order.quantity %]</td>
143
                  <td>[% order.total %]</td>
144
                  <td>[% order.budget_name %]</td>
145
                </tr>
146
              [% END %]
147
            </tbody>
148
            <tfoot>
149
                <tr>
150
                    <th colspan="3">Total Tax Exc.</th>
151
                    <th>[% total_rrp_gste %]</th>
152
                    <th>&nbsp;</th>
153
                    <th>[% total_quantity %]</th>
154
                    <th>[% total_est_gste %]</th>
155
                    <th>&nbsp;</th>
156
                </tr>
157
                <tr>
158
                    <th colspan='3'>Tax ([% gist %]%)</th>
159
                    <th>[% gist_rrp %]</th>
160
                    <th>&nbsp;</th>
161
                    <th>&nbsp;</th>
162
                    <th>[% gist_est %]</th>
163
                    <th>&nbsp;</th>
164
                </tr>
165
                <tr>
166
                    <th colspan='3'>Total Tax Inc. ([% currency %])</th>
167
                    <th>[% total_rrp_gsti %]</th>
168
                    <th>&nbsp;</th>
169
                    <th>[% total_quantity %]</th>
170
                    <th>[% total_est_gsti %]</th>
171
                    <th>&nbsp;</th>
172
                </tr>
173
                <tr>
174
                    <th colspan="3">Total + Shipment cost ([% currency %])</th>
175
                    <th>&nbsp;</th>
176
                    <th>&nbsp;</th>
177
                    <th>[% total_quantity %]</th>
178
                    <th>[% total_gsti_shipment %]</th>
179
                    <th>&nbsp;</th>
180
                </tr>
181
            </tfoot>
182
          </table>
183
        [% ELSE %]
184
            <p>No orders yet</p>
185
        [% END %]
186
    </div>
187
  </div>
188
  <div class="yui-b">
189
    [% INCLUDE 'acquisitions-menu.inc' %]
190
  </div>
191
</div>
192
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+228 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoices</title>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'doc-head-close.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
8
[% INCLUDE 'datatables-strings.inc' %]
9
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
10
[% INCLUDE 'calendar.inc' %]
11
<script type="text/javascript">
12
//<![CDATA[
13
$(document).ready(function() {
14
    Calendar.setup({
15
        inputField: "billingdatefrom",
16
        ifFormat: "[% DHTMLcalendar_dateformat %]",
17
        button: "billingdatefromCalendar"
18
    });
19
    Calendar.setup({
20
        inputField: "billingdateto",
21
        ifFormat: "[% DHTMLcalendar_dateformat %]",
22
        button: "billingdatetoCalendar"
23
    });
24
    $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
25
        bInfo: false,
26
        bPaginate: false,
27
        bFilter: false,
28
        aoColumnDefs: [
29
            { "bSortable": false, "aTargets": [6] }
30
        ]
31
    }));
32
});
33
//]]>
34
</script>
35
</head>
36
37
<body>
38
[% INCLUDE 'header.inc' %]
39
[% INCLUDE 'acquisitions-search.inc' %]
40
41
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; Invoices</div>
42
43
<div id="doc3" class="yui-t2">
44
45
<div id="bd">
46
  <div id="yui-main">
47
    <div class="yui-b">
48
      <h1>Invoices</h1>
49
      [% IF ( do_search ) %]
50
        [% IF ( results_loop ) %]
51
          <table id="resultst">
52
            <thead>
53
              <tr>
54
                <th>Invoice no.</th>
55
                <th>Vendor</th>
56
                <th>Billing date</th>
57
                <th>Received biblios</th>
58
                <th>Received items</th>
59
                <th>Status</th>
60
                <th>&nbsp;</th>
61
              </tr>
62
            </thead>
63
            <tbody>
64
              [% FOREACH result IN results_loop %]
65
                <tr>
66
                  <td>[% result.invoicenumber %]</td>
67
                  <td>[% result.suppliername %]</td>
68
                  <td>
69
                    [% IF (result.billingdate) %]
70
                      [% result.billingdate | $KohaDates %]
71
                    [% END %]
72
                  </td>
73
                  <td>[% result.receivedbiblios %]</td>
74
                  <td>[% result.receiveditems %]</td>
75
                  <td>
76
                    [% IF ( result.closedate ) %]
77
                      Closed on [% result.closedate | $KohaDates %]
78
                    [% ELSE %]
79
                      Open
80
                    [% END %]
81
                  </td>
82
                  <td>
83
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
84
                    [% IF ( result.closedate ) %]
85
                      <a href="invoice.pl?op=reopen&invoiceid=[% result.invoiceid %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber %]%26supplier=[% supplier %]%26billingdatefrom=[% billingdatefrom %]%26billingdateto=[% billingdateto %]%26isbneanissn=[% isbneanissn %]%26title=[% title %]%26author=[% author %]%26publisher=[% publisher %]%26publicationyear=[% publicationyear %]%26branch=[% branch %]">Reopen</a>
86
                    [% ELSE %]
87
                      <a href="invoice.pl?op=close&invoiceid=[% result.invoiceid %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber %]%26supplier=[% supplier %]%26billingdatefrom=[% billingdatefrom %]%26billingdateto=[% billingdateto %]%26isbneanissn=[% isbneanissn %]%26title=[% title %]%26author=[% author %]%26publisher=[% publisher %]%26publicationyear=[% publicationyear %]%26branch=[% branch %]">Close</a>
88
                    [% END %]
89
                  </td>
90
                </tr>
91
              [% END %]
92
            </tbody>
93
          </table>
94
        [% ELSE %]
95
          <p>Sorry, but there is no results for your search.</p>
96
          <p>Search was:
97
            <ul>
98
              [% IF ( invoicenumber ) %]
99
                <li>Invoice no.: [% invoicenumber %]</li>
100
              [% END %]
101
              [% IF ( supplier ) %]
102
                <li>Vendor: [% suppliername %]</li>
103
              [% END %]
104
              [% IF ( billingdatefrom ) %]
105
                <li>Billing date:
106
                [% IF ( billingdateto ) %]
107
                  From [% billingdatefrom %]
108
                  To [% billingdateto %]
109
                [% ELSE %]
110
                  All since [% billingdatefrom %]
111
                [% END %]
112
                </li>
113
              [% ELSE %]
114
                [% IF ( billingdateto ) %]
115
                  <li>Billing date:
116
                    All until [% billingdateto %]
117
                  </li>
118
                [% END %]
119
              [% END %]
120
              [% IF ( isbneanissn ) %]
121
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
122
              [% END %]
123
              [% IF ( title ) %]
124
                <li>Title: [% title %]</li>
125
              [% END %]
126
              [% IF ( author ) %]
127
                <li>Author: [% author %]</li>
128
              [% END %]
129
              [% IF ( publisher ) %]
130
                <li>Publisher: [% publisher %]</li>
131
              [% END %]
132
              [% IF ( publicationyear ) %]
133
                <li>Publication year: [% publicationyear %]</li>
134
              [% END %]
135
              [% IF ( branch ) %]
136
                <li>Branch: [% branchname %]</li>
137
              [% END %]
138
            </ul>
139
          </p>
140
        [% END %]<!-- results_loop -->
141
      [% ELSE %]
142
        <p>Please fill in the form to the left to make a search.</p>
143
      [% END %]<!-- do_search -->
144
    </div>
145
  </div>
146
  <div class="yui-b">
147
    <form action="" method="get">
148
      <fieldset class="brief">
149
        <h3>Search filters</h3>
150
        <ol>
151
          <li>
152
            <label for="invoicenumber">Invoice no:</label>
153
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
154
          </li>
155
          <li>
156
            <label for="supplier">Supplier:</label>
157
            <select id="supplier" name="supplier">
158
              <option value="">All</option>
159
              [% FOREACH supplier IN suppliers_loop %]
160
                [% IF ( supplier.selected ) %]
161
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
162
                [% ELSE %]
163
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
164
                [% END %]
165
              [% END %]
166
            </select>
167
          </li>
168
          <li>
169
            <fieldset class="brief">
170
              <legend>Billing date</legend>
171
              <ol>
172
                <li>
173
                  <label for="billingdatefrom">From:</label>
174
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" />
175
                  <img id="billingdatefromCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
176
                </li>
177
                <li>
178
                  <label for="billingdateto">To:</label>
179
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" />
180
                  <img id="billingdatetoCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
181
                </li>
182
              </ol>
183
            </fieldset>
184
          </li>
185
          <li>
186
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
187
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
188
          </li>
189
          <li>
190
            <label for="title">Title:</label>
191
            <input type="text" id="title" name="title" value="[% title %]" />
192
          </li>
193
          <li>
194
            <label for="author">Author:</label>
195
            <input type="text" id="author" name="author" value="[% author %]" />
196
          </li>
197
          <li>
198
            <label for="publisher">Publisher:</label>
199
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
200
          </li>
201
          <li>
202
            <label for="publicationyear">Publication year:</label>
203
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
204
          </li>
205
          <li>
206
            <label for="branch">Branch:</label>
207
            <select id="branch" name="branch">
208
              <option value="">All</option>
209
              [% FOREACH branch IN branches_loop %]
210
                [% IF ( branch.selected ) %]
211
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
212
                [% ELSE %]
213
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
214
                [% END %]
215
              [% END %]
216
            </select>
217
          </li>
218
        </ol>
219
        <fieldset class="action">
220
          <input type="submit" value="Search" />
221
        </fieldset>
222
      </fieldset>
223
      <input type="hidden" name="op" id="op" value="do_search" />
224
    </form>
225
    [% INCLUDE 'acquisitions-menu.inc' %]
226
  </div>
227
</div>
228
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +3 lines)
Lines 236-246 Link Here
236
        [% END %]
236
        [% END %]
237
    [% END %]
237
    [% END %]
238
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
238
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
239
    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
239
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
240
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
240
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
241
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
241
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
242
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
242
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
243
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
243
    <input type="hidden" name="freight" value="[% freight %]" />
244
    <input type="hidden" name="gst" value="[% gst %]" />
244
    <input type="hidden" name="gst" value="[% gst %]" />
245
	</div>
245
	</div>
246
	<div class="yui-u">
246
	<div class="yui-u">
Lines 296-308 Link Here
296
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
296
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
297
        [% END %]</li></ol>
297
        [% END %]</li></ol>
298
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
298
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
299
        <input type="hidden" name="invoice" value="[% invoice %]" />
300
    </fieldset>
299
    </fieldset>
301
300
302
</div>
301
</div>
303
</div><div class="yui-g"><fieldset class="action">
302
</div><div class="yui-g"><fieldset class="action">
304
        <input type="submit"  value="Save" />
303
        <input type="submit"  value="Save" />
305
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
304
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Cancel</a>
306
</fieldset></div>    </form>
305
</fieldset></div>    </form>
307
[% ELSE %]
306
[% ELSE %]
308
<div id="acqui_acquire_orderlist">
307
<div id="acqui_acquire_orderlist">
Lines 319-325 Link Here
319
        <tr>
318
        <tr>
320
            <td>[% loo.basketno %]</td>
319
            <td>[% loo.basketno %]</td>
321
            <td>[% loo.isbn %]</td>
320
            <td>[% loo.isbn %]</td>
322
         <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>
321
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
323
            <td>[% loo.author %]</td>
322
            <td>[% loo.author %]</td>
324
            <td>[% loo.quantity %]</td>
323
            <td>[% loo.quantity %]</td>
325
            <td>[% loo.quantityreceived %]</td>
324
            <td>[% loo.quantityreceived %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-51 / +65 lines)
Lines 133-139 Link Here
133
                       + '<td>' + order.ecost + '</td>'
133
                       + '<td>' + order.ecost + '</td>'
134
                       + '<td>' + order.ordertotal + '</td>'
134
                       + '<td>' + order.ordertotal + '</td>'
135
                       + '<td>'
135
                       + '<td>'
136
                       + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=' + gst + '&amp;freight=' + order.freight + '&amp;booksellerid=[% booksellerid %]">Receive</a> /'
136
                       + '<a href="orderreceive.pl?ordernumber=' + order.ordernumber + '&amp;invoice=[% invoiceid %]">Receive</a> /'
137
                       + '<a href="parcel.pl?type=intra&amp;ordernumber=' + order.ordernumber + '&amp;biblionumber=' + order.biblionumber + '&amp;action=cancelorder&amp;booksellerid=[% booksellerid %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]" onclick="return confirm(\'' + _('Are you sure you want to cancel this order?') + '\');">Cancel</a>'
137
                       + '<a href="parcel.pl?type=intra&amp;ordernumber=' + order.ordernumber + '&amp;biblionumber=' + order.biblionumber + '&amp;action=cancelorder&amp;booksellerid=[% booksellerid %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]" onclick="return confirm(\'' + _('Are you sure you want to cancel this order?') + '\');">Cancel</a>'
138
                       + '</td></tr>').appendTo("table#pendingt");
138
                       + '</td></tr>').appendTo("table#pendingt");
139
				}
139
				}
Lines 184-194 Link Here
184
[% INCLUDE 'header.inc' %]
184
[% INCLUDE 'header.inc' %]
185
[% INCLUDE 'acquisitions-search.inc' %]
185
[% INCLUDE 'acquisitions-search.inc' %]
186
186
187
<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 ) %]
187
<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;
188
            Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
188
    [% IF ( datereceived ) %]
189
        [% ELSE %]
189
        Receipt summary for <i>[% name %]</i>
190
            Receive orders from [% name %]
190
        [% IF ( invoice ) %]
191
        [% END %]</div>
191
            <i>[ [% invoice %] ]</i>
192
        [% END %]
193
        on <i>[% formatteddatereceived %]</i>
194
    [% ELSE %]
195
        Receive orders from [% name %]
196
    [% END %]
197
</div>
192
198
193
<div id="doc3" class="yui-t2">
199
<div id="doc3" class="yui-t2">
194
200
Lines 226-233 Link Here
226
232
227
<div id="acqui_receive_summary">
233
<div id="acqui_receive_summary">
228
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
234
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
229
	<!-- TODO: Add date picker, change rcv date. -->
235
<p><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">Go to invoice details</a></p>
230
</div>
236
</div>
237
[% UNLESS (invoiceclosedate) %]
231
<div id="acqui_receive_search">
238
<div id="acqui_receive_search">
232
    <h3>Pending orders</h3>
239
    <h3>Pending orders</h3>
233
240
Lines 281-334 Link Here
281
                <td>[% loop_order.ecost %]</td>
288
                <td>[% loop_order.ecost %]</td>
282
                <td>[% loop_order.ordertotal %]</td>
289
                <td>[% loop_order.ordertotal %]</td>
283
				<td>
290
				<td>
284
                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% invoicedatereceived %]&amp;invoice=[% invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;booksellerid=[% loop_order.booksellerid %]">Receive</a>
291
                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
285
				    
292
				    
286
				</td>
293
				</td>
287
				<td>
294
				<td>
288
				    [% IF ( loop_order.left_holds_on_order ) %]
295
                        [% IF ( loop_order.left_holds_on_order ) %]
289
                    <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>
296
                        <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>
290
                    [% ELSE %]
297
                        [% ELSE %]
291
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
298
                        <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
292
                    [% END %]
299
                        [% END %]
293
                    [% IF ( loop_order.can_del_bib ) %]
300
                        [% IF ( loop_order.can_del_bib ) %]
294
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
301
                        <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
295
                    [% ELSE %]
302
                        [% ELSE %]
296
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
303
                        <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
297
                    [% END %]
304
                        [% END %]
298
                    [% IF ( loop_order.left_item ) %]
305
                        [% IF ( loop_order.left_item ) %]
299
                    <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
306
                        <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
300
                    [% END %]
307
                        [% END %]
301
                    [% IF ( loop_order.left_biblio ) %]
308
                        [% IF ( loop_order.left_biblio ) %]
302
                    <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
309
                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
303
                    [% END %]
310
                        [% END %]
304
                    [% IF ( loop_order.left_subscription ) %]
311
                        [% IF ( loop_order.left_subscription ) %]
305
                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
312
                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
306
                    [% END %]
313
                        [% END %]
307
                    [% IF ( loop_order.left_holds ) %]
314
                        [% IF ( loop_order.left_holds ) %]
308
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
315
                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
309
                    [% END %]
316
                        [% END %]
310
				</td>
317
                    </td>
311
            </tr>
318
                </tr>
319
            [% END %]
320
        </tbody>
321
         </table>[% ELSE %]There are no pending orders.[% END %]
322
       <div id="resultnumber">
323
        <!-- Row of numbers corresponding to search result pages -->
324
        [% IF ( displayprev ) %]
325
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% prevstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
312
        [% END %]
326
        [% END %]
313
    </tbody>
327
        [% FOREACH number IN numbers %]
314
     </table>[% ELSE %]There are no pending orders.[% END %]
328
            [% IF ( number.highlight ) %]
315
   <div id="resultnumber">
329
            <span class="current">[% number.number %]</span>
316
	<!-- Row of numbers corresponding to search result pages -->
330
            [% ELSE %]
317
	[% IF ( displayprev ) %]
331
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% number.startfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
318
		<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>
332
            [% END %]
319
	[% END %]
333
        [% END %]
320
	[% FOREACH number IN numbers %]
334
        [% IF ( displaynext ) %]
321
		[% IF ( number.highlight ) %]
335
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% nextstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
322
		<span class="current">[% number.number %]</span>
336
        [% END %]
323
		[% ELSE %]
337
        </div>
324
		<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>
338
    </div>
325
		[% END %]
339
[% ELSE %]
326
	[% END %]
340
    <p>
327
	[% IF ( displaynext ) %]
341
        Invoice is close, so you can't receive orders.
328
		<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>
342
        <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
329
	[% END %]
343
    </p>
330
	</div>
344
[% END %]
331
</div>
345
332
<div id="acqui_receive_receivelist">
346
<div id="acqui_receive_receivelist">
333
    <h3>Already received</h3>
347
    <h3>Already received</h3>
334
348
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-25 / +23 lines)
Lines 27-33 Link Here
27
   <div id="bd">
27
   <div id="bd">
28
	<div id="yui-main">
28
	<div id="yui-main">
29
	<div class="yui-b">
29
	<div class="yui-b">
30
	
30
31
[% IF ( error_failed_to_create_invoice ) %]
32
    <div id="error" class="dialog error">
33
        <p>An error has occured. Invoice cannot be created.</p>
34
    </div>
35
[% END %]
31
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1>
36
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1>
32
37
33
[% IF ( count ) %]
38
[% IF ( count ) %]
Lines 58-68 Link Here
58
                [% searchresult.number %]
63
                [% searchresult.number %]
59
            </td>
64
            </td>
60
            <td>
65
            <td>
61
                <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 %]">
66
                [% searchresult.datereceived %]
62
                    [% searchresult.datereceived %]</a>
63
            </td>
67
            </td>
64
            <td>
68
            <td>
65
                [% IF ( searchresult.code ) %][% searchresult.code %][% ELSE %]<acronym title="not available">n/a</acronym>[% END %]
69
                [% IF ( searchresult.code ) %]
70
                    <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% searchresult.invoiceid %]">[% searchresult.code %]</a>
71
                [% ELSE %]
72
                    <acronym title="not available">n/a</acronym>
73
                [% END %]
66
            </td>
74
            </td>
67
            <td>
75
            <td>
68
                [% searchresult.reccount %]
76
                [% searchresult.reccount %]
Lines 98-104 Link Here
98
[% END %]
106
[% END %]
99
107
100
    <div id="parcels_new_parcel">
108
    <div id="parcels_new_parcel">
101
        <form method="get" action="parcel.pl">
109
        <form method="get" action="parcels.pl">
102
    <fieldset class="rows">
110
    <fieldset class="rows">
103
    <legend>Receive a new shipment</legend>
111
    <legend>Receive a new shipment</legend>
104
       <ol> <li>
112
       <ol> <li>
Lines 107-132 Link Here
107
            <input type="hidden" name="op" value="new" />
115
            <input type="hidden" name="op" value="new" />
108
			<input type="text" size="20" id="invoice" name="invoice" />
116
			<input type="text" size="20" id="invoice" name="invoice" />
109
        </li>
117
        </li>
110
		[% IF ( gst ) %]
118
         <li><label for="shipmentdate">Shipment date: </label>
111
        <li>
119
            <input type="text" id="shipmentdate" name="shipmentdate" maxlength="10" size="10" value="[% shipmentdate_today %]" />
112
            <label for="gst">GST:</label>
120
            <img src="[% themelang %]/lib/calendar/cal.gif" id="shipmentdate_button" alt="Show Calendar" />
113
            <input type="text" size="20" id="gst" name="gst" />
114
        </li>
115
		[% END %]
116
      <!--  // Removing freight input until shipping can be proplerly handled .
117
	  <li>
118
            <label for="freight">Shipping:</label>
119
            <input type="text" size="20" id="freight" name="freight" />
120
        </li> -->
121
         <li><label for="datereceived">Shipment date: </label>
122
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" />
123
            <img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
124
      <script language="JavaScript" type="text/javascript">
121
      <script language="JavaScript" type="text/javascript">
125
        Calendar.setup(
122
        Calendar.setup(
126
          {
123
          {
127
            inputField : "datereceived",
124
            inputField : "shipmentdate",
128
            ifFormat : "[% DHTMLcalendar_dateformat %]",
125
            ifFormat : "[% DHTMLcalendar_dateformat %]",
129
            button : "datereceived_button"          }
126
            button : "shipmentdate_button"
127
          }
130
        );
128
        );
131
      </script>
129
      </script>
132
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
130
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
Lines 147-156 Link Here
147
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
145
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
148
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
146
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
149
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
147
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
150
                <option value="aqorders.booksellerinvoicenumber">Invoice number</option>
148
                <option value="invoicenumber">Invoice number</option>
151
                <option value="datereceived"> Date received</option>
149
                <option value="shipmentdate">Shipment date</option>
152
                <option value="datereceived desc"> Date received reverse</option>
150
                <option value="shipmentdate desc">Shipment date reverse</option>
153
                <option value="aqorders.booksellerinvoicenumber desc"> Invoice number reverse</option>
151
                <option value="invoicenumber desc">Invoice number reverse</option>
154
                </select><br />
152
                </select><br />
155
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
153
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
156
                <option value="20">20</option>
154
                <option value="20">20</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt (-22 / +19 lines)
Lines 42-48 Link Here
42
	<th> Itemtype </th>
42
	<th> Itemtype </th>
43
	<th> Received </th>
43
	<th> Received </th>
44
    <th> Unit price </th>
44
    <th> Unit price </th>
45
    <th> Freight per item </th>
46
    <th> Date ordered </th>
45
    <th> Date ordered </th>
47
    <th> Date received </th>
46
    <th> Date received </th>
48
	<th> Subtotal </th>
47
	<th> Subtotal </th>
Lines 60-72 Link Here
60
	    [% order.title %]
59
	    [% order.title %]
61
	</td>
60
	</td>
62
	<td class="cell">
61
	<td class="cell">
63
            <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>
62
            <a href="/cgi-bin/koha/acqui/orderreceive.pl?ordernumber=[% order.ordernumber %]&amp;biblio=[% order.biblionumber %]&amp;invoiceid=[% order.invoiceid %]">[% order.ordernumber %]</a>
64
	</td>
63
	</td>
65
	<td class="cell">
64
	<td class="cell">
66
	    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.booksellerid %]">[% order.booksellerid %]</a>
65
	    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.booksellerid %]">[% order.booksellerid %]</a>
67
	</td>
66
	</td>
68
	<td class="cell">
67
	<td class="cell">
69
	    <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% order.booksellerinvoicenumber %]&amp;booksellerid=[% order.booksellerid %]&amp;datereceived=[% order.datereceived %]">[% order.booksellerinvoicenumber %]</a>
68
	    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid %]">[% order.invoicenumber %]</a>
70
	</td>
69
	</td>
71
	<td class="cell">
70
	<td class="cell">
72
	    [% order.itype %]
71
	    [% order.itype %]
Lines 78-114 Link Here
78
	    [% order.unitprice %]
77
	    [% order.unitprice %]
79
	</td>
78
	</td>
80
	<td class="cell" align="right">
79
	<td class="cell" align="right">
81
	    [% order.freight %]
82
	</td>
83
	<td class="cell" align="right">
84
	    [% order.entrydate | $KohaDates %]
80
	    [% order.entrydate | $KohaDates %]
85
	</td>
81
	</td>
86
	<td class="cell" align="right">
82
	<td class="cell" align="right">
87
	    [% order.datereceived | $KohaDates %]
83
	    [% order.datereceived | $KohaDates %]
88
	</td>
84
	</td>
89
	<td class="cell" align="right">
85
	<td class="cell" align="right">
90
	    [% order.subtotal %]
86
	    [% order.rowtotal %]
91
	</td>
87
	</td>
92
    </tr>
88
    </tr>
93
[% END %]
89
[% END %]
94
    <tfoot>
90
    <tfoot>
95
        <tr valign="top">
91
        [% IF shipmentcosts.size %]
96
        <td> Total </td>
92
            <tr valign="top">
97
        <td> </td>
93
                <td colspan="9"> Sub total </td>
98
        <td> </td>
94
                <td align="right"> [% subtotal %] </td>
99
        <td> </td>
95
            </tr>
100
        <td> </td>
96
            [% FOREACH shipmentcost IN shipmentcosts %]
101
        <td> </td>
97
                <tr>
102
        <td> </td>
98
                    <td></td>
103
        <td> </td>
99
                    <td colspan="8">Shipment cost for invoice [% shipmentcost.invoicenumber %]</td>
104
	<td> </td>
100
                    <td class="total">[% shipmentcost.shipmentcost %]</td>
105
	<td> </td>
101
                </tr>
106
        <td align="right">
102
            [% END %]
107
		[% total %]
103
        [% END %]
108
	</td>
104
        <tr>
105
            <td colspan="9">TOTAL</td>
106
            <td class="total">[% total %]</td>
109
        </tr>
107
        </tr>
110
    </tfoot>
108
    </tfoot>
111
112
</table>
109
</table>
113
110
114
</div>
111
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-5 / +4 lines)
Lines 184-199 Link Here
184
184
185
            [% IF ITEM_DAT.dateaccessioned %]
185
            [% IF ITEM_DAT.dateaccessioned %]
186
                <li><span class="label">Accession date:</span>
186
                <li><span class="label">Accession date:</span>
187
                    [% IF ( CAN_user_acquisition_order_receive && ITEM_DAT.booksellerinvoicenumber ) %]
187
                    [% IF ( CAN_user_acquisition_order_receive && ITEM_DAT.invoiceid ) %]
188
                        <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>
188
                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% ITEM_DAT.invoiceid %]">[% ITEM_DAT.dateaccessioned | $KohaDates %]</a>
189
                    [% ELSE %]
189
                    [% ELSE %]
190
                        [% ITEM_DAT.dateaccessioned | $KohaDates %]
190
                        [% ITEM_DAT.dateaccessioned | $KohaDates %]
191
                    [% END %]
191
                    [% END %]
192
                </li>
192
                </li>
193
            [% END %]
193
            [% END %]
194
            [% IF ( ITEM_DAT.booksellerinvoicenumber ) %]
194
            [% IF ( ITEM_DAT.invoicenumber ) %]
195
                <li><span class="label">Invoice number:</span>
195
                <li><span class="label">Invoice number:</span>
196
                    [% ITEM_DAT.booksellerinvoicenumber %]
196
                    [% ITEM_DAT.invoicenumber %]
197
                </li>
197
                </li>
198
            [% END %]
198
            [% END %]
199
199
200
- 

Return to bug 5339