$query = qq|SELECT id, description FROM business ORDER BY id|;
$form->{all_business} = selectall_hashref_query($form, $dbh, $query);
- # get tax zones
- $query = qq|SELECT id, description FROM tax_zones|;
- $form->{TAXZONE} = selectall_hashref_query($form, $dbh, $query);
-
# get shipto address
$query =
qq|SELECT shipto_id, shiptoname, shiptodepartment_1 | .
$main::lxdebug->leave_sub();
}
+sub _get_taxzones {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $dbh, $key) = @_;
+
+ $key = "all_taxzones" unless ($key);
+
+ my $query = qq|SELECT * FROM tax_zones ORDER BY id|;
+
+ $self->{$key} = selectall_hashref_query($self, $dbh, $query);
+
+ $main::lxdebug->leave_sub();
+}
+
sub _get_employees {
$main::lxdebug->enter_sub();
$self->_get_taxcharts($dbh, $params{"taxcharts"});
}
+ if ($params{"taxzones"}) {
+ $self->_get_taxzones($dbh, $params{"taxzones"});
+ }
+
if ($params{"employees"}) {
$self->_get_employees($dbh, $params{"employees"});
}
$query = qq|SELECT id, taxkey, taxdescription FROM tax|;
$self->{TAXKEY} = selectall_hashref_query($self, $dbh, $query);
- # get tax zones
- $query = qq|SELECT id, description FROM tax_zones|;
- $self->{TAXZONE} = selectall_hashref_query($self, $dbh, $query);
-
if (($module eq "AP") || ($module eq "AR")) {
# get tax rates and description
$query = qq|SELECT * FROM tax|;
Common::webdav_folder($form) if ($main::webdav);
- # get tax zones
- $query = qq|SELECT id, description FROM tax_zones|;
- $form->{TAXZONE} = selectall_hashref_query($form, $dbh, $query);
-
my $rc = $dbh->commit;
$dbh->disconnect;
sub form_header {
$lxdebug->enter_sub();
- $form->get_lists("employees" => "ALL_SALESMEN");
+ $form->get_lists("employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES");
$form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
$form->{creditlimit} =
}
}
- if (@{ $form->{TAXZONE} }) {
- foreach $item (@{ $form->{TAXZONE} }) {
- if ($item->{id} == $form->{taxzone_id}) {
- $form->{selecttaxzone} .=
- "<option value=$item->{id} selected>$item->{description}\n";
- } else {
- $form->{selecttaxzone} .=
- "<option value=$item->{id}>$item->{description}\n";
- }
-
- }
+ %labels = ();
+ @values = ();
+ foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
+ push(@values, $item->{"id"});
+ $labels{$item->{"id"}} = $item->{"description"};
}
$taxzone = qq|
<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}">
+ <td>| .
+ NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
+ '-values' => \@values, '-labels' => \%labels)) . qq|
+ </td>
|;
$get_contact_url =
$form->get_lists("contacts" => "ALL_CONTACTS",
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
- "old_id" => \@old_project_ids });
+ "old_id" => \@old_project_ids },
+ "taxzones" => "ALL_TAXZONES");
my %labels;
my @values = (undef);
'-labels' => \%labels,
'-default' => $form->{"globalproject_id"}));
- 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/;
- }
+ %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><select name=taxzone_id>$form->{selecttaxzone}</select></td>
- <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
- </tr>|;
-
+ 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)) . 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>|;
+ }
$vendor =
($form->{selectvendor})
my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
push(@ { $form->{AJAX} }, $pjx);
- 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>|;
-
my @old_project_ids = ($form->{"globalproject_id"});
map({ push(@old_project_ids, $form->{"project_id_$_"})
if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
"old_id" => \@old_project_ids },
- "employees" => "ALL_SALESMEN");
+ "employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES");
my %labels;
my @values = (undef);
. 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)) . 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//;
"projects" => { "key" => "ALL_PROJECTS",
"all" => 0,
"old_id" => \@old_project_ids },
- "employees" => "ALL_SALESMEN");
+ "employees" => "ALL_SALESMEN",
+ "taxzones" => "ALL_TAXZONES");
my %labels;
my @values = (undef);
</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)) . qq|
+ </td>
+ </tr>|;
+
$form->{exchangerate} =
$form->format_amount(\%myconfig, $form->{exchangerate});
|;
}
- 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>