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

(-)a/C4/Acquisition.pm (-15 / +363 lines)
Lines 62-67 BEGIN { Link Here
62
        &GetParcels &GetParcel
62
        &GetParcels &GetParcel
63
        &GetContracts &GetContract
63
        &GetContracts &GetContract
64
64
65
        &GetInvoices
66
        &GetInvoice
67
        &GetInvoiceDetails
68
        &AddInvoice
69
        &ModInvoice
70
        &CloseInvoice
71
        &ReopenInvoice
72
65
        &GetItemnumbersFromOrder
73
        &GetItemnumbersFromOrder
66
74
67
        &AddClaim
75
        &AddClaim
Lines 1138-1144 C<$ordernumber>. Link Here
1138
sub ModReceiveOrder {
1146
sub ModReceiveOrder {
1139
    my (
1147
    my (
1140
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1148
        $biblionumber,    $ordernumber,  $quantrec, $user, $cost,
1141
        $invoiceno, $freight, $rrp, $budget_id, $datereceived
1149
        $invoiceid, $rrp, $budget_id, $datereceived
1142
    )
1150
    )
1143
    = @_;
1151
    = @_;
1144
    my $dbh = C4::Context->dbh;
1152
    my $dbh = C4::Context->dbh;
Lines 1164-1177 sub ModReceiveOrder { Link Here
1164
            UPDATE aqorders
1172
            UPDATE aqorders
1165
            SET quantityreceived=?
1173
            SET quantityreceived=?
1166
                , datereceived=?
1174
                , datereceived=?
1167
                , booksellerinvoicenumber=?
1175
                , invoiceid=?
1168
                , unitprice=?
1176
                , unitprice=?
1169
                , freight=?
1170
                , rrp=?
1177
                , rrp=?
1171
                , quantity=?
1178
                , quantity=?
1172
            WHERE biblionumber=? AND ordernumber=?");
1179
            WHERE biblionumber=? AND ordernumber=?");
1173
1180
1174
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$quantrec,$biblionumber,$ordernumber);
1181
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$quantrec,$biblionumber,$ordernumber);
1175
        $sth->finish;
1182
        $sth->finish;
1176
1183
1177
        # create a new order for the remaining items, and set its bookfund.
1184
        # create a new order for the remaining items, and set its bookfund.
Lines 1183-1192 sub ModReceiveOrder { Link Here
1183
        my $newOrder = NewOrder($order);
1190
        my $newOrder = NewOrder($order);
1184
} else {
1191
} else {
1185
        $sth=$dbh->prepare("update aqorders
1192
        $sth=$dbh->prepare("update aqorders
1186
                            set quantityreceived=?,datereceived=?,booksellerinvoicenumber=?,
1193
                            set quantityreceived=?,datereceived=?,invoiceid=?,
1187
                                unitprice=?,freight=?,rrp=?
1194
                                unitprice=?,rrp=?
1188
                            where biblionumber=? and ordernumber=?");
1195
                            where biblionumber=? and ordernumber=?");
1189
        $sth->execute($quantrec,$datereceived,$invoiceno,$cost,$freight,$rrp,$biblionumber,$ordernumber);
1196
        $sth->execute($quantrec,$datereceived,$invoiceid,$cost,$rrp,$biblionumber,$ordernumber);
1190
        $sth->finish;
1197
        $sth->finish;
1191
    }
1198
    }
1192
    return $datereceived;
1199
    return $datereceived;
Lines 1341-1349 sub GetParcel { Link Here
1341
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1348
        LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
1342
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1349
        LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber
1343
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1350
        LEFT JOIN biblio ON aqorders.biblionumber=biblio.biblionumber
1351
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1344
        WHERE
1352
        WHERE
1345
            aqbasket.booksellerid = ?
1353
            aqbasket.booksellerid = ?
1346
            AND aqorders.booksellerinvoicenumber LIKE ?
1354
            AND aqinvoices.invoicenumber LIKE ?
1347
            AND aqorders.datereceived = ? ";
1355
            AND aqorders.datereceived = ? ";
1348
1356
1349
    my @query_params = ( $supplierid, $code, $datereceived );
1357
    my @query_params = ( $supplierid, $code, $datereceived );
Lines 1416-1433 sub GetParcels { Link Here
1416
    my $dbh    = C4::Context->dbh;
1424
    my $dbh    = C4::Context->dbh;
1417
    my @query_params = ();
1425
    my @query_params = ();
1418
    my $strsth ="
1426
    my $strsth ="
1419
        SELECT  aqorders.booksellerinvoicenumber,
1427
        SELECT  aqinvoices.invoicenumber,
1420
                datereceived,purchaseordernumber,
1428
                datereceived,purchaseordernumber,
1421
                count(DISTINCT biblionumber) AS biblio,
1429
                count(DISTINCT biblionumber) AS biblio,
1422
                sum(quantity) AS itemsexpected,
1430
                sum(quantity) AS itemsexpected,
1423
                sum(quantityreceived) AS itemsreceived
1431
                sum(quantityreceived) AS itemsreceived
1424
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1432
        FROM   aqorders LEFT JOIN aqbasket ON aqbasket.basketno = aqorders.basketno
1433
        LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid
1425
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1434
        WHERE aqbasket.booksellerid = ? and datereceived IS NOT NULL
1426
    ";
1435
    ";
1427
    push @query_params, $bookseller;
1436
    push @query_params, $bookseller;
1428
1437
1429
    if ( defined $code ) {
1438
    if ( defined $code ) {
1430
        $strsth .= ' and aqorders.booksellerinvoicenumber like ? ';
1439
        $strsth .= ' and aqinvoices.invoicenumber like ? ';
1431
        # add a % to the end of the code to allow stemming.
1440
        # add a % to the end of the code to allow stemming.
1432
        push @query_params, "$code%";
1441
        push @query_params, "$code%";
1433
    }
1442
    }
Lines 1442-1448 sub GetParcels { Link Here
1442
        push @query_params, $dateto;
1451
        push @query_params, $dateto;
1443
    }
1452
    }
1444
1453
1445
    $strsth .= "group by aqorders.booksellerinvoicenumber,datereceived ";
1454
    $strsth .= "group by aqinvoices.invoicenumber,datereceived ";
1446
1455
1447
    # can't use a placeholder to place this column name.
1456
    # can't use a placeholder to place this column name.
1448
    # but, we could probably be checking to make sure it is a column that will be fetched.
1457
    # but, we could probably be checking to make sure it is a column that will be fetched.
Lines 1657-1663 sub GetHistory { Link Here
1657
            aqorders.quantityreceived,
1666
            aqorders.quantityreceived,
1658
            aqorders.ecost,
1667
            aqorders.ecost,
1659
            aqorders.ordernumber,
1668
            aqorders.ordernumber,
1660
            aqorders.booksellerinvoicenumber as invoicenumber,
1669
            aqinvoices.invoicenumber,
1661
            aqbooksellers.id as id,
1670
            aqbooksellers.id as id,
1662
            aqorders.biblionumber
1671
            aqorders.biblionumber
1663
        FROM aqorders
1672
        FROM aqorders
Lines 1665-1671 sub GetHistory { Link Here
1665
    LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1674
    LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid=aqbasketgroups.id
1666
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1675
        LEFT JOIN aqbooksellers ON aqbasket.booksellerid=aqbooksellers.id
1667
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1676
	LEFT JOIN biblioitems ON biblioitems.biblionumber=aqorders.biblionumber
1668
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber";
1677
        LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber
1678
    LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid";
1669
1679
1670
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1680
    $query .= " LEFT JOIN borrowers ON aqbasket.authorisedby=borrowers.borrowernumber"
1671
    if ( C4::Context->preference("IndependantBranches") );
1681
    if ( C4::Context->preference("IndependantBranches") );
Lines 1716-1723 sub GetHistory { Link Here
1716
    }
1726
    }
1717
1727
1718
    if ($booksellerinvoicenumber) {
1728
    if ($booksellerinvoicenumber) {
1719
        $query .= " AND (aqorders.booksellerinvoicenumber LIKE ? OR aqbasket.booksellerinvoicenumber LIKE ?)";
1729
        $query .= " AND aqinvoices.invoicenumber LIKE ? ";
1720
        push @query_params, "%$booksellerinvoicenumber%", "%$booksellerinvoicenumber%";
1730
        push @query_params, "%$booksellerinvoicenumber%";
1721
    }
1731
    }
1722
1732
1723
    if ( C4::Context->preference("IndependantBranches") ) {
1733
    if ( C4::Context->preference("IndependantBranches") ) {
Lines 1858-1864 sub AddClaim { Link Here
1858
        ";
1868
        ";
1859
    my $sth = $dbh->prepare($query);
1869
    my $sth = $dbh->prepare($query);
1860
    $sth->execute($ordernumber);
1870
    $sth->execute($ordernumber);
1871
}
1872
1873
=head3 GetInvoices
1874
1875
    my @invoices = GetInvoices(
1876
        invoicenumber => $invoicenumber,
1877
        suppliername => $suppliername,
1878
        shipmentdatefrom => $shipmentdatefrom, # ISO format
1879
        shipmentdateto => $shipmentdateto, # ISO format
1880
        billingdatefrom => $billingdatefrom, # ISO format
1881
        billingdateto => $billingdateto, # ISO format
1882
        isbneanissn => $isbn_or_ean_or_issn,
1883
        title => $title,
1884
        author => $author,
1885
        publisher => $publisher,
1886
        publicationyear => $publicationyear,
1887
        branchcode => $branchcode,
1888
        order_by => $order_by
1889
    );
1890
1891
Return a list of invoices that match all given criteria.
1892
1893
$order_by is "column_name (asc|desc)", where column_name is any of
1894
'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate',
1895
'shipmentcost', 'shipmentcost_budgetid'.
1896
1897
asc is the default if omitted
1898
1899
=cut
1900
1901
sub GetInvoices {
1902
    my %args = @_;
1903
1904
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
1905
        closedate shipmentcost shipmentcost_budgetid);
1906
1907
    my $dbh = C4::Context->dbh;
1908
    my $query = qq{
1909
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername,
1910
          COUNT(
1911
            DISTINCT IF(
1912
              aqorders.datereceived IS NOT NULL,
1913
              aqorders.biblionumber,
1914
              NULL
1915
            )
1916
          ) AS receivedbiblios,
1917
          SUM(aqorders.quantityreceived) AS receiveditems
1918
        FROM aqinvoices
1919
          LEFT JOIN aqbooksellers ON aqbooksellers.id = aqinvoices.booksellerid
1920
          LEFT JOIN aqorders ON aqorders.invoiceid = aqinvoices.invoiceid
1921
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
1922
          LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
1923
          LEFT JOIN subscription ON biblio.biblionumber = subscription.biblionumber
1924
    };
1925
1926
    my @bind_args;
1927
    my @bind_strs;
1928
    if($args{supplierid}) {
1929
        push @bind_strs, " aqinvoices.booksellerid = ? ";
1930
        push @bind_args, $args{supplierid};
1931
    }
1932
    if($args{invoicenumber}) {
1933
        push @bind_strs, " aqinvoices.invoicenumber LIKE ? ";
1934
        push @bind_args, "%$args{invoicenumber}%";
1935
    }
1936
    if($args{suppliername}) {
1937
        push @bind_strs, " aqbooksellers.name LIKE ? ";
1938
        push @bind_args, "%$args{suppliername}%";
1939
    }
1940
    if($args{shipmentdatefrom}) {
1941
        push @bind_strs, " aqinvoices.shipementdate >= ? ";
1942
        push @bind_args, $args{shipementdatefrom};
1943
    }
1944
    if($args{shipmentdateto}) {
1945
        push @bind_strs, " aqinvoices.shipementdate <= ? ";
1946
        push @bind_args, $args{shipementdateto};
1947
    }
1948
    if($args{billingdatefrom}) {
1949
        push @bind_strs, " aqinvoices.billingdate >= ? ";
1950
        push @bind_args, $args{billingdatefrom};
1951
    }
1952
    if($args{billingdateto}) {
1953
        push @bind_strs, " aqinvoices.billingdate <= ? ";
1954
        push @bind_args, $args{billingdateto};
1955
    }
1956
    if($args{isbneanissn}) {
1957
        push @bind_strs, " (biblioitems.isbn LIKE ? OR biblioitems.ean LIKE ? OR biblioitems.issn LIKE ? ) ";
1958
        push @bind_args, $args{isbneanissn}, $args{isbneanissn}, $args{isbneanissn};
1959
    }
1960
    if($args{title}) {
1961
        push @bind_strs, " biblio.title LIKE ? ";
1962
        push @bind_args, $args{title};
1963
    }
1964
    if($args{author}) {
1965
        push @bind_strs, " biblio.author LIKE ? ";
1966
        push @bind_args, $args{author};
1967
    }
1968
    if($args{publisher}) {
1969
        push @bind_strs, " biblioitems.publishercode LIKE ? ";
1970
        push @bind_args, $args{publisher};
1971
    }
1972
    if($args{publicationyear}) {
1973
        push @bind_strs, " biblioitems.publicationyear = ? ";
1974
        push @bind_args, $args{publicationyear};
1975
    }
1976
    if($args{branchcode}) {
1977
        push @bind_strs, " aqorders.branchcode = ? ";
1978
        push @bind_args, $args{branchcode};
1979
    }
1980
1981
    $query .= " WHERE " . join(" AND ", @bind_strs) if @bind_strs;
1982
    $query .= " GROUP BY aqinvoices.invoiceid ";
1983
1984
    if($args{order_by}) {
1985
        my ($column, $direction) = split / /, $args{order_by};
1986
        if(grep /^$column$/, @columns) {
1987
            $direction ||= 'ASC';
1988
            $query .= " ORDER BY $column $direction";
1989
        }
1990
    }
1861
1991
1992
    my $sth = $dbh->prepare($query);
1993
    $sth->execute(@bind_args);
1994
1995
    my $results = $sth->fetchall_arrayref({});
1996
    return @$results;
1997
}
1998
1999
=head3 GetInvoice
2000
2001
    my $invoice = GetInvoice($invoiceid);
2002
2003
Get informations about invoice with given $invoiceid
2004
2005
Return a hash filled with aqinvoices.* fields
2006
2007
=cut
2008
2009
sub GetInvoice {
2010
    my ($invoiceid) = @_;
2011
    my $invoice;
2012
2013
    return unless $invoiceid;
2014
2015
    my $dbh = C4::Context->dbh;
2016
    my $query = qq{
2017
        SELECT *
2018
        FROM aqinvoices
2019
        WHERE invoiceid = ?
2020
    };
2021
    my $sth = $dbh->prepare($query);
2022
    $sth->execute($invoiceid);
2023
2024
    $invoice = $sth->fetchrow_hashref;
2025
    return $invoice;
2026
}
2027
2028
=head3 GetInvoiceDetails
2029
2030
    my $invoice = GetInvoiceDetails($invoiceid)
2031
2032
Return informations about an invoice + the list of related order lines
2033
2034
Orders informations are in $invoice->{orders} (array ref)
2035
2036
=cut
2037
2038
sub GetInvoiceDetails {
2039
    my ($invoiceid) = @_;
2040
    my $invoice;
2041
2042
    return unless $invoiceid;
2043
2044
    my $dbh = C4::Context->dbh;
2045
    my $query = qq{
2046
        SELECT aqinvoices.*, aqbooksellers.name AS suppliername
2047
        FROM aqinvoices
2048
          LEFT JOIN aqbooksellers ON aqinvoices.booksellerid = aqbooksellers.id
2049
        WHERE invoiceid = ?
2050
    };
2051
    my $sth = $dbh->prepare($query);
2052
    $sth->execute($invoiceid);
2053
2054
    $invoice = $sth->fetchrow_hashref;
2055
2056
    $query = qq{
2057
        SELECT aqorders.*, biblio.*
2058
        FROM aqorders
2059
          LEFT JOIN biblio ON aqorders.biblionumber = biblio.biblionumber
2060
        WHERE invoiceid = ?
2061
    };
2062
    $sth = $dbh->prepare($query);
2063
    $sth->execute($invoiceid);
2064
    $invoice->{orders} = $sth->fetchall_arrayref({});
2065
    $invoice->{orders} ||= []; # force an empty arrayref if fetchall_arrayref fails
2066
2067
    return $invoice;
2068
}
2069
2070
=head3 AddInvoice
2071
2072
    my $invoiceid = AddInvoice(
2073
        invoicenumber => $invoicenumber,
2074
        booksellerid => $booksellerid,
2075
        shipmentdate => $shipmentdate,
2076
        billingdate => $billingdate,
2077
        closedate => $closedate,
2078
        shipmentcost => $shipmentcost,
2079
        shipmentcost_budgetid => $shipmentcost_budgetid
2080
    );
2081
2082
Create a new invoice and return its id or undef if it fails.
2083
2084
=cut
2085
2086
sub AddInvoice {
2087
    my %invoice = @_;
2088
2089
    return unless(%invoice and $invoice{invoicenumber});
2090
2091
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2092
        closedate shipmentcost shipmentcost_budgetid);
2093
2094
    my @set_strs;
2095
    my @set_args;
2096
    foreach my $key (keys %invoice) {
2097
        if(0 < grep(/^$key$/, @columns)) {
2098
            push @set_strs, "$key = ?";
2099
            push @set_args, ($invoice{$key} || undef);
2100
        }
2101
    }
2102
2103
    my $rv;
2104
    if(@set_args > 0) {
2105
        my $dbh = C4::Context->dbh;
2106
        my $query = "INSERT INTO aqinvoices SET ";
2107
        $query .= join (",", @set_strs);
2108
        my $sth = $dbh->prepare($query);
2109
        $rv = $sth->execute(@set_args);
2110
        if($rv) {
2111
            $rv = $dbh->last_insert_id(undef, undef, 'aqinvoices', undef);
2112
        }
2113
    }
2114
    return $rv;
2115
}
2116
2117
=head3 ModInvoice
2118
2119
    ModInvoice(
2120
        invoiceid => $invoiceid,    # Mandatory
2121
        invoicenumber => $invoicenumber,
2122
        booksellerid => $booksellerid,
2123
        shipmentdate => $shipmentdate,
2124
        billingdate => $billingdate,
2125
        closedate => $closedate,
2126
        shipmentcost => $shipmentcost,
2127
        shipmentcost_budgetid => $shipmentcost_budgetid
2128
    );
2129
2130
Modify an invoice, invoiceid is mandatory.
2131
2132
Return undef if it fails.
2133
2134
=cut
2135
2136
sub ModInvoice {
2137
    my %invoice = @_;
2138
2139
    return unless(%invoice and $invoice{invoiceid});
2140
2141
    my @columns = qw(invoicenumber booksellerid shipmentdate billingdate
2142
        closedate shipmentcost shipmentcost_budgetid);
2143
2144
    my @set_strs;
2145
    my @set_args;
2146
    foreach my $key (keys %invoice) {
2147
        if(0 < grep(/^$key$/, @columns)) {
2148
            push @set_strs, "$key = ?";
2149
            push @set_args, ($invoice{$key} || undef);
2150
        }
2151
    }
2152
2153
    my $dbh = C4::Context->dbh;
2154
    my $query = "UPDATE aqinvoices SET ";
2155
    $query .= join(",", @set_strs);
2156
    $query .= " WHERE invoiceid = ?";
2157
2158
    my $sth = $dbh->prepare($query);
2159
    $sth->execute(@set_args, $invoice{invoiceid});
2160
}
2161
2162
=head3 CloseInvoice
2163
2164
    CloseInvoice($invoiceid);
2165
2166
Close an invoice.
2167
2168
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
2169
2170
=cut
2171
2172
sub CloseInvoice {
2173
    my ($invoiceid) = @_;
2174
2175
    return unless $invoiceid;
2176
2177
    my $dbh = C4::Context->dbh;
2178
    my $query = qq{
2179
        UPDATE aqinvoices
2180
        SET closedate = CAST(NOW() AS DATE)
2181
        WHERE invoiceid = ?
2182
    };
2183
    my $sth = $dbh->prepare($query);
2184
    $sth->execute($invoiceid);
2185
}
2186
2187
=head3 ReopenInvoice
2188
2189
    ReopenInvoice($invoiceid);
2190
2191
Reopen an invoice
2192
2193
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
2194
2195
=cut
2196
2197
sub ReopenInvoice {
2198
    my ($invoiceid) = @_;
2199
2200
    return unless $invoiceid;
2201
2202
    my $dbh = C4::Context->dbh;
2203
    my $query = qq{
2204
        UPDATE aqinvoices
2205
        SET closedate = NULL
2206
        WHERE invoiceid = ?
2207
    };
2208
    my $sth = $dbh->prepare($query);
2209
    $sth->execute($invoiceid);
1862
}
2210
}
1863
2211
1864
1;
2212
1;
(-)a/C4/Budgets.pm (-2 / +22 lines)
Lines 309-317 sub GetBudgetSpent { Link Here
309
            quantityreceived > 0 AND
309
            quantityreceived > 0 AND
310
            datecancellationprinted IS NULL
310
            datecancellationprinted IS NULL
311
    |);
311
    |);
312
313
	$sth->execute($budget_id);
312
	$sth->execute($budget_id);
314
	my $sum =  $sth->fetchrow_array;
313
	my $sum =  $sth->fetchrow_array;
314
315
    $sth = $dbh->prepare(qq|
316
        SELECT SUM(shipmentcost) AS sum
317
        FROM aqinvoices
318
        WHERE shipmentcost_budgetid = ?
319
          AND closedate IS NOT NULL
320
    |);
321
    $sth->execute($budget_id);
322
    my ($shipmentcost_sum) = $sth->fetchrow_array;
323
    $sum += $shipmentcost_sum;
324
315
	return $sum;
325
	return $sum;
316
}
326
}
317
327
Lines 325-333 sub GetBudgetOrdered { Link Here
325
            quantityreceived = 0 AND
335
            quantityreceived = 0 AND
326
            datecancellationprinted IS NULL
336
            datecancellationprinted IS NULL
327
    |);
337
    |);
