Revision e7214232
Von Moritz Bunkus vor etwa 18 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
875 | 875 |
if ($form->{to}) { |
876 | 876 |
$where .= "AND $tabelle.transdate <= '$form->{to}' "; |
877 | 877 |
} |
878 |
my $query = qq|select shiptoname, adr_code, $tabelle.transdate, $tabelle.invnumber, $tabelle.ordnumber, invoice.description, qty, invoice.unit FROM $tabelle LEFT JOIN shipto ON |;
|
|
878 |
my $query = qq|select shiptoname, $tabelle.transdate, $tabelle.invnumber, $tabelle.ordnumber, invoice.description, qty, invoice.unit FROM $tabelle LEFT JOIN shipto ON |; |
|
879 | 879 |
$query .= ($tabelle eq "ar") ? qq|($tabelle.shipto_id=shipto.shipto_id) |:qq|($tabelle.id=shipto.trans_id) |; |
880 |
$query .=qq|LEFT join invoice on ($tabelle.id=invoice.trans_id) LEFT join parts ON (parts.id=invoice.parts_id) LEFT join adr ON (parts.adr_id=adr.id) $where ORDER BY $tabelle.transdate DESC LIMIT 15|;
|
|
880 |
$query .=qq|LEFT join invoice on ($tabelle.id=invoice.trans_id) LEFT join parts ON (parts.id=invoice.parts_id) $where ORDER BY $tabelle.transdate DESC LIMIT 15|; |
|
881 | 881 |
my $sth = $dbh->prepare($query); |
882 | 882 |
$sth->execute || $form->dberror($query); |
883 | 883 |
|
... | ... | |
891 | 891 |
$main::lxdebug->leave_sub(); |
892 | 892 |
} |
893 | 893 |
|
894 |
sub adr { |
|
895 |
$main::lxdebug->enter_sub(); |
|
896 |
|
|
897 |
my ($self, $myconfig, $form) = @_; |
|
898 |
my $dbh = $form->dbconnect($myconfig); |
|
899 |
$where = " WHERE 1=1 "; |
|
900 |
if ($form->{from}) { |
|
901 |
$where .= "AND ar.transdate >= '$form->{from}' "; |
|
902 |
} |
|
903 |
if ($form->{to}) { |
|
904 |
$where .= "AND ar.transdate <= '$form->{to}' "; |
|
905 |
} |
|
906 |
if ($form->{year}) { |
|
907 |
$where = " WHERE ar.transdate >= '$form->{year}-01-01' AND ar.transdate <= '$form->{year}-12-31' "; |
|
908 |
} |
|
909 |
|
|
910 |
my $query = qq|select adr_code, adr_description, sum(base_qty), parts.unit from ar LEFT join invoice on (ar.id=invoice.trans_id) LEFT join parts ON (invoice.parts_id=parts.id) LEFT join adr ON (adr.id=parts.adr_id) $where GROUP BY adr_code,adr_description,parts.unit|; |
|
911 |
my $sth = $dbh->prepare($query); |
|
912 |
$sth->execute || $form->dberror($query); |
|
913 |
|
|
914 |
|
|
915 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
|
916 |
push @{ $form->{ADR} }, $ref; |
|
917 |
} |
|
918 |
$sth->finish; |
|
919 |
$dbh->disconnect; |
|
920 |
|
|
921 |
$main::lxdebug->leave_sub(); |
|
922 |
} |
|
923 |
|
|
924 | 894 |
1; |
925 | 895 |
|
Auch abrufbar als: Unified diff
ADR entfernt (kam aus Kundenprojekt und ist nicht fuer die allgemeine Lx-Office-Variante gedacht).