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 1245-1259 sub GetCancelledOrders { Link Here
1245
=head3 ModReceiveOrder
1253
=head3 ModReceiveOrder
1246
1254
1247
  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
1255
  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
1248
    $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
1256
    $unitprice, $invoiceid, $biblioitemnumber,
1249
    $freight, $bookfund, $rrp);
1257
    $bookfund, $rrp, \@received_itemnumbers);
1250
1258
1251
Updates an order, to reflect the fact that it was received, at least
1259
Updates an order, to reflect the fact that it was received, at least
1252
in part. All arguments not mentioned below update the fields with the
1260
in part. All arguments not mentioned below update the fields with the
1253
same name in the aqorders table of the Koha database.
1261
same name in the aqorders table of the Koha database.
1254
1262
1255
If a partial order is received, splits the order into two.  The received
1263
If a partial order is received, splits the order into two.
1256
portion must have a booksellerinvoicenumber.
1257
1264
1258
Updates the order with bibilionumber C<$biblionumber> and ordernumber
1265
Updates the order with bibilionumber C<$biblionumber> and ordernumber
1259
C<$ordernumber>.
1266
C<$ordernumber>.
Lines 1264-1270 C<$ordernumber>. Link Here
1264
sub ModReceiveOrder {
1271
sub ModReceiveOrder {
1265
    my (
1272
    my (
1266
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1273
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1267
        $invoiceno, $freight, $rrp, $budget_id, $datereceived, $received_items
1274
        $invoiceid, $rrp, $budget_id, $datereceived, $received_items
1268
    )
1275
    )
1269
    = @_;
1276
    = @_;
1270
1277
Lines 1305-1313 sub ModReceiveOrder { Link Here
1305
        $order->{'quantity'} = $quantrec;
1312
        $order->{'quantity'} = $quantrec;
1306
        $order->{'quantityreceived'} = $quantrec;
1313
        $order->{'quantityreceived'} = $quantrec;
1307
        $order->{'datereceived'} = $datereceived;
1314
        $order->{'datereceived'} = $datereceived;
1308
        $order->{'booksellerinvoicenumber'} = $invoiceno;
1315
        $order->{'invoiceid'} = $invoiceid;
1309
        $order->{'unitprice'} = $cost;
1316
        $order->{'unitprice'} = $cost;
1310
        $order->{'freight'} = $freight;
1311
        $order->{'rrp'} = $rrp;
1317
        $order->{'rrp'} = $rrp;
1312
        $order->{'orderstatus'} = 3;    # totally received
1318
        $order->{'orderstatus'} = 3;    # totally received
1313
        $new_ordernumber = NewOrder($order);
1319
        $new_ordernumber = NewOrder($order);
Lines 1319-1328 sub ModReceiveOrder { Link Here
1319
        }
1325
        }
1320
    } else {
1326
    } else {
1321
        $sth=$dbh->prepare("update aqorders
1327
        $sth=$dbh->prepare("update aqorders
1322
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1328
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1323
                                unitprice=?,freight=?,rrp=?
1329
                                unitprice=?,rrp=?
1324
                            where biblionumber=? and ordernumber=?");
1330
                            where biblionumber=? and ordernumber=?");
1325
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1331
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1326
        $sth->finish;
1332
        $sth->finish;
1327
    }
1333
    }
1328
    return ($datereceived, $new_ordernumber);
1334
    return ($datereceived, $new_ordernumber);
Lines 1370-1376 sub CancelReceipt { Link Here
1370
            UPDATE aqorders
1376
            UPDATE aqorders
1371
            SET quantityreceived = ?,
1377
            SET quantityreceived = ?,
1372
                datereceived = ?,
1378
                datereceived = ?,
1373
                booksellerinvoicenumber = ?
1379
                invoiceid = ?
1374
            WHERE ordernumber = ?
1380
            WHERE ordernumber = ?
1375
        };
1381
        };
1376
        $sth = $dbh->prepare($query);
1382
        $sth = $dbh->prepare($query);
Lines 1597-1605 sub GetParcel { Link Here
1597
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1603
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1598
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1604
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1599
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1605
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1606
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1600
        WHERE
1607
        WHERE
1601
            aqbasket.booksellerid = ?
1608
            aqbasket.booksellerid = ?
1602
            AND aqorders.booksellerinvoicenumber LIKE ?
1609
            AND aqinvoices.invoicenumber LIKE ?
1603
            AND aqorders.datereceived = ? ";
1610
            AND aqorders.datereceived = ? ";
1604
1611
1605
    my @query_params = ( $supplierid, $code, $datereceived );
1612
    my @query_params = ( $supplierid, $code, $datereceived );
Lines 1672-1689 sub GetParcels { Link Here
1672
    my $dbh    = C4::Context->dbh;
1679
    my $dbh    = C4::Context->dbh;
1673
    my @query_params = ();
1680
    my @query_params = ();
1674
    my $strsth ="
1681
    my $strsth ="
1675
        SELECT  aqorders.booksellerinvoicenumber,
1682
        SELECT  aqinvoices.invoicenumber,
1676
                datereceived,purchaseordernumber,
1683
                datereceived,purchaseordernumber,
1677
                count(DISTINCT biblionumber) AS biblio,
1684
                count(DISTINCT biblionumber) AS biblio,
1678
                sum(quantity) AS itemsexpected,
1685
                sum(quantity) AS itemsexpected,
1679
                sum(quantityreceived) AS itemsreceived
1686
                sum(quantityreceived) AS itemsreceived
1680
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1687
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1688
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1681
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1689
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1682
    ";
1690
    ";
1683
    push @query_params, $bookseller;
1691
    push @query_params, $bookseller;
1684
1692
1685
    if ( defined $code ) {
1693
    if ( defined $code ) {
1686
        $strsth .= ' and aqorders.booksellerinvoicenumber like ? ';
1694
        $strsth .= ' and aqinvoices.invoicenumber like ? ';
1687
        # add a % to the end of the code to allow stemming.
1695
        # add a % to the end of the code to allow stemming.
1688
        push @query_params, "$code%";
1696
        push @query_params, "$code%";
1689
    }
1697
    }
Lines 1698-1704 sub GetParcels { Link Here
1698
        push @query_params, $dateto;
1706
        push @query_params, $dateto;
1699
    }
1707
    }
1700
1708
1701
    $strsth .= "group by aqorders.booksellerinvoicenumber,datereceived ";
1709
    $strsth .= "group by aqinvoices.invoicenumber,datereceived ";
1702
1710
1703
    # can't use a placeholder to place this column name.
1711
    # can't use a placeholder to place this column name.
1704
    # but, we could probably be checking to make sure it is a column that will be fetched.
1712
    # but, we could probably be checking to make sure it is a column that will be fetched.
Lines 1915-1921 sub GetHistory { Link Here
1915
            aqorders.quantityreceived,
1923
            aqorders.quantityreceived,
1916
            aqorders.ecost,
1924
            aqorders.ecost,
1917
            aqorders.ordernumber,
1925
            aqorders.ordernumber,
1918
            aqorders.booksellerinvoicenumber as invoicenumber,
1926
            aqinvoices.invoicenumber,
1919
            aqbooksellers.id as id,
1927
            aqbooksellers.id as id,
1920
            aqorders.biblionumber
1928
            aqorders.biblionumber
1921
        FROM aqorders
1929
        FROM aqorders
Lines 1923-1929 sub GetHistory { Link Here
1923
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1931
        LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1924
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1932
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1925
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1933
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1926
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1934
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
1935
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
1927
1936
1928
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1937
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1929
    if ( C4::Context->preference("IndependantBranches") );
1938
    if ( C4::Context->preference("IndependantBranches") );
Lines 1977-1984 sub GetHistory { Link Here
1977
    }
1986
    }
1978
1987
1979
    if ($booksellerinvoicenumber) {
1988
    if ($booksellerinvoicenumber) {
1980
        $query .= " AND (aqorders.booksellerinvoicenumber LIKE ? OR aqbasket.booksellerinvoicenumber LIKE ?)";
1989
        $query .= " AND aqinvoices.invoicenumber LIKE ? ";
1981
        push @query_params, "%$booksellerinvoicenumber%", "%$booksellerinvoicenumber%";
1990
        push @query_params, "%$booksellerinvoicenumber%";
1982
    }
1991
    }
1983
1992
1984
    if ($basketgroupname) {
1993
    if ($basketgroupname) {
Lines 2124-2130 sub AddClaim { Link Here
2124
        ";
2133
        ";
2125
    my $sth = $dbh->prepare($query);
2134
    my $sth = $dbh->prepare($query);
2126
    $sth->execute($ordernumber);
2135
    $sth->execute($ordernumber);
2136
}
2137
2138
=head3 GetInvoices
2139
2140
    my @invoices = GetInvoices(
2141
        invoicenumber => $invoicenumber,
2142
        suppliername => $suppliername,
2143
        shipmentdatefrom => $shipmentdatefrom, # ISO format
2144
        shipmentdateto => $shipmentdateto, # ISO format
2145
        billingdatefrom => $billingdatefrom, # ISO format
2146
        billingdateto => $billingdateto, # ISO format
2147
        isbneanissn => $isbn_or_ean_or_issn,
2148
        title => $title,
2149
        author => $author,
2150
        publisher => $publisher,
2151
        publicationyear => $publicationyear,
2152
        branchcode => $branchcode,
2153
        order_by => $order_by
2154
    );
2155
2156
Return a list of invoices that match all given criteria.
2157
2158
$order_by is "column_name (asc|desc)", where column_name is any of
2159
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
2160
'shipmentcost', 'shipmentcost_budgetid'.
2161
2162
asc is the default if omitted
2163
2164
=cut
2165
2166
sub GetInvoices {
2167
    my %args = @_;
2168
2169
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2170
        closedate shipmentcost shipmentcost_budgetid);
2171
2172
    my $dbh = C4::Context->dbh;
2173
    my $query = qq{
2174
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername,
2175
          COUNT(
2176
            DISTINCT IF(
2177
              aqorders.datereceived IS NOT NULL,
2178
              aqorders.biblionumber,
2179
              NULL
2180
            )
2181
          ) AS receivedbiblios,
2182
          SUM(aqorders.quantityreceived) AS receiveditems
2183
        FROM aqinvoices
2184
          LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
2185
          LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid
2186
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2187
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
2188
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
2189
    };
2190
2191
    my @bind_args;
2192
    my @bind_strs;
2193
    if($args{supplierid}) {
2194
        push @bind_strs, " aqinvoices.booksellerid = ? ";
2195
        push @bind_args, $args{supplierid};
2196
    }
2197
    if($args{invoicenumber}) {
2198
        push @bind_strs, " aqinvoices.invoicenumber LIKE ? ";
2199
        push @bind_args, "%$args{invoicenumber}%";
2200
    }
2201
    if($args{suppliername}) {
2202
        push @bind_strs, " aqbooksellers.name LIKE ? ";
2203
        push @bind_args, "%$args{suppliername}%";
2204
    }
2205
    if($args{shipmentdatefrom}) {
2206
        push @bind_strs, " aqinvoices.shipementdate >= ? ";
2207
        push @bind_args, $args{shipementdatefrom};
2208
    }
2209
    if($args{shipmentdateto}) {
2210
        push @bind_strs, " aqinvoices.shipementdate <= ? ";
2211
        push @bind_args, $args{shipementdateto};
2212
    }
2213
    if($args{billingdatefrom}) {
2214
        push @bind_strs, " aqinvoices.billingdate >= ? ";
2215
        push @bind_args, $args{billingdatefrom};
2216
    }
2217
    if($args{billingdateto}) {
2218
        push @bind_strs, " aqinvoices.billingdate <= ? ";
2219
        push @bind_args, $args{billingdateto};
2220
    }
2221
    if($args{isbneanissn}) {
2222
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
2223
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
2224
    }
2225
    if($args{title}) {
2226
        push @bind_strs, " biblio.title LIKE ? ";
2227
        push @bind_args, $args{title};
2228
    }
2229
    if($args{author}) {
2230
        push @bind_strs, " biblio.author LIKE ? ";
2231
        push @bind_args, $args{author};
2232
    }
2233
    if($args{publisher}) {
2234
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
2235
        push @bind_args, $args{publisher};
2236
    }
2237
    if($args{publicationyear}) {
2238
        push @bind_strs, " biblioitems.publicationyear = ? ";
2239
        push @bind_args, $args{publicationyear};
2240
    }
2241
    if($args{branchcode}) {
2242
        push @bind_strs, " aqorders.branchcode = ? ";
2243
        push @bind_args, $args{branchcode};
2244
    }
2245
2246
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
2247
    $query .= " GROUP BY aqinvoices.invoiceid ";
2248
2249
    if($args{order_by}) {
2250
        my ($column, $direction) = split / /, $args{order_by};
2251
        if(grep /^$column$/, @columns) {
2252
            $direction ||= 'ASC';
2253
            $query .= " ORDER BY $column $direction";
2254
        }
2255
    }
2127
2256
2257
    my $sth = $dbh->prepare($query);
2258
    $sth->execute(@bind_args);
2259
2260
    my $results = $sth->fetchall_arrayref({});
2261
    return @$results;
2262
}
2263
2264
=head3 GetInvoice
2265
2266
    my $invoice = GetInvoice($invoiceid);
2267
2268
Get informations about invoice with given $invoiceid
2269
2270
Return a hash filled with aqinvoices.* fields
2271
2272
=cut
2273
2274
sub GetInvoice {
2275
    my ($invoiceid) = @_;
2276
    my $invoice;
2277
2278
    return unless $invoiceid;
2279
2280
    my $dbh = C4::Context->dbh;
2281
    my $query = qq{
2282
        SELECT *
2283
        FROM aqinvoices
2284
        WHERE invoiceid = ?
2285
    };
2286
    my $sth = $dbh->prepare($query);
2287
    $sth->execute($invoiceid);
2288
2289
    $invoice = $sth->fetchrow_hashref;
2290
    return $invoice;
2291
}
2292
2293
=head3 GetInvoiceDetails
2294
2295
    my $invoice = GetInvoiceDetails($invoiceid)
2296
2297
Return informations about an invoice + the list of related order lines
2298
2299
Orders informations are in $invoice->{orders} (array ref)
2300
2301
=cut
2302
2303
sub GetInvoiceDetails {
2304
    my ($invoiceid) = @_;
2305
    my $invoice;
2306
2307
    return unless $invoiceid;
2308
2309
    my $dbh = C4::Context->dbh;
2310
    my $query = qq{
2311
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername
2312
        FROM aqinvoices
2313
          LEFT JOIN aqbooksellers ON aqinvoices.booksellerid = aqbooksellers.id
2314
        WHERE invoiceid = ?
2315
    };
2316
    my $sth = $dbh->prepare($query);
2317
    $sth->execute($invoiceid);
2318
2319
    $invoice = $sth->fetchrow_hashref;
2320
2321
    $query = qq{
2322
        SELECT aqorders.*, biblio.*
2323
        FROM aqorders
2324
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2325
        WHERE invoiceid = ?
2326
    };
2327
    $sth = $dbh->prepare($query);
2328
    $sth->execute($invoiceid);
2329
    $invoice->{orders} = $sth->fetchall_arrayref({});
2330
    $invoice->{orders} ||= []; # force an empty arrayref if fetchall_arrayref fails
2331
2332
    return $invoice;
2333
}
2334
2335
=head3 AddInvoice
2336
2337
    my $invoiceid = AddInvoice(
2338
        invoicenumber => $invoicenumber,
2339
        booksellerid => $booksellerid,
2340
        shipmentdate => $shipmentdate,
2341
        billingdate => $billingdate,
2342
        closedate => $closedate,
2343
        shipmentcost => $shipmentcost,
2344
        shipmentcost_budgetid => $shipmentcost_budgetid
2345
    );
2346
2347
Create a new invoice and return its id or undef if it fails.
2348
2349
=cut
2350
2351
sub AddInvoice {
2352
    my %invoice = @_;
2353
2354
    return unless(%invoice and $invoice{invoicenumber});
2355
2356
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2357
        closedate shipmentcost shipmentcost_budgetid);
2358
2359
    my @set_strs;
2360
    my @set_args;
2361
    foreach my $key (keys %invoice) {
2362
        if(0 < grep(/^$key$/, @columns)) {
2363
            push @set_strs, "$key = ?";
2364
            push @set_args, ($invoice{$key} || undef);
2365
        }
2366
    }
2367
2368
    my $rv;
2369
    if(@set_args > 0) {
2370
        my $dbh = C4::Context->dbh;
2371
        my $query = "INSERT INTO aqinvoices SET ";
2372
        $query .= join (",", @set_strs);
2373
        my $sth = $dbh->prepare($query);
2374
        $rv = $sth->execute(@set_args);
2375
        if($rv) {
2376
            $rv = $dbh->last_insert_id(undef, undef, 'aqinvoices', undef);
2377
        }
2378
    }
2379
    return $rv;
2380
}
2381
2382
=head3 ModInvoice
2383
2384
    ModInvoice(
2385
        invoiceid => $invoiceid,    # Mandatory
2386
        invoicenumber => $invoicenumber,
2387
        booksellerid => $booksellerid,
2388
        shipmentdate => $shipmentdate,
2389
        billingdate => $billingdate,
2390
        closedate => $closedate,
2391
        shipmentcost => $shipmentcost,
2392
        shipmentcost_budgetid => $shipmentcost_budgetid
2393
    );
2394
2395
Modify an invoice, invoiceid is mandatory.
2396
2397
Return undef if it fails.
2398
2399
=cut
2400
2401
sub ModInvoice {
2402
    my %invoice = @_;
2403
2404
    return unless(%invoice and $invoice{invoiceid});
2405
2406
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2407
        closedate shipmentcost shipmentcost_budgetid);
2408
2409
    my @set_strs;
2410
    my @set_args;
2411
    foreach my $key (keys %invoice) {
2412
        if(0 < grep(/^$key$/, @columns)) {
2413
            push @set_strs, "$key = ?";
2414
            push @set_args, ($invoice{$key} || undef);
2415
        }
2416
    }
2417
2418
    my $dbh = C4::Context->dbh;
2419
    my $query = "UPDATE aqinvoices SET ";
2420
    $query .= join(",", @set_strs);
2421
    $query .= " WHERE invoiceid = ?";
2422
2423
    my $sth = $dbh->prepare($query);
2424
    $sth->execute(@set_args, $invoice{invoiceid});
2425
}
2426
2427
=head3 CloseInvoice
2428
2429
    CloseInvoice($invoiceid);
2430
2431
Close an invoice.
2432
2433
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2434
2435
=cut
2436
2437
sub CloseInvoice {
2438
    my ($invoiceid) = @_;
2439
2440
    return unless $invoiceid;
2441
2442
    my $dbh = C4::Context->dbh;
2443
    my $query = qq{
2444
        UPDATE aqinvoices
2445
        SET closedate = CAST(NOW() AS DATE)
2446
        WHERE invoiceid = ?
2447
    };
2448
    my $sth = $dbh->prepare($query);
2449
    $sth->execute($invoiceid);
2450
}
2451
2452
=head3 ReopenInvoice
2453
2454
    ReopenInvoice($invoiceid);
2455
2456
Reopen an invoice
2457
2458
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2459
2460
=cut
2461
2462
sub ReopenInvoice {
2463
    my ($invoiceid) = @_;
2464
2465
    return unless $invoiceid;
2466
2467
    my $dbh = C4::Context->dbh;
2468
    my $query = qq{
2469
        UPDATE aqinvoices
2470
        SET closedate = NULL
2471
        WHERE invoiceid = ?
2472
    };
2473
    my $sth = $dbh->prepare($query);
2474
    $sth->execute($invoiceid);
2128
}
2475
}
2129
2476
2130
1;
2477
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 (-7 / +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 68-75 if ($quantityrec > $origquantityrec ) { Link Here
68
    if ( $quantityrec > 0 ) {
68
    if ( $quantityrec > 0 ) {
69
        ($datereceived, $new_ordernumber) = ModReceiveOrder(
69
        ($datereceived, $new_ordernumber) = ModReceiveOrder(
70
            $biblionumber, $ordernumber, $quantityrec, $user, $unitprice,
70
            $biblionumber, $ordernumber, $quantityrec, $user, $unitprice,
71
            $invoiceno, $freight, $replacement, undef, $datereceived,
71
            $invoiceid, $replacement, undef, $datereceived, \@received_items);
72
            \@received_items);
73
    }
72
    }
74
73
75
    # now, add items if applicable
74
    # now, add items if applicable
Lines 112-118 if ($quantityrec > $origquantityrec ) { Link Here
112
111
113
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
112
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
114
113
115
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&booksellerid=$booksellerid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
114
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
116
115
117
################################ End of script ################################
116
################################ End of script ################################
118
117
(-)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 (-152 / +141 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-106 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');
75
my $bookseller=GetBookSellerFromId($booksellerid);
76
77
my $invoice=$input->param('invoice') || '';
78
my $freight=$input->param('freight');
79
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
80
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
81
my $op = $input->param('op') // '';
82
my $datereceived = ( $op eq ('new' or 'search' ) )
83
    ? C4::Dates->new($input->param('datereceived'))
84
    :  C4::Dates->new($input->param('datereceived'), 'iso');
85
$datereceived = C4::Dates->new() unless $datereceived;
86
my $code            = $input->param('code');
87
my @rcv_err         = $input->param('error');
88
my @rcv_err_barcode = $input->param('error_bc');
89
my $startfrom=$input->param('startfrom');
90
my $resultsperpage = $input->param('resultsperpage');
91
$resultsperpage = 20 unless ($resultsperpage);
92
$startfrom=0 unless ($startfrom);
93
73
94
my ($template, $loggedinuser, $cookie)
74
my ($template, $loggedinuser, $cookie)
95
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
75
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
96
                 query => $input,
76
                 query => $input,
97
				 type => "intranet",
77
                 type => "intranet",
98
                 authnotrequired => 0,
78
                 authnotrequired => 0,
99
                 flagsrequired => {acquisition => 'order_receive'},
79
                 flagsrequired => {acquisition => 'order_receive'},
100
                 debug => 1,
80
                 debug => 1,
101
});
81
});
102
82
103
if($op eq 'cancelreceipt') {
83
my $invoiceid = $input->param('invoiceid');
84
my $op = $input->param('op') // '';
85
86
if ($op eq 'cancelreceipt') {
104
    my $ordernumber = $input->param('ordernumber');
87
    my $ordernumber = $input->param('ordernumber');
105
    my $parent_ordernumber = CancelReceipt($ordernumber);
88
    my $parent_ordernumber = CancelReceipt($ordernumber);
106
    unless($parent_ordernumber) {
89
    unless($parent_ordernumber) {
Lines 108-113 if($op eq 'cancelreceipt') { Link Here
108
    }
91
    }
109
}
92
}
110
93
94
my $invoice = GetInvoiceDetails($invoiceid);
95
my $booksellerid = $invoice->{booksellerid};
96
my $bookseller = GetBookSellerFromId($booksellerid);
97
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
98
my $datereceived = C4::Dates->new();
99
my $code            = $input->param('code');
100
my @rcv_err         = $input->param('error');
101
my @rcv_err_barcode = $input->param('error_bc');
102
my $startfrom=$input->param('startfrom');
103
my $resultsperpage = $input->param('resultsperpage');
104
$resultsperpage = 20 unless ($resultsperpage);
105
$startfrom=0 unless ($startfrom);
106
107
108
111
# If receiving error, report the error (coming from finishrecieve.pl(sic)).
109
# If receiving error, report the error (coming from finishrecieve.pl(sic)).
112
if( scalar(@rcv_err) ) {
110
if( scalar(@rcv_err) ) {
113
	my $cnt=0;
111
	my $cnt=0;
Lines 122-131 if( scalar(@rcv_err) ) { Link Here
122
}
120
}
123
121
124
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
122
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
125
my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso'));
123
my @parcelitems   = @{ $invoice->{orders} };
126
my $countlines    = scalar @parcelitems;
124
my $countlines    = scalar @parcelitems;
127
my $totalprice    = 0;
125
my $totalprice    = 0;
128
my $totalfreight  = 0;
129
my $totalquantity = 0;
126
my $totalquantity = 0;
130
my $total;
127
my $total;
131
my $tototal;
128
my $tototal;
Lines 133-147 my @loop_received = (); Link Here
133
130
134
for (my $i = 0 ; $i < $countlines ; $i++) {
131
for (my $i = 0 ; $i < $countlines ; $i++) {
135
132
136
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
133
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};
137
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
138
    $parcelitems[$i]->{'unitprice'} += 0;
134
    $parcelitems[$i]->{'unitprice'} += 0;
139
    my %line;
135
    my %line;
140
    %line          = %{ $parcelitems[$i] };
136
    %line          = %{ $parcelitems[$i] };
141
    $line{invoice} = $invoice;
137
    $line{invoice} = $invoice->{invoicenumber};
142
    $line{gst}     = $gst;
138
    $line{gst}     = $gst;
143
    $line{total} = sprintf($cfstr, $total);
139
    $line{total} = sprintf($cfstr, $total);
144
    $line{booksellerid} = $booksellerid;
140
    $line{booksellerid} = $invoice->{booksellerid};
145
    $totalprice += $parcelitems[$i]->{'unitprice'};
141
    $totalprice += $parcelitems[$i]->{'unitprice'};
146
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
142
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
147
143
Lines 159-314 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
159
    }
155
    }
160
156
161
    push @loop_received, \%line;
157
    push @loop_received, \%line;
162
    #double FIXME - totalfreight is redefined later.
163
164
# 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..
165
    if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
166
        warn "FREIGHT CHARGE MISMATCH!!";
167
    }
168
    $totalfreight = $parcelitems[$i]->{'freight'};
169
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
158
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
170
    $tototal       += $total;
159
    $tototal       += $total;
171
}
160
}
172
161
173
# We get the pending orders either all or filtered
162
if(!defined $invoice->{closedate}) {
174
my $pendingorders;
163
    my $pendingorders;
175
if($input->param('op') eq "search"){
164
    if($input->param('op') eq "search"){
176
    my $search   = $input->param('summaryfilter') || '';
165
        my $search   = $input->param('summaryfilter') || '';
177
    my $ean      = $input->param('eanfilter') || '';
166
        my $ean      = $input->param('eanfilter') || '';
178
    my $basketno = $input->param('basketfilter') || '';
167
        my $basketno = $input->param('basketfilter') || '';
179
    my $orderno  = $input->param('orderfilter') || '';
168
        my $orderno  = $input->param('orderfilter') || '';
180
    my $grouped;
169
        my $grouped;
181
    my $owner;
170
        my $owner;
182
    $pendingorders = GetPendingOrders($booksellerid,$grouped,$owner,$basketno,$orderno,$search,$ean);
171
        $pendingorders = GetPendingOrders($booksellerid,$grouped,$owner,$basketno,$orderno,$search,$ean);
183
}else{
172
    }else{
184
    $pendingorders = GetPendingOrders($booksellerid);
173
        $pendingorders = GetPendingOrders($booksellerid);
185
}
174
    }
186
my $countpendings = scalar @$pendingorders;
175
    my $countpendings = scalar @$pendingorders;
187
176
188
# pending orders totals
177
    # pending orders totals
189
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
178
    my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
190
my $ordergrandtotal;
179
    my $ordergrandtotal;
191
my @loop_orders = ();
180
    my @loop_orders = ();
192
for (my $i = 0 ; $i < $countpendings ; $i++) {
181
    for (my $i = 0 ; $i < $countpendings ; $i++) {
193
    my %line;
182
        my %line;
194
    %line = %{$pendingorders->[$i]};
183
        %line = %{$pendingorders->[$i]};
195
   
184
196
    $line{quantity}+=0;
185
        $line{quantity}+=0;
197
    $line{quantityreceived}+=0;
186
        $line{quantityreceived}+=0;
198
    $line{unitprice}+=0;
187
        $line{unitprice}+=0;
199
    $totalPunitprice += $line{unitprice};
188
        $totalPunitprice += $line{unitprice};
200
    $totalPquantity +=$line{quantity};
189
        $totalPquantity +=$line{quantity};
201
    $totalPqtyrcvd +=$line{quantityreceived};
190
        $totalPqtyrcvd +=$line{quantityreceived};
202
    $totalPecost += $line{ecost};
191
        $totalPecost += $line{ecost};
203
    $line{ecost} = sprintf("%.2f",$line{ecost});
192
        $line{ecost} = sprintf("%.2f",$line{ecost});
204
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
193
        $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
205
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
194
        $line{unitprice} = sprintf("%.2f",$line{unitprice});
206
    $line{invoice} = $invoice;
195
        $line{invoice} = $invoice;
207
    $line{gst} = $gst;
196
        $line{gst} = $gst;
208
    $line{total} = $total;
197
        $line{total} = $total;
209
    $line{booksellerid} = $booksellerid;
198
        $line{booksellerid} = $booksellerid;
210
    $ordergrandtotal += $line{ecost} * $line{quantity};
199
        $ordergrandtotal += $line{ecost} * $line{quantity};
211
    
200
212
    my $biblionumber = $line{'biblionumber'};
201
        my $biblionumber = $line{'biblionumber'};
213
    my $countbiblio = CountBiblioInOrders($biblionumber);
202
        my $countbiblio = CountBiblioInOrders($biblionumber);
214
    my $ordernumber = $line{'ordernumber'};
203
        my $ordernumber = $line{'ordernumber'};
215
    my @subscriptions = GetSubscriptionsId ($biblionumber);
204
        my @subscriptions = GetSubscriptionsId ($biblionumber);
216
    my $itemcount = GetItemsCount($biblionumber);
205
        my $itemcount = GetItemsCount($biblionumber);
217
    my $holds  = GetHolds ($biblionumber);
206
        my $holds  = GetHolds ($biblionumber);
218
    my @items = GetItemnumbersFromOrder( $ordernumber );
207
        my @items = GetItemnumbersFromOrder( $ordernumber );
219
    my $itemholds;
208
        my $itemholds;
220
    foreach my $item (@items){
209
        foreach my $item (@items){
221
        my $nb = GetItemHolds($biblionumber, $item);
210
            my $nb = GetItemHolds($biblionumber, $item);
222
        if ($nb){
211
            if ($nb){
223
            $itemholds += $nb;
212
                $itemholds += $nb;
213
            }
224
        }
214
        }
215
216
        my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
217
        $line{suggestionid}         = $suggestion->{suggestionid};
218
        $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
219
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
220
221
        # 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
222
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
223
        $line{items}                = ($itemcount) - (scalar @items);
224
        $line{left_item}            = 1 if $line{items} >= 1;
225
        $line{left_biblio}          = 1 if $countbiblio > 1;
226
        $line{biblios}              = $countbiblio - 1;
227
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
228
        $line{subscriptions}        = scalar @subscriptions;
229
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
230
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
231
        $line{holds}                = $holds;
232
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
233
        
234
        
235
        push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
225
    }
236
    }
226
237
227
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
238
    my $count = $countpendings;
228
    $line{suggestionid}         = $suggestion->{suggestionid};
229
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
230
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
231
239
232
    # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
240
    if ($count>$resultsperpage){
233
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
241
        my $displaynext=0;
234
    $line{items}                = ($itemcount) - (scalar @items);
242
        my $displayprev=$startfrom;
235
    $line{left_item}            = 1 if $line{items} >= 1;
243
        if(($count - ($startfrom+$resultsperpage)) > 0 ) {
236
    $line{left_biblio}          = 1 if $countbiblio > 1;
244
            $displaynext = 1;
237
    $line{biblios}              = $countbiblio - 1;
245
        }
238
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
239
    $line{subscriptions}        = scalar @subscriptions;
240
    $line{left_holds}           = 1 if $holds >= 1;
241
    $line{left_holds_on_order}  = 1 if $line{left_holds} == 1 && ($line{items} == 0 || $itemholds );
242
    $line{holds}                = $holds;
243
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
244
    
245
    
246
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
247
}
248
$freight = $totalfreight unless $freight;
249
my $count = $countpendings;
250
251
if ($count>$resultsperpage){
252
    my $displaynext=0;
253
    my $displayprev=$startfrom;
254
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
255
        $displaynext = 1;
256
    }
257
246
258
    my @numbers = ();
247
        my @numbers = ();
259
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
248
        for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
260
            my $highlight=0;
249
                my $highlight=0;
261
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
250
                ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
262
            push @numbers, { number => $i,
251
                push @numbers, { number => $i,
263
                highlight => $highlight ,
252
                    highlight => $highlight ,
264
                startfrom => ($i-1)*$resultsperpage};
253
                    startfrom => ($i-1)*$resultsperpage};
265
    }
254
        }
