1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   6 #############################################################################
 
   7 # Veraendert 2005-01-05 - Marco Welter <mawe@linux-studio.de> - Neue Optik  #
 
   8 #############################################################################
 
   9 # SQL-Ledger, Accounting
 
  10 # Copyright (c) 1998-2002
 
  12 #  Author: Dieter Simader
 
  13 #   Email: dsimader@sql-ledger.org
 
  14 #     Web: http://www.sql-ledger.org
 
  17 # This program is free software; you can redistribute it and/or modify
 
  18 # it under the terms of the GNU General Public License as published by
 
  19 # the Free Software Foundation; either version 2 of the License, or
 
  20 # (at your option) any later version.
 
  22 # This program is distributed in the hope that it will be useful,
 
  23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  25 # GNU General Public License for more details.
 
  26 # You should have received a copy of the GNU General Public License
 
  27 # along with this program; if not, write to the Free Software
 
  28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  30 #######################################################################
 
  32 # common routines used in is, ir but not in oe
 
  34 #######################################################################
 
  38 use List::Util qw(max);
 
  44 require "bin/mozilla/common.pl";
 
  46 # any custom scripts for this one
 
  47 if (-f "bin/mozilla/custom_invoice_io.pl") {
 
  48   eval { require "bin/mozilla/custom_ivvoice_io.pl"; };
 
  50 if (-f "bin/mozilla/$form->{login}_invoice_io.pl") {
 
  51   eval { require "bin/mozilla/$form->{login}_invoice_io.pl"; };
 
  58 # this is for our long dates
 
  59 # $locale->text('January')
 
  60 # $locale->text('February')
 
  61 # $locale->text('March')
 
  62 # $locale->text('April')
 
  63 # $locale->text('May ')
 
  64 # $locale->text('June')
 
  65 # $locale->text('July')
 
  66 # $locale->text('August')
 
  67 # $locale->text('September')
 
  68 # $locale->text('October')
 
  69 # $locale->text('November')
 
  70 # $locale->text('December')
 
  72 # this is for our short month
 
  73 # $locale->text('Jan')
 
  74 # $locale->text('Feb')
 
  75 # $locale->text('Mar')
 
  76 # $locale->text('Apr')
 
  77 # $locale->text('May')
 
  78 # $locale->text('Jun')
 
  79 # $locale->text('Jul')
 
  80 # $locale->text('Aug')
 
  81 # $locale->text('Sep')
 
  82 # $locale->text('Oct')
 
  83 # $locale->text('Nov')
 
  84 # $locale->text('Dec')
 
  89 ########################################
 
  90 # Eintrag fuer Version 2.2.0 geaendert #
 
  91 # neue Optik im Rechnungsformular      #
 
  92 ########################################
 
  94 #  $lxdebug->enter_sub();
 
  95 #  my $numrows = shift;
 
  98 #    (substr($form->{type}, 0, 6) eq "sales_")
 
  99 #    || (($form->{type} eq "invoice") && ($form->{script} eq "is.pl"))
 
 100 #    || ($form->{type} eq 'credit_note');
 
 102 #  if ($lizenzen && $form->{vc} eq "customer") {
 
 103 #    if ($form->{type} =~ /sales_order/) {
 
 104 #      @column_index = (runningnumber, partnumber, description, ship, qty);
 
 105 #    } elsif ($form->{type} =~ /sales_quotation/) {
 
 106 #      @column_index = (runningnumber, partnumber, description, qty);
 
 108 #      @column_index = (runningnumber, partnumber, description, qty);
 
 111 #    if (   ($form->{type} =~ /purchase_order/)
 
 112 #        || ($form->{type} =~ /sales_order/)) {
 
 113 #      @column_index = (runningnumber, partnumber, description, ship, qty);
 
 115 #      @column_index = (runningnumber, partnumber, description, qty);
 
 118 ############### ENDE Neueintrag ##################
 
 120 #  my $all_units = AM->retrieve_units(\%myconfig, $form);
 
 121 #  my $dimension_units = $all_units;
 
 122 #  my $service_units = $all_units;
 
 124 #  my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
 
 126 #  push @column_index, qw(unit);
 
 128 #  #for pricegroups column
 
 129 #  if (   $form->{type} =~ (/sales_quotation/)
 
 130 #      or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
 
 131 #      or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
 
 132 #      or ($form->{type} =~ /sales_order/)) {
 
 133 #    push @column_index, qw(sellprice_pg);
 
 136 #  push @column_index, qw(sellprice);
 
 138 #  if ($form->{vc} eq 'customer') {
 
 139 #    push @column_index, qw(discount);
 
 142 #  push @column_index, "linetotal";
 
 144 #  my $colspan = $#column_index + 1;
 
 146 #  $form->{invsubtotal} = 0;
 
 147 #  map { $form->{"${_}_base"} = 0 } (split(/ /, $form->{taxaccounts}));
 
 149 #########################################
 
 150 #  # Eintrag fuer Version 2.2.0 geaendert #
 
 151 #  # neue Optik im Rechnungsformular      #
 
 152 #########################################
 
 153 #  $column_data{runningnumber} = qq|<th align="left" nowrap width="5%"  class="listheading">| . $locale->text('No.') .         qq|</th>|;
 
 154 #  $column_data{partnumber}    = qq|<th align="left" nowrap width="12%" class="listheading">| . $locale->text('Number') .      qq|</th>|;
 
 155 #  $column_data{description}   = qq|<th align="left" nowrap width="30%" class="listheading">| . $locale->text('Part Description') . qq|</th>|;
 
 156 #  if ($form->{"type"} eq "purchase_order") {
 
 157 #    $column_data{ship}        = qq|<th align="left" nowrap width="5%"  class="listheading">| . $locale->text('Ship rcvd') .   qq|</th>|;
 
 159 #    $column_data{ship}        = qq|<th align="left" nowrap width="5%"  class="listheading">| . $locale->text('Ship') .        qq|</th>|;
 
 161 #  $column_data{qty}           = qq|<th align="left" nowrap width="5%"  class="listheading">| . $locale->text('Qty') .         qq|</th>|;
 
 162 #  $column_data{unit}          = qq|<th align="left" nowrap width="20%" class="listheading">| . $locale->text('Unit') .        qq|</th>|;
 
 163 #  $column_data{license}       = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('License') .     qq|</th>|;
 
 164 #  $column_data{serialnr}      = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Serial No.') .  qq|</th>|;
 
 165 #  $column_data{projectnr}     = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Project') .     qq|</th>|;
 
 166 #  $column_data{sellprice}     = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Price') .       qq|</th>|;
 
 167 #  $column_data{sellprice_pg}  = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Pricegroup') .  qq|</th>|;
 
 168 #  $column_data{discount}      = qq|<th align="left" nowrap width="5%"  class="listheading">| . $locale->text('Discount') .    qq|</th>|;
 
 169 #  $column_data{linetotal}     = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Extended') .    qq|</th>|;
 
 170 #  $column_data{bin}           = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Bin') .         qq|</th>|;
 
 171 ############### ENDE Neueintrag ##################
 
 173 #  $myconfig{"show_form_details"} = 1
 
 174 #    unless (defined($myconfig{"show_form_details"}));
 
 175 #  $form->{"show_details"} = $myconfig{"show_form_details"}
 
 176 #    unless (defined($form->{"show_details"}));
 
 177 #  $form->{"show_details"} = $form->{"show_details"} ? 1 : 0;
 
 178 #  my $show_details_new = 1 - $form->{"show_details"};
 
 179 #  my $show_details_checked = $form->{"show_details"} ? "checked" : "";
 
 183 #    <td>| . $cgi->hidden("-name" => "show_details", "-value" => $form->{show_details}) . qq|
 
 184 #      <input type="checkbox" id="cb_show_details" onclick="show_form_details($show_details_new);" $show_details_checked>
 
 185 #      <label for="cb_show_details">| . $locale->text("Show details") . qq|</label><br>
 
 186 #      <table width="100%">
 
 187 #       <tr class="listheading">|;
 
 189 #  map { print "\n$column_data{$_}" } @column_index;
 
 195 #  $runningnumber = $locale->text('No.');
 
 196 #  $deliverydate  = $locale->text('Delivery Date');
 
 197 #  $serialnumber  = $locale->text('Serial No.');
 
 198 #  $projectnumber = $locale->text('Project');
 
 199 #  $partsgroup    = $locale->text('Group');
 
 200 #  $reqdate       = $locale->text('Reqdate');
 
 202 #  $delvar = 'deliverydate';
 
 204 #  if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
 
 205 #    $deliverydate = $locale->text('Required by');
 
 206 #    $delvar       = 'reqdate';
 
 209 #  $form->{marge_total} = 0;
 
 210 #  $form->{sellprice_total} = 0;
 
 211 #  $form->{lastcost_total} = 0;
 
 212 #  my %projectnumber_labels = ();
 
 213 #  my @projectnumber_values = ("");
 
 214 #  foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
 
 215 #    push(@projectnumber_values, $item->{"id"});
 
 216 #    $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
 
 219 #  for $i (1 .. $numrows) {
 
 223 #      $form->{"${_}_$i"} =
 
 224 #        $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
 
 225 #    } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
 
 227 #    if (!$form->{"unit_old_$i"}) {
 
 228 #      # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
 
 229 #      # Einheit, wie sie in den Stammdaten hinterlegt wurde.
 
 230 #      # Es sollte also angenommen werden, dass diese ausgewaehlt war.
 
 231 #      $form->{"unit_old_$i"} = $form->{"unit_$i"};
 
 234 #    # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
 
 235 #    # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
 
 236 #    $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
 
 238 #    my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
 
 239 #    if (!$check_units->{$form->{"selected_unit_$i"}} ||
 
 240 #        ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
 
 241 #         $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
 
 242 #      # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
 
 243 #      # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
 
 244 #      # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
 
 245 #      $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
 
 247 #    if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
 
 248 #      if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
 
 249 #        my $basefactor = 1;
 
 250 #        if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
 
 251 #            $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
 
 252 #          $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
 
 253 #            $all_units->{$form->{"unit_old_$i"}}->{"factor"};
 
 255 #        $form->{"sellprice_$i"} *= $basefactor;
 
 256 #        $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
 
 260 #    ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
 
 261 #    $decimalplaces = max length($dec), 2;
 
 263 #    $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1;
 
 264 #    $discount     = (100 - $form->{"discount_$i"} * 1) / 100;
 
 266 #    $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces);
 
 268 #    my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor;
 
 270 #    # marge calculations
 
 271 #    my ($marge_font_start, $marge_font_end);
 
 273 #    $form->{"lastcost_$i"} *= 1;
 
 275 #    $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1;
 
 277 #    if ($real_sellprice && ($form->{"qty_$i"} * 1)) {
 
 278 #      $form->{"marge_percent_$i"}     = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
 
 279 #      $myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"}));
 
 281 #      if ($form->{"id_$i"} &&
 
 282 #          ($form->{"marge_percent_$i"} < (1 * $myconfig{"marge_percent_warn"}))) {
 
 283 #        $marge_font_start = "<font color=\"#ff0000\">";
 
 284 #        $marge_font_end   = "</font>";
 
 288 #      $form->{"marge_percent_$i"} = 0;
 
 291 #    my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
 
 292 #    $form->{"marge_total_$i"}  = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
 
 293 #    $form->{"marge_total"}      += $form->{"marge_total_$i"};
 
 294 #    $form->{"lastcost_total"}   += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
 
 295 #    $form->{"sellprice_total"}  += $real_sellprice * $form->{"qty_$i"};
 
 297 #    map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_total marge_percent);
 
 299 #    # convert " to "
 
 300 #    map { $form->{"${_}_$i"} =~ s/\"/"/g }
 
 301 #      qw(partnumber description unit unit_old);
 
 303 #########################################
 
 304 #    # Eintrag fuer Version 2.2.0 geaendert #
 
 305 #    # neue Optik im Rechnungsformular      #
 
 306 #########################################
 
 307 #    $column_data{runningnumber} =
 
 308 #      qq|<td><input name="runningnumber_$i" size="5" value="$i"></td>|;    # HuT
 
 309 ############### ENDE Neueintrag ##################
 
 311 #    $column_data{partnumber} =
 
 312 #      qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
 
 314 #    if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
 
 315 #      $column_data{description} =
 
 316 #        qq|<td><textarea name="description_$i" rows="$rows" cols="30" wrap="soft">| . H($form->{"description_$i"}) . qq|</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
 
 318 #      $column_data{description} =
 
 319 #        qq|<td><input name="description_$i" size="30" value="| . $form->quote($form->{"description_$i"}) . qq|"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
 
 322 #    (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
 
 323 #    $qty_dec = length $qty_dec;
 
 325 #    $column_data{qty} =
 
 326 #        qq|<td align="right" nowrap><input name="qty_$i" size="5" value="|
 
 327 #      . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|">|;
 
 328 #    if ($form->{"formel_$i"}) {
 
 329 #      $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>|
 
 330 #        . $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"});
 
 332 #    $column_data{qty} .= qq|</td>|;
 
 333 #    $column_data{ship} =
 
 334 #        qq|<td align="right"><input name="ship_$i" size=5 value="|
 
 335 #      . $form->format_amount(\%myconfig, $form->{"ship_$i"})
 
 338 #    my $is_part     = $form->{"inventory_accno_$i"};
 
 339 #    my $is_assembly = $form->{"assembly_$i"};
 
 340 #    my $is_assigned = $form->{"id_$i"};
 
 341 #    my $this_unit = $form->{"unit_$i"};
 
 342 #    if ($form->{"selected_unit_$i"} && $this_unit &&
 
 343 #        $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
 
 344 #        ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
 
 345 #      $this_unit = $form->{"selected_unit_$i"};
 
 346 #    } elsif (!$is_assigned ||
 
 347 #             ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
 
 351 #    my $price_factor_select;
 
 352 #    if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
 
 353 #      my @values = ('', map { $_->{id}                      } @{ $form->{ALL_PRICE_FACTORS} });
 
 354 #      my %labels =      map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
 
 356 #      $price_factor_select =
 
 357 #        NTI($cgi->popup_menu('-name'    => "price_factor_id_$i",
 
 358 #                             '-default' => $form->{"price_factor_id_$i"},
 
 359 #                             '-values'  => \@values,
 
 360 #                             '-labels'  => \%labels,
 
 361 #                             '-style'   => 'width:90px'))
 
 365 #    $column_data{"unit"} = "<td>" .
 
 366 #      $price_factor_select .
 
 367 #       AM->unit_select_html($is_part || $is_assembly ? $dimension_units :
 
 368 #                            $is_assigned ? $service_units : $all_units,
 
 369 #                            "unit_$i", $this_unit,
 
 370 #                            $is_assigned ? $form->{"unit_$i"} : undef)
 
 373 #    # build in drop down list for pricesgroups
 
 374 #    if ($form->{"prices_$i"}) {
 
 375 #      if  ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
 
 376 #        $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
 
 378 #        $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
 
 381 #      $column_data{sellprice_pg} =
 
 382 #      qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
 
 383 #      $column_data{sellprice} =
 
 384 #      qq|<td><input name="sellprice_$i" size="10" value="$price_tmp" onBlur=\"check_right_number_format(this)\"></td>|;
 
 387 #      # for last row and report
 
 388 #      # set pricegroup drop down list from report menu
 
 389 #      if ($form->{"sellprice_$i"} != 0) {
 
 391 #          qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
 
 393 #        $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
 
 395 #        $column_data{sellprice_pg} =
 
 396 #          qq|<td align="right"><select name="sellprice_pg_$i">$prices</select></td>|;
 
 401 #        $column_data{sellprice_pg} = qq|<td align="right"> </td>|;
 
 404 #      $column_data{sellprice} =
 
 405 #      qq|<td><input name="sellprice_$i" size="10" onBlur=\"check_right_number_format(this)\" value="|
 
 406 #        . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
 
 410 #    $column_data{discount} =
 
 411 #        qq|<td align="right"><input name="discount_$i" size=3 value="|
 
 412 #      . $form->format_amount(\%myconfig, $form->{"discount_$i"})
 
 414 #    $column_data{linetotal} =
 
 415 #        qq|<td align="right">|
 
 416 #      . $form->format_amount(\%myconfig, $linetotal, 2)
 
 418 #    $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
 
 420 #########################################
 
 421 #    # Eintrag fuer Version 2.2.0 geaendert #
 
 422 #    # neue Optik im Rechnungsformular      #
 
 423 #########################################
 
 424 #    #     if ($lizenzen &&  $form->{type} eq "invoice" &&  $form->{vc} eq "customer") {
 
 425 #    #     $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
 
 428 #    #     if ($form->{type} !~ /_quotation/) {
 
 429 #    #     $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
 
 432 #    #     $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
 
 433 ############### ENDE Neueintrag ##################
 
 437 #        <tr valign="top" class="listrow$j">|;
 
 439 #    map { print "\n$column_data{$_}" } @column_index;
 
 442 #          $cgi->hidden("-name" => "unit_old_$i",
 
 443 #                       "-value" => $form->{"selected_unit_$i"})
 
 445 #          $cgi->hidden("-name" => "price_new_$i",
 
 446 #                       "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"}))
 
 448 #    map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_}) . "\n"); }
 
 449 #        ("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i",
 
 450 #         "id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i",
 
 451 #         "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i",
 
 452 #         "taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i",
 
 453 #         "longdescription_$i", "basefactor_$i", "marge_total_$i", "marge_percent_$i", "lastcost_$i",
 
 454 #         "marge_price_factor_$i"));
 
 456 #########################################
 
 457 #    # Eintrag fuer Version 2.2.0 geaendert #
 
 458 #    # neue Optik im Rechnungsformular      #
 
 459 #########################################
 
 461 #    my $row_style_attr =
 
 462 #      'style="display:none;"' if (!$form->{"show_details"});
 
 466 #        <tr  class="listrow$j" $row_style_attr>
 
 467 #         <td colspan="$colspan">
 
 469 #    if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
 
 470 #      my $selected = $form->{"licensenumber_$i"};
 
 471 #      my $lizenzen_quoted;
 
 472 #      $form->{"lizenzen_$i"} =~ s/ selected//g;
 
 473 #      $form->{"lizenzen_$i"} =~
 
 474 #        s/value="${selected}"\>/value="${selected}" selected\>/;
 
 475 #      $lizenzen_quoted = $form->{"lizenzen_$i"};
 
 476 #      $lizenzen_quoted =~ s/\"/"/g;
 
 478 #       <b>Lizenz\#</b> <select name="licensenumber_$i" size="1">
 
 479 #       $form->{"lizenzen_$i"}
 
 481 #       <input type="hidden" name="lizenzen_$i" value="${lizenzen_quoted}">
 
 484 #    if ($form->{type} !~ /_quotation/) {
 
 486 #          <b>$serialnumber</b> <input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|;
 
 489 #    print qq|<b>$projectnumber</b> | .
 
 490 #      NTI($cgi->popup_menu('-name' => "project_id_$i",
 
 491 #                           '-values' => \@projectnumber_values,
 
 492 #                           '-labels' => \%projectnumber_labels,
 
 493 #                           '-default' => $form->{"project_id_$i"}));
 
 495 #    if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
 
 497 #        ($form->{type} eq 'invoice')
 
 499 #        : 'reqdate';    # invoice uses a different term for the same thing.
 
 501 #        <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size="11" onBlur="check_right_date_format(this)" value="$form->{"${reqdate_term}_$i"}">
 
 504 #    my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
 
 506 #          <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" $subtotalchecked>
 
 509 #    if ($form->{"id_$i"} && $is_sales) {
 
 510 #      my $marge_price_factor;
 
 512 #      $form->{"marge_price_factor_$i"} *= 1;
 
 514 #      if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) {
 
 515 #        $marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"});
 
 519 #          ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b> $form->{"marge_total_$i"} $form->{"marge_percent_$i"} % ${marge_font_end}|;
 
 522 #           <b>| . $locale->text('LP') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
 
 523 #           <b>| . $locale->text('EK') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor;
 
 531 ############### ENDE Neueintrag ##################
 
 533 #    map { $form->{"${_}_base"} += $linetotal }
 
 534 #      (split(/ /, $form->{"taxaccounts_$i"}));
 
 536 #    $form->{invsubtotal} += $linetotal;
 
 545 #  if (0 != ($form->{sellprice_total} * 1)) {
 
 546 #    $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;
 
 549 #  $lxdebug->leave_sub();
 
 553   $lxdebug->enter_sub();
 
 554   my $rowcount = shift;
 
 555   for $j (1 .. $rowcount) {
 
 556     my $pricegroup_old = $form->{"pricegroup_old_$i"};
 
 557     if ($form->{PRICES}{$j}) {
 
 559       $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
 
 561       foreach $item (@{ $form->{PRICES}{$j} }) {
 
 563         #$price = $form->round_amount($myconfig,  $item->{price}, 5);
 
 564         #$price = $form->format_amount($myconfig, $item->{price}, 2);
 
 565         $price         = $item->{price};
 
 566         $pricegroup_id = $item->{pricegroup_id};
 
 567         $pricegroup    = $item->{pricegroup};
 
 569         # build drop down list for pricegroups
 
 571           qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
 
 576         #               $form->{"${_}_$j"} =
 
 577         #               $form->format_amount(\%myconfig, $form->{"${_}_$j"})
 
 578         #              } qw(sellprice price_new price_old);
 
 580         # set new selectedpricegroup_id and prices for "Preis"
 
 581         if ($item->{selected} && ($pricegroup_id != 0)) {
 
 582           $form->{"pricegroup_old_$j"} = $pricegroup_id;
 
 583           $form->{"price_new_$j"}      = $price;
 
 584           $form->{"sellprice_$j"}      = $price;
 
 586         if ($pricegroup_id == 0) {
 
 587           $form->{"price_new_$j"} = $form->{"sellprice_$j"};
 
 590       $form->{"prices_$j"} = $prices;
 
 593   $lxdebug->leave_sub();
 
 597   $lxdebug->enter_sub();
 
 599   $auth->assert('part_service_assembly_edit   | vendor_invoice_edit       | sales_order_edit    | invoice_edit |' .
 
 600                 'request_quotation_edit       | sales_quotation_edit      | purchase_order_edit | '.
 
 601                 'purchase_delivery_order_edit | sales_delivery_order_edit');
 
 604   retrieve_partunits() if ($form->{type} =~ /_delivery_order$/);
 
 606   my $new_rowcount = $form->{"rowcount"} * 1 + 1;
 
 607   $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
 
 609   $form->language_payment(\%myconfig);
 
 611   # if we have a display_form
 
 612   if ($form->{display_form}) {
 
 613     call_sub($form->{"display_form"});
 
 617   Common::webdav_folder($form) if ($webdav);
 
 619   #   if (   $form->{print_and_post}
 
 620   #       && $form->{second_run}
 
 621   #       && ($form->{action} eq "display_form")) {
 
 622   #     for (keys %$form) { $old_form->{$_} = $form->{$_} }
 
 623   #     $old_form->{rowcount}++;
 
 625   #     #$form->{rowcount}--;
 
 626   #     #$form->{rowcount}--;
 
 628   #     $form->{print_and_post} = 0;
 
 630   #     &print_form($old_form);
 
 634   #   $form->{action}   = "";
 
 635   #   $form->{resubmit} = 0;
 
 637   #   if ($form->{print_and_post} && !$form->{second_run}) {
 
 638   #     $form->{second_run} = 1;
 
 639   #     $form->{action}     = "display_form";
 
 640   #     $form->{rowcount}--;
 
 641   #     my $rowcount = $form->{rowcount};
 
 643   #     # get pricegroups for parts
 
 644   #     IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
 646   #     # build up html code for prices_$i
 
 647   #     set_pricegroup($rowcount);
 
 649   #     $form->{resubmit} = 1;
 
 654   $numrows    = ++$form->{rowcount};
 
 655   $subroutine = "display_row";
 
 657   if ($form->{item} eq 'part') {
 
 659     #set preisgruppenanzahl
 
 660     $numrows    = $form->{price_rows};
 
 661     $subroutine = "price_row";
 
 663     &{$subroutine}($numrows);
 
 665     $numrows    = ++$form->{makemodel_rows};
 
 666     $subroutine = "makemodel_row";
 
 668   if ($form->{item} eq 'assembly') {
 
 669     $numrows    = $form->{price_rows};
 
 670     $subroutine = "price_row";
 
 672     &{$subroutine}($numrows);
 
 674     $numrows    = ++$form->{makemodel_rows};
 
 675     $subroutine = "makemodel_row";
 
 677     # create makemodel rows
 
 678     &{$subroutine}($numrows);
 
 680     $numrows    = ++$form->{assembly_rows};
 
 681     $subroutine = "assembly_row";
 
 683   if ($form->{item} eq 'service') {
 
 684     $numrows    = $form->{price_rows};
 
 685     $subroutine = "price_row";
 
 687     &{$subroutine}($numrows);
 
 693   &{$subroutine}($numrows) if $numrows;
 
 697   $lxdebug->leave_sub();