Revision f5c548f0
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
SL/OE.pm | ||
---|---|---|
588 | 588 |
# connect to database |
589 | 589 |
my $dbh = $form->dbconnect_noauto($myconfig); |
590 | 590 |
|
591 |
my ($query, @values, @ids);
|
|
591 |
my ($query, $query_add, @values, @ids, $sth);
|
|
592 | 592 |
|
593 | 593 |
# translate the ids (given by id_# and trans_id_#) into one array of ids, so we can join them later |
594 | 594 |
map { |
... | ... | |
602 | 602 |
undef @ids; |
603 | 603 |
} |
604 | 604 |
|
605 |
if ($form->{id}) { |
|
606 |
|
|
607 |
# get default accounts and last order number |
|
608 |
$query = qq|SELECT (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, |
|
609 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
|
610 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
|
611 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
|
612 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
613 |
d.curr AS currencies |
|
614 |
FROM defaults d|; |
|
615 |
} else { |
|
616 |
$query = qq|SELECT (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, |
|
617 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
|
618 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
|
619 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
|
620 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
621 |
d.curr AS currencies, current_date AS transdate, current_date AS reqdate |
|
622 |
FROM defaults d|; |
|
623 |
} |
|
624 |
my $sth = $dbh->prepare($query); |
|
625 |
$sth->execute || $form->dberror($query); |
|
626 |
|
|
627 |
my $ref = $sth->fetchrow_hashref(NAME_lc); |
|
605 |
$query_add = qq|, current_date AS transdate, current_date AS reqdate| if (!$form->{id}); |
|
606 |
|
|
607 |
# get default accounts |
|
608 |
$query = qq|SELECT (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, |
|
609 |
(SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, |
|
610 |
(SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, |
|
611 |
(SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, |
|
612 |
(SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, |
|
613 |
d.curr AS currencies |
|
614 |
$query_add |
|
615 |
FROM defaults d|; |
|
616 |
my $ref = selectfirst_hashref_query($form, $dbh, $query); |
|
628 | 617 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
629 |
$sth->finish; |
|
630 | 618 |
|
631 | 619 |
($form->{currency}) = split(/:/, $form->{currencies}); |
632 | 620 |
|
Auch abrufbar als: Unified diff
Kosmetik/Vereinfachung