- my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
- $form->get_lists("contacts" => "ALL_CONTACTS",
- "shipto" => "ALL_SHIPTO",
- "projects" => {
- "key" => "ALL_PROJECTS",
- "all" => 0,
- "old_id" => \@old_project_ids
- },
- "employees" => "ALL_EMPLOYEES",
- "salesmen" => "ALL_SALESMEN",
- "taxzones" => "ALL_TAXZONES",
- "payments" => "ALL_PAYMENTS",
- "currencies" => "ALL_CURRENCIES",
- $vc => "ALL_" . uc($vc));
-
- my %labels;
- my @values = (undef);
- foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
- push(@values, $item->{"cp_id"});
- $labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($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->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
- push(@values, $item->{"name"}.qq|--|.$item->{"id"});
- $labels{$item->{"name"}.qq|--|.$item->{"id"}} = $item->{name};
- }
-
- $vc = qq|
- <input type="hidden" name="$form->{vc}_id" value="| . H($form->{"$form->{vc}_id"}) . qq|">
- <input type="hidden" name="old$form->{vc}" value="| . H($form->{"old$form->{vc}"}) . qq|">
- <th align="right">| . $locale->text(ucfirst($form->{vc})) . qq|</th>
- <td>| .
- (($myconfig{vclimit} <= scalar(@values))
- ? qq|<input type="text" value="| . H(($form->{"old$form->{vc}"} =~ /^(.*)\-\-.*$/)) . qq|" name="$form->{vc}">|
- : (NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"},
- '-onChange' => 'document.getElementById(\'update_button\').click();',
- '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
- <input type="button" value="?" onclick="show_vc_details('$form->{vc}')">
- </td><input type=hidden name="select$form->{vc}" value="| .
- Q($form->{"select$form->{vc}"}) . qq|">|;
-
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{"ALL_PAYMENTS"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"description"};
- }
-
- $payments = qq|
- <th align="right">| . $locale->text('Payment Terms') . qq|</th>
- <td>| .
- NTI($cgi->popup_menu('-name' => 'payment_id', '-values' => \@values, '-style' => 'width: 250px',
- '-labels' => \%labels, '-default' => $form->{payment_id}))
- . qq|</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_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"}));
-
- my $salesmen = "";
- %labels = ();
- @values = ();
- if ($form->{type} =~ /^sales_/) {
- foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = ($item->{"name"} ne "" ? $item->{"name"} : $item->{"login"});
- }
- $salesmen =
- qq|<tr>
- <th align="right">| . $locale->text('Salesman') . qq|</th>
- <td>| .
- NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{"salesman_id"} ? $form->{"salesman_id"} : $form->{"employee_id"},
- '-values' => \@values, '-labels' => \%labels))
- . qq|</td>
- </tr>|;
- }
-
- %labels = ();
- @values = ();
- foreach my $item (@{ $form->{"ALL_EMPLOYEES"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"name"} ne "" ? $item->{"name"} : $item->{"login"};
- }
-
- my $employee = 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_TAXZONES"} }) {
- push(@values, $item->{"id"});
- $labels{$item->{"id"}} = $item->{"description"};
- }
-
- $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>|;
-
- %labels = ();
- @values = ();
- my $i = 0;
- 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>|;
- }
-
- $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate});
- $form->{exchangerate} = "" unless $form->{exchangerate};
-
- $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
-
- $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
-
- $exchangerate = qq|\n<input type=hidden name=forex value=$form->{forex}>\n|;
-
- if ($form->{currency} ne $form->{defaultcurrency}) {
- if ($form->{forex}) {
- $exchangerate .=
- qq|<th align=right>| . $locale->text('Exchangerate')
- . qq|</th><td>$form->{exchangerate}</td>
- <input type=hidden name=exchangerate value=$form->{exchangerate}>
-|;
- } else {
- $exchangerate .=
- qq|<th align=right>| . $locale->text('Exchangerate')
- . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;