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

(-)a/C4/Acquisition.pm (-19 / +366 lines)
Lines 64-69 BEGIN { Link Here
64
        &GetParcels &GetParcel
64
        &GetParcels &GetParcel
65
        &GetContracts &GetContract
65
        &GetContracts &GetContract
66
66
67
        &GetInvoices
68
        &GetInvoice
69
        &GetInvoiceDetails
70
        &AddInvoice
71
        &ModInvoice
72
        &CloseInvoice
73
        &ReopenInvoice
74
67
        &GetItemnumbersFromOrder
75
        &GetItemnumbersFromOrder
68
76
69
        &AddClaim
77
        &AddClaim
Lines 1224-1238 sub GetCancelledOrders { Link Here
1224
=head3 ModReceiveOrder
1232
=head3 ModReceiveOrder
1225
1233
1226
  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
1234
  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
1227
    $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
1235
    $unitprice, $invoiceid, $biblioitemnumber,
1228
    $freight, $bookfund, $rrp);
1236
    $bookfund, $rrp, \@received_itemnumbers);
1229
1237
1230
Updates an order, to reflect the fact that it was received, at least
1238
Updates an order, to reflect the fact that it was received, at least
1231
in part. All arguments not mentioned below update the fields with the
1239
in part. All arguments not mentioned below update the fields with the
1232
same name in the aqorders table of the Koha database.
1240
same name in the aqorders table of the Koha database.
1233
1241
1234
If a partial order is received, splits the order into two.  The received
1242
If a partial order is received, splits the order into two.
1235
portion must have a booksellerinvoicenumber.
1236
1243
1237
Updates the order with bibilionumber C<$biblionumber> and ordernumber
1244
Updates the order with bibilionumber C<$biblionumber> and ordernumber
1238
C<$ordernumber>.
1245
C<$ordernumber>.
Lines 1243-1249 C<$ordernumber>. Link Here
1243
sub ModReceiveOrder {
1250
sub ModReceiveOrder {
1244
    my (
1251
    my (
1245
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1252
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1246
        $invoiceno, $freight, $rrp, $budget_id, $datereceived, $received_items
1253
        $invoiceid, $rrp, $budget_id, $datereceived, $received_items
1247
    )
1254
    )
1248
    = @_;
1255
    = @_;
1249
    my $dbh = C4::Context->dbh;
1256
    my $dbh = C4::Context->dbh;
Lines 1269-1282 sub ModReceiveOrder { Link Here
1269
            UPDATE aqorders
1276
            UPDATE aqorders
1270
            SET quantityreceived=?
1277
            SET quantityreceived=?
1271
                , datereceived=?
1278
                , datereceived=?
1272
                , booksellerinvoicenumber=?
1279
                , invoiceid=?
1273
                , unitprice=?
1280
                , unitprice=?
1274
                , freight=?
1275
                , rrp=?
1281
                , rrp=?
1276
                , quantity=?
1282
                , quantity=?
1277
            WHERE biblionumber=? AND ordernumber=?");
1283
            WHERE biblionumber=? AND ordernumber=?");
1278
1284
1279
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
1285
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$quantrec,$biblionumber,$ordernumber);
1280
        $sth->finish;
1286
        $sth->finish;
1281
1287
1282
        # create a new order for the remaining items, and set its bookfund.
1288
        # create a new order for the remaining items, and set its bookfund.
Lines 1300-1309 sub ModReceiveOrder { Link Here
1300
        }
1306
        }
1301
    } else {
1307
    } else {
1302
        $sth=$dbh->prepare("update aqorders
1308
        $sth=$dbh->prepare("update aqorders
1303
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1309
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1304
                                unitprice=?,freight=?,rrp=?
1310
                                unitprice=?,rrp=?
1305
                            where biblionumber=? and ordernumber=?");
1311
                            where biblionumber=? and ordernumber=?");
1306
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1312
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1307
        $sth->finish;
1313
        $sth->finish;
1308
    }
1314
    }
1309
    return $datereceived;
1315
    return $datereceived;
Lines 1462-1470 sub GetParcel { Link Here
1462
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1468
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1463
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1469
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1464
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1470
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1471
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1465
        WHERE
1472
        WHERE
1466
            aqbasket.booksellerid = ?
1473
            aqbasket.booksellerid = ?
1467
            AND aqorders.booksellerinvoicenumber LIKE ?
1474
            AND aqinvoices.invoicenumber LIKE ?
1468
            AND aqorders.datereceived = ? ";
1475
            AND aqorders.datereceived = ? ";
1469
1476
1470
    my @query_params = ( $supplierid, $code, $datereceived );
1477
    my @query_params = ( $supplierid, $code, $datereceived );
Lines 1537-1554 sub GetParcels { Link Here
1537
    my $dbh    = C4::Context->dbh;
1544
    my $dbh    = C4::Context->dbh;
1538
    my @query_params = ();
1545
    my @query_params = ();
1539
    my $strsth ="
1546
    my $strsth ="
1540
        SELECT  aqorders.booksellerinvoicenumber,
1547
        SELECT  aqinvoices.invoicenumber,
1541
                datereceived,purchaseordernumber,
1548
                datereceived,purchaseordernumber,
1542
                count(DISTINCT biblionumber) AS biblio,
1549
                count(DISTINCT biblionumber) AS biblio,
1543
                sum(quantity) AS itemsexpected,
1550
                sum(quantity) AS itemsexpected,
1544
                sum(quantityreceived) AS itemsreceived
1551
                sum(quantityreceived) AS itemsreceived
1545
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1552
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1553
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1546
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1554
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1547
    ";
1555
    ";
1548
    push @query_params, $bookseller;
1556
    push @query_params, $bookseller;
1549
1557
1550
    if ( defined $code ) {
1558
    if ( defined $code ) {
1551
        $strsth .= ' and aqorders.booksellerinvoicenumber like ? ';
1559
        $strsth .= ' and aqinvoices.invoicenumber like ? ';
1552
        # add a % to the end of the code to allow stemming.
1560
        # add a % to the end of the code to allow stemming.
1553
        push @query_params, "$code%";
1561
        push @query_params, "$code%";
1554
    }
1562
    }
Lines 1563-1569 sub GetParcels { Link Here
1563
        push @query_params, $dateto;
1571
        push @query_params, $dateto;
1564
    }
1572
    }
1565
1573
1566
    $strsth .= "group by aqorders.booksellerinvoicenumber,datereceived ";
1574
    $strsth .= "group by aqinvoices.invoicenumber,datereceived ";
1567
1575
1568
    # can't use a placeholder to place this column name.
1576
    # can't use a placeholder to place this column name.
1569
    # but, we could probably be checking to make sure it is a column that will be fetched.
1577
    # but, we could probably be checking to make sure it is a column that will be fetched.
Lines 1779-1785 sub GetHistory { Link Here
1779
            aqorders.quantityreceived,
1787
            aqorders.quantityreceived,
1780
            aqorders.ecost,
1788
            aqorders.ecost,
1781
            aqorders.ordernumber,
1789
            aqorders.ordernumber,
1782
            aqorders.booksellerinvoicenumber as invoicenumber,
1790
            aqinvoices.invoicenumber,
1783
            aqbooksellers.id as id,
1791
            aqbooksellers.id as id,
1784
            aqorders.biblionumber
1792
            aqorders.biblionumber
1785
        FROM aqorders
1793
        FROM aqorders
Lines 1787-1793 sub GetHistory { Link Here
1787
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1795
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1788
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1796
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1789
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1797
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1790
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1798
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
1799
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
1791
1800
1792
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1801
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1793
    if ( C4::Context->preference("IndependantBranches") );
1802
    if ( C4::Context->preference("IndependantBranches") );
Lines 1841-1848 sub GetHistory { Link Here
1841
    }
1850
    }
1842
1851
1843
    if ($booksellerinvoicenumber) {
1852
    if ($booksellerinvoicenumber) {
1844
        $query .= " AND (aqorders.booksellerinvoicenumber LIKE ? OR aqbasket.booksellerinvoicenumber LIKE ?)";
1853
        $query .= " AND aqinvoices.invoicenumber LIKE ? ";
1845
        push @query_params, "%$booksellerinvoicenumber%", "%$booksellerinvoicenumber%";
1854
        push @query_params, "%$booksellerinvoicenumber%";
1846
    }
1855
    }
1847
1856
1848
    if ( C4::Context->preference("IndependantBranches") ) {
1857
    if ( C4::Context->preference("IndependantBranches") ) {
Lines 1983-1989 sub AddClaim { Link Here
1983
        ";
1992
        ";
1984
    my $sth = $dbh->prepare($query);
1993
    my $sth = $dbh->prepare($query);
1985
    $sth->execute($ordernumber);
1994
    $sth->execute($ordernumber);
1995
}
1996
1997
=head3 GetInvoices
1998
1999
    my @invoices = GetInvoices(
2000
        invoicenumber => $invoicenumber,
2001
        suppliername => $suppliername,
2002
        shipmentdatefrom => $shipmentdatefrom, # ISO format
2003
        shipmentdateto => $shipmentdateto, # ISO format
2004
        billingdatefrom => $billingdatefrom, # ISO format
2005
        billingdateto => $billingdateto, # ISO format
2006
        isbneanissn => $isbn_or_ean_or_issn,
2007
        title => $title,
2008
        author => $author,
2009
        publisher => $publisher,
2010
        publicationyear => $publicationyear,
2011
        branchcode => $branchcode,
2012
        order_by => $order_by
2013
    );
2014
2015
Return a list of invoices that match all given criteria.
2016
2017
$order_by is "column_name (asc|desc)", where column_name is any of
2018
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
2019
'shipmentcost', 'shipmentcost_budgetid'.
2020
2021
asc is the default if omitted
2022
2023
=cut
2024
2025
sub GetInvoices {
2026
    my %args = @_;
2027
2028
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2029
        closedate shipmentcost shipmentcost_budgetid);
2030
2031
    my $dbh = C4::Context->dbh;
2032
    my $query = qq{
2033
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername,
2034
          COUNT(
2035
            DISTINCT IF(
2036
              aqorders.datereceived IS NOT NULL,
2037
              aqorders.biblionumber,
2038
              NULL
2039
            )
2040
          ) AS receivedbiblios,
2041
          SUM(aqorders.quantityreceived) AS receiveditems
2042
        FROM aqinvoices
2043
          LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
2044
          LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid
2045
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2046
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
2047
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
2048
    };
2049
2050
    my @bind_args;
2051
    my @bind_strs;
2052
    if($args{supplierid}) {
2053
        push @bind_strs, " aqinvoices.booksellerid = ? ";
2054
        push @bind_args, $args{supplierid};
2055
    }
2056
    if($args{invoicenumber}) {
2057
        push @bind_strs, " aqinvoices.invoicenumber LIKE ? ";
2058
        push @bind_args, "%$args{invoicenumber}%";
2059
    }
2060
    if($args{suppliername}) {
2061
        push @bind_strs, " aqbooksellers.name LIKE ? ";
2062
        push @bind_args, "%$args{suppliername}%";
2063
    }
2064
    if($args{shipmentdatefrom}) {
2065
        push @bind_strs, " aqinvoices.shipementdate >= ? ";
2066
        push @bind_args, $args{shipementdatefrom};
2067
    }
2068
    if($args{shipmentdateto}) {
2069
        push @bind_strs, " aqinvoices.shipementdate <= ? ";
2070
        push @bind_args, $args{shipementdateto};
2071
    }
2072
    if($args{billingdatefrom}) {
2073
        push @bind_strs, " aqinvoices.billingdate >= ? ";
2074
        push @bind_args, $args{billingdatefrom};
2075
    }
2076
    if($args{billingdateto}) {
2077
        push @bind_strs, " aqinvoices.billingdate <= ? ";
2078
        push @bind_args, $args{billingdateto};
2079
    }
2080
    if($args{isbneanissn}) {
2081
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
2082
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
2083
    }
2084
    if($args{title}) {
2085
        push @bind_strs, " biblio.title LIKE ? ";
2086
        push @bind_args, $args{title};
2087
    }
2088
    if($args{author}) {
2089
        push @bind_strs, " biblio.author LIKE ? ";
2090
        push @bind_args, $args{author};
2091
    }
2092
    if($args{publisher}) {
2093
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
2094
        push @bind_args, $args{publisher};
2095
    }
2096
    if($args{publicationyear}) {
2097
        push @bind_strs, " biblioitems.publicationyear = ? ";
2098
        push @bind_args, $args{publicationyear};
2099
    }
2100
    if($args{branchcode}) {
2101
        push @bind_strs, " aqorders.branchcode = ? ";
2102
        push @bind_args, $args{branchcode};
2103
    }
2104
2105
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
2106
    $query .= " GROUP BY aqinvoices.invoiceid ";
2107
2108
    if($args{order_by}) {
2109
        my ($column, $direction) = split / /, $args{order_by};
2110
        if(grep /^$column$/, @columns) {
2111
            $direction ||= 'ASC';
2112
            $query .= " ORDER BY $column $direction";
2113
        }
2114
    }
1986
2115
2116
    my $sth = $dbh->prepare($query);
2117
    $sth->execute(@bind_args);
2118
2119
    my $results = $sth->fetchall_arrayref({});
2120
    return @$results;
2121
}
2122
2123
=head3 GetInvoice
2124
2125
    my $invoice = GetInvoice($invoiceid);
2126
2127
Get informations about invoice with given $invoiceid
2128
2129
Return a hash filled with aqinvoices.* fields
2130
2131
=cut
2132
2133
sub GetInvoice {
2134
    my ($invoiceid) = @_;
2135
    my $invoice;
2136
2137
    return unless $invoiceid;
2138
2139
    my $dbh = C4::Context->dbh;
2140
    my $query = qq{
2141
        SELECT *
2142
        FROM aqinvoices
2143
        WHERE invoiceid = ?
2144
    };
2145
    my $sth = $dbh->prepare($query);
2146
    $sth->execute($invoiceid);
2147
2148
    $invoice = $sth->fetchrow_hashref;
2149
    return $invoice;
2150
}
2151
2152
=head3 GetInvoiceDetails
2153
2154
    my $invoice = GetInvoiceDetails($invoiceid)
2155
2156
Return informations about an invoice + the list of related order lines
2157
2158
Orders informations are in $invoice->{orders} (array ref)
2159
2160
=cut
2161
2162
sub GetInvoiceDetails {
2163
    my ($invoiceid) = @_;
2164
    my $invoice;
2165
2166
    return unless $invoiceid;
2167
2168
    my $dbh = C4::Context->dbh;
2169
    my $query = qq{
2170
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername
2171
        FROM aqinvoices
2172
          LEFT JOIN aqbooksellers ON aqinvoices.booksellerid = aqbooksellers.id
2173
        WHERE invoiceid = ?
2174
    };
2175
    my $sth = $dbh->prepare($query);
2176
    $sth->execute($invoiceid);
2177
2178
    $invoice = $sth->fetchrow_hashref;
2179
2180
    $query = qq{
2181
        SELECT aqorders.*, biblio.*
2182
        FROM aqorders
2183
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2184
        WHERE invoiceid = ?
2185
    };
2186
    $sth = $dbh->prepare($query);
2187
    $sth->execute($invoiceid);
2188
    $invoice->{orders} = $sth->fetchall_arrayref({});
2189
    $invoice->{orders} ||= []; # force an empty arrayref if fetchall_arrayref fails
2190
2191
    return $invoice;
2192
}
2193
2194
=head3 AddInvoice
2195
2196
    my $invoiceid = AddInvoice(
2197
        invoicenumber => $invoicenumber,
2198
        booksellerid => $booksellerid,
2199
        shipmentdate => $shipmentdate,
2200
        billingdate => $billingdate,
2201
        closedate => $closedate,
2202
        shipmentcost => $shipmentcost,
2203
        shipmentcost_budgetid => $shipmentcost_budgetid
2204
    );
2205
2206
Create a new invoice and return its id or undef if it fails.
2207
2208
=cut
2209
2210
sub AddInvoice {
2211
    my %invoice = @_;
2212
2213
    return unless(%invoice and $invoice{invoicenumber});
2214
2215
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2216
        closedate shipmentcost shipmentcost_budgetid);
2217
2218
    my @set_strs;
2219
    my @set_args;
2220
    foreach my $key (keys %invoice) {
2221
        if(0 < grep(/^$key$/, @columns)) {
2222
            push @set_strs, "$key = ?";
2223
            push @set_args, ($invoice{$key} || undef);
2224
        }
2225
    }
2226
2227
    my $rv;
2228
    if(@set_args > 0) {
2229
        my $dbh = C4::Context->dbh;
2230
        my $query = "INSERT INTO aqinvoices SET ";
2231
        $query .= join (",", @set_strs);
2232
        my $sth = $dbh->prepare($query);
2233
        $rv = $sth->execute(@set_args);
2234
        if($rv) {
2235
            $rv = $dbh->last_insert_id(undef, undef, 'aqinvoices', undef);
2236
        }
2237
    }
2238
    return $rv;
2239
}
2240
2241
=head3 ModInvoice
2242
2243
    ModInvoice(
2244
        invoiceid => $invoiceid,    # Mandatory
2245
        invoicenumber => $invoicenumber,
2246
        booksellerid => $booksellerid,
2247
        shipmentdate => $shipmentdate,
2248
        billingdate => $billingdate,
2249
        closedate => $closedate,
2250
        shipmentcost => $shipmentcost,
2251
        shipmentcost_budgetid => $shipmentcost_budgetid
2252
    );
2253
2254
Modify an invoice, invoiceid is mandatory.
2255
2256
Return undef if it fails.
2257
2258
=cut
2259
2260
sub ModInvoice {
2261
    my %invoice = @_;
2262
2263
    return unless(%invoice and $invoice{invoiceid});
2264
2265
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2266
        closedate shipmentcost shipmentcost_budgetid);
2267
2268
    my @set_strs;
2269
    my @set_args;
2270
    foreach my $key (keys %invoice) {
2271
        if(0 < grep(/^$key$/, @columns)) {
2272
            push @set_strs, "$key = ?";
2273
            push @set_args, ($invoice{$key} || undef);
2274
        }
2275
    }
2276
2277
    my $dbh = C4::Context->dbh;
2278
    my $query = "UPDATE aqinvoices SET ";
2279
    $query .= join(",", @set_strs);
2280
    $query .= " WHERE invoiceid = ?";
2281
2282
    my $sth = $dbh->prepare($query);
2283
    $sth->execute(@set_args, $invoice{invoiceid});
2284
}
2285
2286
=head3 CloseInvoice
2287
2288
    CloseInvoice($invoiceid);
2289
2290
Close an invoice.
2291
2292
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2293
2294
=cut
2295
2296
sub CloseInvoice {
2297
    my ($invoiceid) = @_;
2298
2299
    return unless $invoiceid;
2300
2301
    my $dbh = C4::Context->dbh;
2302
    my $query = qq{
2303
        UPDATE aqinvoices
2304
        SET closedate = CAST(NOW() AS DATE)
2305
        WHERE invoiceid = ?
2306
    };
2307
    my $sth = $dbh->prepare($query);
2308
    $sth->execute($invoiceid);
2309
}
2310
2311
=head3 ReopenInvoice
2312
2313
    ReopenInvoice($invoiceid);
2314
2315
Reopen an invoice
2316
2317
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2318
2319
=cut
2320
2321
sub ReopenInvoice {
2322
    my ($invoiceid) = @_;
2323
2324
    return unless $invoiceid;
2325
2326
    my $dbh = C4::Context->dbh;
2327
    my $query = qq{
2328
        UPDATE aqinvoices
2329
        SET closedate = NULL
2330
        WHERE invoiceid = ?
2331
    };
2332
    my $sth = $dbh->prepare($query);
2333
    $sth->execute($invoiceid);
1987
}
2334
}
1988
2335
1989
1;
2336
1;
(-)a/C4/Budgets.pm (-2 / +22 lines)
Lines 314-322 sub GetBudgetSpent { Link Here
314
            quantityreceived > 0 AND
314
            quantityreceived > 0 AND
315
            datecancellationprinted IS NULL
315
            datecancellationprinted IS NULL
316
    |);
316
    |);