328
329
	$sth->execute($budget_id);
338
	$sth->execute($budget_id);
330
	my $sum =  $sth->fetchrow_array;
339
	my $sum =  $sth->fetchrow_array;
340
341
    $sth = $dbh->prepare(qq|
342
        SELECT SUM(shipmentcost) AS sum
343
        FROM aqinvoices
344
        WHERE shipmentcost_budgetid = ?
345
          AND closedate IS NULL
346
    |);
347
    $sth->execute($budget_id);
348
    my ($shipmentcost_sum) = $sth->fetchrow_array;
349
    $sum += $shipmentcost_sum;
350
331
	return $sum;
351
	return $sum;
332
}
352
}
333
353
(-)a/acqui/addorderiso2709.pl (-2 lines)
Lines 190-202 if ($op eq ""){ Link Here
190
        # 3rd add order
190
        # 3rd add order
191
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
191
        my $patron = C4::Members->GetMember( borrowernumber => $loggedinuser );
192
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
192
        my $branch = C4::Branch->GetBranchDetail( $patron->{branchcode} );
193
        my ($invoice);
194
        # get quantity in the MARC record (1 if none)
193
        # get quantity in the MARC record (1 if none)
195
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
194
        my $quantity = GetMarcQuantity($marcrecord, C4::Context->preference('marcflavour')) || 1;
196
        my %orderinfo = (
195
        my %orderinfo = (
197
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
196
            "biblionumber", $biblionumber, "basketno", $cgiparams->{'basketno'},
198
            "quantity", $quantity, "branchcode", $branch, 
197
            "quantity", $quantity, "branchcode", $branch, 
199
            "booksellerinvoicenumber", $invoice, 
200
            "budget_id", $budget_id, "uncertainprice", 1,
198
            "budget_id", $budget_id, "uncertainprice", 1,
201
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
199
            "sort1", $cgiparams->{'sort1'},"sort2", $cgiparams->{'sort2'},
202
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
200
            "notes", $cgiparams->{'notes'}, "budget_id", $cgiparams->{'budget_id'},
(-)a/acqui/finishreceive.pl (-6 / +6 lines)
Lines 45-58 my $origquantityrec=$input->param('origquantityrec'); Link Here
45
my $quantityrec=$input->param('quantityrec');
45
my $quantityrec=$input->param('quantityrec');
46
my $quantity=$input->param('quantity');
46
my $quantity=$input->param('quantity');
47
my $unitprice=$input->param('cost');
47
my $unitprice=$input->param('cost');
48
my $invoiceno=$input->param('invoice');
48
my $invoiceid = $input->param('invoiceid');
49
my $datereceived=$input->param('datereceived');
49
my $invoice = GetInvoice($invoiceid);
50
my $invoiceno = $invoice->{invoicenumber};
51
my $datereceived= $invoice->{shipmentdate};
50
my $replacement=$input->param('rrp');
52
my $replacement=$input->param('rrp');
51
my $gst=$input->param('gst');
53
my $gst=$input->param('gst');
52
my $freight=$input->param('freight');
53
my $booksellerid = $input->param('booksellerid');
54
my $booksellerid = $input->param('booksellerid');
54
my $cnt=0;
55
my $cnt=0;
55
my $error_url_str;
56
my $ecost = $input->param('ecost');
56
my $ecost = $input->param('ecost');
57
my $note = $input->param("note");
57
my $note = $input->param("note");
58
58
Lines 96-107 if ($quantityrec > $origquantityrec ) { Link Here
96
    }
96
    }
97
    
97
    
98
    # save the quantity received.
98
    # save the quantity received.
99
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoiceno,$freight,$replacement,undef,$datereceived);
99
    $datereceived = ModReceiveOrder($biblionumber,$ordernumber, $quantityrec ,$user,$unitprice,$invoice->{invoiceid},$replacement,undef,$datereceived);
100
}
100
}
101
101
102
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
102
update_item( $_ ) foreach GetItemnumbersFromOrder( $ordernumber );
103
103
104
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoice=$invoiceno&booksellerid=$booksellerid&freight=$freight&gst=$gst&datereceived=$datereceived$error_url_str");
104
print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
105
105
106
################################ End of script ################################
106
################################ End of script ################################
107
107
(-)a/acqui/invoice.pl (+211 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
invoice.pl
22
23
=head1 DESCRIPTION
24
25
Invoice details
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
use C4::Acquisition;
36
use C4::Bookseller qw/GetBookSellerFromId/;
37
use C4::Budgets;
38
39
my $input = new CGI;
40
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
41
    template_name   => 'acqui/invoice.tmpl',
42
    query           => $input,
43
    type            => 'intranet',
44
    authnotrequired => 0,
45
    flagsrequired   => { 'acquisition' => '*' },
46
    debug           => 1,
47
} );
48
49
my $invoiceid = $input->param('invoiceid');
50
my $op = $input->param('op');
51
52
if($op && $op eq 'close') {
53
    CloseInvoice($invoiceid);
54
    my $referer = $input->param('referer');
55
    if($referer) {
56
        print $input->redirect($referer);
57
        exit 0;
58
    }
59
}elsif($op && $op eq 'reopen') {
60
    ReopenInvoice($invoiceid);
61
    my $referer = $input->param('referer');
62
    if($referer) {
63
        print $input->redirect($referer);
64
        exit 0;
65
    }
66
}elsif($op && $op eq 'mod') {
67
    my $shipmentdate = $input->param('shipmentdate');
68
    my $billingdate = $input->param('billingdate');
69
    my $shipmentcost = $input->param('shipmentcost');
70
    my $shipment_budget_id = $input->param('shipment_budget_id');
71
    ModInvoice(
72
        invoiceid => $invoiceid,
73
        shipmentdate   => C4::Dates->new($shipmentdate)->output("iso"),
74
        billingdate   => C4::Dates->new($billingdate)->output("iso"),
75
        shipmentcost  => $shipmentcost,
76
        shipmentcost_budgetid => $shipment_budget_id
77
    );
78
    $template->param(modified => 1);
79
}
80
81
my $details = GetInvoiceDetails($invoiceid);
82
my $bookseller = GetBookSellerFromId($details->{booksellerid});
83
my @orders_loop = ();
84
my $orders = $details->{'orders'};
85
my $qty_total;
86
my @books_loop;
87
my @book_foot_loop;
88
my %foot;
89
my $total_quantity = 0;
90
my $total_rrp = 0;
91
my $total_est = 0;
92
foreach my $order (@$orders) {
93
    my $line = get_infos( $order, $bookseller);
94
95
    $total_quantity += $$line{quantity};
96
    $total_rrp += $order->{quantity} * $order->{rrp};
97
    $total_est += $order->{quantity} * $order->{'ecost'};
98
99
    my %row = (%$order, %$line);
100
    push @orders_loop, \%row;
101
}
102
103
my $gist = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
104
my $discount = $bookseller->{'discount'} ? ($bookseller->{discount} / 100) : 0;
105
my $total_est_gste;
106
my $total_est_gsti;
107
my $total_rrp_gsti; # RRP Total, GST included
108
my $total_rrp_gste; # RRP Total, GST excluded
109
my $gist_est;
110
my $gist_rrp;
111
if ($gist){
112
    # if we have GST
113
    if ( $bookseller->{'listincgst'} ) {
114
        # if prices already includes GST
115
116
        # we know $total_rrp_gsti
117
        $total_rrp_gsti = $total_rrp;
118
        # and can reverse compute other values
119
        $total_rrp_gste = $total_rrp_gsti / ( $gist + 1 );
120
121
        $gist_rrp       = $total_rrp_gsti - $total_rrp_gste;
122
        $total_est_gste = $total_rrp_gste - ( $total_rrp_gste * $discount );
123
        $total_est_gsti = $total_est;
124
    } else {
125
        # if prices does not include GST
126
127
        # then we use the common way to compute other values
128
        $total_rrp_gste = $total_rrp;
129
        $gist_rrp       = $total_rrp_gste * $gist;
130
        $total_rrp_gsti = $total_rrp_gste + $gist_rrp;
131
        $total_est_gste = $total_est;
132
        $total_est_gsti = $total_rrp_gsti - ( $total_rrp_gsti * $discount );
133
   }
134
   $gist_est = $gist_rrp - ( $gist_rrp * $discount );
135
} else {
136
    $total_rrp_gsti = $total_rrp;
137
    $total_est_gsti = $total_est;
138
}
139
my $total_gsti_shipment = $total_est_gsti + $details->{shipmentcost};
140
141
my $format = "%.2f";
142
$template->param(
143
    total_rrp_gste => sprintf($format, $total_rrp_gste),
144
    total_rrp_gsti => sprintf($format, $total_rrp_gsti),
145
    total_est_gste => sprintf($format, $total_est_gste),
146
    total_est_gsti => sprintf($format, $total_est_gsti),
147
    gist_rrp => sprintf($format, $gist_rrp),
148
    gist_est => sprintf($format, $gist_est),
149
    total_gsti_shipment => sprintf($format, $total_gsti_shipment),
150
    gist => sprintf($format, $gist * 100),
151
);
152
153
my $budgets = GetBudgets();
154
my @budgets_loop;
155
my $shipmentcost_budgetid = $details->{shipmentcost_budgetid};
156
foreach (@$budgets) {
157
    my %line = %{ $_ };
158
    if($shipmentcost_budgetid and $_->{'budget_id'} == $shipmentcost_budgetid) {
159
        $line{'selected'} = 1;
160
    }
161
    push @budgets_loop, \%line;
162
}
163
164
$template->param(
165
    invoiceid        => $details->{'invoiceid'},
166
    invoicenumber    => $details->{'invoicenumber'},
167
    suppliername     => $details->{'suppliername'},
168
    supplierid       => $details->{'booksellerid'},
169
    datereceived     => $details->{'datereceived'},
170
    shipmentdate     => $details->{'shipmentdate'},
171
    billingdate      => $details->{'billingdate'},
172
    invoiceclosedate => $details->{'closedate'},
173
    shipmentcost     => sprintf($format, $details->{'shipmentcost'} || 0),
174
    orders_loop      => \@orders_loop,
175
    total_quantity   => $total_quantity,
176
    invoiceincgst    => $bookseller->{invoiceincgst},
177
    currency         => $bookseller->{listprice},
178
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
179
    budgets_loop     => \@budgets_loop,
180
);
181
182
sub get_infos {
183
    my $order = shift;
184
    my $bookseller = shift;
185
    my $qty = $order->{'quantity'} || 0;
186
    if ( !defined $order->{quantityreceived} ) {
187
        $order->{quantityreceived} = 0;
188
    }
189
    my $budget = GetBudget( $order->{'budget_id'} );
190
191
    my %line = %{ $order };
192
    $line{order_received} = ( $qty == $order->{'quantityreceived'} );
193
    $line{budget_name}    = $budget->{budget_name};
194
    $line{total} = $qty * $order->{ecost};
195
196
    if ( $line{uncertainprice} ) {
197
        $line{rrp} .= ' (Uncertain)';
198
    }
199
    if ( $line{'title'} ) {
200
        my $volume      = $order->{'volume'};
201
        my $seriestitle = $order->{'seriestitle'};
202
        $line{'title'} .= " / $seriestitle" if $seriestitle;
203
        $line{'title'} .= " / $volume"      if $volume;
204
    } else {
205
        $line{'title'} = "Deleted bibliographic notice, can't find title.";
206
    }
207
208
    return \%line;
209
}
210
211
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/invoices.pl (+150 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
invoices.pl
22
23
=head1 DESCRIPTION
24
25
Search for invoices
26
27
=cut
28
29
use strict;
30
use warnings;
31
32
use CGI;
33
use C4::Auth;
34
use C4::Output;
35
36
use C4::Acquisition;
37
use C4::Bookseller qw/GetBookSeller/;
38
use C4::Branch;
39
40
my $input = new CGI;
41
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
42
    template_name   => 'acqui/invoices.tmpl',
43
    query           => $input,
44
    type            => 'intranet',
45
    authnotrequired => 0,
46
    flagsrequired   => { 'acquisition' => '*' },
47
    debug           => 1,
48
} );
49
50
my $invoicenumber   = $input->param('invoicenumber');
51
my $supplier        = $input->param('supplier');
52
my $billingdatefrom = $input->param('billingdatefrom');
53
my $billingdateto   = $input->param('billingdateto');
54
my $isbneanissn     = $input->param('isbneanissn');
55
my $title           = $input->param('title');
56
my $author          = $input->param('author');
57
my $publisher       = $input->param('publisher');
58
my $publicationyear = $input->param('publicationyear');
59
my $branch          = $input->param('branch');
60
my $op              = $input->param('op');
61
62
my @results_loop = ();
63
if($op and $op eq "do_search") {
64
    my $billingdatefrom_iso = C4::Dates->new($billingdatefrom)->output("iso");
65
    my $billingdateto_iso = C4::Dates->new($billingdateto)->output("iso");
66
    my @invoices = GetInvoices(
67
        invoicenumber => $invoicenumber,
68
        suppliername => $supplier,
69
        billingdatefrom => $billingdatefrom_iso,
70
        billingdateto => $billingdateto_iso,
71
        isbneanissn => $isbneanissn,
72
        title => $title,
73
        author => $author,
74
        publisher => $publisher,
75
        publicationyear => $publicationyear,
76
        branchcode => $branch
77
    );
78
    foreach (@invoices) {
79
        my %row = (
80
            invoiceid       => $_->{invoiceid},
81
            billingdate     => $_->{billingdate},
82
            invoicenumber   => $_->{invoicenumber},
83
            suppliername    => $_->{suppliername},
84
            receivedbiblios => $_->{receivedbiblios},
85
            receiveditems   => $_->{receiveditems},
86
            subscriptionid  => $_->{subscriptionid},
87
            closedate => $_->{closedate},
88
        );
89
        push @results_loop, \%row;
90
    }
91
}
92
93
94
# Build suppliers list
95
my @suppliers = GetBookSeller(undef);
96
my @suppliers_loop = ();
97
my $suppliername;
98
foreach (@suppliers) {
99
    my $selected = 0;
100
    if ($supplier && $supplier == $_->{'id'}) {
101
        $selected = 1;
102
        $suppliername = $_->{'name'};
103
    }
104
    my %row = (
105
        suppliername => $_->{'name'},
106
        supplierid   => $_->{'id'},
107
        selected     => $selected,
108
    );
109
    push @suppliers_loop, \%row;
110
}
111
112
# Build branches list
113
my $branches = GetBranches();
114
my @branches_loop = ();
115
my $branchname;
116
foreach (sort keys %$branches) {
117
    my $selected = 0;
118
    if ($branch && $branch eq $_) {
119
        $selected = 1;
120
        $branchname = $branches->{$_}->{'branchname'};
121
    }
122
    my %row = (
123
        branchcode => $_,
124
        branchname => $branches->{$_}->{'branchname'},
125
        selected   => $selected,
126
    );
127
    push @branches_loop, \%row;
128
}
129
130
$template->param(
131
    do_search       => ($op and $op eq "do_search") ? 1 : 0,
132
    results_loop    => \@results_loop,
133
    invoicenumber   => $invoicenumber,
134
    supplier        => $supplier,
135
    suppliername    => $suppliername,
136
    billingdatefrom => $billingdatefrom,
137
    billingdateto   => $billingdateto,
138
    isbneanissn     => $isbneanissn,
139
    title           => $title,
140
    author          => $author,
141
    publisher       => $publisher,
142
    publicationyear => $publicationyear,
143
    branch          => $branch,
144
    branchname      => $branchname,
145
    suppliers_loop  => \@suppliers_loop,
146
    branches_loop   => \@branches_loop,
147
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
148
);
149
150
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/orderreceive.pl (-17 / +17 lines)
Lines 40-48 to know on what supplier this script has to display receive order. Link Here
40
40
41
=item receive
41
=item receive
42
42
43
=item invoice
43
=item invoiceid
44
44
45
the number of this invoice.
45
the id of this invoice.
46
46
47
=item freight
47
=item freight
48
48
Lines 61-67 The biblionumber of this order. Link Here
61
=cut
61
=cut
62
62
63
use strict;
63
use strict;
64
#use warnings; FIXME - Bug 2505
64
use warnings;
65
65
use CGI;
66
use CGI;
66
use C4::Context;
67
use C4::Context;
67
use C4::Koha;   # GetKohaAuthorisedValues GetItemTypes
68
use C4::Koha;   # GetKohaAuthorisedValues GetItemTypes
Lines 81-106 use C4::Suggestions; Link Here
81
my $input      = new CGI;
82
my $input      = new CGI;
82
83
83
my $dbh          = C4::Context->dbh;
84
my $dbh          = C4::Context->dbh;
84
my $booksellerid   = $input->param('booksellerid');
85
my $invoiceid    = $input->param('invoiceid');
85
my $ordernumber       = $input->param('ordernumber');
86
my $invoice      = GetInvoice($invoiceid);
87
my $booksellerid   = $invoice->{booksellerid};
88
my $freight      = $invoice->{shipmentcost};
89
my $datereceived = $invoice->{shipmentdate};
90
my $ordernumber  = $input->param('ordernumber');
86
my $search       = $input->param('receive');
91
my $search       = $input->param('receive');
87
my $invoice      = $input->param('invoice');
88
my $freight      = $input->param('freight');
89
my $datereceived = $input->param('datereceived');
90
91
92
92
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
93
$datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates->new();
93
94
94
my $bookseller = GetBookSellerFromId($booksellerid);
95
my $bookseller = GetBookSellerFromId($booksellerid);
95
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
96
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
96
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
97
my $results = SearchOrder($ordernumber,$search);
97
my $results = SearchOrder($ordernumber,$search);
98
98
99
100
my $count   = scalar @$results;
99
my $count   = scalar @$results;
101
my $order 	= GetOrder($ordernumber);
100
my $order 	= GetOrder($ordernumber);
102
101
103
104
my $date = @$results[0]->{'entrydate'};
102
my $date = @$results[0]->{'entrydate'};
105
103
106
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
104
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 166-172 if ( $count == 1 ) { Link Here
166
        unitprice             => @$results[0]->{'unitprice'},
164
        unitprice             => @$results[0]->{'unitprice'},
167
        memberfirstname       => $member->{firstname} || "",
165
        memberfirstname       => $member->{firstname} || "",
168
        membersurname         => $member->{surname} || "",
166
        membersurname         => $member->{surname} || "",
169
        invoice               => $invoice,
167
        invoiceid             => $invoice->{invoiceid},
168
        invoice               => $invoice->{invoicenumber},
170
        datereceived          => $datereceived->output(),
169
        datereceived          => $datereceived->output(),
171
        datereceived_iso      => $datereceived->output('iso'),
170
        datereceived_iso      => $datereceived->output('iso'),
172
        notes                 => $order->{notes},
171
        notes                 => $order->{notes},
Lines 180-186 else { Link Here
180
    for ( my $i = 0 ; $i < $count ; $i++ ) {
179
    for ( my $i = 0 ; $i < $count ; $i++ ) {
181
        my %line = %{ @$results[$i] };
180
        my %line = %{ @$results[$i] };
182
181
183
        $line{invoice}      = $invoice;
182
        $line{invoice}      = $invoice->{invoicenumber};
184
        $line{datereceived} = $datereceived->output();
183
        $line{datereceived} = $datereceived->output();
185
        $line{freight}      = $freight;
184
        $line{freight}      = $freight;
186
        $line{gst}          = $gst;
185
        $line{gst}          = $gst;
Lines 192-202 else { Link Here
192
191
193
    $template->param(
192
    $template->param(
194
        loop         => \@loop,
193
        loop         => \@loop,
195
        booksellerid   => $booksellerid,
194
        booksellerid => $booksellerid,
195
        invoiceid    => $invoice->{invoiceid},
196
    );
196
    );
197
}
197
}
198
my $op = $input->param('op');
198
my $op = $input->param('op');
199
if ($op eq 'edit'){
199
if ($op and $op eq 'edit'){
200
    $template->param(edit   =>   1);
200
    $template->param(edit   =>   1);
201
}
201
}
202
output_html_with_http_headers $input, $cookie, $template->output;
202
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/parcel.pl (-136 / +123 lines)
Lines 42-49 To know the supplier this script has to show orders. Link Here
42
42
43
is the bookseller invoice number.
43
is the bookseller invoice number.
44
44
45
=item freight
46
47
45
48
=item gst
46
=item gst
49
47
Lines 57-63 To filter the results list on this given date. Link Here
57
=cut
55
=cut
58
56
59
use strict;
57
use strict;
60
#use warnings; FIXME - Bug 2505
58
use warnings;
59
61
use C4::Auth;
60
use C4::Auth;
62
use C4::Acquisition;
61
use C4::Acquisition;
63
use C4::Budgets;
62
use C4::Budgets;
Lines 71-86 use C4::Suggestions; Link Here
71
use JSON;
70
use JSON;
72
71
73
my $input=new CGI;
72
my $input=new CGI;
74
my $booksellerid=$input->param('booksellerid');
73
75
my $bookseller=GetBookSellerFromId($booksellerid);
74
my $invoiceid = $input->param('invoiceid');
76
75
my $invoice = GetInvoiceDetails($invoiceid);
77
my $invoice=$input->param('invoice') || '';
76
my $booksellerid = $invoice->{booksellerid};
78
my $freight=$input->param('freight');
77
my $bookseller = GetBookSellerFromId($booksellerid);
79
my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
78
my $gst = $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
80
my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
79
my $datereceived = C4::Dates->new();
81
my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
82
					:  C4::Dates->new($input->param('datereceived'), 'iso')   ;
83
$datereceived = C4::Dates->new() unless $datereceived;
84
my $code            = $input->param('code');
80
my $code            = $input->param('code');
85
my @rcv_err         = $input->param('error');
81
my @rcv_err         = $input->param('error');
86
my @rcv_err_barcode = $input->param('error_bc');
82
my @rcv_err_barcode = $input->param('error_bc');
Lines 90-105 my $resultsperpage = $input->param('resultsperpage'); Link Here
90
$resultsperpage = 20 unless ($resultsperpage);
86
$resultsperpage = 20 unless ($resultsperpage);
91
$startfrom=0 unless ($startfrom);
87
$startfrom=0 unless ($startfrom);
92
88
93
if($input->param('format') eq "json"){
89
my $format = $input->param('format') || '';
90
if($format eq "json"){
94
    my ($template, $loggedinuser, $cookie)
91
    my ($template, $loggedinuser, $cookie)
95
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
92
        = get_template_and_user({template_name => "acqui/ajax.tmpl",
96
                 query => $input,
93
                 query => $input,
97
				 type => "intranet",
94
                 type => "intranet",
98
                 authnotrequired => 0,
95
                 authnotrequired => 0,
99
                 flagsrequired => {acquisition => 'order_receive'},
96
                 flagsrequired => {acquisition => 'order_receive'},
100
                 debug => 1,
97
                 debug => 1,
101
    });
98
    });
102
       
99
103
    my @datas;
100
    my @datas;
104
    my $search   = $input->param('search') || '';
101
    my $search   = $input->param('search') || '';
105
    my $supplier = $input->param('booksellerid') || '';
102
    my $supplier = $input->param('booksellerid') || '';
Lines 110-116 if($input->param('format') eq "json"){ Link Here
110
    foreach my $order (@$orders){
107
    foreach my $order (@$orders){
111
        if($order->{quantityreceived} < $order->{quantity}){
108
        if($order->{quantityreceived} < $order->{quantity}){
112
            my $data = {};
109
            my $data = {};
113
            
110
114
            $data->{basketno} = $order->{basketno};
111
            $data->{basketno} = $order->{basketno};
115
            $data->{ordernumber} = $order->{ordernumber};
112
            $data->{ordernumber} = $order->{ordernumber};
116
            $data->{title} = $order->{title};
113
            $data->{title} = $order->{title};
Lines 118-131 if($input->param('format') eq "json"){ Link Here
118
            $data->{isbn} = $order->{isbn};
115
            $data->{isbn} = $order->{isbn};
119
            $data->{booksellerid} = $order->{booksellerid};
116
            $data->{booksellerid} = $order->{booksellerid};
120
            $data->{biblionumber} = $order->{biblionumber};
117
            $data->{biblionumber} = $order->{biblionumber};
121
            $data->{freight} = $order->{freight};
122
            $data->{quantity} = $order->{quantity};
118
            $data->{quantity} = $order->{quantity};
123
            $data->{ecost} = $order->{ecost};
119
            $data->{ecost} = $order->{ecost};
124
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
120
            $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
125
            push @datas, $data;
121
            push @datas, $data;
126
        }
122
        }
127
    }
123
    }
128
    
124
129
    my $json_text = to_json(\@datas);
125
    my $json_text = to_json(\@datas);
130
    $template->param(return => $json_text);
126
    $template->param(return => $json_text);
131
    output_html_with_http_headers $input, $cookie, $template->output;
127
    output_html_with_http_headers $input, $cookie, $template->output;
Lines 135-141 if($input->param('format') eq "json"){ Link Here
135
my ($template, $loggedinuser, $cookie)
131
my ($template, $loggedinuser, $cookie)
136
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
132
    = get_template_and_user({template_name => "acqui/parcel.tmpl",
137
                 query => $input,
133
                 query => $input,
138
				 type => "intranet",
134
                 type => "intranet",
139
                 authnotrequired => 0,
135
                 authnotrequired => 0,
140
                 flagsrequired => {acquisition => 'order_receive'},
136
                 flagsrequired => {acquisition => 'order_receive'},
141
                 debug => 1,
137
                 debug => 1,
Lines 155-164 if( scalar(@rcv_err) ) { Link Here
155
}
151
}
156
152
157
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
153
my $cfstr         = "%.2f";                                                           # currency format string -- could get this from currency table.
158
my @parcelitems   = GetParcel($booksellerid, $invoice, $datereceived->output('iso'));
154
my @parcelitems   = @{ $invoice->{orders} };
159
my $countlines    = scalar @parcelitems;
155
my $countlines    = scalar @parcelitems;
160
my $totalprice    = 0;
156
my $totalprice    = 0;
161
my $totalfreight  = 0;
162
my $totalquantity = 0;
157
my $totalquantity = 0;
163
my $total;
158
my $total;
164
my $tototal;
159
my $tototal;
Lines 166-180 my @loop_received = (); Link Here
166
161
167
for (my $i = 0 ; $i < $countlines ; $i++) {
162
for (my $i = 0 ; $i < $countlines ; $i++) {
168
163
169
    #$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'};   #weird, are the freight fees counted by book? (pierre)
164
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};
170
    $total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'};    #weird, are the freight fees counted by book? (pierre)
171
    $parcelitems[$i]->{'unitprice'} += 0;
165
    $parcelitems[$i]->{'unitprice'} += 0;
172
    my %line;
166
    my %line;
173
    %line          = %{ $parcelitems[$i] };
167
    %line          = %{ $parcelitems[$i] };
174
    $line{invoice} = $invoice;
168
    $line{invoice} = $invoice->{invoicenumber};
175
    $line{gst}     = $gst;
169
    $line{gst}     = $gst;
176
    $line{total} = sprintf($cfstr, $total);
170
    $line{total} = sprintf($cfstr, $total);
177
    $line{booksellerid} = $booksellerid;
171
    $line{booksellerid} = $invoice->{booksellerid};
178
    push @loop_received, \%line;
172
    push @loop_received, \%line;
179
    $totalprice += $parcelitems[$i]->{'unitprice'};
173
    $totalprice += $parcelitems[$i]->{'unitprice'};
180
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
174
    $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
Lines 184-327 for (my $i = 0 ; $i < $countlines ; $i++) { Link Here
184
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
178
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
185
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
179
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
186
180
187
    #double FIXME - totalfreight is redefined later.
188
189
# FIXME - each order in a  parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget..
190
    if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
191
        warn "FREIGHT CHARGE MISMATCH!!";
192
    }
193
    $totalfreight = $parcelitems[$i]->{'freight'};
194
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
181
    $totalquantity += $parcelitems[$i]->{'quantityreceived'};
195
    $tototal       += $total;
182
    $tototal       += $total;
196
}
183
}
197
184
198
my $pendingorders = GetPendingOrders($booksellerid);
185
if(!defined $invoice->{closedate}) {
199
my $countpendings = scalar @$pendingorders;
186
    my $pendingorders = GetPendingOrders($booksellerid);
200
187
    my $countpendings = scalar @$pendingorders;
201
# pending orders totals
188
202
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
189
    # pending orders totals
203
my $ordergrandtotal;
190
    my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
204
my @loop_orders = ();
191
    my $ordergrandtotal;
205
for (my $i = 0 ; $i < $countpendings ; $i++) {
192
    my @loop_orders = ();
206
    my %line;
193
    for (my $i = 0 ; $i < $countpendings ; $i++) {
207
    %line = %{$pendingorders->[$i]};
194
        my %line;
208
   
195
        %line = %{$pendingorders->[$i]};
209
    $line{quantity}+=0;
196
210
    $line{quantityreceived}+=0;
197
        $line{quantity}+=0;
211
    $line{unitprice}+=0;
198
        $line{quantityreceived}+=0;
212
    $totalPunitprice += $line{unitprice};
199
        $line{unitprice}+=0;
213
    $totalPquantity +=$line{quantity};
200
        $totalPunitprice += $line{unitprice};
214
    $totalPqtyrcvd +=$line{quantityreceived};
201
        $totalPquantity +=$line{quantity};
215
    $totalPecost += $line{ecost};
202
        $totalPqtyrcvd +=$line{quantityreceived};
216
    $line{ecost} = sprintf("%.2f",$line{ecost});
203
        $totalPecost += $line{ecost};
217
    $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
204
        $line{ecost} = sprintf("%.2f",$line{ecost});
218
    $line{unitprice} = sprintf("%.2f",$line{unitprice});
205
        $line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
219
    $line{invoice} = $invoice;
206
        $line{unitprice} = sprintf("%.2f",$line{unitprice});
220
    $line{gst} = $gst;
207
        $line{invoice} = $invoice;
221
    $line{total} = $total;
208
        $line{gst} = $gst;
222
    $line{booksellerid} = $booksellerid;
209
        $line{total} = $total;
223
    $ordergrandtotal += $line{ecost} * $line{quantity};
210
        $line{booksellerid} = $booksellerid;
224
    
211
        $ordergrandtotal += $line{ecost} * $line{quantity};
225
    my $biblionumber = $line{'biblionumber'};
212
226
    my $countbiblio = CountBiblioInOrders($biblionumber);
213
        my $biblionumber = $line{'biblionumber'};
227
    my $ordernumber = $line{'ordernumber'};
214
        my $countbiblio = CountBiblioInOrders($biblionumber);
228
    my @subscriptions = GetSubscriptionsId ($biblionumber);
215
        my $ordernumber = $line{'ordernumber'};
229
    my $itemcount = GetItemsCount($biblionumber);
216
        my @subscriptions = GetSubscriptionsId ($biblionumber);
230
    my $holds  = GetHolds ($biblionumber);
217
        my $itemcount = GetItemsCount($biblionumber);
231
    my @items = GetItemnumbersFromOrder( $ordernumber );
218
        my $holds  = GetHolds ($biblionumber);
232
    my $itemholds;
219
        my @items = GetItemnumbersFromOrder( $ordernumber );
233
    foreach my $item (@items){
220
        my $itemholds;
234
        my $nb = GetItemHolds($biblionumber, $item);
221
        foreach my $item (@items){
235
        if ($nb){
222
            my $nb = GetItemHolds($biblionumber, $item);
236
            $itemholds += $nb;
223
            if ($nb){
224
                $itemholds += $nb;
225
            }
237
        }
226
        }
238
    }
239
227
240
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
228
        my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
241
    $line{suggestionid}         = $suggestion->{suggestionid};
229
        $line{suggestionid}         = $suggestion->{suggestionid};
242
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
230
        $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
243
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
231
        $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
232
233
        # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
234
        $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
235
        $line{items}                = ($itemcount) - (scalar @items);
236
        $line{left_item}            = 1 if $line{items} >= 1;
237
        $line{left_biblio}          = 1 if $countbiblio > 1;
238
        $line{biblios}              = $countbiblio - 1;
239
        $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
240
        $line{subscriptions}        = scalar @subscriptions;
241
        $line{left_holds}           = ($holds >= 1) ? 1 : 0;
242
        $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
243
        $line{holds}                = $holds;
244
        $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
245
        
246
        
247
        push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
248
    }
244
249
245
    # if the biblio is not in other orders and if there is no items elsewhere and no subscriptions and no holds we can then show the link "Delete order and Biblio" see bug 5680
250
    my $count = $countpendings;
246
    $line{can_del_bib}          = 1 if $countbiblio <= 1 && $itemcount == scalar @items && !(@subscriptions) && !($holds);
247
    $line{items}                = ($itemcount) - (scalar @items);
248
    $line{left_item}            = 1 if $line{items} >= 1;
249
    $line{left_biblio}          = 1 if $countbiblio > 1;
250
    $line{biblios}              = $countbiblio - 1;
251
    $line{left_subscription}    = 1 if scalar @subscriptions >= 1;
252
    $line{subscriptions}        = scalar @subscriptions;
253
    $line{left_holds}           = 1 if $holds >= 1;
254
    $line{left_holds_on_order}  = 1 if $line{left_holds}==1 && ($line{items} == 0 || $itemholds );
255
    $line{holds}                = $holds;
256
    $line{holds_on_order}       = $itemholds?$itemholds:$holds if $line{left_holds_on_order};
257
    
258
    
259
    push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
260
}
261
$freight = $totalfreight unless $freight;
262
251
263
my $count = $countpendings;
252
    if ($count>$resultsperpage){
253
        my $displaynext=0;
254
        my $displayprev=$startfrom;
255
        if(($count - ($startfrom+$resultsperpage)) > 0 ) {
256
            $displaynext = 1;
257
        }
264
258
265
if ($count>$resultsperpage){
259
        my @numbers = ();
266
    my $displaynext=0;
260
        for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
267
    my $displayprev=$startfrom;
261
                my $highlight=0;
268
    if(($count - ($startfrom+$resultsperpage)) > 0 ) {
262
                ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
269
        $displaynext = 1;
263
                push @numbers, { number => $i,
270
    }
264
                    highlight => $highlight ,
265
                    startfrom => ($i-1)*$resultsperpage};
266
        }
271
267
272
    my @numbers = ();
268
        my $from = $startfrom*$resultsperpage+1;
273
    for (my $i=1; $i<$count/$resultsperpage+1; $i++) {
269
        my $to;
274
            my $highlight=0;
270
        if($count < (($startfrom+1)*$resultsperpage)){
275
            ($startfrom/$resultsperpage==($i-1)) && ($highlight=1);
271
            $to = $count;
276
            push @numbers, { number => $i,
272
        } else {
277
                highlight => $highlight ,
273
            $to = (($startfrom+1)*$resultsperpage);
278
                startfrom => ($i-1)*$resultsperpage};
274
        }
275
        $template->param(numbers=>\@numbers,
276
                         displaynext=>$displaynext,
277
                         displayprev=>$displayprev,
278
                         nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
279
                         prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
280
                        );
279
    }
281
    }
280
282
281
    my $from = $startfrom*$resultsperpage+1;
283
    $template->param(
282
    my $to;
284
        countpending => $countpendings,
283
    if($count < (($startfrom+1)*$resultsperpage)){
285
        loop_orders  => \@loop_orders,
284
        $to = $count;
286
        ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
285
    } else {
287
        totalPunitprice => sprintf("%.2f", $totalPunitprice),
286
        $to = (($startfrom+1)*$resultsperpage);
288
        totalPquantity  => $totalPquantity,
287
    }
289
        totalPqtyrcvd   => $totalPqtyrcvd,
288
    $template->param(numbers=>\@numbers,
290
        totalPecost     => sprintf("%.2f", $totalPecost),
289
                     displaynext=>$displaynext,
291
    );
290
                     displayprev=>$displayprev,
291
                     nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count),
292
                     prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0)
293
                    );
294
}
292
}
295
293
296
#$totalfreight=$freight;
297
$tototal = $tototal + $freight;
298
294
299
$template->param(
295
$template->param(
300
    invoice               => $invoice,
296
    invoiceid             => $invoice->{invoiceid},
297
    invoice               => $invoice->{invoicenumber},
298
    invoiceclosedate      => $invoice->{closedate},
301
    datereceived          => $datereceived->output('iso'),
299
    datereceived          => $datereceived->output('iso'),
302
    invoicedatereceived   => $datereceived->output('iso'),
300
    invoicedatereceived   => $datereceived->output('iso'),
303
    formatteddatereceived => $datereceived->output(),
301
    formatteddatereceived => $datereceived->output(),
304
    name                  => $bookseller->{'name'},
302
    name                  => $bookseller->{'name'},
305
    booksellerid            => $booksellerid,
303
    booksellerid          => $bookseller->{id},
306
    gst                   => $gst,
304
    gst                   => $gst,
307
    freight               => $freight,
308
    invoice               => $invoice,
309
    countreceived         => $countlines,
305
    countreceived         => $countlines,
310
    loop_received         => \@loop_received,
306
    loop_received         => \@loop_received,
311
    countpending          => $countpendings,
312
    loop_orders           => \@loop_orders,
313
    totalprice            => sprintf($cfstr, $totalprice),
307
    totalprice            => sprintf($cfstr, $totalprice),
314
    totalfreight          => $totalfreight,
315
    totalquantity         => $totalquantity,
308
    totalquantity         => $totalquantity,
316
    tototal               => sprintf($cfstr, $tototal),
309
    tototal               => sprintf($cfstr, $tototal),
317
    ordergrandtotal       => sprintf($cfstr, $ordergrandtotal),
318
    gst                   => $gst,
310
    gst                   => $gst,
319
    grandtot              => sprintf($cfstr, $tototal + $gst),
311
    grandtot              => sprintf($cfstr, $tototal + $gst),
320
    totalPunitprice       => sprintf("%.2f", $totalPunitprice),
321
    totalPquantity        => $totalPquantity,
322
    totalPqtyrcvd         => $totalPqtyrcvd,
323
    totalPecost           => sprintf("%.2f", $totalPecost),
324
    resultsperpage        => $resultsperpage,
312
    resultsperpage        => $resultsperpage,
325
);
313
);
326
output_html_with_http_headers $input, $cookie, $template->output;
314
output_html_with_http_headers $input, $cookie, $template->output;
327
 
(-)a/acqui/parcels.pl (-12 / +40 lines)
Lines 44-52 To know the supplier this script has to show orders. Link Here
44
sort list of order by 'orderby'.
44
sort list of order by 'orderby'.
45
Orderby can be equals to
45
Orderby can be equals to
46
    * datereceived desc (default value)
46
    * datereceived desc (default value)
47
    * aqorders.booksellerinvoicenumber
47
    * invoicenumber
48
    * datereceived
48
    * datereceived
49
    * aqorders.booksellerinvoicenumber desc
49
    * invoicenumber desc
50
50
51
=item filter
51
=item filter
52
52
Lines 84-89 my $code = $input->param('filter'); Link Here
84
my $datefrom       = $input->param('datefrom');
84
my $datefrom       = $input->param('datefrom');
85
my $dateto         = $input->param('dateto');
85
my $dateto         = $input->param('dateto');
86
my $resultsperpage = $input->param('resultsperpage');
86
my $resultsperpage = $input->param('resultsperpage');
87
my $op             = $input->param('op');
87
$resultsperpage ||= 20;
88
$resultsperpage ||= 20;
88
89
89
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
90
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 96-103 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
96
    }
97
    }
97
);
98
);
98
99
100
if($op and $op eq 'new') {
101
    my $invoicenumber = $input->param('invoice');
102
    my $shipmentdate = $input->param('shipmentdate');
103
    if($shipmentdate) {
104
        $shipmentdate = C4::Dates->new($shipmentdate)->output('iso');
105
    }
106
    my $invoiceid = AddInvoice(
107
        invoicenumber => $invoicenumber,
108
        booksellerid => $booksellerid,
109
        shipmentdate => $shipmentdate,
110
    );
111
    if(defined $invoiceid) {
112
        # Successful 'Add'
113
        print $input->redirect("/cgi-bin/koha/acqui/parcel.pl?invoiceid=$invoiceid");
114
        exit 0;
115
    } else {
116
        $template->param(error_failed_to_create_invoice => 1);
117
    }
118
}
119
99
my $bookseller = GetBookSellerFromId($booksellerid);
120
my $bookseller = GetBookSellerFromId($booksellerid);
100
my @parcels = GetParcels( $booksellerid, $order, $code, $datefrom, $dateto );
121
my @parcels = GetInvoices(
122
    supplierid => $booksellerid,
123
    invoicenumber => $code,
124
    shipmentdatefrom => $datefrom,
125
    shipmentdateto => $dateto,
126
    order_by => $order
127
);
101
my $count_parcels = @parcels;
128
my $count_parcels = @parcels;
102
129
103
# multi page display gestion
130
# multi page display gestion
Lines 114-127 for my $i ( $startfrom .. $last_row) { Link Here
114
141
115
    push @{$loopres},
142
    push @{$loopres},
116
      { number           => $i + 1,
143
      { number           => $i + 1,
117
        code             => $p->{booksellerinvoicenumber},
144
        invoiceid        => $p->{invoiceid},
118
        nullcode         => $p->{booksellerinvoicenumber} eq 'NULL',
145
        code             => $p->{invoicenumber},
119
        emptycode        => $p->{booksellerinvoicenumber} eq q{},
146
        nullcode         => $p->{invoicenumber} eq 'NULL',
120
        raw_datereceived => $p->{datereceived},
147
        emptycode        => $p->{invoicenumber} eq q{},
121
        datereceived     => format_date( $p->{datereceived} ),
148
        raw_datereceived => $p->{shipmentdate},
122
        bibcount         => $p->{biblio},
149
        datereceived     => format_date( $p->{shipmentdate} ),
123
        reccount         => $p->{itemsreceived},
150
        bibcount         => $p->{receivedbiblios} || 0,
124
        itemcount        => $p->{itemsexpected},
151
        reccount         => $p->{receiveditems} || 0,
152
        itemcount        => $p->{itemsexpected} || 0,
125
      };
153
      };
126
}
154
}
127
if ($count_parcels) {
155
if ($count_parcels) {
Lines 135-141 $template->param( Link Here
135
    resultsperpage           => $resultsperpage,
163
    resultsperpage           => $resultsperpage,
136
    name                     => $bookseller->{'name'},
164
    name                     => $bookseller->{'name'},
137
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
165
    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
138
    datereceived_today       => C4::Dates->new()->output(),
166
    shipmentdate_today       => C4::Dates->new()->output(),
139
    booksellerid             => $booksellerid,
167
    booksellerid             => $booksellerid,
140
    GST                      => C4::Context->preference('gist'),
168
    GST                      => C4::Context->preference('gist'),
141
);
169
);
(-)a/acqui/spent.pl (-12 / +35 lines)
Lines 60-69 SELECT Link Here
60
    aqbasket.booksellerid,
60
    aqbasket.booksellerid,
61
    itype,
61
    itype,
62
    title,
62
    title,
63
    aqorders.booksellerinvoicenumber,
63
    aqorders.invoiceid,
64
    aqinvoices.invoicenumber,
64
    quantityreceived,
65
    quantityreceived,
65
    unitprice,
66
    unitprice,
66
    freight,
67
    datereceived,
67
    datereceived,
68
    aqorders.biblionumber
68
    aqorders.biblionumber
69
FROM (aqorders, aqbasket)
69
FROM (aqorders, aqbasket)
Lines 73-78 LEFT JOIN biblio ON Link Here
73
    biblio.biblionumber=aqorders.biblionumber
73
    biblio.biblionumber=aqorders.biblionumber
74
LEFT JOIN aqorders_items ON
74
LEFT JOIN aqorders_items ON
75
    aqorders.ordernumber=aqorders_items.ordernumber
75
    aqorders.ordernumber=aqorders_items.ordernumber
76
LEFT JOIN aqinvoices ON
77
    aqorders.invoiceid = aqinvoices.invoiceid
76
WHERE
78
WHERE
77
    aqorders.basketno=aqbasket.basketno AND
79
    aqorders.basketno=aqbasket.basketno AND
78
    budget_id=? AND
80
    budget_id=? AND
Lines 85-111 $sth->execute($bookfund); Link Here
85
if ( $sth->err ) {
87
if ( $sth->err ) {
86
    die "An error occurred fetching records: " . $sth->errstr;
88
    die "An error occurred fetching records: " . $sth->errstr;
87
}
89
}
88
my $total = 0;
90
my $subtotal = 0;
89
my $toggle;
91
my $toggle;
90
my @spent;
92
my @spent;
91
while ( my $data = $sth->fetchrow_hashref ) {
93
while ( my $data = $sth->fetchrow_hashref ) {
92
    my $recv = $data->{'quantityreceived'};
94
    my $recv = $data->{'quantityreceived'};
93
    if ( $recv > 0 ) {
95
    if ( $recv > 0 ) {
94
        my $subtotal = $recv * ( $data->{'unitprice'} + $data->{'freight'} );
96
        my $rowtotal = $recv * $data->{'unitprice'};
95
        $data->{'subtotal'}  = sprintf( "%.2f", $subtotal );
97
        $data->{'rowtotal'}  = sprintf( "%.2f", $rowtotal );
96
        $data->{'freight'}   = sprintf( "%.2f", $data->{'freight'} );
97
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
98
        $data->{'unitprice'} = sprintf( "%.2f", $data->{'unitprice'} );
98
        $total += $subtotal;
99
        $subtotal += $rowtotal;
99
        push @spent, $data;
100
        push @spent, $data;
100
    }
101
    }
101
102
102
}
103
}
103
$total = sprintf( "%.2f", $total );
104
104
105
$template->{VARS}->{'fund'}  = $bookfund;
105
my $total = $subtotal;
106
$template->{VARS}->{'spent'} = \@spent;
106
$query = qq{
107
$template->{VARS}->{'total'} = $total;
107
    SELECT invoicenumber, shipmentcost
108
$template->{VARS}->{'fund_code'} = $fund_code;
108
    FROM aqinvoices
109
    WHERE shipmentcost_budgetid = ?
110
};
111
$sth = $dbh->prepare($query);
112
$sth->execute($bookfund);
113
my @shipmentcosts;
114
while (my $data = $sth->fetchrow_hashref) {
115
    push @shipmentcosts, {
116
        shipmentcost => sprintf("%.2f", $data->{shipmentcost}),
117
        invoicenumber => $data->{invoicenumber}
118
    };
119
    $total += $data->{shipmentcost};
120
}
109
$sth->finish;
121
$sth->finish;
110
122
123
$total = sprintf( "%.2f", $total );
124
125
$template->param(
126
    fund => $bookfund,
127
    spent => \@spent,
128
    subtotal => $subtotal,
129
    shipmentcosts => \@shipmentcosts,
130
    total => $total,
131
    fund_code => $fund_code
132
);
133
111
output_html_with_http_headers $input, $cookie, $template->output;
134
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/catalogue/moredetail.pl (-3 / +5 lines)
Lines 141-157 foreach my $item (@items){ Link Here
141
    }
141
    }
