From b1d38913571c810a6e09fa2f756e8dd17b35a25a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 22 Jul 2011 13:07:15 +0200 Subject: [PATCH] Lieferadressentab mit jQuery & AJAX neu laden lassen, nicht via CGI::AJAX --- bin/mozilla/ct.pl | 22 ++++--- templates/webpages/ct/_shipto.html | 69 ++++++++++++++++++++++ templates/webpages/ct/form_header.html | 79 +------------------------- 3 files changed, 86 insertions(+), 84 deletions(-) create mode 100644 templates/webpages/ct/_shipto.html diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index b25509ec6..3202dfb04 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -293,6 +293,11 @@ sub edit { $main::lxdebug->leave_sub(); } +sub _shipto_label { + my $s = shift(@_); + join('; ', grep { $_ } map { $s->{"shipto$_"} } qw(name department_1 street city)) || ' ' +} + sub form_header { $main::lxdebug->enter_sub(); @@ -313,14 +318,14 @@ sub form_header { $form->{is_admin} = $myconfig{role} eq 'admin'; $form->{is_customer} = $form->{db} eq 'customer'; $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} }; - $form->{shipto_label} = sub { my $s = shift(@_); join('; ', grep { $_ } map { $s->{"shipto$_"} } qw(name department_1 street city)) || ' ' }; + $form->{shipto_label} = \&_shipto_label; $form->{contacts_label} = sub { join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname} }; $form->{taxzone_id} = 0 if !$form->{id}; $form->{jsscript} = 1; $form->{fokus} = "ct.greeting"; - $form->{AJAX} = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(shipto contact delivery) ) ]; + $form->{AJAX} = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(contact delivery) ) ]; + $form->{SHIPTO_ALL} = [ +{ shipto_id => '0', shiptoname => $::locale->text('All') }, @{ $form->{SHIPTO} } ]; - unshift @{ $form->{SHIPTO} }, +{ shipto_id => '0', shiptoname => '' }, +{ shipto_id => '0', shiptoname => 'Alle' }; unshift @{ $form->{CONTACTS} }, +{ cp_id => '0', cp_name => $locale->text('New contact') }; $form->{title} = $form->{title_save} @@ -661,13 +666,14 @@ sub get_shipto { $main::auth->assert('customer_vendor_edit'); - my $form = $main::form; - my %myconfig = %main::myconfig; + CT->populate_drop_down_boxes(\%::myconfig, $::form); + CT->get_shipto(\%::myconfig, $::form) if $::form->{shipto_id}; - CT->get_shipto(\%myconfig, \%$form); - print $form->ajax_response_header(), join('__pjx__', map($form->{"shipto$_"}, qw(name department_1 department_2 street zipcode city country contact phone fax email used))); - $main::lxdebug->leave_sub(); + $::form->{shipto_label} = \&_shipto_label; + print $::form->ajax_response_header(), $::form->parse_html_template('ct/_shipto'); + + $main::lxdebug->leave_sub(); } sub get_delivery { diff --git a/templates/webpages/ct/_shipto.html b/templates/webpages/ct/_shipto.html new file mode 100644 index 000000000..46d8444f8 --- /dev/null +++ b/templates/webpages/ct/_shipto.html @@ -0,0 +1,69 @@ +[% USE L %][% USE HTML %][% USE T8 %][% USE LxERP %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% 'Shipping Address' | $T8 %] + [%- INCLUDE generic/multibox.html + name = 'shipto_id', + id = 'shipto_id', + DATA = SHIPTO, + onChange = "\$('#shipto_table').load('ct.pl?action=get_shipto&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&shipto_id=' + this.value)", + id_key = 'shipto_id', + label_sub = 'shipto_label', + label_key = 'shipto_label', + show_empty = 1, + -%] +
[% 'Company Name' | $T8 %]
[% 'Abteilung' | $T8 %] + + +
[% 'Street' | $T8 %]
[% 'Zipcode' | $T8 %]/[% 'City' | $T8 %] + + +
[% 'Country' | $T8 %]
[% 'Contact' | $T8 %]
[% 'Phone' | $T8 %]
[% 'Fax' | $T8 %]
[% 'E-mail' | $T8 %]
diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index 1473a71d2..e2e5334bf 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -300,81 +300,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[% 'Shipping Address' | $T8 %] - [%- INCLUDE generic/multibox.html - name = 'shipto_id', - id = 'shipto_id', - DATA = SHIPTO, - onChange = "get_shipto(['shipto_id__' + this.value], ['shiptoname','shiptodepartment_1', 'shiptodepartment_2','shiptostreet','shiptozipcode','shiptocity','shiptocountry','shiptocontact','shiptophone','shiptofax','shiptoemail',enable_delete_shipto,set_gender])", - id_key = 'shipto_id', - label_sub = 'shipto_label', - label_key = 'shipto_label', - -%] -
[% 'Company Name' | $T8 %]
[% 'Abteilung' | $T8 %] - - -
[% 'Street' | $T8 %]
[% 'Zipcode' | $T8 %]/[% 'City' | $T8 %] - - -
[% 'Country' | $T8 %]
[% 'Contact' | $T8 %]
[% 'Phone' | $T8 %]
[% 'Fax' | $T8 %]
[% 'E-mail' | $T8 %]
 
 
+ [% INCLUDE 'ct/_shipto.html' %]
@@ -530,10 +456,11 @@ [%- INCLUDE generic/multibox.html name = 'delivery_id', id = 'delivery_id', - DATA = SHIPTO, + DATA = SHIPTO_ALL, onChange = "get_delivery(['shipto_id__' + this.value, 'from__' + from.value, 'to__' + to.value, 'id__' + cvid.value, 'db__' + db.value], ['delivery'])", id_key = 'shipto_id', label_sub = 'shipto_label', + show_empty = 1, -%] -- 2.20.1