317
318
	$sth->execute($budget_id);
317
	$sth->execute($budget_id);
319
	my $sum =  $sth->fetchrow_array;
318
	my $sum =  $sth->fetchrow_array;
319
320
    $sth = $dbh->prepare(qq|
321
        SELECT SUM(shipmentcost) AS sum
322
        FROM aqinvoices
323
        WHERE shipmentcost_budgetid = ?
324
          AND closedate IS NOT NULL
325
    |);
326
    $sth->execute($budget_id);
327
    my ($shipmentcost_sum) = $sth->fetchrow_array;
328
    $sum += $shipmentcost_sum;
329
320
	return $sum;
330
	return $sum;
321
}
331
}
322
332
Lines 330-338 sub GetBudgetOrdered { Link Here
330
            quantityreceived = 0 AND
340
            quantityreceived = 0 AND
331
            datecancellationprinted IS NULL
341
            datecancellationprinted IS NULL
332
    |);
342
    |);
333
334
	$sth->execute($budget_id);
343
	$sth->execute($budget_id);
335
	my $sum =  $sth->fetchrow_array;
344
	my $sum =  $sth->fetchrow_array;
345
346
    $sth = $dbh->prepare(qq|
347
        SELECT SUM(shipmentcost) AS sum
348
        FROM aqinvoices
349
        WHERE shipmentcost_budgetid = ?
350
          AND closedate IS NULL
351
    |);
