|
Lines 102-120
Searches for suppliers with late orders.
Link Here
|
| 102 |
=cut |
102 |
=cut |
| 103 |
|
103 |
|
| 104 |
sub GetBooksellersWithLateOrders { |
104 |
sub GetBooksellersWithLateOrders { |
| 105 |
my $delay = shift; |
105 |
my ( $delay, $branch, $estimateddeliverydatefrom, $estimateddeliverydateto ) = @_; # FIXME: Branch argument unused. |
| 106 |
my $dbh = C4::Context->dbh; |
106 |
my $dbh = C4::Context->dbh; |
| 107 |
|
107 |
|
| 108 |
# TODO delay should be verified |
108 |
# FIXME NOT quite sure that this operation is valid for DBMs different from Mysql, HOPING so |
| 109 |
my $query_string = |
109 |
# should be tested with other DBMs |
| 110 |
"SELECT DISTINCT aqbasket.booksellerid, aqbooksellers.name |
110 |
|
| 111 |
FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno |
111 |
my $strsth; |
| 112 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
112 |
my @query_params = (); |
| 113 |
WHERE (closedate < DATE_SUB(CURDATE( ),INTERVAL $delay DAY) |
113 |
my $dbdriver = C4::Context->config("db_scheme") || "mysql"; |
| 114 |
AND (datereceived = '' OR datereceived IS NULL))"; |
114 |
$strsth = " |
| 115 |
|
115 |
SELECT DISTINCT aqbasket.booksellerid, aqbooksellers.name |
| 116 |
my $sth = $dbh->prepare($query_string); |
116 |
FROM aqorders LEFT JOIN aqbasket ON aqorders.basketno=aqbasket.basketno |
| 117 |
$sth->execute; |
117 |
LEFT JOIN aqbooksellers ON aqbasket.booksellerid = aqbooksellers.id |
|
|
118 |
WHERE |
| 119 |
( datereceived = '' |
| 120 |
OR datereceived IS NULL |
| 121 |
OR aqorders.quantityreceived < aqorders.quantity |
| 122 |
) |
| 123 |
AND aqorders.rrp <> 0 |
| 124 |
AND aqorders.ecost <> 0 |
| 125 |
AND aqorders.quantity - IFNULL(aqorders.quantityreceived,0) <> 0 |
| 126 |
AND aqbasket.closedate IS NOT NULL |
| 127 |
"; |
| 128 |
if ( defined $delay ) { |
| 129 |
$strsth .= " AND (closedate <= DATE_SUB(CURDATE( ),INTERVAL ? DAY)) "; |
| 130 |
push @query_params, $delay; |
| 131 |
} |
| 132 |
if ( defined $estimateddeliverydatefrom ) { |
| 133 |
$strsth .= ' |
| 134 |
AND aqbooksellers.deliverytime IS NOT NULL |
| 135 |
AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) >= ?'; |
| 136 |
push @query_params, $estimateddeliverydatefrom; |
| 137 |
} |
| 138 |
if ( defined $estimateddeliverydatefrom and defined $estimateddeliverydateto ) { |
| 139 |
$strsth .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= ?'; |
| 140 |
push @query_params, $estimateddeliverydateto; |
| 141 |
} elsif ( defined $estimateddeliverydatefrom ) { |
| 142 |
$strsth .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CURDATE()'; |
| 143 |
} |
| 144 |
|
| 145 |
my $sth = $dbh->prepare($strsth); |
| 146 |
$sth->execute( @query_params ); |
| 118 |
my %supplierlist; |
147 |
my %supplierlist; |
| 119 |
while ( my ( $id, $name ) = $sth->fetchrow ) { |
148 |
while ( my ( $id, $name ) = $sth->fetchrow ) { |
| 120 |
$supplierlist{$id} = $name; |
149 |
$supplierlist{$id} = $name; |
|
Lines 201-207
sub ModBookseller {
Link Here
|
| 201 |
contphone=?,contfax=?,contaltphone=?,contemail=?, |
230 |
contphone=?,contfax=?,contaltphone=?,contemail=?, |
| 202 |
contnotes=?,active=?,listprice=?, invoiceprice=?, |
231 |
contnotes=?,active=?,listprice=?, invoiceprice=?, |
| 203 |
gstreg=?,listincgst=?,invoiceincgst=?, |
232 |
gstreg=?,listincgst=?,invoiceincgst=?, |
| 204 |
discount=?,notes=?,gstrate=? |
233 |
discount=?,notes=?,gstrate=?,deliverytime=? |
| 205 |
WHERE id=?'; |
234 |
WHERE id=?'; |
| 206 |
my $sth = $dbh->prepare($query); |
235 |
my $sth = $dbh->prepare($query); |
| 207 |
$sth->execute( |
236 |
$sth->execute( |
|
Lines 218-224
sub ModBookseller {
Link Here
|
| 218 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
247 |
$data->{'invoiceprice'}, $data->{'gstreg'}, |
| 219 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
248 |
$data->{'listincgst'}, $data->{'invoiceincgst'}, |
| 220 |
$data->{'discount'}, $data->{'notes'}, |
249 |
$data->{'discount'}, $data->{'notes'}, |
| 221 |
$data->{'gstrate'}, $data->{'id'} |
250 |
$data->{'gstrate'}, |
|
|
251 |
$data->{deliverytime}, |
| 252 |
$data->{'id'} |
| 222 |
); |
253 |
); |
| 223 |
return; |
254 |
return; |
| 224 |
} |
255 |
} |