142
142
143
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
143
    my $order  = GetOrderFromItemnumber( $item->{'itemnumber'} );
144
    my $basket = GetBasket( $order->{'basketno'} );
145
    $item->{'booksellerid'}            = $basket->{'booksellerid'};
146
    $item->{'ordernumber'}             = $order->{'ordernumber'};
144
    $item->{'ordernumber'}             = $order->{'ordernumber'};
147
    $item->{'basketno'}                = $order->{'basketno'};
145
    $item->{'basketno'}                = $order->{'basketno'};
148
    $item->{'booksellerinvoicenumber'} = $order->{'booksellerinvoicenumber'};
149
    $item->{'orderdate'}               = $order->{'entrydate'};
146
    $item->{'orderdate'}               = $order->{'entrydate'};
150
    if ($item->{'basketno'}){
147
    if ($item->{'basketno'}){
151
	    my $basket = GetBasket($item->{'basketno'});
148
	    my $basket = GetBasket($item->{'basketno'});
152
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
149
	    my $bookseller = GetBookSellerFromId($basket->{'booksellerid'});
153
	    $item->{'vendor'} = $bookseller->{'name'};
150
	    $item->{'vendor'} = $bookseller->{'name'};
154
    }
151
    }
152
    $item->{'invoiceid'}               = $order->{'invoiceid'};