352
    $sth->execute($budget_id);
353
    my ($shipmentcost_sum) = $sth->fetchrow_array;
354
    $sum += $shipmentcost_sum;
355
336
	return $sum;
356
	return $sum;
337
}
357
}
338
358
(-)a/acqui/addorderiso2709.pl (-2 lines)
Lines 191-203 if ($op eq ""){ Link Here
191
        # 3rd add order
191
        # 3rd add order
192
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
192
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
193
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
193
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
194
        my ($invoice);
195
        # get quantity in the MARC record (1 if none)
194
        # get quantity in the MARC record (1 if none)
196
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
195
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
197
        my %orderinfo = (
196
        my %orderinfo = (
198
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
197
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
199
            "quantity", $quantity, "branchcode", $branch, 
198
            "quantity", $quantity, "branchcode", $branch, 
200
            "booksellerinvoicenumber", $invoice, 
201
            "budget_id", $budget_id, "uncertainprice", 1,
199
            "budget_id", $budget_id, "uncertainprice", 1,
202
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
200
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
203
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
201
            "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 (+213 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_gste = $total_rrp_gsti = $total_rrp;
137
    $total_est_gste = $total_est_gsti = $total_est;
138
    $gist_rrp = $gist_est = 0;
139
}
140
my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost};
141
142
my $format = "%.2f";
143
$template->param(
144
    total_rrp_gste => sprintf($format, $total_rrp_gste),
145
    total_rrp_gsti => sprintf($format, $total_rrp_gsti),
146
    total_est_gste => sprintf($format, $total_est_gste),
147
    total_est_gsti => sprintf($format, $total_est_gsti),
148
    gist_rrp => sprintf($format, $gist_rrp),
149
    gist_est => sprintf($format, $gist_est),
150
    total_gsti_shipment => sprintf($format, $total_gsti_shipment),
151
    gist => sprintf($format, $gist * 100),
152
);
153
154
my $budgets = GetBudgets();
155
my @budgets_loop;
156
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
157
foreach my $budget (@$budgets) {
158
    next unless CanUserUseBudget($loggedinuser, $budget, $flags);
159
    my %line = %{ $budget };
160
    if($shipmentcost_budgetid and $budget->{budget_id} == $shipmentcost_budgetid) {
161
        $line{selected} = 1;
162
    }
163
    push @budgets_loop, \%line;
164
}
165
166
$template->param(
167
    invoiceid        => $details->{'invoiceid'},
168
    invoicenumber    => $details->{'invoicenumber'},
169
    suppliername     => $details->{'suppliername'},
170
    supplierid       => $details->{'booksellerid'},
171
    datereceived     => $details->{'datereceived'},
172
    shipmentdate     => $details->{'shipmentdate'},
173
    billingdate      => $details->{'billingdate'},
174
    invoiceclosedate => $details->{'closedate'},
175
    shipmentcost     => sprintf($format, $details->{'shipmentcost'} || 0),
176
    orders_loop      => \@orders_loop,
177
    total_quantity   => $total_quantity,
178
    invoiceincgst    => $bookseller->{invoiceincgst},
179
    currency         => $bookseller->{listprice},
180
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
181
    budgets_loop     => \@budgets_loop,
182
);
183
184
sub get_infos {
185
    my $order = shift;
186
    my $bookseller = shift;
187
    my $qty = $order->{'quantity'} || 0;
188
    if ( !defined $order->{quantityreceived} ) {
189
        $order->{quantityreceived} = 0;
190
    }
191
    my $budget = GetBudget( $order->{'budget_id'} );
192
193
    my %line = %{ $order };
194
    $line{order_received} = ( $qty == $order->{'quantityreceived'} );
195
    $line{budget_name}    = $budget->{budget_name};
196
    $line{total} = $qty * $order->{ecost};
197
198
    if ( $line{uncertainprice} ) {
199
        $line{rrp} .= ' (Uncertain)';
200
    }
201
    if ( $line{'title'} ) {
202
        my $volume      = $order->{'volume'};
203
        my $seriestitle = $order->{'seriestitle'};
204
        $line{'title'} .= " / $seriestitle" if $seriestitle;
205
        $line{'title'} .= " / $volume"      if $volume;
206
    } else {
207
        $line{'title'} = "Deleted bibliographic notice, can't find title.";
208
    }
209
210
    return \%line;
211
}
212
213
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/invoices.pl (+156 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 $shipmentdatefrom = $input->param('shipmentdatefrom');
53
my $shipmentdateto  = $input->param('shipmentdateto');
54
my $billingdatefrom = $input->param('billingdatefrom');
55
my $billingdateto   = $input->param('billingdateto');
56
my $isbneanissn     = $input->param('isbneanissn');
57
my $title           = $input->param('title');
58
my $author          = $input->param('author');
59
my $publisher       = $input->param('publisher');
60
my $publicationyear = $input->param('publicationyear');
61
my $branch          = $input->param('branch');
62
my $op              = $input->param('op');
63
64
my @results_loop = ();
65
if($op and $op eq "do_search") {
66
    my $shipmentdatefrom_iso = C4::Dates->new($shipmentdatefrom)->output("iso");
67
    my $shipmentdateto_iso = C4::Dates->new($shipmentdateto)->output("iso");
68
    my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso");
69
    my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso");
70
    my @invoices = GetInvoices(
71
        invoicenumber => $invoicenumber,
72
        suppliername => $supplier,
73
        shipmentdatefrom => $shipmentdatefrom_iso,
74
        shipmentdateto => $shipmentdateto_iso,
75
        billingdatefrom => $billingdatefrom_iso,
76
        billingdateto => $billingdateto_iso,
77
        isbneanissn => $isbneanissn,
78
        title => $title,
79
        author => $author,
80
        publisher => $publisher,
81
        publicationyear => $publicationyear,
82
        branchcode => $branch
83
    );
84
    foreach (@invoices) {
85
        my %row = (
86
            invoiceid       => $_->{invoiceid},
87
            billingdate     => $_->{billingdate},
88
            invoicenumber   => $_->{invoicenumber},
89
            suppliername    => $_->{suppliername},
90
            receivedbiblios => $_->{receivedbiblios},
91
            receiveditems   => $_->{receiveditems},
92
            subscriptionid  => $_->{subscriptionid},
93
            closedate => $_->{closedate},
94
        );
95
        push @results_loop, \%row;
96
    }
97
}
98
99
100
# Build suppliers list
101
my @suppliers = GetBookSeller(undef);
102
my @suppliers_loop = ();
103
my $suppliername;
104
foreach (@suppliers) {
105
    my $selected = 0;
106
    if ($supplier && $supplier == $_->{'id'}) {
107
        $selected = 1;
108
        $suppliername = $_->{'name'};
109
    }
110
    my %row = (
111
        suppliername => $_->{'name'},
112
        supplierid   => $_->{'id'},
113
        selected     => $selected,
114
    );
115
    push @suppliers_loop, \%row;
116
}
117
118
# Build branches list
119
my $branches = GetBranches();
120
my @branches_loop = ();
121
my $branchname;
122
foreach (sort keys %$branches) {
123
    my $selected = 0;
124
    if ($branch && $branch eq $_) {
125
        $selected = 1;
126
        $branchname = $branches->{$_}->{'branchname'};
127
    }
128
    my %row = (
129
        branchcode => $_,
130
        branchname => $branches->{$_}->{'branchname'},
131
        selected   => $selected,
132
    );
133
    push @branches_loop, \%row;
134
}
135
136
$template->param(
137
    do_search       => ($op and $op eq "do_search") ? 1 : 0,
138
    results_loop    => \@results_loop,
139
    invoicenumber   => $invoicenumber,
140
    supplier        => $supplier,
141
    suppliername    => $suppliername,
142
    billingdatefrom => $billingdatefrom,
143
    billingdateto   => $billingdateto,
144
    isbneanissn     => $isbneanissn,
145
    title           => $title,
146
    author          => $author,
147
    publisher       => $publisher,
148
    publicationyear => $publicationyear,
149
    branch          => $branch,
150
    branchname      => $branchname,
151
    suppliers_loop  => \@suppliers_loop,
152
    branches_loop   => \@branches_loop,
153
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
154
);
155
156
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 (-13 / +55 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 75-80 use C4::Output; Link Here
75
use C4::Dates qw/format_date/;
75
use C4::Dates qw/format_date/;
76
use C4::Acquisition;
76
use C4::Acquisition;
77
use C4::Bookseller qw/ GetBookSellerFromId /;
77
use C4::Bookseller qw/ GetBookSellerFromId /;
78
use C4::Budgets;
78
79
79
my $input          = CGI->new;
80
my $input          = CGI->new;
80
my $booksellerid     = $input->param('booksellerid');
81
my $booksellerid     = $input->param('booksellerid');
Lines 84-92 my $code = $input->param('filter'); Link Here
84
my $datefrom       = $input->param('datefrom');
85
my $datefrom       = $input->param('datefrom');
85
my $dateto         = $input->param('dateto');
86
my $dateto         = $input->param('dateto');
86
my $resultsperpage = $input->param('resultsperpage');
87
my $resultsperpage = $input->param('resultsperpage');
88
my $op             = $input->param('op');
87
$resultsperpage ||= 20;
89
$resultsperpage ||= 20;
88
90
89
our ( $template, $loggedinuser, $cookie ) = get_template_and_user(
91
our ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
90
    {   template_name   => 'acqui/parcels.tmpl',
92
    {   template_name   => 'acqui/parcels.tmpl',
91
        query           => $input,
93
        query           => $input,
92
        type            => 'intranet',
94
        type            => 'intranet',
Lines 96-103 our ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
96
    }
98
    }
97
);
99
);
98
100
101
if($op and $op eq 'new') {
102
    my $invoicenumber = $input->param('invoice');
103
    my $shipmentdate = $input->param('shipmentdate');
104
    my $shipmentcost = $input->param('shipmentcost');
105
    my $shipmentcost_budgetid = $input->param('shipmentcost_budgetid');
106
    if($shipmentdate) {
107
        $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
108
    }
109
    my $invoiceid = AddInvoice(
110
        invoicenumber => $invoicenumber,
111
        booksellerid => $booksellerid,
112
        shipmentdate => $shipmentdate,
113
        shipmentcost => $shipmentcost,
114
        shipmentcost_budgetid => $shipmentcost_budgetid,
115
    );
116
    if(defined $invoiceid) {
117
        # Successful 'Add'
118
        print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
119
        exit 0;
120
    } else {
121
        $template->param(error_failed_to_create_invoice => 1);
122
    }
123
}
124
99
my $bookseller = GetBookSellerFromId($booksellerid);
125
my $bookseller = GetBookSellerFromId($booksellerid);
100
my @parcels = GetParcels( $booksellerid, $order, $code, $datefrom, $dateto );
126
my @parcels = GetInvoices(
127
    supplierid => $booksellerid,
128
    invoicenumber => $code,
129
    shipmentdatefrom => $datefrom,
130
    shipmentdateto => $dateto,
131
    order_by => $order
132
);
101
my $count_parcels = @parcels;
133
my $count_parcels = @parcels;
102
134
103
# multi page display gestion
135
# multi page display gestion
Lines 114-132 for my $i ( $startfrom .. $last_row) { Link Here
114
146
115
    push @{$loopres},
147
    push @{$loopres},
116
      { number           => $i + 1,
148
      { number           => $i + 1,
117
        code             => $p->{booksellerinvoicenumber},
149
        invoiceid        => $p->{invoiceid},
118
        nullcode         => $p->{booksellerinvoicenumber} eq 'NULL',
150
        code             => $p->{invoicenumber},
119
        emptycode        => $p->{booksellerinvoicenumber} eq q{},
151
        nullcode         => $p->{invoicenumber} eq 'NULL',
120
        raw_datereceived => $p->{datereceived},
152
        emptycode        => $p->{invoicenumber} eq q{},
121
        datereceived     => format_date( $p->{datereceived} ),
153
        raw_datereceived => $p->{shipmentdate},
122
        bibcount         => $p->{biblio},
154
        datereceived     => format_date( $p->{shipmentdate} ),
123
        reccount         => $p->{itemsreceived},
155
        bibcount         => $p->{receivedbiblios} || 0,
124
        itemcount        => $p->{itemsexpected},
156
        reccount         => $p->{receiveditems} || 0,
157
        itemcount        => $p->{itemsexpected} || 0,
125
      };
158
      };
126
}
159
}
127
if ($count_parcels) {
160
if ($count_parcels) {
128
    $template->param( searchresults => $loopres, count => $count_parcels );
161
    $template->param( searchresults => $loopres, count => $count_parcels );
129
}
162
}
163
164
my $budgets = GetBudgets();
165
my @budgets_loop;
166
foreach my $budget (@$budgets) {
167
    next unless CanUserUseBudget($loggedinuser, $budget, $flags);
168
    push @budgets_loop, $budget;
169
}
170
130
$template->param(
171
$template->param(
131
    orderby                  => $order,
172
    orderby                  => $order,
132
    filter                   => $code,
173
    filter                   => $code,
Lines 135-143 $template->param( Link Here
135
    resultsperpage           => $resultsperpage,
176
    resultsperpage           => $resultsperpage,
136
    name                     => $bookseller->{'name'},
177
    name                     => $bookseller->{'name'},
137
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
178
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
138
    datereceived_today       => C4::Dates->new()->output(),
179
    shipmentdate_today       => C4::Dates->new()->output(),
139
    booksellerid             => $booksellerid,
180
    booksellerid             => $booksellerid,
140
    GST                      => C4::Context->preference('gist'),
181
    GST                      => C4::Context->preference('gist'),
182
    budgets                  => \@budgets_loop,
141
);
183
);
142
184
143
output_html_with_http_headers $input, $cookie, $template->output;
185
output_html_with_http_headers $input, $cookie, $template->output;
(-)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 152-168 foreach my $item (@items){ Link Here
152
    }
152
    }
153
153
154
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
154
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
155
    my $basket = GetBasket( $order->{'basketno'} );
156
    $item->{'booksellerid'}            = $basket->{'booksellerid'};
157
    $item->{'ordernumber'}             = $order->{'ordernumber'};
155
    $item->{'ordernumber'}             = $order->{'ordernumber'};
158
    $item->{'basketno'}                = $order->{'basketno'};
156
    $item->{'basketno'}                = $order->{'basketno'};
159
    $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
160
    $item->{'orderdate'}               = $order->{'entrydate'};
157
    $item->{'orderdate'}               = $order->{'entrydate'};
161
    if ($item->{'basketno'}){
158
    if ($item->{'basketno'}){
162
	    my $basket = GetBasket($item->{'basketno'});
159
	    my $basket = GetBasket($item->{'basketno'});
163
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
160
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
164
	    $item->{'vendor'} = $bookseller->{'name'};
161
	    $item->{'vendor'} = $bookseller->{'name'};
165
    }
162
    }
163
    $item->{'invoiceid'}               = $order->{'invoiceid'};
164
    if($item->{invoiceid}) {
165
        my $invoice = GetInvoice($item->{invoiceid});
166
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
167
    }
166
    $item->{'datereceived'}            = $order->{'datereceived'};
168
    $item->{'datereceived'}            = $order->{'datereceived'};
167
169
168
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
170
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
(-)a/installer/data/mysql/kohastructure.sql (-2 / +24 lines)
Lines 2744-2750 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2744
  `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
2744
  `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
2745
  `totalamount` decimal(28,6) default NULL, -- not used? always NULL
2745
  `totalamount` decimal(28,6) default NULL, -- not used? always NULL
2746
  `datereceived` date default NULL, -- the date this order was received
2746
  `datereceived` date default NULL, -- the date this order was received
2747
  `booksellerinvoicenumber` mediumtext, -- the invoice number this line item was received on
2747
  invoiceid int(11) default NULL, -- id of invoice
2748
  `freight` decimal(28,6) default NULL, -- shipping costs (not used)
2748
  `freight` decimal(28,6) default NULL, -- shipping costs (not used)
2749
  `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
2749
  `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
2750
  `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
2750
  `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
Lines 2776-2782 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2776
  KEY `biblionumber` (`biblionumber`),
2776
  KEY `biblionumber` (`biblionumber`),
2777
  KEY `budget_id` (`budget_id`),
2777
  KEY `budget_id` (`budget_id`),
2778
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2778
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2779
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2779
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2780
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
2780
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2781
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2781
2782
2782
2783
Lines 2793-2798 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisiti Link Here
2793
  KEY `ordernumber` (`ordernumber`)
2794
  KEY `ordernumber` (`ordernumber`)
2794
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2795
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2795
2796
2797
2798
--
2799
-- Table structure for table aqinvoices
2800
--
2801
2802
DROP TABLE IF EXISTS aqinvoices;
2803
CREATE TABLE aqinvoices (
2804
  invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
2805
  invoicenumber mediumtext NOT NULL,    -- Name of invoice
2806
  booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
2807
  shipmentdate date default NULL,   -- date of shipment
2808
  billingdate date default NULL,    -- date of billing
2809
  closedate date default NULL,  -- invoice close date, NULL means the invoice is open
2810
  shipmentcost decimal(28,6) default NULL,  -- shipment cost
2811
  shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
2812
  PRIMARY KEY (invoiceid),
2813
  CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
2814
  CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
2815
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2816
2817
2796
--
2818
--
2797
-- Table structure for table `fieldmapping`
2819
-- Table structure for table `fieldmapping`
2798
--
2820
--
(-)a/installer/data/mysql/updatedatabase.pl (+60 lines)
Lines 5635-5640 if(C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5635
    SetVersion($DBversion);
5635
    SetVersion($DBversion);
5636
}
5636
}
5637
5637
5638
$DBversion = "XXX";
5639
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5640
    $dbh->do("
5641
        CREATE TABLE aqinvoices (
5642
          invoiceid int(11) NOT NULL AUTO_INCREMENT,
5643
          invoicenumber mediumtext NOT NULL,
5644
          booksellerid int(11) NOT NULL,
5645
          shipmentdate date default NULL,
5646
          billingdate date default NULL,
5647
          closedate date default NULL,
5648
          shipmentcost decimal(28,6) default NULL,
5649
          shipmentcost_budgetid int(11) default NULL,
5650
          PRIMARY KEY (invoiceid),
5651
          CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5652
          CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5653
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5654
    ");
5655
5656
    # Fill this new table with existing invoices
5657
    my $sth = $dbh->prepare("
5658
        SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid, aqorders.datereceived
5659
        FROM aqorders
5660
          LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5661
        WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5662
          AND aqorders.booksellerinvoicenumber != ''
5663
        GROUP BY aqorders.booksellerinvoicenumber
5664
    ");
5665
    $sth->execute;
5666
    my $results = $sth->fetchall_arrayref({});
5667
    $sth = $dbh->prepare("
5668
        INSERT INTO aqinvoices (invoicenumber, booksellerid, shipmentdate) VALUES (?,?,?)
5669
    ");
5670
    foreach(@$results) {
5671
        $sth->execute($_->{invoicenumber}, $_->{booksellerid}, $_->{datereceived});
5672
    }
5673
5674
    # Add the column in aqorders, fill it with correct value
5675
    # and then drop booksellerinvoicenumber column
5676
    $dbh->do("
5677
        ALTER TABLE aqorders
5678
        ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5679
        ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5680
    ");
5681
5682
    $dbh->do("
5683
        UPDATE aqorders, aqinvoices
5684
        SET aqorders.invoiceid = aqinvoices.invoiceid
5685
        WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5686
    ");
5687
5688
    $dbh->do("
5689
        ALTER TABLE aqorders
5690
        DROP COLUMN booksellerinvoicenumber
5691
    ");
5692
5693
    print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5694
    SetVersion ($DBversion);
5695
}
5696
5697
5638
=head1 FUNCTIONS
5698
=head1 FUNCTIONS
5639
5699
5640
=head2 TableExists($table)
5700
=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 94-100 Link Here
94
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
94
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
95
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
95
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
96
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
96
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
97
					<td>[% suggestions_loo.datereceived | $KohaDates %]</td>
97
                    <td>
98
                        [% IF suggestions_loo.datereceived %]
99
                            [% suggestions_loo.datereceived | $KohaDates %]
100
                        [% END %]
101
                    </td>
98
					<td>[% suggestions_loo.quantity %]</td>
102
					<td>[% suggestions_loo.quantity %]</td>
99
					<td>[% suggestions_loo.ecost %]</td>
103
					<td>[% suggestions_loo.ecost %]</td>
100
				</tr>
104
				</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (+173 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
            sDom: "t"
19
        }));
20
    });
21
//]]>
22
</script>
23
</head>
24
25
<body>
26
[% INCLUDE 'header.inc' %]
27
[% INCLUDE 'acquisitions-search.inc' %]
28
29
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">[% invoicenumber %]</a></div>
30
31
<div id="doc3" class="yui-t2">
32
33
<div id="bd">
34
  <div id="yui-main">
35
    <div class="yui-b">
36
      [% IF ( modified ) %]
37
        <div class="dialog">
38
          <p>Invoice has been modified</p>
39
        </div>
40
      [% END %]
41
      <h1>Invoice: [% invoicenumber %]</h1>
42
43
      <p>Supplier: [% suppliername %]</p>
44
      <form action="" method="post">
45
        <label for="shipmentdate">Shipment date:</label>
46
        <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" readonly="readonly" class="datepicker" />
47
        <p></p>
48
        <label for="billingdate">Billing date:</label>
49
        <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" class="datepicker" />
50
        <p></p>
51
        <label for="shipmentcost">Shipment cost:</label>
52
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
53
        <label for="shipment_budget_id">Budget:</label>
54
        <select id="shipment_budget_id" name="shipment_budget_id">
55
            <option value="">No budget</option>
56
          [% FOREACH budget IN budgets_loop %]
57
            [% IF ( budget.selected ) %]
58
              <option selected="selected" value="[% budget.budget_id %]">
59
            [% ELSE %]
60
              <option value="[% budget.budget_id %]">
61
            [% END %]
62
              [% budget.budget_name %]
63
            </option>
64
          [% END %]
65
        </select>
66
        <input type="hidden" name="op" value="mod" />
67
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
68
        <fieldset class="action">
69
            <input type="submit" value="Save">
70
        </fieldset>
71
      </form>
72
      <p>Status:
73
        [% IF ( invoiceclosedate ) %]
74
          Closed on [% invoiceclosedate | $KohaDates %].
75
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
76
            Reopen
77
          </a>
78
        [% ELSE %]
79
          Open.
80
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
81
            Close
82
          </a>
83
        [% END %]
84
      </p>
85
      <p>
86
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
87
      </p>
88
      <h2>Invoice details</h2>
89
      [% IF orders_loop.size %]
90
          <table id="orderst">
91
            <thead>
92
              <tr>
93
                <th>Summary</th>
94
                <th>Publisher</th>
95
                <th>Branch</th>
96
                <th>RRP</th>
97
                <th>Est.</th>
98
                <th>Qty.</th>
99
                <th>Total</th>
100
                <th>Fund</th>
101
              </tr>
102
            </thead>
103
            <tbody>
104
              [% FOREACH order IN orders_loop %]
105
                <tr>
106
                  <td><p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber %]">[% order.title %]</a>
107
                    [% IF ( order.author ) %]
108
                      <br /><em>by</em> [% order.author %]
109
                    [% END %]
110
                  </p></td>
111
                  <td>
112
                    [% IF ( order.publishercode ) %]
113
                      <p>[% order.publishercode %]
114
                        [% IF ( order.publicationyear ) %]
115
                          - [% order.publicationyear %]
116
                        [% END %]
117
                      </p>
118
                    [% END %]
119
                  </td>
120
                  <td><p>[% order.branchcode %]</p></td>
121
                  <td>[% order.rrp %]</td>
122
                  <td>[% order.ecost %]</td>
123
                  <td class="number">[% order.quantity %]</td>
124
                  <td>[% order.total %]</td>
125
                  <td>[% order.budget_name %]</td>
126
                </tr>
127
              [% END %]
128
            </tbody>
129
            <tfoot>
130
                <tr>
131
                    <th colspan="3">Total Tax Exc.</th>
132
                    <th>[% total_rrp_gste %]</th>
133
                    <th>&nbsp;</th>
134
                    <th>[% total_quantity %]</th>
135
                    <th>[% total_est_gste %]</th>
136
                    <th>&nbsp;</th>
137
                </tr>
138
                <tr>
139
                    <th colspan='3'>Tax ([% gist %]%)</th>
140
                    <th>[% gist_rrp %]</th>
141
                    <th>&nbsp;</th>
142
                    <th>&nbsp;</th>
143
                    <th>[% gist_est %]</th>
144
                    <th>&nbsp;</th>
145
                </tr>
146
                <tr>
147
                    <th colspan='3'>Total Tax Inc. ([% currency %])</th>
148
                    <th>[% total_rrp_gsti %]</th>
149
                    <th>&nbsp;</th>
150
                    <th>[% total_quantity %]</th>
151
                    <th>[% total_est_gsti %]</th>
152
                    <th>&nbsp;</th>
153
                </tr>
154
                <tr>
155
                    <th colspan="3">Total + Shipment cost ([% currency %])</th>
156
                    <th>&nbsp;</th>
157
                    <th>&nbsp;</th>
158
                    <th>[% total_quantity %]</th>
159
                    <th>[% total_gsti_shipment %]</th>
160
                    <th>&nbsp;</th>
161
                </tr>
162
            </tfoot>
163
          </table>
164
        [% ELSE %]
165
            <p>No orders yet</p>
166
        [% END %]
167
    </div>
168
  </div>
169
  <div class="yui-b">
170
    [% INCLUDE 'acquisitions-menu.inc' %]
171
  </div>
172
</div>
173
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+232 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
    $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
15
        bInfo: false,
16
        bPaginate: false,
17
        bFilter: false,
18
        sDom: "t",
19
        aoColumnDefs: [
20
            { "bSortable": false, "aTargets": [6] }
21
        ]
22
    }));