266
255
267
    my $from = $startfrom*$resultsperpage+1;
256
        my $from = $startfrom*$resultsperpage+1;
268
    my $to;
257
        my $to;
269
    if($count < (($startfrom+1)*$resultsperpage)){
258
        if($count < (($startfrom+1)*$resultsperpage)){
270
        $to = $count;
259
            $to = $count;
271
    } else {
260
        } else {
272
        $to = (($startfrom+1)*$resultsperpage);
261
            $to = (($startfrom+1)*$resultsperpage);
262
        }
263
        $template->param(numbers=>\@numbers,
264
                         displaynext=>$displaynext,
265
                         displayprev=>$displayprev,
266
                         nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
267
                         prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
268
                        );
273
    }
269
    }
274
    $template->param(numbers=>\@numbers,
270
275
                     displaynext=>$displaynext,
271
    $template->param(
276
                     displayprev=>$displayprev,
272
        countpending => $countpendings,
277
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
273
        loop_orders  => \@loop_orders,
278
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
274
        ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
279
                    );
275
        totalPunitprice => sprintf("%.2f", $totalPunitprice),
276
        totalPquantity  => $totalPquantity,
277
        totalPqtyrcvd   => $totalPqtyrcvd,
278
        totalPecost     => sprintf("%.2f", $totalPecost),
279
    );
