expense_accno_id_3,
(SELECT accno FROM chart WHERE id = expense_accno_id_3) AS expense_accno_3
FROM buchungsgruppen
- ORDER BY id|;
+ ORDER BY sortkey|;
$sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
$form->{income_accno_id_2}, $form->{expense_accno_id_2},
$form->{income_accno_id_3}, $form->{expense_accno_id_3});
+ my $query;
+
# id is the old record
if ($form->{id}) {
$query = qq|UPDATE buchungsgruppen SET
WHERE id = ?|;
push(@values, $form->{id});
} else {
+ $query = qq|SELECT MAX(sortkey) + 1 FROM buchungsgruppen|;
+ my ($sortkey) = $dbh->selectrow_array($query);
+ $form->dberror($query) if ($dbh->err);
+ push(@values, $sortkey);
$query = qq|INSERT INTO buchungsgruppen
(description, inventory_accno_id,
income_accno_id_0, expense_accno_id_0,
income_accno_id_1, expense_accno_id_1,
income_accno_id_2, expense_accno_id_2,
- income_accno_id_3, expense_accno_id_3)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
+ income_accno_id_3, expense_accno_id_3,
+ sortkey)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
}
do_query($form, $dbh, $query, @values);
$main::lxdebug->leave_sub();
}
+sub swap_buchungsgruppen {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $myconfig, $form) = @_;
+
+ # connect to database
+ my $dbh = $form->dbconnect_noauto($myconfig);
+
+ my $query =
+ qq|SELECT
+ (SELECT sortkey FROM buchungsgruppen WHERE id = ?) AS sortkey1,
+ (SELECT sortkey FROM buchungsgruppen WHERE id = ?) AS sortkey2|;
+ my @values = ($form->{"id1"}, $form->{"id2"});
+ my @sortkeys = selectrow_query($form, $dbh, $query, @values);
+
+ $query = qq|UPDATE buchungsgruppen SET sortkey = ? WHERE id = ?|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute($sortkeys[1], $form->{"id1"}) ||
+ $form->dberror($query . " ($sortkeys[1], $form->{id1})");
+ $sth->execute($sortkeys[0], $form->{"id2"}) ||
+ $form->dberror($query . " ($sortkeys[0], $form->{id2})");
+ $sth->finish();
+
+ $dbh->commit();
+ $dbh->disconnect;
+
+ $main::lxdebug->leave_sub();
+}
+
sub printer {
$main::lxdebug->enter_sub();
# get buchungsgruppen
$query = qq|SELECT id, description
- FROM buchungsgruppen|;
+ FROM buchungsgruppen
+ ORDER BY sortkey|;
$sth = $dbh->prepare($query);
$sth->execute || $form->dberror($query);
$form->{title} = $locale->text('Buchungsgruppen');
- @column_index = qw(description inventory_accno income_accno_0 expense_accno_0 income_accno_1 expense_accno_1 income_accno_2 expense_accno_2 income_accno_3 expense_accno_3 );
-
+ @column_index = qw(up down description inventory_accno
+ income_accno_0 expense_accno_0
+ income_accno_1 expense_accno_1
+ income_accno_2 expense_accno_2
+ income_accno_3 expense_accno_3 );
+
+ $column_header{up} =
+ qq|<th class="listheading">|
+ . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
+ . qq|</th>|;
+ $column_header{down} =
+ qq|<th class="listheading">|
+ . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
+ . qq|</th>|;
$column_header{description} =
- qq|<th class=listheading width=60%>|
+ qq|<th class="listheading" width="40%">|
. $locale->text('Description')
. qq|</th>|;
$column_header{inventory_accno} =
- qq|<th class=listheading width=10%>|
+ qq|<th class=listheading>|
. $locale->text('Bestandskonto')
. qq|</th>|;
$column_header{income_accno_0} =
</tr>
|;
+ my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
+ map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
+ qw(login password path));
+
+ my $row = 0;
foreach $ref (@{ $form->{ALL} }) {
$i++;
<tr valign=top class=listrow$i>
|;
+ if ($row) {
+ my $pref = $form->{ALL}->[$row - 1];
+ $column_data{up} =
+ qq|<td align="center" valign="center">| .
+ qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
+ qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
+ qq|</a></td>|;
+ } else {
+ $column_data{up} = qq|<td> </td>|;
+ }
+
+ if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
+ $column_data{down} = qq|<td> </td>|;
+ } else {
+ my $nref = $form->{ALL}->[$row + 1];
+ $column_data{down} =
+ qq|<td align="center" valign="center">| .
+ qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
+ qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
+ qq|</a></td>|;
+ }
$column_data{description} =
qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
print qq|
</tr>
|;
+
+ $row++;
}
print qq|
$lxdebug->leave_sub();
}
+sub swap_buchungsgruppen {
+ $lxdebug->enter_sub();
+
+ AM->swap_buchungsgruppen(\%myconfig, $form);
+ list_buchungsgruppe();
+
+ $lxdebug->leave_sub();
+}
+
sub add_printer {
$lxdebug->enter_sub();
'dimension units' => 'Maßeinheiten',
'does not exist' => 'existiert nicht',
'done' => 'erledigt',
+ 'down' => 'hoch',
'eMail Send?' => 'eMail-Versand?',
'eMail?' => 'eMail?',
'ea' => 'St.',
'successfully created!' => 'wurde erfolgreich erstellt',
'successfully deleted!' => 'wurde erfolgreich gelöscht',
'to (date)' => 'bis',
+ 'up' => 'runter',
'use program settings' => 'benutze Programmeinstellungen',
'ustva' => 'UStVA',
'website' => 'Webseite',
'Year End' => 'Jahresende',
'Yes' => 'Ja',
'dimension units' => 'Maßeinheiten',
+ 'down' => 'hoch',
'equal Outputformat' => 'wie Ausgabeformat',
'lead deleted!' => 'Kundenquelle gelöscht',
'lead saved!' => 'Kundenquelle geichert',
'service units' => 'Dienstleistungseinheiten',
+ 'up' => 'runter',
'use program settings' => 'benutze Programmeinstellungen',
};
'set_longdescription' => 'set_longdescription',
'set_unit_languages' => 'set_unit_languages',
'sic_header' => 'sic_header',
+ 'swap_buchungsgruppen' => 'swap_buchungsgruppen',
'vendor_selection' => 'vendor_selection',
'warehouse_header' => 'warehouse_header',
'erfassen' => 'add',
--- /dev/null
+-- @tag: buchungsgruppen_sortkey
+-- @description: Neue Spalte für Sortierreihenfolge der Buchungsgruppen
+-- @depends: release_2_4_1
+ALTER TABLE buchungsgruppen ADD COLUMN sortkey integer;
+CREATE SEQUENCE tmp_counter;
+UPDATE buchungsgruppen SET sortkey = nextval('tmp_counter');
+DROP SEQUENCE tmp_counter;
+ALTER TABLE buchungsgruppen ALTER COLUMN sortkey SET NOT NULL;