23
});
24
//]]>
25
</script>
26
</head>
27
28
<body>
29
[% INCLUDE 'header.inc' %]
30
[% INCLUDE 'acquisitions-search.inc' %]
31
32
<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>
33
34
<div id="doc3" class="yui-t2">
35
36
<div id="bd">
37
  <div id="yui-main">
38
    <div class="yui-b">
39
      <h1>Invoices</h1>
40
      [% IF ( do_search ) %]
41
        [% IF ( results_loop ) %]
42
          <table id="resultst">
43
            <thead>
44
              <tr>
45
                <th>Invoice no.</th>
46
                <th>Vendor</th>
47
                <th>Billing date</th>
48
                <th>Received biblios</th>
49
                <th>Received items</th>
50
                <th>Status</th>
51
                <th>&nbsp;</th>
52
              </tr>
53
            </thead>
54
            <tbody>
55
              [% FOREACH result IN results_loop %]
56
                <tr>
57
                  <td>[% result.invoicenumber %]</td>
58
                  <td>[% result.suppliername %]</td>
59
                  <td>
60
                    [% IF (result.billingdate) %]
61
                      [% result.billingdate | $KohaDates %]
62
                    [% END %]
63
                  </td>
64
                  <td>[% result.receivedbiblios %]</td>
65
                  <td>[% result.receiveditems %]</td>
