ajax_autocomplete für Kunden/Lieferanten.
authorSven Schöling <s.schoeling@linet-services.de>
Wed, 9 Dec 2009 11:47:57 +0000 (12:47 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Wed, 9 Dec 2009 11:47:57 +0000 (12:47 +0100)
bin/mozilla/ct.pl
locale/de/ct

index 10ff706..01de062 100644 (file)
@@ -714,4 +714,25 @@ sub delete_contact {
   $main::lxdebug->leave_sub();
 }
 
+sub ajax_autocomplete {
+  $main::lxdebug->enter_sub();
+
+  my $form     = $main::form;
+  my %myconfig = %main::myconfig;
+
+  $form->{column}          = 'name'     unless $form->{column} =~ /^name$/;
+  $form->{vc}              = 'customer' unless $form->{vc} =~ /^customer|vendor$/;
+  $form->{db}              = $form->{vc}; # CT expects this
+  $form->{$form->{column}} = $form->{q}           || '';
+  $form->{limit}           = ($form->{limit} * 1) || 10;
+  $form->{searchitems}   ||= '';
+
+  CT->search(\%myconfig, $form);
+
+  print $form->ajax_response_header(),
+        $form->parse_html_template('ct/ajax_autocomplete');
+
+  $main::lxdebug->leave_sub();
+}
+
 sub continue { call_sub($main::form->{nextsub}); }
index fac93f8..21d9277 100644 (file)
@@ -213,6 +213,7 @@ $self->{subs} = {
   'Q'                           => 'Q',
   'add'                         => 'add',
   'add_transaction'             => 'add_transaction',
+  'ajax_autocomplete'           => 'ajax_autocomplete',
   'ap_transaction'              => 'ap_transaction',
   'ar_transaction'              => 'ar_transaction',
   'build_std_url'               => 'build_std_url',