From: Moritz Bunkus Date: Fri, 2 Feb 2007 10:32:03 +0000 (+0000) Subject: Die Buchungsgruppen sortierbar gemacht. X-Git-Tag: release-2.4.2~173 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c98a426e3bc4461e663570ca4da8c12091daa7a9;p=kivitendo-erp.git Die Buchungsgruppen sortierbar gemacht. --- diff --git a/SL/AM.pm b/SL/AM.pm index 0cac83f02..b3874bdf5 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1017,7 +1017,7 @@ sub buchungsgruppe { 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); @@ -1141,6 +1141,8 @@ sub save_buchungsgruppe { $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 @@ -1152,13 +1154,18 @@ sub save_buchungsgruppe { 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); @@ -1183,6 +1190,35 @@ sub delete_buchungsgruppe { $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(); diff --git a/SL/IC.pm b/SL/IC.pm index 3141b805e..56bc2eeeb 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -310,7 +310,8 @@ sub retrieve_buchungsgruppen { # get buchungsgruppen $query = qq|SELECT id, description - FROM buchungsgruppen|; + FROM buchungsgruppen + ORDER BY sortkey|; $sth = $dbh->prepare($query); $sth->execute || $form->dberror($query); diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 7084aa388..ddfa954b0 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -1782,14 +1782,26 @@ sub list_buchungsgruppe { $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|| + . qq|| . $locale->text(| + . qq||; + $column_header{down} = + qq|| + . qq|| . $locale->text(| + . qq||; $column_header{description} = - qq|| + qq|| . $locale->text('Description') . qq||; $column_header{inventory_accno} = - qq|| + qq|| . $locale->text('Bestandskonto') . qq||; $column_header{income_accno_0} = @@ -1846,6 +1858,11 @@ sub list_buchungsgruppe { |; + 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++; @@ -1855,6 +1872,27 @@ sub list_buchungsgruppe { |; + if ($row) { + my $pref = $form->{ALL}->[$row - 1]; + $column_data{up} = + qq|| . + qq|| . + qq|| . $locale->text(| . + qq||; + } else { + $column_data{up} = qq| |; + } + + if ($row == (scalar(@{ $form->{ALL} }) - 1)) { + $column_data{down} = qq| |; + } else { + my $nref = $form->{ALL}->[$row + 1]; + $column_data{down} = + qq|| . + qq|| . + qq|| . $locale->text(| . + qq||; + } $column_data{description} = qq|{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}|; @@ -1877,6 +1915,8 @@ sub list_buchungsgruppe { print qq| |; + + $row++; } print qq| @@ -2071,6 +2111,15 @@ sub delete_buchungsgruppe { $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(); diff --git a/image/down.png b/image/down.png new file mode 100755 index 000000000..0ba4c058a Binary files /dev/null and b/image/down.png differ diff --git a/image/up.png b/image/up.png new file mode 100755 index 000000000..e5586cdef Binary files /dev/null and b/image/up.png differ diff --git a/locale/de/all b/locale/de/all index 6e15be25b..a368ce845 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1158,6 +1158,7 @@ gestartet', 'dimension units' => 'Maßeinheiten', 'does not exist' => 'existiert nicht', 'done' => 'erledigt', + 'down' => 'hoch', 'eMail Send?' => 'eMail-Versand?', 'eMail?' => 'eMail?', 'ea' => 'St.', @@ -1187,6 +1188,7 @@ gestartet', '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', diff --git a/locale/de/am b/locale/de/am index ef6bf66a4..051d201bd 100644 --- a/locale/de/am +++ b/locale/de/am @@ -288,10 +288,12 @@ $self->{texts} = { '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', }; @@ -398,6 +400,7 @@ $self->{subs} = { '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', diff --git a/sql/Pg-upgrade2/buchungsgruppen_sortkey.sql b/sql/Pg-upgrade2/buchungsgruppen_sortkey.sql new file mode 100644 index 000000000..640559133 --- /dev/null +++ b/sql/Pg-upgrade2/buchungsgruppen_sortkey.sql @@ -0,0 +1,8 @@ +-- @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;