66
                  <td>
67
                    [% IF ( result.closedate ) %]
68
                      Closed on [% result.closedate | $KohaDates %]
69
                    [% ELSE %]
70
                      Open
71
                    [% END %]
72
                  </td>
73
                  <td>
74
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
75
                    [% IF ( result.closedate ) %]
76
                      <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>
77
                    [% ELSE %]
78
                      <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>
79
                    [% END %]
80
                  </td>
81
                </tr>
82
              [% END %]
83
            </tbody>
84
          </table>
85
        [% ELSE %]
86
          <p>Sorry, but there is no results for your search.</p>
87
          <p>Search was:
88
            <ul>
89
              [% IF ( invoicenumber ) %]
90
                <li>Invoice no.: [% invoicenumber %]</li>
91
              [% END %]
92
              [% IF ( supplier ) %]
93
                <li>Vendor: [% suppliername %]</li>
94
              [% END %]
95
              [% IF ( billingdatefrom ) %]
96
                <li>Billing date:
97
                [% IF ( billingdateto ) %]
98
                  From [% billingdatefrom %]
99
                  To [% billingdateto %]
100
                [% ELSE %]
101
                  All since [% billingdatefrom %]
102
                [% END %]
103
                </li>
104
              [% ELSE %]
105
                [% IF ( billingdateto ) %]
