- # set option selected
- foreach $item ($form->{vc}, currency, department, employee) {
- $form->{"select$item"} =~ s/ selected//;
- $form->{"select$item"} =~
- s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
- }
-
- #quote select[customer|vendor] Bug 133
- $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
-
- #substitute \n and \r to \s (bug 543)
- $form->{"select$form->{vc}"} =~ s/[\n\r]/ /g;
-
- 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");
-
- 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 =
- NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
- '-labels' => \%labels, '-default' => $form->{"cp_id"}));
-
- %labels = ();
- @values = ("");
- foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
- push(@values, $item->{"shipto_id"});
- $labels{$item->{"shipto_id"}} =
- $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
- }
-
- my $shipto = qq|
- <th align=right>| . $locale->text('Shipping Address') . qq|</th>
- <td>| .
- NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
- '-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"}));
-
- $salesman = "";
- if ($form->{type} =~ /^sales_/) {
- %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', '-default' => $form->{salesman_id},
- '-values' => \@values, '-labels' => \%labels))
- . qq|</td>
- </tr>|;
- }
-
- $form->{exchangerate} =
- $form->format_amount(\%myconfig, $form->{exchangerate});
-
- if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
- $creditwarning = 1;
- } else {
- $creditwarning = 0;
- }
-
- $form->{creditlimit} =
- $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
- $form->{creditremaining} =
- $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
-
- $exchangerate = qq|
-<input type=hidden name=forex value=$form->{forex}>
-|;
-
- 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>|;
- }
- }
-
- $vclabel = ucfirst $form->{vc};
- $vclabel = $locale->text($vclabel);
-
-
-
- if ($form->{business}) {
- $business = qq|
- <tr>
- <th align=right>| . $locale->text('Business') . qq|</th>
- <td>$form->{business}</td>
- <th align=right>| . $locale->text('Trade Discount') . qq|</th>
- <td>|
- . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
- . qq| %</td>
- </tr>
-|;
- }
-
- if ($form->{max_dunning_level}) {
- $dunning = qq|
- <tr>
- <td colspan=4>
- <table>
- <tr>
- <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
- <td><b>$form->{max_dunning_level}</b></td>
- <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
- <td><b>|
- . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
- . qq|</b></td>
- </tr>
- </table>
- </td>
- </tr>
-|;