153
    if($item->{invoiceid}) {
154
        my $invoice = GetInvoice($item->{invoiceid});
155
        $item->{invoicenumber} = $invoice->{invoicenumber} if $invoice;
156
    }
155
    $item->{'datereceived'}            = $order->{'datereceived'};
157
    $item->{'datereceived'}            = $order->{'datereceived'};
156
158
157
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
159
    if ($item->{notforloantext} or $item->{itemlost} or $item->{damaged} or $item->{wthdrawn}) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc (+1 lines)
Lines 1-6 Link Here
1
<ul>
1
<ul>
2
	<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>
2
	<li><a href="/cgi-bin/koha/acqui/lateorders.pl">Late orders</a></li>
3
	[% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% ELSE %][% END %]
3
	[% IF ( suggestion ) %]<li><a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a></li>[% ELSE %][% END %]
4
    <li><a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a></li>
4
    [% IF ( CAN_user_acquisition_budget_manage ) %]
5
    [% IF ( CAN_user_acquisition_budget_manage ) %]
5
    <li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets &amp; funds</a></li>
6
    <li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets &amp; funds</a></li>
6
    [% END %]
7
    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-1 / +5 lines)
Lines 89-95 Link Here
89
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
89
                        <br />[% suggestions_loo.author %] <br /> [% suggestions_loo.isbn %]</td>