106
                  <li>Billing date:
107
                    All until [% billingdateto %]
108
                  </li>
109
                [% END %]
110
              [% END %]
111
              [% IF ( isbneanissn ) %]
112
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
113
              [% END %]
114
              [% IF ( title ) %]
115
                <li>Title: [% title %]</li>
116
              [% END %]
117
              [% IF ( author ) %]
118
                <li>Author: [% author %]</li>
119
              [% END %]
120
              [% IF ( publisher ) %]
121
                <li>Publisher: [% publisher %]</li>
122
              [% END %]
123
              [% IF ( publicationyear ) %]
124
                <li>Publication year: [% publicationyear %]</li>
125
              [% END %]
126
              [% IF ( branch ) %]
127
                <li>Branch: [% branchname %]</li>
128
              [% END %]
129
            </ul>
130
          </p>
131
        [% END %]<!-- results_loop -->
132
      [% ELSE %]
133
        <p>Please fill in the form to the left to make a search.</p>
134
      [% END %]<!-- do_search -->
135
    </div>
136
  </div>
137
  <div class="yui-b">
138
    <form action="" method="get">
139
      <fieldset class="brief">
140
        <h3>Search filters</h3>
141
        <ol>
142
          <li>
143
            <label for="invoicenumber">Invoice no:</label>
