Revision c98a426e
Von Moritz Bunkus vor fast 18 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
1017 | 1017 |
expense_accno_id_3, |
1018 | 1018 |
(SELECT accno FROM chart WHERE id = expense_accno_id_3) AS expense_accno_3 |
1019 | 1019 |
FROM buchungsgruppen |
1020 |
ORDER BY id|;
|
|
1020 |
ORDER BY sortkey|;
|
|
1021 | 1021 |
|
1022 | 1022 |
$sth = $dbh->prepare($query); |
1023 | 1023 |
$sth->execute || $form->dberror($query); |
... | ... | |
1141 | 1141 |
$form->{income_accno_id_2}, $form->{expense_accno_id_2}, |
1142 | 1142 |
$form->{income_accno_id_3}, $form->{expense_accno_id_3}); |
1143 | 1143 |
|
1144 |
my $query; |
|
1145 |
|
|
1144 | 1146 |
# id is the old record |
1145 | 1147 |
if ($form->{id}) { |
1146 | 1148 |
$query = qq|UPDATE buchungsgruppen SET |
... | ... | |
1152 | 1154 |
WHERE id = ?|; |
1153 | 1155 |
push(@values, $form->{id}); |
1154 | 1156 |
} else { |
1157 |
$query = qq|SELECT MAX(sortkey) + 1 FROM buchungsgruppen|; |
|
1158 |
my ($sortkey) = $dbh->selectrow_array($query); |
|
1159 |
$form->dberror($query) if ($dbh->err); |
|
1160 |
push(@values, $sortkey); |
|
1155 | 1161 |
$query = qq|INSERT INTO buchungsgruppen |
1156 | 1162 |
(description, inventory_accno_id, |
1157 | 1163 |
income_accno_id_0, expense_accno_id_0, |
1158 | 1164 |
income_accno_id_1, expense_accno_id_1, |
1159 | 1165 |
income_accno_id_2, expense_accno_id_2, |
1160 |
income_accno_id_3, expense_accno_id_3) |
|
1161 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
1166 |
income_accno_id_3, expense_accno_id_3, |
|
1167 |
sortkey) |
|
1168 |
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
1162 | 1169 |
} |
1163 | 1170 |
do_query($form, $dbh, $query, @values); |
1164 | 1171 |
|
... | ... | |
1183 | 1190 |
$main::lxdebug->leave_sub(); |
1184 | 1191 |
} |
1185 | 1192 |
|
1193 |
sub swap_buchungsgruppen { |
|
1194 |
$main::lxdebug->enter_sub(); |
|
1195 |
|
|
1196 |
my ($self, $myconfig, $form) = @_; |
|
1197 |
|
|
1198 |
# connect to database |
|
1199 |
my $dbh = $form->dbconnect_noauto($myconfig); |
|
1200 |
|
|
1201 |
my $query = |
|
1202 |
qq|SELECT |
|
1203 |
(SELECT sortkey FROM buchungsgruppen WHERE id = ?) AS sortkey1, |
|
1204 |
(SELECT sortkey FROM buchungsgruppen WHERE id = ?) AS sortkey2|; |
|
1205 |
my @values = ($form->{"id1"}, $form->{"id2"}); |
|
1206 |
my @sortkeys = selectrow_query($form, $dbh, $query, @values); |
|
1207 |
|
|
1208 |
$query = qq|UPDATE buchungsgruppen SET sortkey = ? WHERE id = ?|; |
|
1209 |
my $sth = $dbh->prepare($query); |
|
1210 |
$sth->execute($sortkeys[1], $form->{"id1"}) || |
|
1211 |
$form->dberror($query . " ($sortkeys[1], $form->{id1})"); |
|
1212 |
$sth->execute($sortkeys[0], $form->{"id2"}) || |
|
1213 |
$form->dberror($query . " ($sortkeys[0], $form->{id2})"); |
|
1214 |
$sth->finish(); |
|
1215 |
|
|
1216 |
$dbh->commit(); |
|
1217 |
$dbh->disconnect; |
|
1218 |
|
|
1219 |
$main::lxdebug->leave_sub(); |
|
1220 |
} |
|
1221 |
|
|
1186 | 1222 |
sub printer { |
1187 | 1223 |
$main::lxdebug->enter_sub(); |
1188 | 1224 |
|
Auch abrufbar als: Unified diff
Die Buchungsgruppen sortierbar gemacht.