90
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
90
					<td><a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% suggestions_loo.id %]">[% suggestions_loo.name %]</a></td>
91
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
91
					<td>[% suggestions_loo.creationdate | $KohaDates %]</td>
92
					<td>[% suggestions_loo.datereceived | $KohaDates %]</td>
92
                    <td>
93
                        [% IF suggestions_loo.datereceived %]
94
                            [% suggestions_loo.datereceived | $KohaDates %]
95
                        [% END %]
96
                    </td>
93
					<td>[% suggestions_loo.quantity %]</td>
97
					<td>[% suggestions_loo.quantity %]</td>
94
					<td>[% suggestions_loo.ecost %]</td>
98
					<td>[% suggestions_loo.ecost %]</td>
95
				</tr>
99
				</tr>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (+192 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
9
[% INCLUDE 'datatables-strings.inc' %]
10
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
11
<script type="text/javascript">
12
//<![CDATA[
13
    $(document).ready(function() {
14
        $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
15
            bInfo: false,
16
            bPaginate: false,
17
            bFilter: false,
18
        }));
19
        Calendar.setup({
20
            inputField: "shipmentdate",
21
            ifFormat: "[% DHTMLcalendar_dateformat %]",
22
            button: "shipmentdateCalendar"
23
        });
24
        Calendar.setup({
25
            inputField: "billingdate",
26
            ifFormat: "[% DHTMLcalendar_dateformat %]",
27
            button: "billingdateCalendar"
28
        });
