+ my $set_duedate_url = "$form->{script}?action=set_duedate";
+
+ my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
+ push(@ { $form->{AJAX} }, $pjx);
+
+ my @old_project_ids = ($form->{"globalproject_id"});
+ map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
+
+ $form->get_lists("contacts" => "ALL_CONTACTS",
+ "shipto" => "ALL_SHIPTO",
+ "projects" => { "key" => "ALL_PROJECTS",
+ "all" => 0,
+ "old_id" => \@old_project_ids },
+ "employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES",
+ "currencies" => "ALL_CURRENCIES",
+ "customers" => "ALL_CUSTOMERS",
+ "price_factors" => "ALL_PRICE_FACTORS");
+
+ my %labels;
+ my @values = (undef);
+ foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
+ push(@values, $item->{"cp_id"});
+ $labels{$item->{"cp_id"}} = join(',', $item->{"cp_name"}, $item->{"cp_givenname"}) . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
+ }
+ my $contact;
+ if (scalar @values > 1) {
+ $contact = qq|
+ <tr>
+ <th align="right">| . $locale->text('Contact Person') . qq|</th>
+ <td>| . NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
+ '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq|
+ </td>
+ </tr>|;
+ }
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
+ }
+
+ my $employees = qq|
+ <tr>
+ <th align="right">| . $locale->text('Employee') . qq|</th>
+ <td>| . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ </td>
+ </tr>|;
+
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
+ push(@values, $item->{name}.qq|--|.$item->{"id"});
+ $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
+ }
+
+ $form->{selectcustomer} = ($myconfig{vclimit} > scalar(@values));
+
+ my $customers = qq|
+ <th align="right">| . $locale->text('Customer') . qq|</th>
+ <td>| .
+ (($myconfig{vclimit} <= scalar(@values))
+ ? qq|<input type="text" value="| . H($form->{customer}) . qq|" name="customer">|
+ : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
+ '-onChange' => 'document.getElementById(\'update_button\').click();',
+ '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
+ <input type="button" value="| . $locale->text('Details (one letter abbreviation)') . qq|" onclick="show_vc_details('customer')">
+ </td>|;
+
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
+ push(@values, $item->{"shipto_id"});
+ $labels{$item->{"shipto_id"}} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city);
+ }
+
+ my $shipto;
+ if (scalar @values > 1) {
+ $shipto = qq|
+ <tr>
+ <th align="right">| . $locale->text('Shipping Address') . qq|</th>
+ <td>| . NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
+ '-labels' => \%labels, '-default' => $form->{"shipto_id"})). qq|
+ </td>|;
+ }
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
+ push(@values, $item);
+ $labels{$item} = $item;
+ }
+
+ $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
+ my $currencies;
+ if (scalar @values) {
+ $currencies = qq|
+ <tr>
+ <th align="right">| . $locale->text('Currency') . qq|</th>
+ <td>| . NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ </td>
+ </tr>|;
+ }
+
+ %labels = ();
+ @values = ("");
+ foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"projectnumber"};
+ }
+ my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
+ '-labels' => \%labels,
+ '-default' => $form->{"globalproject_id"}));
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{ALL_SALESMEN} }) {
+ push(@values, $item->{id});
+ $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
+ }
+
+ $salesman =
+ qq|<tr> <th align="right">| . $locale->text('Salesman') . qq|</th>
+ <td>| . NTI($cgi->popup_menu('-name' => 'salesman_id', '-values' => \@values, '-labels' => \%labels,
+ '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id})) . qq|
+ </td>
+ </tr>|;
+
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"description"};
+ }
+
+ if (!$form->{"id"}) {
+ $taxzone = qq|
+ <tr>
+ <th align="right">| . $locale->text('Steuersatz') . qq|</th>
+ <td>| . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+ '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
+ </td>
+ </tr>|;
+
+ } else {
+ $taxzone = qq|
+ <tr>
+ <th align="right">| . $locale->text('Steuersatz') . qq|</th>
+ <td>
+ <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
+ | . H($labels{$form->{"taxzone_id"}}) . qq|
+ </td>
+ </tr>|;
+ }
+
+ # set option selected
+ foreach $item (qw(AR customer currency department employee)) {
+ $form->{"select$item"} =~ s/ selected//;
+ $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
+ }