- $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>
-|;
- }
-
- if (@{ $form->{TAXZONE} }) {
- $form->{selecttaxzone} = "";
- foreach $item (@{ $form->{TAXZONE} }) {
- if ($item->{id} == $form->{taxzone_id}) {
- $form->{selecttaxzone} .=
- "<option value=$item->{id} selected>" . H($item->{description}) .
- "</option>";
- } else {
- $form->{selecttaxzone} .=
- "<option value=$item->{id}>" . H($item->{description}) . "</option>";
- }
-
- }
- } else {
- $form->{selecttaxzone} =~ s/ selected//g;
- if ($form->{taxzone_id} ne "") {
- $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
- }
- }
-
- $taxzone = qq|
- <tr>
- <th align=right>| . $locale->text('Steuersatz') . qq|</th>
- <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
- <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
- </tr>|;
-
-
- if ($form->{type} !~ /_quotation$/) {
- $ordnumber = qq|
- <tr>
- <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
- <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
- </tr>
- <tr>
- <th width=70% align=right nowrap>|
- . $locale->text('Quotation Number') . qq|</th>
- <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
- </tr>
- <tr>
- <th width=70% align=right nowrap>|
- . $locale->text('Customer Order Number') . qq|</th>
- <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
- </tr>
- <tr>
- <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
- $button1
+ # use JavaScript Calendar or not
+ $form->{jsscript} = 1;
+
+ # openclosed checkboxes
+ my @tmp;
+ push @tmp, sprintf qq|<input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" %s><label for="delivered">%s</label>|,
+ $form->{"delivered"} ? "checked" : "", $locale->text('Delivered') if $form->{"type"} =~ /_order$/;
+ push @tmp, sprintf qq|<input name="closed" id="closed" type="checkbox" class="checkbox" value="1" %s><label for="closed">%s</label>|,
+ $form->{"closed"} ? "checked" : "", $locale->text('Closed') if $form->{id};
+ $TMPL_VAR{openclosed} = sprintf qq|<tr><td colspan=%d align=center>%s</td></tr>\n|, 2 * scalar @tmp, join "\n", @tmp if @tmp;
+
+ # project ids
+ my @old_project_ids = ($form->{"globalproject_id"}, grep { $_ } map { $form->{"project_id_$_"} } 1..$form->{"rowcount"});
+
+ 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",
+ "departments" => "ALL_DEPARTMENTS",
+ $vc => { key => "ALL_" . uc($vc),
+ limit => $myconfig{vclimit} + 1 },
+ "price_factors" => "ALL_PRICE_FACTORS");
+
+ # label subs
+ $TMPL_VAR{sales_employee_labels} = sub { $_[0]->{name} || $_[0]->{login} };
+ $TMPL_VAR{shipto_labels} = sub { join "; ", grep { $_ } map { $_[0]->{"shipto${_}" } } qw(name department_1 street city) };
+ $TMPL_VAR{contact_labels} = sub { join(', ', $_[0]->{"cp_name"}, $_[0]->{"cp_givenname"}) . ($_[0]->{cp_abteilung} ? " ($_[0]->{cp_abteilung})" : "") };
+ $TMPL_VAR{department_labels} = sub { "$_[0]->{description}--$_[0]->{id}" };
+
+ # vendor/customer
+ $TMPL_VAR{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
+ $TMPL_VAR{vclimit} = $myconfig{vclimit};
+ $TMPL_VAR{vc_select} = "customer_or_vendor_selection_window('$form->{vc}', '', @{[ $form->{vc} eq 'vendor' ? 1 : 0 ]}, 0)";
+ push @custom_hiddens, "$form->{vc}_id";
+ push @custom_hiddens, "old$form->{vc}";
+ push @custom_hiddens, "select$form->{vc}";
+
+ # currencies and exchangerate
+ @values = map { $_ } @{ $form->{ALL_CURRENCIES} };
+ %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
+ $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
+ $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
+ $TMPL_VAR{currencies} = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
+ '-values' => \@values, '-labels' => \%labels)) if scalar @values;
+ push @custom_hiddens, "forex";
+ push @custom_hiddens, "exchangerate" if $form->{forex};
+
+ # credit remaining
+ $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0;
+ $TMPL_VAR{is_credit_remaining_negativ} = ($form->{creditremaining} =~ /-/) ? "0" : "1";
+
+ # business
+ $TMPL_VAR{business_label} = ($form->{vc} eq "customer" ? $locale->text('Customer type') : $locale->text('Vendor type'));
+
+ push @custom_hiddens, "customer_klass" if $form->{vc} eq 'customer';