From c98a426e3bc4461e663570ca4da8c12091daa7a9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 2 Feb 2007 10:32:03 +0000 Subject: [PATCH] Die Buchungsgruppen sortierbar gemacht. --- SL/AM.pm | 42 +++++++++++++-- SL/IC.pm | 3 +- bin/mozilla/am.pl | 57 ++++++++++++++++++-- image/down.png | Bin 0 -> 348 bytes image/up.png | Bin 0 -> 344 bytes locale/de/all | 2 + locale/de/am | 3 ++ sql/Pg-upgrade2/buchungsgruppen_sortkey.sql | 8 +++ 8 files changed, 107 insertions(+), 8 deletions(-) create mode 100755 image/down.png create mode 100755 image/up.png create mode 100644 sql/Pg-upgrade2/buchungsgruppen_sortkey.sql 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 0000000000000000000000000000000000000000..0ba4c058a15168efc5166fadd535a566f435a5e2 GIT binary patch literal 348 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6I14-?iy0WWg+Z8+Vb&Z8pdd@S zqpu?a!^Xav-+_~Xe1&9>AYTTCDpdxChGqtapZ|gMO9qBg0|tgy2@DKYGZ+}e^C!h0 zbpxus*q#0uwn)IFy-BnD#jQk@smj zV4}dR&~SiDLb6Lj!Al`XVClaEGY5vowLj+HJN}{Tp{l?>hRN$2F3fKN+V>zQ+O!oJB5We-;ytYh_dPGMl;Sk*95F-a`> zmt@;|p8FD2jbVPXS&e~;AKYWn{5ij_H&N}vyO*0K9!_Iq5l~*ZfQ>_;iIG*nfkhPP ka7R`KMwb9ahXzK5cS5=WJr|0Tfxct#boFyt=akR{09EO0{{R30 literal 0 HcmV?d00001 diff --git a/image/up.png b/image/up.png new file mode 100755 index 0000000000000000000000000000000000000000..e5586cdefad8b1822ca7cea3e011933f38a4c58d GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6I14-?iy0WWg+Z8+Vb&Z8pdd@S zqpu?a!^Xav-+_~Xe1&9>AYTTCDpdxChGqtapZ|gMO9qBg0|tgy2@DKYGZ+}e^C!h0 zbpxtB=jq}YQgJKk&-n&<1{MKf#!9vZ2Bj4Y3Jn}u3>*qgTntPdtS&N12`LPgWv;jW z&uo{JxV-!fb(yryyvuW3QX(yFS>qDPgNqm#S;7u*T)lhZ!;FWT zhqX2cxvem3U}&1PL1xA7u7_ratrcp{Gi*sr3zJf50U9sp!g%%kne-jZ=3*|>neP@! zt`JgaP~iHPZWMF0pkDj1=z^*S1}5zbf6pIa;4X4wW0770be;s~QC0^AK^_ex=Nd4~ YUv21mz3bj)pwAdQUHx3vIVCg!085Z-dH?_b literal 0 HcmV?d00001 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; -- 2.20.1