280
}
280
}
281
281
282
#$totalfreight=$freight;
283
$tototal = $tototal + $freight;
284
282
285
$template->param(
283
$template->param(
286
    invoice               => $invoice,
284
    invoiceid             => $invoice->{invoiceid},
285
    invoice               => $invoice->{invoicenumber},
286
    invoiceclosedate      => $invoice->{closedate},
287
    datereceived          => $datereceived->output('iso'),
287
    datereceived          => $datereceived->output('iso'),
288
    invoicedatereceived   => $datereceived->output('iso'),
288
    invoicedatereceived   => $datereceived->output('iso'),
289
    formatteddatereceived => $datereceived->output(),
289
    formatteddatereceived => $datereceived->output(),
290
    name                  => $bookseller->{'name'},
290
    name                  => $bookseller->{'name'},
291
    booksellerid            => $booksellerid,
291
    booksellerid          => $bookseller->{id},
292
    gst                   => $gst,
292
    gst                   => $gst,
293
    freight               => $freight,
294
    invoice               => $invoice,
295
    countreceived         => $countlines,
293
    countreceived         => $countlines,
296
    loop_received         => \@loop_received,
294
    loop_received         => \@loop_received,
297
    countpending          => $countpendings,
298
    loop_orders           => \@loop_orders,
299
    totalprice            => sprintf($cfstr, $totalprice),
295
    totalprice            => sprintf($cfstr, $totalprice),
300
    totalfreight          => $totalfreight,
301
    totalquantity         => $totalquantity,
296
    totalquantity         => $totalquantity,
302
    tototal               => sprintf($cfstr, $tototal),
297
    tototal               => sprintf($cfstr, $tototal),
303
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
304
    gst                   => $gst,
298
    gst                   => $gst,
305
    grandtot              => sprintf($cfstr, $tototal + $gst),
299
    grandtot              => sprintf($cfstr, $tototal + $gst),
306
    totalPunitprice       => sprintf("%.2f", $totalPunitprice),
307
    totalPquantity        => $totalPquantity,
308
    totalPqtyrcvd         => $totalPqtyrcvd,
309
    totalPecost           => sprintf("%.2f", $totalPecost),
310
    resultsperpage        => $resultsperpage,
300
    resultsperpage        => $resultsperpage,
311
    (uc(C4::Context->preference("marcflavour"))) => 1
301
    (uc(C4::Context->preference("marcflavour"))) => 1
312
);
302
);
313
output_html_with_http_headers $input, $cookie, $template->output;
303
output_html_with_http_headers $input, $cookie, $template->output;
314
 
