|
Lines 1859-1865
sub GetParcels {
Link Here
|
| 1859 |
|
1859 |
|
| 1860 |
=head3 GetLateOrders |
1860 |
=head3 GetLateOrders |
| 1861 |
|
1861 |
|
| 1862 |
@results = &GetLateOrders; |
1862 |
$results = &GetLateOrders($delay, $supplierid, $branch, $estimateddeliverydatefrom, $estimateddeliverydateto); |
| 1863 |
|
1863 |
|
| 1864 |
Searches for bookseller with late orders. |
1864 |
Searches for bookseller with late orders. |
| 1865 |
|
1865 |
|
|
Lines 1885-1890
sub GetLateOrders {
Link Here
|
| 1885 |
SELECT aqbasket.basketno, |
1885 |
SELECT aqbasket.basketno, |
| 1886 |
aqorders.ordernumber, |
1886 |
aqorders.ordernumber, |
| 1887 |
DATE(aqbasket.closedate) AS orderdate, |
1887 |
DATE(aqbasket.closedate) AS orderdate, |
|
|
1888 |
aqbasket.basketname AS basketname, |
| 1889 |
aqbasket.basketgroupid AS basketgroupid, |
| 1890 |
aqbasketgroups.name AS basketgroupname, |
| 1888 |
aqorders.rrp AS unitpricesupplier, |
1891 |
aqorders.rrp AS unitpricesupplier, |
| 1889 |
aqorders.ecost AS unitpricelib, |
1892 |
aqorders.ecost AS unitpricelib, |
| 1890 |
aqorders.claims_count AS claims_count, |
1893 |
aqorders.claims_count AS claims_count, |
|
Lines 1905-1910
sub GetLateOrders {
Link Here
|
| 1905 |
LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id, |
1908 |
LEFT JOIN aqbudgets ON aqorders.budget_id = aqbudgets.budget_id, |
| 1906 |
aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber |
1909 |
aqbasket LEFT JOIN borrowers ON aqbasket.authorisedby = borrowers.borrowernumber |
| 1907 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
1910 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
|
|
1911 |
LEFT JOIN aqbasketgroups ON aqbasket.basketgroupid = aqbasketgroups.id |
| 1908 |
WHERE aqorders.basketno = aqbasket.basketno |
1912 |
WHERE aqorders.basketno = aqbasket.basketno |
| 1909 |
AND ( datereceived = '' |
1913 |
AND ( datereceived = '' |
| 1910 |
OR datereceived IS NULL |
1914 |
OR datereceived IS NULL |
|
Lines 1918-1927
sub GetLateOrders {
Link Here
|
| 1918 |
$select .= " |
1922 |
$select .= " |
| 1919 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, |
1923 |
aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity, |
| 1920 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal, |
1924 |
(aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal, |
| 1921 |
DATEDIFF(CAST(now() AS date),closedate) AS latesince |
1925 |
DATEDIFF(CAST(now() AS date),aqbasket.closedate) AS latesince |
| 1922 |
"; |
1926 |
"; |
| 1923 |
if ( defined $delay ) { |
1927 |
if ( defined $delay ) { |
| 1924 |
$from .= " AND (closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ; |
1928 |
$from .= " AND (aqbasket.closedate <= DATE_SUB(CAST(now() AS date),INTERVAL ? DAY)) " ; |
| 1925 |
push @query_params, $delay; |
1929 |
push @query_params, $delay; |
| 1926 |
} |
1930 |
} |
| 1927 |
$having = " |
1931 |
$having = " |
|
Lines 1934-1943
sub GetLateOrders {
Link Here
|
| 1934 |
$select .= " |
1938 |
$select .= " |
| 1935 |
aqorders.quantity AS quantity, |
1939 |
aqorders.quantity AS quantity, |
| 1936 |
aqorders.quantity * aqorders.rrp AS subtotal, |
1940 |
aqorders.quantity * aqorders.rrp AS subtotal, |
| 1937 |
(CAST(now() AS date) - closedate) AS latesince |
1941 |
(CAST(now() AS date) - aqbasket.closedate) AS latesince |
| 1938 |
"; |
1942 |
"; |
| 1939 |
if ( defined $delay ) { |
1943 |
if ( defined $delay ) { |
| 1940 |
$from .= " AND (closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) "; |
1944 |
$from .= " AND (aqbasket.closedate <= (CAST(now() AS date) -(INTERVAL ? DAY)) "; |
| 1941 |
push @query_params, $delay; |
1945 |
push @query_params, $delay; |
| 1942 |
} |
1946 |
} |
| 1943 |
} |
1947 |
} |