From 5eadc96699ee3f70f3a0bb3f473f3cfea7e8ea68 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 16 Aug 2010 09:51:06 +0200 Subject: [PATCH] =?utf8?q?Vertretermodus:=20Immer=20bisherigen=20Vertreter?= =?utf8?q?=20anzeigen=20&=20nur=20wahlweise=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Neues Verhalten in der Kundenmaske: Wird ein Kunde neu angelegt, so muss ein Vertreter ausgewählt werden. Wird ein bestehender Kunde bearbeitet, so wird der Name des bisher für ihn ausgewählten Vertreters immer angezeigt. Zusätzlich hat der Bearbeiter die Möglichkeit, den Vertreter über die Drop-Down-Box der aktuell gültigen Kunden zu ändern. Wird hier kein Vertreter ausgewählt, so bleibt der bisherige Vertreter bestehen. --- bin/mozilla/ct.pl | 60 ++++++++++++-------------- locale/de/all | 2 +- templates/webpages/ct/form_header.html | 24 +++++++++-- 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index b6526b933..07a6d2ec8 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -289,7 +289,7 @@ sub form_header { taxzones => "ALL_TAXZONES"); $form->get_pricegroup(\%myconfig, { all => 1 }); - $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1, with_obsolete => 1 }) if $::vertreter; + $form->get_lists(customers => { key => "ALL_SALESMAN_CUSTOMERS", business_is_salesman => 1 }) if $::vertreter; $form->{ALL_SALESMEN} = $form->{ALL_EMPLOYEES}; $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : ""; @@ -336,6 +336,29 @@ sub form_footer { $main::lxdebug->leave_sub(); } +sub _do_save { + $main::auth->assert('customer_vendor_edit & ' . + '(general_ledger | invoice_edit | vendor_invoice_edit | ' . + ' request_quotation_edit | sales_quotation_edit | sales_order_edit | purchase_order_edit)'); + + $::form->isblank("name", $::locale->text("Name missing!")); + + if ($::form->{new_salesman_id} && $::vertreter) { + $::form->{salesman_id} = $::form->{new_salesman_id}; + delete $::form->{new_salesman_id}; + } + + my $res = $::form->{db} eq 'customer' ? CT->save_customer(\%::myconfig, $::form) : CT->save_vendor(\%::myconfig, $::form); + + if (3 == $res) { + if ($::form->{"db"} eq "customer") { + $::form->error($::locale->text('This customer number is already in use.')); + } else { + $::form->error($::locale->text('This vendor number is already in use.')); + } + } +} + sub add_transaction { $main::lxdebug->enter_sub(); @@ -354,12 +377,7 @@ sub add_transaction { # } # # /saving the history - $form->isblank("name", $locale->text("Name missing!")); - if ($form->{"db"} eq "customer") { - CT->save_customer(\%myconfig, \%$form); - } else { - CT->save_vendor(\%myconfig, \%$form); - } + _do_save(); $form->{callback} = $form->escape($form->{callback}, 1); my $name = $form->escape("$form->{name}", 1); @@ -516,16 +534,8 @@ sub save_and_close { my $msg = ucfirst $form->{db}; $msg .= " saved!"; - $form->isblank("name", $locale->text("Name missing!")); - my $rc; - if ($form->{"db"} eq "customer") { - $rc = CT->save_customer(\%myconfig, \%$form); - } else { - $rc = CT->save_vendor(\%myconfig, \%$form); - } - if ($rc == 3) { - $form->error($locale->text('customernumber not unique!')); - } + _do_save(); + # saving the history if(!exists $form->{addition}) { $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); @@ -550,22 +560,8 @@ sub save { my $msg = ucfirst $form->{db}; $msg .= " saved!"; - $form->isblank("name", $locale->text("Name missing!")); - - my $res; - if ($form->{"db"} eq "customer") { - $res = CT->save_customer(\%myconfig, \%$form); - } else { - $res = CT->save_vendor(\%myconfig, \%$form); - } + _do_save(); - if (3 == $res) { - if ($form->{"db"} eq "customer") { - $form->error($locale->text('This customer number is already in use.')); - } else { - $form->error($locale->text('This vendor number is already in use.')); - } - } # saving the history if(!exists $form->{addition}) { $form->{snumbers} = ($form->{"db"} eq "customer" ? qq|customernumber_| . $form->{customernumber} : qq|vendornumber_| . $form->{vendornumber}); diff --git a/locale/de/all b/locale/de/all index e88c5e231..50fa6001a 100644 --- a/locale/de/all +++ b/locale/de/all @@ -343,6 +343,7 @@ $self->{texts} = { 'Cash' => 'Zahlungsverkehr', 'Cc' => 'Cc', 'Change Lx-Office installation settings (all menu entries beneath \'System\')' => 'Verändern der Lx-Office-Installationseinstellungen (Menüpunkte unterhalb von \'System\')', + 'Change representative to' => 'Vertreter ändern in', 'Charge Number' => 'Chargennummer', 'Charge number' => 'Chargennummer', 'Chart' => 'Buchungskonto', @@ -1925,7 +1926,6 @@ $self->{texts} = { 'cp_greeting to cp_gender migration' => 'Datenumwandlung von Titel nach Geschlecht (cp_greeting to cp_gender)', 'customer' => 'Kunde', 'customer_list' => 'kundenliste', - 'customernumber not unique!' => 'Die Kundennummer ist schon vergeben', 'debug' => 'Debug', 'delete' => 'Löschen', 'deliverydate' => 'Lieferdatum', diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index 71a2a165b..2c95fac40 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -36,14 +36,30 @@ -%] + [%- IF id %] [% 'Representative' | $T8 %] + + + [%- HTML.escape(salesman) %] + + + [%- END %] + + + [%- IF !id %] + [% 'Representative' | $T8 %] + [%- ELSE %] + [% 'Change representative to' | $T8 %] + [%- END %] + [%- INCLUDE generic/multibox.html - name = 'salesman_id', - DATA = ALL_SALESMAN_CUSTOMERS, - id_key = 'id', - label_key = 'name', + name = 'new_salesman_id', + DATA = ALL_SALESMAN_CUSTOMERS, + id_key = 'id', + label_key = 'name', + show_empty = id, -%] -- 2.20.1