(-)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 2748-2754 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2748
  `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
2748
  `listprice` decimal(28,6) default NULL, -- the vendor price for this line item
2749
  `totalamount` decimal(28,6) default NULL, -- not used? always NULL
2749
  `totalamount` decimal(28,6) default NULL, -- not used? always NULL
2750
  `datereceived` date default NULL, -- the date this order was received
2750
  `datereceived` date default NULL, -- the date this order was received
2751
  `booksellerinvoicenumber` mediumtext, -- the invoice number this line item was received on
2751
  invoiceid int(11) default NULL, -- id of invoice
2752
  `freight` decimal(28,6) default NULL, -- shipping costs (not used)
2752
  `freight` decimal(28,6) default NULL, -- shipping costs (not used)
2753
  `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
2753
  `unitprice` decimal(28,6) default NULL, -- the actual cost entered when receiving this line item
2754
  `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
2754
  `quantityreceived` smallint(6) NOT NULL default 0, -- the quantity that have been received so far
Lines 2781-2787 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
2781
  KEY `biblionumber` (`biblionumber`),
2781
  KEY `biblionumber` (`biblionumber`),
2782
  KEY `budget_id` (`budget_id`),
2782
  KEY `budget_id` (`budget_id`),
2783
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2783
  CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
2784
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE
2784
  CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
2785
  CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
2785
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2786
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2786
2787
2787
2788
Lines 2798-2803 CREATE TABLE `aqorders_items` ( -- information on items entered in the acquisiti Link Here
2798
  KEY `ordernumber` (`ordernumber`)
2799
  KEY `ordernumber` (`ordernumber`)
2799
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2800
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2800
2801
2802
2803
--
2804
-- Table structure for table aqinvoices
2805
--
2806
2807
DROP TABLE IF EXISTS aqinvoices;
2808
CREATE TABLE aqinvoices (
2809
  invoiceid int(11) NOT NULL AUTO_INCREMENT,    -- ID of the invoice, primary key
2810
  invoicenumber mediumtext NOT NULL,    -- Name of invoice
2811
  booksellerid int(11) NOT NULL,    -- foreign key to aqbooksellers
2812
  shipmentdate date default NULL,   -- date of shipment
2813
  billingdate date default NULL,    -- date of billing
2814
  closedate date default NULL,  -- invoice close date, NULL means the invoice is open
2815
  shipmentcost decimal(28,6) default NULL,  -- shipment cost
2816
  shipmentcost_budgetid int(11) default NULL,   -- foreign key to aqbudgets, link the shipment cost to a budget
2817
  PRIMARY KEY (invoiceid),
2818
  CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
2819
  CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
2820
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2821
2822
2801
--
2823
--
2802
-- Table structure for table `fieldmapping`
2824
-- Table structure for table `fieldmapping`
2803
--
2825
--
(-)a/installer/data/mysql/updatedatabase.pl (+60 lines)
Lines 5795-5800 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5795
    SetVersion($DBversion);
5795
    SetVersion($DBversion);
5796
}
5796
}
5797
5797
5798
$DBversion = "XXX";
5799
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5800
    $dbh->do("
5801
        CREATE TABLE aqinvoices (
5802
          invoiceid int(11) NOT NULL AUTO_INCREMENT,
5803
          invoicenumber mediumtext NOT NULL,
5804
          booksellerid int(11) NOT NULL,
5805
          shipmentdate date default NULL,
5806
          billingdate date default NULL,
5807
          closedate date default NULL,
5808
          shipmentcost decimal(28,6) default NULL,
5809
          shipmentcost_budgetid int(11) default NULL,
5810
          PRIMARY KEY (invoiceid),
5811
          CONSTRAINT aqinvoices_fk_aqbooksellerid FOREIGN KEY (booksellerid) REFERENCES aqbooksellers (id) ON DELETE CASCADE ON UPDATE CASCADE,
5812
          CONSTRAINT aqinvoices_fk_shipmentcost_budgetid FOREIGN KEY (shipmentcost_budgetid) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE
5813
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8
5814
    ");
5815
5816
    # Fill this new table with existing invoices
5817
    my $sth = $dbh->prepare("
5818
        SELECT aqorders.booksellerinvoicenumber AS invoicenumber, aqbasket.booksellerid, aqorders.datereceived
5819
        FROM aqorders
5820
          LEFT JOIN aqbasket ON aqorders.basketno = aqbasket.basketno
5821
        WHERE aqorders.booksellerinvoicenumber IS NOT NULL
5822
          AND aqorders.booksellerinvoicenumber != ''
5823
        GROUP BY aqorders.booksellerinvoicenumber
5824
    ");
5825
    $sth->execute;
5826
    my $results = $sth->fetchall_arrayref({});
5827
    $sth = $dbh->prepare("
5828
        INSERT INTO aqinvoices (invoicenumber, booksellerid, shipmentdate) VALUES (?,?,?)
5829
    ");
5830
    foreach(@$results) {
5831
        $sth->execute($_->{invoicenumber}, $_->{booksellerid}, $_->{datereceived});
5832
    }
5833
5834
    # Add the column in aqorders, fill it with correct value
5835
    # and then drop booksellerinvoicenumber column
5836
    $dbh->do("
5837
        ALTER TABLE aqorders
5838
        ADD COLUMN invoiceid int(11) default NULL AFTER booksellerinvoicenumber,
5839
        ADD CONSTRAINT aqorders_ibfk_3 FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE SET NULL ON UPDATE CASCADE
5840
    ");
5841
5842
    $dbh->do("
5843
        UPDATE aqorders, aqinvoices
5844
        SET aqorders.invoiceid = aqinvoices.invoiceid
5845
        WHERE aqorders.booksellerinvoicenumber = aqinvoices.invoicenumber
5846
    ");
5847
5848
    $dbh->do("
5849
        ALTER TABLE aqorders
5850
        DROP COLUMN booksellerinvoicenumber
5851
    ");
5852
5853
    print "Upgrade to $DBversion done (Add aqinvoices table) \n";
5854
    SetVersion ($DBversion);
5855
}
5856
5857
5798
=head1 FUNCTIONS
5858
=head1 FUNCTIONS
5799
5859
5800
=head2 TableExists($table)
5860
=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 98-104 Link Here
98
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
98
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
99
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
99
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
100
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
100
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
101
					<td>[% suggestions_loo.datereceived | $KohaDates %]</td>
101
                    <td>
102
                        [% IF suggestions_loo.datereceived %]
103
                            [% suggestions_loo.datereceived | $KohaDates %]
104
                        [% END %]
105
                    </td>
102
					<td>[% suggestions_loo.quantity %]</td>
106
					<td>[% suggestions_loo.quantity %]</td>
103
					<td>[% suggestions_loo.ecost %]</td>
107
					<td>[% suggestions_loo.ecost %]</td>
104
				</tr>
108
				</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 258-268 Link Here
258
        [% END %]
258
        [% END %]
259
    [% END %]
259
    [% END %]
260
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
260
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
261
    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
261
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
262
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
262
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
263
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
263
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
264
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
264
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
265
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
265
    <input type="hidden" name="freight" value="[% freight %]" />
266
    <input type="hidden" name="gst" value="[% gst %]" />
266
    <input type="hidden" name="gst" value="[% gst %]" />
267
	</div>
267
	</div>
268
	<div class="yui-u">
268
	<div class="yui-u">
Lines 318-330 Link Here
318
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
318
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
319
        [% END %]</li></ol>
319
        [% END %]</li></ol>
320
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
320
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
321
        <input type="hidden" name="invoice" value="[% invoice %]" />
322
    </fieldset>
321
    </fieldset>
323
322
324
</div>
323
</div>
325
</div><div class="yui-g"><fieldset class="action">
324
</div><div class="yui-g"><fieldset class="action">
326
        <input type="submit"  value="Save" />
325
        <input type="submit"  value="Save" />
327
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
326
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Cancel</a>
328
</fieldset></div>    </form>
327
</fieldset></div>    </form>
329
[% ELSE %]
328
[% ELSE %]
330
<div id="acqui_acquire_orderlist">
329
<div id="acqui_acquire_orderlist">
Lines 341-347 Link Here
341
        <tr>
340
        <tr>
342
            <td>[% loo.basketno %]</td>
341
            <td>[% loo.basketno %]</td>
343
            <td>[% loo.isbn %]</td>
342
            <td>[% loo.isbn %]</td>
344
         <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>
343
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
345
            <td>[% loo.author %]</td>
344
            <td>[% loo.author %]</td>
346
            <td>[% loo.quantity %]</td>
345
            <td>[% loo.quantity %]</td>
347
            <td>[% loo.quantityreceived %]</td>
346
            <td>[% loo.quantityreceived %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-51 / +66 lines)
Lines 45-50 Link Here
45
                null,
45
                null,
46
                null,
46
                null,
47
                null,
47
                null,
48
                null
48
            ],
49
            ],
49
            "sPaginationType": "four_button"
50
            "sPaginationType": "four_button"
50
        } ) );
51
        } ) );
Lines 125-135 Link Here
125
[% INCLUDE 'header.inc' %]
126
[% INCLUDE 'header.inc' %]
126
[% INCLUDE 'acquisitions-search.inc' %]
127
[% INCLUDE 'acquisitions-search.inc' %]
127
128
128
<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 ) %]
129
<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;
129
            Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
130
    [% IF ( datereceived ) %]
130
        [% ELSE %]
131
        Receipt summary for <i>[% name %]</i>
131
            Receive orders from [% name %]
132
        [% IF ( invoice ) %]
132
        [% END %]</div>
133
            <i>[ [% invoice %] ]</i>
134
        [% END %]
135
        on <i>[% formatteddatereceived %]</i>
136
    [% ELSE %]
137
        Receive orders from [% name %]
138
    [% END %]
139
</div>
133
140
134
<div id="doc3" class="yui-t2">
141
<div id="doc3" class="yui-t2">
135
142
Lines 185-192 Link Here
185
192
186
<div id="acqui_receive_summary">
193
<div id="acqui_receive_summary">
187
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
194
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
188
	<!-- TODO: Add date picker, change rcv date. -->
195
<p><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">Go to invoice details</a></p>
189
</div>
196
</div>
197
[% UNLESS (invoiceclosedate) %]
190
<div id="acqui_receive_search">
198
<div id="acqui_receive_search">
191
    <h3>Pending orders</h3>
199
    <h3>Pending orders</h3>
192
200
Lines 240-293 Link Here
240
                <td>[% loop_order.ecost %]</td>
248
                <td>[% loop_order.ecost %]</td>
241
                <td>[% loop_order.ordertotal %]</td>
249
                <td>[% loop_order.ordertotal %]</td>
242
				<td>
250
				<td>
243
                              <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>
251
                              <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
244
				    
252
				    
245
				</td>
253
				</td>
246
				<td>
254
				<td>
247
				    [% IF ( loop_order.left_holds_on_order ) %]
255
                        [% IF ( loop_order.left_holds_on_order ) %]
248
                    <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
256
                        <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>
249
                    [% ELSE %]
257
                        [% ELSE %]
250
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
258
                        <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
251
                    [% END %]
259
                        [% END %]
252
                    [% IF ( loop_order.can_del_bib ) %]
260
                        [% IF ( loop_order.can_del_bib ) %]
253
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
261
                        <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
254
                    [% ELSE %]
262
                        [% ELSE %]
255
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
263
                        <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
256
                    [% END %]
264
                        [% END %]
257
                    [% IF ( loop_order.left_item ) %]
265
                        [% IF ( loop_order.left_item ) %]
258
                    <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
266
                        <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
259
                    [% END %]
267
                        [% END %]
260
                    [% IF ( loop_order.left_biblio ) %]
268
                        [% IF ( loop_order.left_biblio ) %]
261
                    <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
269
                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
262
                    [% END %]
270
                        [% END %]
263
                    [% IF ( loop_order.left_subscription ) %]
271
                        [% IF ( loop_order.left_subscription ) %]
264
                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
272
                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
265
                    [% END %]
273
                        [% END %]
266
                    [% IF ( loop_order.left_holds ) %]
274
                        [% IF ( loop_order.left_holds ) %]
267
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
275
                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
268
                    [% END %]
276
                        [% END %]
269
				</td>
277
                    </td>
270
            </tr>
278
                </tr>
279
            [% END %]
280
        </tbody>
281
         </table>[% ELSE %]There are no pending orders.[% END %]
282
       <div id="resultnumber">
283
        <!-- Row of numbers corresponding to search result pages -->
284
        [% IF ( displayprev ) %]
285
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% prevstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
271
        [% END %]
286
        [% END %]
272
    </tbody>
287
        [% FOREACH number IN numbers %]
273
     </table>[% ELSE %]There are no pending orders.[% END %]
288
            [% IF ( number.highlight ) %]
274
   <div id="resultnumber">
289
            <span class="current">[% number.number %]</span>
275
	<!-- Row of numbers corresponding to search result pages -->
290
            [% ELSE %]
276
	[% IF ( displayprev ) %]
291
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% number.startfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
277
		<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>
292
            [% END %]
278
	[% END %]
293
        [% END %]
279
	[% FOREACH number IN numbers %]
294
        [% IF ( displaynext ) %]
280
		[% IF ( number.highlight ) %]
295
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% nextstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
281
		<span class="current">[% number.number %]</span>
296
        [% END %]
282
		[% ELSE %]
297
        </div>
283
		<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>
298
    </div>
284
		[% END %]
299
[% ELSE %]
285
	[% END %]
300
    <p>
286
	[% IF ( displaynext ) %]
301
        Invoice is close, so you can't receive orders.
287
		<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>
302
        <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
288
	[% END %]
303
    </p>
289
	</div>
304
[% END %]
290
</div>
305
291
<div id="acqui_receive_receivelist">
306
<div id="acqui_receive_receivelist">
292
    <h3>Already received</h3>
307
    <h3>Already received</h3>
293
308
Lines 378-384 Link Here
378
                            Can't cancel receipt
393
                            Can't cancel receipt
379
                        </span>
394
                        </span>
380
                    [% ELSE %]
395
                    [% ELSE %]
381
                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% loop_receive.invoice %]&booksellerid=[% booksellerid %]&datereceived=[% datereceived %]&op=cancelreceipt&ordernumber=[% loop_receive.ordernumber %]">Cancel receipt</a>
396
                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]&op=cancelreceipt&ordernumber=[% loop_receive.ordernumber %]">Cancel receipt</a>
382
                    [% END %]
397
                    [% END %]
383
                </td>
398
                </td>
384
            </tr>
399
            </tr>
(-)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