144
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
145
          </li>
146
          <li>
147
            <label for="supplier">Supplier:</label>
148
            <select id="supplier" name="supplier">
149
              <option value="">All</option>
150
              [% FOREACH supplier IN suppliers_loop %]
151
                [% IF ( supplier.selected ) %]
152
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
153
                [% ELSE %]
154
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
155
                [% END %]
156
              [% END %]
157
            </select>
158
          </li>
159
          <li>
160
            <fieldset class="brief">
161
              <legend>Shipment date</legend>
162
              <ol>
163
                <li>
164
                  <label for="shipmentdatefrom">From:</label>
165
                  <input type="text" id="shipmentdatefrom" name="shipmentdatefrom" size="10" value="[% shipmentdatefrom %]" class="datepicker" />
166
                </li>
167
                <li>
168
                  <label for="shipmentdateto">To:</label>
169
                  <input type="text" id="shipmentdateto" name="shipmentdateto" size="10" value="[% shipmentdateto %]" class="datepicker" />
170
                </li>
171
              </ol>
172
            </fieldset>
173
          </li>
174
          <li>
175
            <fieldset class="brief">
176
              <legend>Billing date</legend>
177
              <ol>
178
                <li>
179
                  <label for="billingdatefrom">From:</label>
180
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" class="datepicker" />
181
                </li>
