From a65c8e991906fc1ad47af84decc066672348ce1b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 22 Jul 2011 13:34:54 +0200 Subject: [PATCH] Ansprechpersonentab mit jQuery & AJAX neu laden lassen, nicht via CGI::AJAX --- bin/mozilla/ct.pl | 25 +++-- templates/webpages/ct/_contact.html | 117 ++++++++++++++++++++ templates/webpages/ct/form_header.html | 145 +------------------------ 3 files changed, 132 insertions(+), 155 deletions(-) create mode 100644 templates/webpages/ct/_contact.html diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 3202dfb04..92ef085d4 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -298,6 +298,10 @@ sub _shipto_label { join('; ', grep { $_ } map { $s->{"shipto$_"} } qw(name department_1 street city)) || ' ' } +sub _contacts_label { + join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname}; +} + sub form_header { $main::lxdebug->enter_sub(); @@ -319,20 +323,18 @@ sub form_header { $form->{is_customer} = $form->{db} eq 'customer'; $form->{salesman_label} = sub { $_[0]->{name} ne "" ? $_[0]->{name} : $_[0]->{login} }; $form->{shipto_label} = \&_shipto_label; - $form->{contacts_label} = sub { join ", ", grep { $_ } $_[0]->{cp_name}, $_[0]->{cp_givenname} }; + $form->{contacts_label} = \&_contacts_label; $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(contact delivery) ) ]; + $form->{AJAX} = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(delivery) ) ]; $form->{SHIPTO_ALL} = [ +{ shipto_id => '0', shiptoname => $::locale->text('All') }, @{ $form->{SHIPTO} } ]; - unshift @{ $form->{CONTACTS} }, +{ cp_id => '0', cp_name => $locale->text('New contact') }; - $form->{title} = $form->{title_save} || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : ''); CT->query_titles_and_greetings(\%myconfig, \%$form); - map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT); + map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(COMPANY_GREETINGS); $form->{NOTES} ||= [ ]; @@ -651,14 +653,15 @@ sub get_contact { $main::auth->assert('customer_vendor_edit'); - my $form = $main::form; - my %myconfig = %main::myconfig; + CT->populate_drop_down_boxes(\%::myconfig, $::form); + CT->query_titles_and_greetings(\%::myconfig, $::form); + CT->get_contact(\%::myconfig, $::form) if $::form->{cp_id}; - CT->get_contact(\%myconfig, \%$form); - print $form->ajax_response_header(), join '__pjx__', map $form->{"cp_$_"}, - qw(name title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used gender); - $main::lxdebug->leave_sub(); + $::form->{contacts_label} = \&_contacts_label; + print $::form->ajax_response_header(), $::form->parse_html_template('ct/_contact'); + + $main::lxdebug->leave_sub(); } sub get_shipto { diff --git a/templates/webpages/ct/_contact.html b/templates/webpages/ct/_contact.html new file mode 100644 index 000000000..8da17e9cb --- /dev/null +++ b/templates/webpages/ct/_contact.html @@ -0,0 +1,117 @@ +[% USE L %][% USE HTML %][% USE T8 %][% USE LxERP %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[% 'Contacts' | $T8 %] + [%- L.select_tag('cp_id', L.options_for_select(CONTACTS, default => cp_id, with_empty => 1, empty_title => LxERP.t8('New contact'), value => 'cp_id', title_sub => \contacts_label), + onchange => "\$('#contact_table').load('ct.pl?action=get_contact&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&cp_id=' + \$('#cp_id').attr('value'))") %] +
[% 'Gender' | $T8 %] + +
[% 'Title' | $T8 %] +   + [% L.select_tag('selected_cp_title', L.options_for_select(TITLES, with_empty => 1)) %] +
[% 'Department' | $T8 %] +   + [% L.select_tag('selected_cp_abteilung', L.options_for_select(DEPARTMENT, with_empty => 1)) %] +
[% 'Given Name' | $T8 %]
[% 'Name' | $T8 %]
[% 'Phone1' | $T8 %]
[% 'Phone2' | $T8 %]
[% 'Fax' | $T8 %]
[% 'Mobile1' | $T8 %]
[% 'Mobile2' | $T8 %]
[% 'Sat. Phone' | $T8 %]
[% 'Sat. Fax' | $T8 %]
[% 'Project' | $T8 %]
[% 'E-mail' | $T8 %]
[% 'Private Phone' | $T8 %]
[% 'Private E-mail' | $T8 %]
[% 'Birthday' | $T8 %]

[% 'Bcc' | $T8 %]
diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index e2e5334bf..a09bfe33d 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -307,142 +307,7 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[% 'Contacts' | $T8 %] - [%- INCLUDE generic/multibox.html - name = 'cp_id', - id = 'cp_id', - DATA = CONTACTS, - onChange = "on_contact_changed()", - id_key = 'cp_id', - label_sub = 'contacts_label', - -%] -
[% 'Gender' | $T8 %] - -
[% 'Title' | $T8 %] -   - [%- INCLUDE generic/multibox.html - name = 'selected_cp_title', - id = 'selected_cp_title', - DATA = MB_TITLES, - show_empty = 1, - id_key = 'id', - label_key = 'description', - -%] -
[% 'Department' | $T8 %] -   - [%- INCLUDE generic/multibox.html - name = 'selected_cp_abteilung', - id = 'selected_cp_abteilung', - DATA = MB_DEPARTMENT, - show_empty = 1, - id_key = 'id', - label_key = 'description', - -%] -
[% 'Given Name' | $T8 %]
[% 'Name' | $T8 %]
[% 'Phone1' | $T8 %]
[% 'Phone2' | $T8 %]
[% 'Fax' | $T8 %]
[% 'Mobile1' | $T8 %]
[% 'Mobile2' | $T8 %]
[% 'Sat. Phone' | $T8 %]
[% 'Sat. Fax' | $T8 %]
[% 'Project' | $T8 %]
[% 'E-mail' | $T8 %]
[% 'Private Phone' | $T8 %]
[% 'Private E-mail' | $T8 %]
[% 'Birthday' | $T8 %]

[% 'Bcc' | $T8 %]
+ [% INCLUDE 'ct/_contact.html' %]
@@ -597,14 +462,6 @@ s.selectedIndex = (gender == 'f') ? 1 : 0; } } - - function on_contact_changed() { - get_contact(['cp_id__' + $('#cp_id').attr('value')], - ['cp_name','cp_title','cp_givenname','cp_phone1','cp_phone2','cp_email','cp_abteilung','cp_fax','cp_mobile1','cp_mobile2', - 'cp_satphone','cp_satfax','cp_project','cp_privatphone','cp_privatemail','cp_birthday',enable_delete_contact,set_gender]); - $('#selected_cp_title').attr('selectedIndex', 0); - $('#selected_cp_abteilung').attr('selectedIndex', 0); - } --> -- 2.20.1