29
    });
30
//]]>
31
</script>
32
</head>
33
34
<body>
35
[% INCLUDE 'header.inc' %]
36
[% INCLUDE 'acquisitions-search.inc' %]
37
38
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">[% invoicenumber %]</a></div>
39
40
<div id="doc3" class="yui-t2">
41
42
<div id="bd">
43
  <div id="yui-main">
44
    <div class="yui-b">
45
      [% IF ( modified ) %]
46
        <div class="dialog">
47
          <p>Invoice has been modified</p>
48
        </div>
49
      [% END %]
50
      <h1>Invoice: [% invoicenumber %]</h1>
51
52
      <p>Supplier: [% suppliername %]</p>
53
      <form action="" method="post">
54
        <label for="shipmentdate">Shipment date:</label>
55
        [% IF (shipmentdate) %]
56
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" readonly="readonly" />
57
        [% ELSE %]
58
            <input type="text" size="10" id="shipmentdate" name="shipmentdate" readonly="readonly" />
59
        [% END %]
60
        <img id="shipmentdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
61
        <p></p>
62
        <label for="billingdate">Billing date:</label>
63
        [% IF (billingdate) %]
64
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
65
        [% ELSE %]
66
            <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" readonly="readonly" />
67
        [% END %]
68
        <img id="billingdateCalendar" alt="Show Calendar" style="cursor:pointer" src="[% themelang %]/lib/calendar/cal.gif" />
69
        <p></p>
70
        <label for="shipmentcost">Shipment cost:</label>
71
        <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost %]" />
72
        <label for="shipment_budget_id">Budget:</label>
73
        <select id="shipment_budget_id" name="shipment_budget_id">
74
            <option value="">No budget</option>
75
          [% FOREACH budget IN budgets_loop %]
76
            [% IF ( budget.selected ) %]
77
              <option selected="selected" value="[% budget.budget_id %]">
78
            [% ELSE %]
79
              <option value="[% budget.budget_id %]">
80
            [% END %]
81
              [% budget.budget_name %]
82
            </option>
83
          [% END %]
84
        </select>
85
        <input type="hidden" name="op" value="mod" />
86
        <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
87
        <fieldset class="action">
88
            <input type="submit" value="Save">
89
        </fieldset>
90
      </form>
91
      <p>Status:
92
        [% IF ( invoiceclosedate ) %]
93
          Closed on [% invoiceclosedate | $KohaDates %].
94
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]">
95
            Reopen
96
          </a>
97
        [% ELSE %]
98
          Open.
99
          <a href="/cgi-bin/koha/acqui/invoice.pl?op=close&invoiceid=[% invoiceid %]">
100
            Close
101
          </a>
102
        [% END %]
103
      </p>
104
      <p>
105
          <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
106
      </p>
107
      <h2>Invoice details</h2>
108
      [% IF orders_loop.size %]
109
          <table id="orderst">
110
            <thead>
111
              <tr>
112
                <th>Summary</th>
113
                <th>Publisher</th>
114
                <th>Branch</th>
115
                <th>RRP</th>
116
                <th>Est.</th>
117
                <th>Qty.</th>
118
                <th>Total</th>
119
                <th>Fund</th>
120
              </tr>
121
            </thead>
122
            <tbody>
123
              [% FOREACH order IN orders_loop %]
124
                <tr>
125
                  <td><p>[% order.title %]
126
                    [% IF ( order.author ) %]
127
                      <br /><em>by</em> [% order.author %]
128
                    [% END %]
129
                  </p></td>
130
                  <td>
131
                    [% IF ( order.publishercode ) %]
132
                      <p>[% order.publishercode %]
133
                        [% IF ( order.publicationyear ) %]
134
                          - [% order.publicationyear %]
135
                        [% END %]
136
                      </p>
137
                    [% END %]
138
                  </td>
139
                  <td><p>[% order.branchcode %]</p></td>
140
                  <td>[% order.rrp %]</td>
141
                  <td>[% order.ecost %]</td>
142
                  <td class="number">[% order.quantity %]</td>
143
                  <td>[% order.total %]</td>
144
                  <td>[% order.budget_name %]</td>
145
                </tr>
146
              [% END %]
147
            </tbody>
148
            <tfoot>
149
                <tr>
150
                    <th colspan="3">Total Tax Exc.</th>
151
                    <th>[% total_rrp_gste %]</th>
152
                    <th>&nbsp;</th>
153
                    <th>[% total_quantity %]</th>
154
                    <th>[% total_est_gste %]</th>
155
                    <th>&nbsp;</th>
156
                </tr>
157
                <tr>
158
                    <th colspan='3'>Tax ([% gist %]%)</th>
159
                    <th>[% gist_rrp %]</th>
160
                    <th>&nbsp;</th>
161
                    <th>&nbsp;</th>
162
                    <th>[% gist_est %]</th>
163
                    <th>&nbsp;</th>
164
                </tr>
165
                <tr>
166
                    <th colspan='3'>Total Tax Inc. ([% currency %])</th>
167
                    <th>[% total_rrp_gsti %]</th>
168
                    <th>&nbsp;</th>
169
                    <th>[% total_quantity %]</th>
170
                    <th>[% total_est_gsti %]</th>
171
                    <th>&nbsp;</th>
172
                </tr>
173
                <tr>
174
                    <th colspan="3">Total + Shipment cost ([% currency %])</th>
175
                    <th>&nbsp;</th>
176
                    <th>&nbsp;</th>
177
                    <th>[% total_quantity %]</th>
178
                    <th>[% total_gsti_shipment %]</th>
179
                    <th>&nbsp;</th>
180
                </tr>
181
            </tfoot>
182
          </table>
183
        [% ELSE %]
184
            <p>No orders yet</p>
185
        [% END %]
186
    </div>
187
  </div>
188
  <div class="yui-b">
189
    [% INCLUDE 'acquisitions-menu.inc' %]
190
  </div>
191
</div>
192
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt (+228 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoices</title>
5
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
6
[% INCLUDE 'doc-head-close.inc' %]
7
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
8
[% INCLUDE 'datatables-strings.inc' %]
9
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
10
[% INCLUDE 'calendar.inc' %]
11
<script type="text/javascript">
12
//<![CDATA[
13
$(document).ready(function() {
14
    Calendar.setup({
15
        inputField: "billingdatefrom",
16
        ifFormat: "[% DHTMLcalendar_dateformat %]",
17
        button: "billingdatefromCalendar"
18
    });
19
    Calendar.setup({
20
        inputField: "billingdateto",
21
        ifFormat: "[% DHTMLcalendar_dateformat %]",
22
        button: "billingdatetoCalendar"
23
    });
24
    $("#resultst").dataTable($.extend(true, {}, dataTablesDefaults, {
25
        bInfo: false,
26
        bPaginate: false,
27
        bFilter: false,
28
        aoColumnDefs: [
29
            { "bSortable": false, "aTargets": [6] }
30
        ]
31
    }));
32
});
33
//]]>
34
</script>
35
</head>
36
37
<body>
38
[% INCLUDE 'header.inc' %]
39
[% INCLUDE 'acquisitions-search.inc' %]
40
41
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; Invoices</div>
42
43
<div id="doc3" class="yui-t2">
44
45
<div id="bd">
46
  <div id="yui-main">
47
    <div class="yui-b">
48
      <h1>Invoices</h1>
49
      [% IF ( do_search ) %]
50
        [% IF ( results_loop ) %]
51
          <table id="resultst">
52
            <thead>
53
              <tr>
54
                <th>Invoice no.</th>
55
                <th>Vendor</th>
56
                <th>Billing date</th>
57
                <th>Received biblios</th>
58
                <th>Received items</th>
59
                <th>Status</th>
60
                <th>&nbsp;</th>
61
              </tr>
62
            </thead>
63
            <tbody>
64
              [% FOREACH result IN results_loop %]
65
                <tr>
66
                  <td>[% result.invoicenumber %]</td>
67
                  <td>[% result.suppliername %]</td>
68
                  <td>
69
                    [% IF (result.billingdate) %]
70
                      [% result.billingdate | $KohaDates %]
71
                    [% END %]
72
                  </td>
73
                  <td>[% result.receivedbiblios %]</td>
74
                  <td>[% result.receiveditems %]</td>
75
                  <td>
76
                    [% IF ( result.closedate ) %]
77
                      Closed on [% result.closedate | $KohaDates %]
78
                    [% ELSE %]
79
                      Open
80
                    [% END %]
81
                  </td>
82
                  <td>
83
                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% result.invoiceid %]">Details</a> /
84
                    [% IF ( result.closedate ) %]
85
                      <a href="invoice.pl?op=reopen&invoiceid=[% result.invoiceid %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber %]%26supplier=[% supplier %]%26billingdatefrom=[% billingdatefrom %]%26billingdateto=[% billingdateto %]%26isbneanissn=[% isbneanissn %]%26title=[% title %]%26author=[% author %]%26publisher=[% publisher %]%26publicationyear=[% publicationyear %]%26branch=[% branch %]">Reopen</a>
86
                    [% ELSE %]
87
                      <a href="invoice.pl?op=close&invoiceid=[% result.invoiceid %]&referer=/cgi-bin/koha/acqui/invoices.pl%3Fop=do_search%26invoicenumber=[% invoicenumber %]%26supplier=[% supplier %]%26billingdatefrom=[% billingdatefrom %]%26billingdateto=[% billingdateto %]%26isbneanissn=[% isbneanissn %]%26title=[% title %]%26author=[% author %]%26publisher=[% publisher %]%26publicationyear=[% publicationyear %]%26branch=[% branch %]">Close</a>
88
                    [% END %]
89
                  </td>
90
                </tr>
91
              [% END %]
92
            </tbody>
93
          </table>
94
        [% ELSE %]
95
          <p>Sorry, but there is no results for your search.</p>
96
          <p>Search was:
97
            <ul>
98
              [% IF ( invoicenumber ) %]
99
                <li>Invoice no.: [% invoicenumber %]</li>
100
              [% END %]
101
              [% IF ( supplier ) %]
102
                <li>Vendor: [% suppliername %]</li>
103
              [% END %]
104
              [% IF ( billingdatefrom ) %]
105
                <li>Billing date:
106
                [% IF ( billingdateto ) %]
107
                  From [% billingdatefrom %]
108
                  To [% billingdateto %]
109
                [% ELSE %]
110
                  All since [% billingdatefrom %]
111
                [% END %]
112
                </li>
113
              [% ELSE %]
114
                [% IF ( billingdateto ) %]
115
                  <li>Billing date:
116
                    All until [% billingdateto %]
117
                  </li>
118
                [% END %]
119
              [% END %]
120
              [% IF ( isbneanissn ) %]
121
                <li>ISBN/EAN/ISSN: [% isbneanissn %]</li>
122
              [% END %]
123
              [% IF ( title ) %]
124
                <li>Title: [% title %]</li>
125
              [% END %]
126
              [% IF ( author ) %]
127
                <li>Author: [% author %]</li>
128
              [% END %]
129
              [% IF ( publisher ) %]
130
                <li>Publisher: [% publisher %]</li>
131
              [% END %]
132
              [% IF ( publicationyear ) %]
133
                <li>Publication year: [% publicationyear %]</li>
134
              [% END %]
135
              [% IF ( branch ) %]
136
                <li>Branch: [% branchname %]</li>
137
              [% END %]
138
            </ul>
139
          </p>
140
        [% END %]<!-- results_loop -->
141
      [% ELSE %]
142
        <p>Please fill in the form to the left to make a search.</p>
143
      [% END %]<!-- do_search -->
144
    </div>
145
  </div>
146
  <div class="yui-b">
147
    <form action="" method="get">
148
      <fieldset class="brief">
149
        <h3>Search filters</h3>
150
        <ol>
151
          <li>
152
            <label for="invoicenumber">Invoice no:</label>
153
            <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber %]" />
154
          </li>
155
          <li>
156
            <label for="supplier">Supplier:</label>
157
            <select id="supplier" name="supplier">
158
              <option value="">All</option>
159
              [% FOREACH supplier IN suppliers_loop %]
160
                [% IF ( supplier.selected ) %]
161
                  <option selected="selected" value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