182
                <li>
183
                  <label for="billingdateto">To:</label>
184
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" class="datepicker" />
185
                </li>
186
              </ol>
187
            </fieldset>
188
          </li>
189
          <li>
190
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
191
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
192
          </li>
193
          <li>
194
            <label for="title">Title:</label>
195
            <input type="text" id="title" name="title" value="[% title %]" />
196
          </li>
197
          <li>
198
            <label for="author">Author:</label>
199
            <input type="text" id="author" name="author" value="[% author %]" />
200
          </li>
201
          <li>
202
            <label for="publisher">Publisher:</label>
203
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
204
          </li>
205
          <li>
206
            <label for="publicationyear">Publication year:</label>
207
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
208
          </li>
209
          <li>
210
            <label for="branch">Branch:</label>
211
            <select id="branch" name="branch">
212
              <option value="">All</option>
213
              [% FOREACH branch IN branches_loop %]
214
                [% IF ( branch.selected ) %]
215
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
216
                [% ELSE %]
217
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
218
                [% END %]
219
              [% END %]
220
            </select>
221
          </li>
222
        </ol>
223
        <fieldset class="action">
224
          <input type="submit" value="Search" />
225
        </fieldset>
226
      </fieldset>
227
      <input type="hidden" name="op" id="op" value="do_search" />
228
    </form>
229
    [% INCLUDE 'acquisitions-menu.inc' %]
230
  </div>
231
</div>
232
[% 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 (-12 / +35 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 118-126 Link Here
118
            <label for="freight">Shipping:</label>
126
            <label for="freight">Shipping:</label>
119
            <input type="text" size="20" id="freight" name="freight" />
127
            <input type="text" size="20" id="freight" name="freight" />
120
        </li> -->
128
        </li> -->
121
         <li><label for="datereceived">Shipment date: </label>
129
         <li>
122
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" class="datepicker" />
130
            <label for="shipmentdate">Shipment date: </label>
123
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
131
            <input type="text" id="shipmentdate" name="shipmentdate" maxlength="10" size="10" value="[% shipmentdate_today %]" class="datepicker" />
132
            <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
133
        </li>
134
        <li>
135
            <label for="shipmentcost">Shipment cost: </label>
136
            <input type="text" id="shipmentcost" name="shipmentcost" size="10" />
137
        </li>
138
        <li>
139
            <label for="shipmentcost_budgetid">Budget: </label>
140
            <select id="shipmentcost_budgetid" name="shipmentcost_budgetid">
141
                <option value="">No budget</option>
142
                [% FOREACH budget IN budgets %]
143
                    <option value="[% budget.budget_id %]">[% budget.budget_name %]</option>
144
                [% END %]
145
            </select>
146
        </li>
124
		</ol>
147
		</ol>
125
    </fieldset>
148
    </fieldset>
126
            <fieldset class="action"><input type="submit" class="button" value="Next" /> <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">Cancel</a></fieldset>
149
            <fieldset class="action"><input type="submit" class="button" value="Next" /> <a class="cancel" href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">Cancel</a></fieldset>
Lines 138-147 Link Here
138
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
161
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
139
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
162
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
140
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
163
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
141
                <option value="aqorders.booksellerinvoicenumber">Invoice number</option>
164
                <option value="invoicenumber">Invoice number</option>
142
                <option value="datereceived"> Date received</option>
165
                <option value="shipmentdate">Shipment date</option>
143
                <option value="datereceived desc"> Date received reverse</option>
166
                <option value="shipmentdate desc">Shipment date reverse</option>
144
                <option value="aqorders.booksellerinvoicenumber desc"> Invoice number reverse</option>
167
                <option value="invoicenumber desc">Invoice number reverse</option>
145
                </select><br />
168
                </select><br />
146
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
169
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
147
                <option value="20">20</option>
170
                <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