162
                [% ELSE %]
163
                  <option value="[% supplier.supplierid %]">[% supplier.suppliername %]</option>
164
                [% END %]
165
              [% END %]
166
            </select>
167
          </li>
168
          <li>
169
            <fieldset class="brief">
170
              <legend>Billing date</legend>
171
              <ol>
172
                <li>
173
                  <label for="billingdatefrom">From:</label>
174
                  <input type="text" id="billingdatefrom" name="billingdatefrom" size="10" value="[% billingdatefrom %]" />
175
                  <img id="billingdatefromCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
176
                </li>
177
                <li>
178
                  <label for="billingdateto">To:</label>
179
                  <input type="text" id="billingdateto" name="billingdateto" size="10" value="[% billingdateto %]" />
180
                  <img id="billingdatetoCalendar" alt="Show Calendar" style="cursor:pointer;" src="[% themelang %]/lib/calendar/cal.gif" />
181
                </li>
182
              </ol>
183
            </fieldset>
184
          </li>
185
          <li>
186
            <label for="isbneanissn">ISBN / EAN / ISSN:</label>
187
            <input type="text" id="isbneanissn" name="isbneanissn" value="[% isbneanissn %]" />
188
          </li>
189
          <li>
190
            <label for="title">Title:</label>
191
            <input type="text" id="title" name="title" value="[% title %]" />
192
          </li>
193
          <li>
194
            <label for="author">Author:</label>
195
            <input type="text" id="author" name="author" value="[% author %]" />
196
          </li>
197
          <li>
198
            <label for="publisher">Publisher:</label>
199
            <input type="text" id="publisher" name="publisher" value="[% publisher %]" />
200
          </li>
201
          <li>
202
            <label for="publicationyear">Publication year:</label>
203
            <input type="text" id="publicationyear" name="publicationyear" value="[% publicationyear %]" />
204
          </li>
205
          <li>
206
            <label for="branch">Branch:</label>
207
            <select id="branch" name="branch">
208
              <option value="">All</option>
209
              [% FOREACH branch IN branches_loop %]
210
                [% IF ( branch.selected ) %]
211
                  <option selected="selected" value="[% branch.branchcode %]">[% branch.branchname %]</option>
212
                [% ELSE %]
213
                  <option value="[% branch.branchcode %]">[% branch.branchname %]</option>
214
                [% END %]
215
              [% END %]
216
            </select>
217
          </li>
218
        </ol>
219
        <fieldset class="action">
220
          <input type="submit" value="Search" />
221
        </fieldset>
222
      </fieldset>
223
      <input type="hidden" name="op" id="op" value="do_search" />
224
    </form>
225
    [% INCLUDE 'acquisitions-menu.inc' %]
226
  </div>
227
</div>
228
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-4 / +3 lines)
Lines 129-139 Link Here
129
        </fieldset>
129
        </fieldset>
130
    [% END %][%# IF (AcqCreateItemReceiving) %]
130
    [% END %][%# IF (AcqCreateItemReceiving) %]
131
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
131
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
132
    <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
132
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
133
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
133
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
134
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
134
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
135
    <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
135
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
136
    <input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
136
    <input type="hidden" name="freight" value="[% freight %]" />
137
    <input type="hidden" name="gst" value="[% gst %]" />
137
    <input type="hidden" name="gst" value="[% gst %]" />
138
	</div>
138
	</div>
139
	<div class="yui-u">
139
	<div class="yui-u">
Lines 185-197 Link Here
185
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
185
            <input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
186
        [% END %]</li></ol>
186
        [% END %]</li></ol>
187
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
187
        <label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
188
        <input type="hidden" name="invoice" value="[% invoice %]" />
189
    </fieldset>
188
    </fieldset>
190
189
191
</div>
190
</div>
192
</div><div class="yui-g"><fieldset class="action">
191
</div><div class="yui-g"><fieldset class="action">
193
        <input type="submit"  value="Save" />
192
        <input type="submit"  value="Save" />
194
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
193
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Cancel</a>
195
</fieldset></div>    </form>
194
</fieldset></div>    </form>
196
[% ELSE %]
195
[% ELSE %]
197
<div id="acqui_acquire_orderlist">
196
<div id="acqui_acquire_orderlist">
Lines 208-214 Link Here
208
        <tr>
207
        <tr>
209
            <td>[% loo.basketno %]</td>
208
            <td>[% loo.basketno %]</td>
210
            <td>[% loo.isbn %]</td>
209
            <td>[% loo.isbn %]</td>
211
         <td><a href="orderreceive.pl?datereceived=[% loo.datereceived %]&amp;receive=[% loo.ordernumber %]&amp;biblio=[% loo.biblionumber %]&amp;invoice=[% loo.invoice %]&amp;freight=[% loo.freight %]&amp;gst=[% loo.gst %]&amp;id=[% loo.id %]">[% loo.title |html %]</a></td>
210
         <td><a href="orderreceive.pl?ordernumber=[% loo.ordernumber %]&amp;invoiceid=[% invoiceid %]">[% loo.title |html %]</a></td>
212
            <td>[% loo.author %]</td>
211
            <td>[% loo.author %]</td>
213
            <td>[% loo.quantity %]</td>
212
            <td>[% loo.quantity %]</td>
214
            <td>[% loo.quantityreceived %]</td>
213
            <td>[% loo.quantityreceived %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-106 / +120 lines)
Lines 157-167 Link Here
157
[% INCLUDE 'header.inc' %]
157
[% INCLUDE 'header.inc' %]
158
[% INCLUDE 'acquisitions-search.inc' %]
158
[% INCLUDE 'acquisitions-search.inc' %]
159
159
160
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;  [% IF ( datereceived ) %]
160
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;
161
            Receipt summary for <i>[% name %]</i> [% IF ( invoice ) %]<i>[ [% invoice %] ]</i>[% END %] on <i>[% formatteddatereceived %]</i>
161
    [% IF ( datereceived ) %]
162
        [% ELSE %]
162
        Receipt summary for <i>[% name %]</i>
163
            Receive orders from [% name %]
163
        [% IF ( invoice ) %]
164
        [% END %]</div>
164
            <i>[ [% invoice %] ]</i>
165
        [% END %]
166
        on <i>[% formatteddatereceived %]</i>
167
    [% ELSE %]
168
        Receive orders from [% name %]
169
    [% END %]
170
</div>
165
171
166
<div id="doc3" class="yui-t2">
172
<div id="doc3" class="yui-t2">
167
173
Lines 199-311 Link Here
199
205
200
<div id="acqui_receive_summary">
206
<div id="acqui_receive_summary">
201
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
207
<p><strong>Invoice number:</strong> [% invoice %] <strong>Received by:</strong> [% loggedinusername %] <strong>On:</strong> [% formatteddatereceived %]</p>
202
	<!-- TODO: Add date picker, change rcv date. -->
208
<p><a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid %]">Go to invoice details</a></p>
203
</div>
209
</div>
204
<div id="acqui_receive_search">
210
[% UNLESS (invoiceclosedate) %]
205
    <h3>Pending orders</h3>
211
    <div id="acqui_receive_search">
206
212
        <h3>Pending Orders</h3>
207
 [% IF ( loop_orders ) %]<table id="pendingt">
213
208
    <thead>
214
     [% IF ( loop_orders ) %]<table id="pendingt">
209
        <tr>
215
        <thead>
210
            <th>Basket</th>
211
            <th>Order line</th>
212
            <th>Summary</th>
213
        <th>View record</th>
214
            <th>Quantity</th>
215
            <th>Unit cost</th>
216
            <th>Order cost</th>
217
            <th>&nbsp;</th>
218
            <th>&nbsp;</th>
219
        </tr>
220
    </thead>
221
		<tfoot>
222
            <tr><td colspan="4" class="total">TOTAL</td>
223
                <td> [% totalPquantity %] </td>
224
				<td>&nbsp;</td>
225
                <td>[% ordergrandtotal %]</td>
226
				<td>&nbsp;</td>
227
				<td>&nbsp;</td>
228
            </tr>
229
		</tfoot>
230
    <tbody class="filterclass">
231
        [% FOREACH loop_order IN loop_orders %]
232
	[% UNLESS ( loop.odd ) %]
233
            <tr class="highlight">
234
        [% ELSE %]
235
            <tr>
216
            <tr>
236
        [% END %]
217
                <th>Basket</th>
237
                <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
218
                <th>Order line</th>
238
                <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.booksellerid %]">[% loop_order.ordernumber %]</a></td>
219
                <th>Summary</th>
239
                <td class="summaryfilterclass">
220
                <th>View record</th>
240
                  <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
221
                <th>Quantity</th>
241
                [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
222
                <th>Unit cost</th>
242
                [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
223
                <th>Order cost</th>
243
                [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
224
                <th>&nbsp;</th>
244
                [% IF ( loop_order.suggestionid ) %]
225
                <th>&nbsp;</th>
245
                    <br/>
226
            </tr>
246
                    Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
227
        </thead>
247
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
228
            <tfoot>
248
                [% END %]
229
                <tr><td colspan="4" class="total">TOTAL</td>
249
                <br />
230
                    <td> [% totalPquantity %] </td>
250
                [% IF ( loop_order.notes ) %]
231
                    <td>&nbsp;</td>
251
                    <p class="ordernote"><strong>Note: </strong>[% loop_order.notes|html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Change note</a>]</p>
232
                    <td>[% ordergrandtotal %]</td>
252
                [% ELSE %]
233
                    <td>&nbsp;</td>
253
                    [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Fbooksellerid=[% loop_order.booksellerid %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]">Add note</a>]
234
                    <td>&nbsp;</td>
254
                [% END %]
235
                </tr>
255
                </td>
236
            </tfoot>
256
                <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
237
        <tbody class="filterclass">
257
                <td>[% loop_order.quantity %]</td>
238
            [% FOREACH loop_order IN loop_orders %]
258
                <td>[% loop_order.ecost %]</td>
239
        [% UNLESS ( loop.odd ) %]
259
                <td>[% loop_order.ordertotal %]</td>
240
                <tr class="highlight">
260
				<td>
241
            [% ELSE %]
261
				    <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;datereceived=[% loop_order.invoicedatereceived %]&amp;invoice=[% loop_order.invoice %]&amp;gst=[% loop_order.gst %]&amp;freight=[% loop_order.freight %]&amp;booksellerid=[% loop_order.booksellerid %]">Receive</a>
242
                <tr>
262
				    
243
            [% END %]
263
				</td>
244
                    <td class="basketfilterclass"><a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% loop_order.basketno %]">[% loop_order.basketno %]</a></td>
264
				<td>
245
                    <td class="orderfilterclass"><a href="neworderempty.pl?ordernumber=[% loop_order.ordernumber %]&amp;booksellerid=[% loop_order.booksellerid %]">[% loop_order.ordernumber %]</a></td>
265
				    [% IF ( loop_order.left_holds_on_order ) %]
246
                    <td class="summaryfilterclass">
266
                    <span class="button" title="Can't delete order, ([% loop_order.holds_on_order %]) holds are linked with this order cancel holds first">Can't delete order</span><br>
247
                      <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% loop_order.biblionumber %]">[% loop_order.title |html %]</a>
267
                    [% ELSE %]
248
                    [% IF ( loop_order.author ) %] by [% loop_order.author %][% END %]
268
                    <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
249
                    [% IF ( loop_order.isbn ) %] &ndash; [% loop_order.isbn %][% END %]
250
                    [% IF ( loop_order.publishercode ) %]<br />Publisher :[% loop_order.publishercode %][% END %]
251
                    [% IF ( loop_order.suggestionid ) %]
252
                        <br/>
253
                        Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
254
                        (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
269
                    [% END %]
255
                    [% END %]
270
                    [% IF ( loop_order.can_del_bib ) %]
256
                    <br />
271
                    <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.basketno %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
257
                    [% IF ( loop_order.notes ) %]
258
                        <p class="ordernote"><strong>Note: </strong>[% loop_order.notes|html %] [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Change note</a>]</p>
272
                    [% ELSE %]
259
                    [% ELSE %]
273
                    <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
260
                        [<a href="/cgi-bin/koha/acqui/modordernotes.pl?ordernumber=[% loop_order.ordernumber %]&amp;referrer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Add note</a>]
274
                    [% END %]
275
                    [% IF ( loop_order.left_item ) %]
276
                    <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
277
                    [% END %]
261
                    [% END %]
278
                    [% IF ( loop_order.left_biblio ) %]
262
                    </td>
279
                    <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
263
                    <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
280
                    [% END %]
264
                    <td>[% loop_order.quantity %]</td>
281
                    [% IF ( loop_order.left_subscription ) %]
265
                    <td>[% loop_order.ecost %]</td>
282
                    <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
266
                    <td>[% loop_order.ordertotal %]</td>
283
                    [% END %]
267
                    <td>
284
                    [% IF ( loop_order.left_holds ) %]
268
                        <a href="orderreceive.pl?ordernumber=[% loop_order.ordernumber %]&amp;invoiceid=[% invoiceid %]">Receive</a>
285
                    <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
269
286
                    [% END %]
270
                    </td>
287
				</td>
271
                    <td>
288
            </tr>
272
                        [% IF ( loop_order.left_holds_on_order ) %]
273
                        <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>
274
                        [% ELSE %]
275
                        <a href="javascript:confirm_delete_item([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order</a><br>
276
                        [% END %]
277
                        [% IF ( loop_order.can_del_bib ) %]
278
                        <a href="javascript:confirm_delete_biblio([% loop_order.ordernumber %],[% loop_order.biblionumber %])" class="button">Delete order and catalog record</a><br>
279
                        [% ELSE %]
280
                        <span class="button" title="Can't delete catalog record, see constraints below">Can't delete order and catalog record</span><br>
281
                        [% END %]
282
                        [% IF ( loop_order.left_item ) %]
283
                        <b title="Can't delete catalog record, because of [% loop_order.items %] existing item(s)" >[% loop_order.items %] item(s) left</b><br>
284
                        [% END %]
285
                        [% IF ( loop_order.left_biblio ) %]
286
                        <b title="Can't delete catalog record, delete other orders linked to it first">[% loop_order.biblios %] order(s) left</b><br>
287
                        [% END %]
288
                        [% IF ( loop_order.left_subscription ) %]
289
                        <b title="Can't delete catalog record, delete subscriptions first">[% loop_order.subscriptions %] subscription(s) left</b><br>
290
                        [% END %]
291
                        [% IF ( loop_order.left_holds ) %]
292
                        <b title="Can't delete catalog record or order, cancel holds first">[% loop_order.holds %] hold(s) left</b>
293
                        [% END %]
294
                    </td>
295
                </tr>
296
            [% END %]
297
        </tbody>
298
         </table>[% ELSE %]There are no pending orders.[% END %]
299
       <div id="resultnumber">
300
        <!-- Row of numbers corresponding to search result pages -->
301
        [% IF ( displayprev ) %]
302
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% prevstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
289
        [% END %]
303
        [% END %]
290
    </tbody>
304
        [% FOREACH number IN numbers %]
291
     </table>[% ELSE %]There are no pending orders.[% END %]
305
            [% IF ( number.highlight ) %]
292
   <div id="resultnumber">
306
            <span class="current">[% number.number %]</span>
293
	<!-- Row of numbers corresponding to search result pages -->
307
            [% ELSE %]
294
	[% IF ( displayprev ) %]
308
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% number.startfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
295
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% prevstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">&lt;&lt; Previous</a>
309
            [% END %]
296
	[% END %]
310
        [% END %]
297
	[% FOREACH number IN numbers %]
311
        [% IF ( displaynext ) %]
298
		[% IF ( number.highlight ) %]
312
            <a href="parcel.pl?invoiceid=[% invoiceid %]&amp;startfrom=[% nextstartfrom %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
299
		<span class="current">[% number.number %]</span>
313
        [% END %]
300
		[% ELSE %]
314
        </div>
301
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% number.startfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">[% number.number %]</a>
315
    </div>
302
		[% END %]
316
[% ELSE %]
303
	[% END %]
317
    <p>
304
	[% IF ( displaynext ) %]
318
        Invoice is close, so you can't receive orders.
305
		<a href="parcel.pl?type=intra&amp;booksellerid=[% booksellerid %]&amp;startfrom=[% nextstartfrom %][% IF ( datereceived ) %]&amp;datereceived=[% datereceived %][% END %][% IF ( invoice ) %]&amp;invoice=[% invoice %][% END %][% IF ( resultsperpage ) %]&amp;resultsperpage=[% resultsperpage %][% END %]#resultnumber">Next &gt;&gt;</a>
319
        <a href="/cgi-bin/koha/acqui/invoice.pl?op=reopen&invoiceid=[% invoiceid %]&referer=/cgi-bin/koha/acqui/parcel.pl%3Finvoiceid=[% invoiceid %]">Reopen it</a>.
306
	[% END %]
320
    </p>
307
	</div>
321
[% END %]
308
</div>
322
309
<div id="acqui_receive_receivelist">
323
<div id="acqui_receive_receivelist">
310
    <h3>Already received</h3>
324
    <h3>Already received</h3>
311
325
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt (-25 / +25 lines)
Lines 14-20 Link Here
14
   <div id="bd">
14
   <div id="bd">
15
	<div id="yui-main">
15
	<div id="yui-main">
16
	<div class="yui-b">
16
	<div class="yui-b">
17
	
17
18
[% IF ( error_failed_to_create_invoice ) %]
19
    <div id="error" class="dialog error">
20
        <p>An error has occured. Invoice cannot be created.</p>
21
    </div>
22
[% END %]
18
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1>
23
<h1>Receive shipment from vendor <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid %]">[% name %]</a></h1>
19
24
20
[% IF ( count ) %]
25
[% IF ( count ) %]
Lines 42-52 Link Here
42
            [% searchresult.number %]
47
            [% searchresult.number %]
43
        </td>
48
        </td>
44
        <td>
49
        <td>
45
            <a href="/cgi-bin/koha/acqui/parcel.pl?type=intra&amp;booksellerid=[% booksellerid |url %]&amp;datereceived=[% searchresult.raw_datereceived |url %][% IF ( searchresult.code ) %]&amp;invoice=[% searchresult.code |url %][% END %]">
50
            [% searchresult.datereceived %]
46
                [% searchresult.datereceived %]</a>
47
        </td>
51
        </td>
48
        <td>
52
        <td>
49
            [% IF ( searchresult.code ) %][% searchresult.code %][% ELSE %]<acronym title="not available">n/a</acronym>[% END %]
53
            [% IF ( searchresult.code ) %]
54
                <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% searchresult.invoiceid %]">
55
                    [% searchresult.code %]
56
            </a>
57
            [% ELSE %]
58
                <acronym title="not available">n/a</acronym>
59
            [% END %]
50
        </td>
60
        </td>
51
        <td>
61
        <td>
52
            [% searchresult.reccount %] 
62
            [% searchresult.reccount %] 
Lines 81-87 Link Here
81
[% END %]
91
[% END %]
82
92
83
    <div id="parcels_new_parcel">
93
    <div id="parcels_new_parcel">
84
        <form method="get" action="parcel.pl">
94
        <form method="get" action="parcels.pl">
85
    <fieldset class="rows">
95
    <fieldset class="rows">
86
    <legend>Receive a new shipment</legend>
96
    <legend>Receive a new shipment</legend>
87
       <ol> <li>
97
       <ol> <li>
Lines 90-115 Link Here
90
            <input type="hidden" name="op" value="new" />
100
            <input type="hidden" name="op" value="new" />
91
			<input type="text" size="20" id="invoice" name="invoice" />
101
			<input type="text" size="20" id="invoice" name="invoice" />
92
        </li>
102
        </li>
93
		[% IF ( gst ) %]
103
         <li><label for="shipmentdate">Shipment date: </label>
94
        <li>
104
            <input type="text" id="shipmentdate" name="shipmentdate" maxlength="10" size="10" value="[% shipmentdate_today %]" />
95
            <label for="gst">GST:</label>
105
            <img src="[% themelang %]/lib/calendar/cal.gif" id="shipmentdate_button" alt="Show Calendar" />
96
            <input type="text" size="20" id="gst" name="gst" />
97
        </li>
98
		[% END %]
99
      <!--  // Removing freight input until shipping can be proplerly handled .
100
	  <li>
101
            <label for="freight">Shipping:</label>
102
            <input type="text" size="20" id="freight" name="freight" />
103
        </li> -->
104
         <li><label for="datereceived">Shipment date: </label>
105
            <input type="text" id="datereceived" name="datereceived"  maxlength="10" size="10"  value="[% datereceived_today %]" />
106
            <img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
107
      <script language="JavaScript" type="text/javascript">
106
      <script language="JavaScript" type="text/javascript">
108
        Calendar.setup(
107
        Calendar.setup(
109
          {
108
          {
110
            inputField : "datereceived",
109
            inputField : "shipmentdate",
111
            ifFormat : "[% DHTMLcalendar_dateformat %]",
110
            ifFormat : "[% DHTMLcalendar_dateformat %]",
112
            button : "datereceived_button"          }
111
            button : "shipmentdate_button"
112
          }
113
        );
113
        );
114
      </script>
114
      </script>
115
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
115
				<div class="hint">[% INCLUDE 'date-format.inc' %]</div>	</li>
Lines 130-139 Link Here
130
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
130
            <li><label for="datefrom">From:</label><input type="text" size="9" id="datefrom" name="datefrom" value="[% datefrom %]" /><br /> 
131
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
131
                <label for="dateto">To:</label><input type="text" size="9" id="dateto" name="dateto" value="[% dateto %]" /></li>
132
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
132
            <li><label for="orderby">Sort by :</label><select name="orderby" id="orderby">
133
                <option value="aqorders.booksellerinvoicenumber">Invoice number</option>
133
                <option value="invoicenumber">Invoice number</option>
134
                <option value="datereceived"> Date received</option>
134
                <option value="shipmentdate">Shipment date</option>
135
                <option value="datereceived desc"> Date received reverse</option>
135
                <option value="shipmentdate desc">Shipment date reverse</option>
136
                <option value="aqorders.booksellerinvoicenumber desc"> Invoice number reverse</option>
136
                <option value="invoicenumber desc">Invoice number reverse</option>
137
                </select><br />
137
                </select><br />
138
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
138
                <label for="resultsperpage">Results per page :</label><select name="resultsperpage" id="resultsperpage">
139
                <option value="20">20</option>
139
                <option value="20">20</option>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/spent.tt (-22 / +19 lines)
Lines 29-35 Link Here
29
	<th> Itemtype </th>
29
	<th> Itemtype </th>
30
	<th> Received </th>
30
	<th> Received </th>
31
    <th> Unit price </th>
31
    <th> Unit price </th>
32
    <th> Freight per item </th>
33
    <th> Date ordered </th>
32
    <th> Date ordered </th>
34
    <th> Date received </th>
33
    <th> Date received </th>
35
	<th> Subtotal </th>
34
	<th> Subtotal </th>
Lines 47-59 Link Here
47
	    [% order.title %]
46
	    [% order.title %]
48
	</td>
47
	</td>
49
	<td class="cell">
48
	<td class="cell">
50
            <a href="/cgi-bin/koha/acqui/orderreceive.pl?ordernumber=[% order.ordernumber %]&amp;biblio=[% order.biblionumber %]&amp;invoice=[% order.booksellerinvoicenumber %]&amp;booksellerid=[% order.booksellerid %]&amp;catview=yes">[% order.ordernumber %]</a>
49
            <a href="/cgi-bin/koha/acqui/orderreceive.pl?ordernumber=[% order.ordernumber %]&amp;biblio=[% order.biblionumber %]&amp;invoiceid=[% order.invoiceid %]">[% order.ordernumber %]</a>
51
	</td>
50
	</td>
52
	<td class="cell">
51
	<td class="cell">
53
	    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.booksellerid %]">[% order.booksellerid %]</a>
52
	    <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.booksellerid %]">[% order.booksellerid %]</a>
54
	</td>
53
	</td>
55
	<td class="cell">
54
	<td class="cell">
56
	    <a href="/cgi-bin/koha/acqui/parcel.pl?invoice=[% order.booksellerinvoicenumber %]&amp;booksellerid=[% order.booksellerid %]&amp;datereceived=[% order.datereceived %]">[% order.booksellerinvoicenumber %]</a>
55
	    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid %]">[% order.invoicenumber %]</a>
57
	</td>
56
	</td>
58
	<td class="cell">
57
	<td class="cell">
59
	    [% order.itype %]
58
	    [% order.itype %]
Lines 65-101 Link Here
65
	    [% order.unitprice %]
64
	    [% order.unitprice %]
66
	</td>
65
	</td>
67
	<td class="cell" align="right">
66
	<td class="cell" align="right">
68
	    [% order.freight %]
69
	</td>
70
	<td class="cell" align="right">
71
	    [% order.entrydate | $KohaDates %]
67
	    [% order.entrydate | $KohaDates %]
72
	</td>
68
	</td>
73
	<td class="cell" align="right">
69
	<td class="cell" align="right">
74
	    [% order.datereceived | $KohaDates %]
70
	    [% order.datereceived | $KohaDates %]
75
	</td>
71
	</td>
76
	<td class="cell" align="right">
72
	<td class="cell" align="right">
77
	    [% order.subtotal %]
73
	    [% order.rowtotal %]
78
	</td>
74
	</td>
79
    </tr>
75
    </tr>
80
[% END %]
76
[% END %]
81
    <tfoot>
77
    <tfoot>
82
        <tr valign="top">
78
        [% IF shipmentcosts.size %]
83
        <td> Total </td>
79
            <tr valign="top">
84
        <td> </td>
80
                <td colspan="9"> Sub total </td>
85
        <td> </td>
81
                <td align="right"> [% subtotal %] </td>
86
        <td> </td>
82
            </tr>
87
        <td> </td>
83
            [% FOREACH shipmentcost IN shipmentcosts %]
88
        <td> </td>
84
                <tr>
89
        <td> </td>
85
                    <td></td>
90
        <td> </td>
86
                    <td colspan="8">Shipment cost for invoice [% shipmentcost.invoicenumber %]</td>
91
	<td> </td>
87
                    <td class="total">[% shipmentcost.shipmentcost %]</td>
92
	<td> </td>
88
                </tr>
93
        <td align="right">
89
            [% END %]
94
		[% total %]
90
        [% END %]
95
	</td>
91
        <tr>
92
            <td colspan="9">TOTAL</td>
93
            <td class="total">[% total %]</td>
96
        </tr>
94
        </tr>
97
    </tfoot>
95
    </tfoot>
98
99
</table>
96
</table>
100
97
101
</div>
98
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (-5 / +4 lines)
Lines 168-183 Link Here
168
168
169
            [% IF ITEM_DAT.dateaccessioned %]
169
            [% IF ITEM_DAT.dateaccessioned %]
170
                <li><span class="label">Accession date:</span>
170
                <li><span class="label">Accession date:</span>
171
                    [% IF ( CAN_user_acquisition_order_receive && ITEM_DAT.booksellerinvoicenumber ) %]
171
                    [% IF ( CAN_user_acquisition_order_receive && ITEM_DAT.invoiceid ) %]
172
                        <a href="/cgi-bin/koha/acqui/parcel.pl?booksellerid=[% ITEM_DAT.booksellerid %]&amp;invoice=[% ITEM_DAT.booksellerinvoicenumber %]&amp;datereceived=[% ITEM_DAT.datereceived %]">[% ITEM_DAT.dateaccessioned | $KohaDates %]</a>
172
                        <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% ITEM_DAT.invoiceid %]">[% ITEM_DAT.dateaccessioned | $KohaDates %]</a>
173
                    [% ELSE %]
173
                    [% ELSE %]
174
                        [% ITEM_DAT.dateaccessioned | $KohaDates %]
174
                        [% ITEM_DAT.dateaccessioned | $KohaDates %]
175
                    [% END %]
175
                    [% END %]
176
                </li>
176
                </li>
177
            [% END %]
177
            [% END %]
178
            [% IF ( ITEM_DAT.booksellerinvoicenumber ) %]
178
            [% IF ( ITEM_DAT.invoicenumber ) %]
179
                <li><span class="label">Invoice number:</span>
179
                <li><span class="label">Invoice number:</span>
180
                    [% ITEM_DAT.booksellerinvoicenumber %]
180
                    [% ITEM_DAT.invoicenumber %]
181
                </li>
181
                </li>
182
            [% END %]
182
            [% END %]
183
183
184
- 

Return to bug 5339