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, oe
 
  34 #######################################################################
 
  40 require "$form->{path}/common.pl";
 
  42 # any custom scripts for this one
 
  43 if (-f "$form->{path}/custom_io.pl") {
 
  44   eval { require "$form->{path}/custom_io.pl"; };
 
  46 if (-f "$form->{path}/$form->{login}_io.pl") {
 
  47   eval { require "$form->{path}/$form->{login}_io.pl"; };
 
  54 # this is for our long dates
 
  55 # $locale->text('January')
 
  56 # $locale->text('February')
 
  57 # $locale->text('March')
 
  58 # $locale->text('April')
 
  59 # $locale->text('May ')
 
  60 # $locale->text('June')
 
  61 # $locale->text('July')
 
  62 # $locale->text('August')
 
  63 # $locale->text('September')
 
  64 # $locale->text('October')
 
  65 # $locale->text('November')
 
  66 # $locale->text('December')
 
  68 # this is for our short month
 
  69 # $locale->text('Jan')
 
  70 # $locale->text('Feb')
 
  71 # $locale->text('Mar')
 
  72 # $locale->text('Apr')
 
  73 # $locale->text('May')
 
  74 # $locale->text('Jun')
 
  75 # $locale->text('Jul')
 
  76 # $locale->text('Aug')
 
  77 # $locale->text('Sep')
 
  78 # $locale->text('Oct')
 
  79 # $locale->text('Nov')
 
  80 # $locale->text('Dec')
 
  85 ########################################
 
  86 # Eintrag fuer Version 2.2.0 geaendert #
 
  87 # neue Optik im Rechnungsformular      #
 
  88 ########################################
 
  90   $lxdebug->enter_sub();
 
  92   if ($lizenzen && $form->{vc} eq "customer") {
 
  93     if ($form->{type} =~ /sales_order/) {
 
  94       @column_index = (runningnumber, partnumber, description, ship, qty);
 
  95     } elsif ($form->{type} =~ /sales_quotation/) {
 
  96       @column_index = (runningnumber, partnumber, description, qty);
 
  98       @column_index = (runningnumber, partnumber, description, qty);
 
 101     if (   ($form->{type} =~ /purchase_order/)
 
 102         || ($form->{type} =~ /sales_order/)) {
 
 103       @column_index = (runningnumber, partnumber, description, ship, qty);
 
 105       @column_index = (runningnumber, partnumber, description, qty);
 
 108 ############## ENDE Neueintrag ##################
 
 110   my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension");
 
 111   my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
 
 112   my $all_units = AM->retrieve_units(\%myconfig, $form);
 
 114   push @column_index, qw(unit);
 
 116   #for pricegroups column
 
 117   if (   $form->{type} =~ (/sales_quotation/)
 
 118       or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
 
 119       or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
 
 120       or ($form->{type} =~ /sales_order/)) {
 
 121     push @column_index, qw(sellprice_pg);
 
 124   push @column_index, qw(sellprice);
 
 126   if ($form->{vc} eq 'customer') {
 
 127     push @column_index, qw(discount);
 
 130   push @column_index, "linetotal";
 
 132   my $colspan = $#column_index + 1;
 
 134   $form->{invsubtotal} = 0;
 
 135   map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
 
 137 ########################################
 
 138   # Eintrag fuer Version 2.2.0 geaendert #
 
 139   # neue Optik im Rechnungsformular      #
 
 140 ########################################
 
 141   $column_data{runningnumber} =
 
 142       qq|<th align=left nowrap width=5 class=listheading>|
 
 143     . $locale->text('No.')
 
 145   $column_data{partnumber} =
 
 146       qq|<th align=left nowrap width=12 class=listheading>|
 
 147     . $locale->text('Number')
 
 149   $column_data{description} =
 
 150       qq|<th align=left nowrap width=30 class=listheading>|
 
 151     . $locale->text('Part Description')
 
 154       qq|<th align=left nowrap width=5 class=listheading>|
 
 155     . $locale->text('Ship')
 
 158       qq|<th align=left nowrap width=5 class=listheading>|
 
 159     . $locale->text('Qty')
 
 162       qq|<th align=left nowrap width=5 class=listheading>|
 
 163     . $locale->text('Unit')
 
 165   $column_data{license} =
 
 166       qq|<th align=left nowrap width=10 class=listheading>|
 
 167     . $locale->text('License')
 
 169   $column_data{serialnr} =
 
 170       qq|<th align=left nowrap width=10 class=listheading>|
 
 171     . $locale->text('Serial No.')
 
 173   $column_data{projectnr} =
 
 174       qq|<th align=left nowrap width=10 class=listheading>|
 
 175     . $locale->text('Project')
 
 177   $column_data{sellprice} =
 
 178       qq|<th align=left nowrap width=15 class=listheading>|
 
 179     . $locale->text('Price')
 
 181   $column_data{sellprice_pg} =
 
 182       qq|<th align=left nowrap width=15 class=listheading>|
 
 183     . $locale->text('Pricegroup')
 
 185   $column_data{discount} =
 
 186       qq|<th align=left class=listheading>|
 
 187     . $locale->text('Discount')
 
 189   $column_data{linetotal} =
 
 190       qq|<th align=left nowrap width=10 class=listheading>|
 
 191     . $locale->text('Extended')
 
 194       qq|<th align=left nowrap width=10 class=listheading>|
 
 195     . $locale->text('Bin')
 
 197 ############## ENDE Neueintrag ##################
 
 203         <tr class=listheading>|;
 
 205   map { print "\n$column_data{$_}" } @column_index;
 
 211   $runningnumber = $locale->text('No.');
 
 212   $deliverydate  = $locale->text('Delivery Date');
 
 213   $serialnumber  = $locale->text('Serial No.');
 
 214   $projectnumber = $locale->text('Project');
 
 215   $partsgroup    = $locale->text('Group');
 
 216   $reqdate       = $locale->text('Reqdate');
 
 218   $delvar = 'deliverydate';
 
 220   if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
 
 221     $deliverydate = $locale->text('Required by');
 
 225   for $i (1 .. $numrows) {
 
 230         $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
 
 231     } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
 
 233     if (!$form->{"unit_old_$i"}) {
 
 234       # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
 
 235       # Einheit, wie sie in den Stammdaten hinterlegt wurde.
 
 236       # Es sollte also angenommen werden, dass diese ausgewaehlt war.
 
 237       $form->{"unit_old_$i"} = $form->{"unit_$i"};
 
 242     # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
 
 243     # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
 
 244     $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
 
 246     my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
 
 247     if (!$check_units->{$form->{"selected_unit_$i"}} ||
 
 248         ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
 
 249          $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
 
 250       # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
 
 251       # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
 
 252       # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
 
 253       $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
 
 255     if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
 
 256       if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
 
 258         if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
 
 259             $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
 
 260           $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
 
 261             $all_units->{$form->{"unit_old_$i"}}->{"factor"};
 
 263         $form->{"sellprice_$i"} *= $basefactor;
 
 264         $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
 
 267     ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
 
 269     $decimalplaces = ($dec > 2) ? $dec : 2;
 
 273                         $form->{"sellprice_$i"} * $form->{"discount_$i"} / 100,
 
 277       $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
 
 278     $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
 
 280     # convert " to "
 
 281     map { $form->{"${_}_$i"} =~ s/\"/"/g }
 
 282       qw(partnumber description unit unit_old);
 
 284 ########################################
 
 285     # Eintrag fuer Version 2.2.0 geaendert #
 
 286     # neue Optik im Rechnungsformular      #
 
 287 ########################################
 
 288     $column_data{runningnumber} =
 
 289       qq|<td><input name="runningnumber_$i" size=5 value=$i></td>|;    # HuT
 
 290 ############## ENDE Neueintrag ##################
 
 292     $column_data{partnumber} =
 
 293       qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
 
 295     if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
 
 296       $column_data{description} =
 
 297         qq|<td><textarea name="description_$i" rows=$rows cols=30 wrap=soft>$form->{"description_$i"}</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
 
 299       $column_data{description} =
 
 300         qq|<td><input name="description_$i" size=30 value="$form->{"description_$i"}"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
 
 303     (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
 
 304     $qty_dec = length $qty_dec;
 
 307         qq|<td align=right><input name="qty_$i" size=5 value=|
 
 308       . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|>|;
 
 309     if ($form->{"formel_$i"}) {
 
 310     $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>
 
 311           <input type=hidden name="formel_$i" value="$form->{"formel_$i"}"><input type=hidden name="alu_$i" value="$form->{"alu_$i"}"></td>|;
 
 314         qq|<td align=right><input name="ship_$i" size=5 value=|
 
 315       . $form->format_amount(\%myconfig, $form->{"ship_$i"})
 
 318     my $is_part = $form->{"inventory_accno_$i"};
 
 319     my $is_assigned = $form->{"id_$i"};
 
 320     my $this_unit = $form->{"unit_$i"};
 
 321     if ($form->{"selected_unit_$i"} && $this_unit &&
 
 322         $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
 
 323         ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
 
 324       $this_unit = $form->{"selected_unit_$i"};
 
 325     } elsif (!$is_assigned ||
 
 326              ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
 
 330     $column_data{"unit"} = "<td>" .
 
 331       ($qty_readonly ? " " :
 
 332        AM->unit_select_html($is_part ? $dimension_units :
 
 333                             $is_assigned ? $service_units : $all_units,
 
 334                             "unit_$i", $this_unit,
 
 335                             $is_assigned ? $form->{"unit_$i"} : undef))
 
 338     # build in drop down list for pricesgroups
 
 339     if ($form->{"prices_$i"}) {
 
 340       if  ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
 
 341         $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
 
 343         $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
 
 346       $column_data{sellprice_pg} =
 
 347         qq|<td align=right><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
 
 348       $column_data{sellprice} =
 
 349         qq|<td><input name="sellprice_$i" size=10 value=$price_tmp></td>|;
 
 352       # for last row and report
 
 353       # set pricegroup drop down list from report menu
 
 354       if ($form->{"sellprice_$i"} != 0) {
 
 356           qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
 
 358         $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
 
 360         $column_data{sellprice_pg} =
 
 361           qq|<td align=right><select name="sellprice_pg_$i">$prices</select></td>|;
 
 366         $column_data{sellprice_pg} = qq|<td align=right> </td>|;
 
 369       $column_data{sellprice} =
 
 370         qq|<td><input name="sellprice_$i" size=10 value=|
 
 371         . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
 
 375     $column_data{discount} =
 
 376         qq|<td align=right><input name="discount_$i" size=3 value=|
 
 377       . $form->format_amount(\%myconfig, $form->{"discount_$i"})
 
 379     $column_data{linetotal} =
 
 381       . $form->format_amount(\%myconfig, $linetotal, 2)
 
 383     $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
 
 385 ########################################
 
 386     # Eintrag fuer Version 2.2.0 geaendert #
 
 387     # neue Optik im Rechnungsformular      #
 
 388 ########################################
 
 389     #     if ($lizenzen &&  $form->{type} eq "invoice" &&  $form->{vc} eq "customer") {
 
 390     #     $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
 
 393     #     if ($form->{type} !~ /_quotation/) {
 
 394     #     $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
 
 397     #     $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
 
 398 ############## ENDE Neueintrag ##################
 
 402         <tr valign=top class=listrow$j>|;
 
 404     map { print "\n$column_data{$_}" } @column_index;
 
 409 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
 
 410 <input type=hidden name="bo_$i" value=$form->{"bo_$i"}>
 
 412 <input type=hidden name="pricegroup_old_$i" value=$form->{"pricegroup_old_$i"}>
 
 413 <input type=hidden name="price_old_$i" value=$form->{"price_old_$i"}>
 
 414 <input type=hidden name="unit_old_$i" value="$form->{"selected_unit_$i"}">
 
 415 <input type=hidden name="price_new_$i" value=|
 
 416       . $form->format_amount(\%myconfig, $form->{"price_new_$i"}) . qq|>
 
 418 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
 
 419 <input type=hidden name="inventory_accno_$i" value=$form->{"inventory_accno_$i"}>
 
 420 <input type=hidden name="bin_$i" value="$form->{"bin_$i"}">
 
 421 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
 
 422 <input type=hidden name="partnotes_$i" value="$form->{"partnotes_$i"}">
 
 423 <input type=hidden name="income_accno_$i" value=$form->{"income_accno_$i"}>
 
 424 <input type=hidden name="expense_accno_$i" value=$form->{"expense_accno_$i"}>
 
 425 <input type=hidden name="listprice_$i" value="$form->{"listprice_$i"}">
 
 426 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
 
 427 <input type=hidden name="taxaccounts_$i" value="$form->{"taxaccounts_$i"}">
 
 428 <input type=hidden name="ordnumber_$i" value="$form->{"ordnumber_$i"}">
 
 429 <input type=hidden name="transdate_$i" value="$form->{"transdate_$i"}">
 
 430 <input type=hidden name="cusordnumber_$i" value="$form->{"cusordnumber_$i"}">
 
 431 <input type=hidden name="longdescription_$i" value="$form->{"longdescription_$i"}">
 
 432 <input type=hidden name="basefactor_$i" value="$form->{"basefactor_$i"}">
 
 436 ########################################
 
 437     # Eintrag fuer Version 2.2.0 geaendert #
 
 438     # neue Optik im Rechnungsformular      #
 
 439 ########################################
 
 443           <td colspan=$colspan>
 
 445     if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
 
 446       my $selected = $form->{"licensenumber_$i"};
 
 448       $form->{"lizenzen_$i"} =~ s/ selected//g;
 
 449       $form->{"lizenzen_$i"} =~
 
 450         s/value="${selected}"\>/value="${selected}" selected\>/;
 
 451       $lizenzen_quoted = $form->{"lizenzen_$i"};
 
 452       $lizenzen_quoted =~ s/\"/"/g;
 
 454         <b>Lizenz\#</b> <select name="licensenumber_$i" size=1>
 
 455         $form->{"lizenzen_$i"}
 
 457         <input type=hidden name="lizenzen_$i" value="${lizenzen_quoted}">
 
 460     if ($form->{type} !~ /_quotation/) {
 
 462           <b>$serialnumber</b> <input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}">|;
 
 466           <b>$projectnumber</b> <input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}">
 
 467                   <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}">
 
 468                   <input type=hidden name="project_id_$i" value="$form->{"project_id_$i"}">
 
 470     if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
 
 472         ($form->{type} eq 'invoice')
 
 474         : 'reqdate';    # invoice uses a different term for the same thing.
 
 476         <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size=11 value="$form->{"${reqdate_term}_$i"}">
 
 479     my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
 
 481           <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" "$subtotalchecked">
 
 487 ############## ENDE Neueintrag ##################
 
 489     map { $form->{"${_}_base"} += $linetotal }
 
 490       (split / /, $form->{"taxaccounts_$i"});
 
 492     $form->{invsubtotal} += $linetotal;
 
 501   $lxdebug->leave_sub();
 
 504 ##################################################
 
 505 # build html-code for pricegroups in variable $form->{prices_$j}
 
 508   $lxdebug->enter_sub();
 
 509   my $rowcount = shift;
 
 510   for $j (1 .. $rowcount) {
 
 511     my $pricegroup_old = $form->{"pricegroup_old_$i"};
 
 512     if ($form->{PRICES}{$j}) {
 
 514       $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
 
 516       foreach $item (@{ $form->{PRICES}{$j} }) {
 
 518         #$price = $form->round_amount($myconfig,  $item->{price}, 5);
 
 519         #$price = $form->format_amount($myconfig, $item->{price}, 2);
 
 520         $price         = $item->{price};
 
 521         $pricegroup_id = $item->{pricegroup_id};
 
 522         $pricegroup    = $item->{pricegroup};
 
 524         # build drop down list for pricegroups
 
 526           qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
 
 531         #               $form->{"${_}_$j"} =
 
 532         #               $form->format_amount(\%myconfig, $form->{"${_}_$j"})
 
 533         #              } qw(sellprice price_new price_old);
 
 535         # set new selectedpricegroup_id and prices for "Preis"
 
 536         if ($item->{selected} && ($pricegroup_id != 0)) {
 
 537           $form->{"pricegroup_old_$j"} = $pricegroup_id;
 
 538           $form->{"price_new_$j"}      = $price;
 
 539           $form->{"sellprice_$j"}      = $price;
 
 541         if ($pricegroup_id == 0) {
 
 542           $form->{"price_new_$j"} = $form->{"sellprice_$j"};
 
 545       $form->{"prices_$j"} = $prices;
 
 548   $lxdebug->leave_sub();
 
 552   $lxdebug->enter_sub();
 
 553   @column_index = qw(ndx partnumber description onhand unit sellprice);
 
 555   $column_data{ndx}        = qq|<th> </th>|;
 
 556   $column_data{partnumber} =
 
 557     qq|<th class=listheading>| . $locale->text('Number') . qq|</th>|;
 
 558   $column_data{description} =
 
 559     qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
 
 560   $column_data{sellprice} =
 
 561     qq|<th class=listheading>| . $locale->text('Price') . qq|</th>|;
 
 562   $column_data{onhand} =
 
 563     qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
 
 565     qq|<th class=listheading>| . $locale->text('Unit') . qq|</th>|;
 
 566   # list items with radio button on a form
 
 569   $title   = $locale->text('Select from one of the items below');
 
 570   $colspan = $#column_index + 1;
 
 575 <form method=post action=$form->{script}>
 
 579     <th class=listtop colspan=$colspan>$title</th>
 
 582   <tr class=listheading>|;
 
 584   map { print "\n$column_data{$_}" } @column_index;
 
 589   foreach $ref (@{ $form->{item_list} }) {
 
 590     $checked = ($i++) ? "" : "checked";
 
 593       if ($ref->{inventory_accno} > 0) {
 
 594         $ref->{"lizenzen"} = qq|<option></option>|;
 
 595         foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
 
 596           $ref->{"lizenzen"} .=
 
 597             qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
 
 599         $ref->{"lizenzen"} .= qq|<option value=-1>Neue Lizenz</option>|;
 
 600         $ref->{"lizenzen"} =~ s/\"/"/g;
 
 604     map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description unit);
 
 608       $form->round_amount($ref->{sellprice} * (1 - $form->{tradediscount}), 2);
 
 610       qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
 
 611     $column_data{partnumber} =
 
 612       qq|<td><input name="new_partnumber_$i" type=hidden value="$ref->{partnumber}">$ref->{partnumber}</td>|;
 
 613     $column_data{description} =
 
 614       qq|<td><input name="new_description_$i" type=hidden value="$ref->{description}">$ref->{description}</td>|;
 
 615     $column_data{sellprice} =
 
 616       qq|<td align=right><input name="new_sellprice_$i" type=hidden value=$ref->{sellprice}>|
 
 617       . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
 
 619     $column_data{onhand} =
 
 620       qq|<td align=right><input name="new_onhand_$i" type=hidden value=$ref->{onhand}>|
 
 621       . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
 
 624       qq|<td>$ref->{unit}</td>|;
 
 628 <tr class=listrow$j>|;
 
 630     map { print "\n$column_data{$_}" } @column_index;
 
 635 <input name="new_bin_$i" type=hidden value="$ref->{bin}">
 
 636 <input name="new_listprice_$i" type=hidden value=$ref->{listprice}>
 
 637 <input name="new_inventory_accno_$i" type=hidden value=$ref->{inventory_accno}>
 
 638 <input name="new_income_accno_$i" type=hidden value=$ref->{income_accno}>
 
 639 <input name="new_expense_accno_$i" type=hidden value=$ref->{expense_accno}>
 
 640 <input name="new_unit_$i" type=hidden value="$ref->{unit}">
 
 641 <input name="new_weight_$i" type=hidden value="$ref->{weight}">
 
 642 <input name="new_assembly_$i" type=hidden value="$ref->{assembly}">
 
 643 <input name="new_taxaccounts_$i" type=hidden value="$ref->{taxaccounts}">
 
 644 <input name="new_partsgroup_$i" type=hidden value="$ref->{partsgroup}">
 
 645 <input name="new_formel_$i" type=hidden value="$ref->{formel}">
 
 646 <input name="new_longdescription_$i" type=hidden value="$ref->{longdescription}">
 
 647 <input name="new_not_discountable_$i" type=hidden value="$ref->{not_discountable}">
 
 648 <input name="new_part_payment_id_$i" type=hidden value="$ref->{part_payment_id}">
 
 650 <input name="new_id_$i" type=hidden value=$ref->{id}>
 
 655 <input name="new_lizenzen_$i" type=hidden value="$ref->{lizenzen}">
 
 662 <tr><td colspan=8><hr size=3 noshade></td></tr>
 
 665 <input name=lastndx type=hidden value=$i>
 
 669   # delete action variable
 
 670   map { delete $form->{$_} } qw(action item_list header);
 
 672   # save all other form variables
 
 673   foreach $key (keys %${form}) {
 
 674     $form->{$key} =~ s/\"/"/g;
 
 675     print qq|<input name=$key type=hidden value="$form->{$key}">\n|;
 
 679 <input type=hidden name=nextsub value=item_selected>
 
 682 <input class=submit type=submit name=action value="|
 
 683     . $locale->text('Continue') . qq|">
 
 690   $lxdebug->leave_sub();
 
 694   $lxdebug->enter_sub();
 
 696   # replace the last row with the checked row
 
 697   $i = $form->{rowcount};
 
 698   $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
 
 704   #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
 
 705   #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
 
 707   # if there was a price entered, override it
 
 708   $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
 
 710   map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} }
 
 711     qw(id partnumber description sellprice listprice inventory_accno income_accno expense_accno bin unit weight assembly taxaccounts partsgroup formel longdescription not_discountable);
 
 712   if ($form->{"part_payment_id_$i"} ne "") {
 
 713     $form->{payment_id} = $form->{"part_payment_id_$i"};
 
 717     map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
 
 720   ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
 
 722   $decimalplaces = ($dec > 2) ? $dec : 2;
 
 725     $form->{"sellprice_$i"} = $sellprice;
 
 728     # if there is an exchange rate adjust sellprice
 
 729     if (($form->{exchangerate} * 1) != 0) {
 
 730       $form->{"sellprice_$i"} /= $form->{exchangerate};
 
 731       $form->{"sellprice_$i"} =
 
 732         $form->round_amount($form->{"sellprice_$i"}, $decimalplaces);
 
 736   map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
 737     qw(sellprice listprice weight);
 
 739   $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
 
 740   $form->{weight}    += ($form->{"weight_$i"} * $form->{"qty_$i"});
 
 742   if ($form->{"not_discountable_$i"}) {
 
 743     $form->{"discount_$i"} = 0;
 
 747     $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
 
 749   map { $form->{"${_}_base"} += $amount }
 
 750     (split / /, $form->{"taxaccounts_$i"});
 
 751   map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /,
 
 752     $form->{"taxaccounts_$i"}
 
 753     if !$form->{taxincluded};
 
 755   $form->{creditremaining} -= $amount;
 
 757   $form->{"runningnumber_$i"} = $i;
 
 759   # delete all the new_ variables
 
 760   for $i (1 .. $form->{lastndx}) {
 
 761     map { delete $form->{"new_${_}_$i"} }
 
 762       qw(partnumber description sellprice bin listprice inventory_accno income_accno expense_accno unit assembly taxaccounts id);
 
 765   map { delete $form->{$_} } qw(ndx lastndx nextsub);
 
 770       $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces)
 
 771   } qw(sellprice listprice) if $form->{item} ne 'assembly';
 
 773   # get pricegroups for parts
 
 774   IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
 776   # build up html code for prices_$i
 
 777   set_pricegroup($form->{rowcount});
 
 781   $lxdebug->leave_sub();
 
 785   $lxdebug->enter_sub();
 
 788   $form->{old_callback} = $form->escape($form->{callback}, 1);
 
 789   $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
 
 792   delete $form->{action};
 
 794   # save all other form variables in a previousform variable
 
 795   foreach $key (keys %$form) {
 
 798     $form->{$key} =~ s/&/%26/g;
 
 799     $previousform .= qq|$key=$form->{$key}&|;
 
 802   $previousform = $form->escape($previousform, 1);
 
 804   $i = $form->{rowcount};
 
 805   map { $form->{"${_}_$i"} =~ s/\"/"/g } qw(partnumber description);
 
 812 <h4 class=error>| . $locale->text('Item not on file!') . qq|
 
 815 | . $locale->text('What type of item is this?') . qq|</h4>
 
 817 <form method=post action=ic.pl>
 
 821   <input class=radio type=radio name=item value=part checked> |
 
 822     . $locale->text('Part') . qq|<br>
 
 823   <input class=radio type=radio name=item value=service> |
 
 824     . $locale->text('Service')
 
 827 <input type=hidden name=previousform value="$previousform">
 
 828 <input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
 
 829 <input type=hidden name=description value="$form->{"description_$i"}">
 
 830 <input type=hidden name=rowcount value=$form->{rowcount}>
 
 831 <input type=hidden name=taxaccount2 value=$form->{taxaccounts}>
 
 832 <input type=hidden name=vc value=$form->{vc}>
 
 834 <input type=hidden name=path value=$form->{path}>
 
 835 <input type=hidden name=login value=$form->{login}>
 
 836 <input type=hidden name=password value=$form->{password}>
 
 838 <input type=hidden name=nextsub value=add>
 
 841 <input class=submit type=submit name=action value="|
 
 842     . $locale->text('Continue') . qq|">
 
 849   $lxdebug->leave_sub();
 
 853   $lxdebug->enter_sub();
 
 857   $form->language_payment(\%myconfig);
 
 859   # if we have a display_form
 
 860   if ($form->{display_form}) {
 
 861     &{"$form->{display_form}"};
 
 865   #   if (   $form->{print_and_post}
 
 866   #       && $form->{second_run}
 
 867   #       && ($form->{action} eq "display_form")) {
 
 868   #     for (keys %$form) { $old_form->{$_} = $form->{$_} }
 
 869   #     $old_form->{rowcount}++;
 
 871   #     #$form->{rowcount}--;
 
 872   #     #$form->{rowcount}--;
 
 874   #     $form->{print_and_post} = 0;
 
 876   #     &print_form($old_form);
 
 880   #   $form->{action}   = "";
 
 881   #   $form->{resubmit} = 0;
 
 883   #   if ($form->{print_and_post} && !$form->{second_run}) {
 
 884   #     $form->{second_run} = 1;
 
 885   #     $form->{action}     = "display_form";
 
 886   #     $form->{rowcount}--;
 
 887   #     my $rowcount = $form->{rowcount};
 
 889   #     # get pricegroups for parts
 
 890   #     IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
 892   #     # build up html code for prices_$i
 
 893   #     set_pricegroup($rowcount);
 
 895   #     $form->{resubmit} = 1;
 
 900   $numrows    = ++$form->{rowcount};
 
 901   $subroutine = "display_row";
 
 903   if ($form->{item} eq 'part') {
 
 905     #set preisgruppenanzahl
 
 906     $numrows    = $form->{price_rows};
 
 907     $subroutine = "price_row";
 
 909     &{$subroutine}($numrows);
 
 911     $numrows    = ++$form->{makemodel_rows};
 
 912     $subroutine = "makemodel_row";
 
 914   if ($form->{item} eq 'assembly') {
 
 915     $numrows    = $form->{price_rows};
 
 916     $subroutine = "price_row";
 
 918     &{$subroutine}($numrows);
 
 920     $numrows    = ++$form->{makemodel_rows};
 
 921     $subroutine = "makemodel_row";
 
 923     # create makemodel rows
 
 924     &{$subroutine}($numrows);
 
 926     $numrows    = ++$form->{assembly_rows};
 
 927     $subroutine = "assembly_row";
 
 929   if ($form->{item} eq 'service') {
 
 930     $numrows    = $form->{price_rows};
 
 931     $subroutine = "price_row";
 
 933     &{$subroutine}($numrows);
 
 939   &{$subroutine}($numrows) if $numrows;
 
 943   $lxdebug->leave_sub();
 
 947   $lxdebug->enter_sub();
 
 951     qw(id partnumber description qty ship sellprice unit discount inventory_accno income_accno expense_accno listprice taxaccounts bin assembly weight projectnumber project_id oldprojectnumber runningnumber serialnumber partsgroup payment_id not_discountable shop ve gv buchungsgruppen_id language_values sellprice_pg pricegroup_old price_old price_new unit_old ordnumber transdate longdescription basefactor)
 
 955   # remove any makes or model rows
 
 956   if ($form->{item} eq 'part') {
 
 957     map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
 958       qw(listprice sellprice lastcost weight rop);
 
 960     @flds = (make, model);
 
 961     for my $i (1 .. ($form->{makemodel_rows})) {
 
 962       if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
 
 966         map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
 
 971     $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
 
 972     $form->{makemodel_rows} = $count;
 
 974   } elsif ($form->{item} eq 'assembly') {
 
 976     $form->{sellprice} = 0;
 
 978     map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
 979       qw(listprice rop stock);
 
 982       qw(id qty unit bom partnumber description sellprice weight runningnumber partsgroup);
 
 984     for my $i (1 .. ($form->{assembly_rows} - 1)) {
 
 985       if ($form->{"qty_$i"}) {
 
 989         $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
 
 991         map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
 
 993         #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
 
 995         $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"});
 
 996         $form->{weight}    += ($form->{"qty_$i"} * $form->{"weight_$i"});
 
1001     $form->{sellprice} = $form->round_amount($form->{sellprice}, 2);
 
1003     $form->redo_rows(\@flds, \@a, $count, $form->{assembly_rows});
 
1004     $form->{assembly_rows} = $count;
 
1007     @flds  = qw(make model);
 
1010     for my $i (1 .. ($form->{makemodel_rows})) {
 
1011       if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
 
1015         map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
 
1020     $form->redo_rows(\@flds, \@a, $count, $form->{makemodel_rows});
 
1021     $form->{makemodel_rows} = $count;
 
1025     # this section applies to invoices and orders
 
1026     # remove any empty numbers
 
1027     if ($form->{rowcount}) {
 
1028       for my $i (1 .. $form->{rowcount} - 1) {
 
1029         if ($form->{"partnumber_$i"}) {
 
1033           map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
 
1036             if ($form->{"licensenumber_$i"} == -1) {
 
1044       $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
 
1045       $form->{rowcount} = $count;
 
1047       $form->{creditremaining} -= &invoicetotal;
 
1054   if (   $form->{type} =~ (/sales_quotation/)
 
1055       or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
 
1056       or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
 
1057       or ($form->{type} =~ /sales_order/)) {
 
1059     # get pricegroups for parts
 
1060     IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
1062     # build up html code for prices_$i
 
1063     set_pricegroup($form->{rowcount});
 
1069   $lxdebug->leave_sub();
 
1073   $lxdebug->enter_sub();
 
1075   $form->{oldinvtotal} = 0;
 
1077   # add all parts and deduct paid
 
1078   map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts};
 
1080   my ($amount, $sellprice, $discount, $qty);
 
1082   for my $i (1 .. $form->{rowcount}) {
 
1083     $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
 
1084     $discount  = $form->parse_amount(\%myconfig, $form->{"discount_$i"});
 
1085     $qty       = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
 
1087     #($form->{"sellprice_$i"}, $form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
 
1089     $amount = $sellprice * (1 - $discount / 100) * $qty;
 
1090     map { $form->{"${_}_base"} += $amount }
 
1091       (split / /, $form->{"taxaccounts_$i"});
 
1092     $form->{oldinvtotal} += $amount;
 
1095   map { $form->{oldinvtotal} += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
 
1096     split / /, $form->{taxaccounts}
 
1097     if !$form->{taxincluded};
 
1099   $form->{oldtotalpaid} = 0;
 
1100   for $i (1 .. $form->{paidaccounts}) {
 
1101     $form->{oldtotalpaid} += $form->{"paid_$i"};
 
1104   $lxdebug->leave_sub();
 
1107   return ($form->{oldinvtotal} - $form->{oldtotalpaid});
 
1110 sub validate_items {
 
1111   $lxdebug->enter_sub();
 
1113   # check if items are valid
 
1114   if ($form->{rowcount} == 1) {
 
1119   for $i (1 .. $form->{rowcount} - 1) {
 
1120     $form->isblank("partnumber_$i",
 
1121                    $locale->text('Number missing in Row') . " $i");
 
1124   $lxdebug->leave_sub();
 
1128   $lxdebug->enter_sub();
 
1129   if ($form->{second_run}) {
 
1130     $form->{print_and_post} = 0;
 
1132   $form->{ordnumber} = $form->{invnumber};
 
1134   map { delete $form->{$_} } qw(id printed emailed queued);
 
1135   if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
 
1136     $form->{title} = $locale->text('Add Purchase Order');
 
1137     $form->{vc}    = 'vendor';
 
1138     $form->{type}  = 'purchase_order';
 
1141   if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_quotation') {
 
1142     $form->{title} = $locale->text('Add Sales Order');
 
1143     $form->{vc}    = 'customer';
 
1144     $form->{type}  = 'sales_order';
 
1147   $form->{script} = 'oe.pl';
 
1149   $form->{shipto} = 1;
 
1151   $form->{rowcount}--;
 
1153   $form->{cp_id} *= 1;
 
1155   require "$form->{path}/$form->{script}";
 
1157   map { $form->{"select$_"} = "" } ($form->{vc}, currency);
 
1159   $currency = $form->{currency};
 
1163   $form->{currency}     = $currency;
 
1164   $form->{exchangerate} = "";
 
1165   $form->{forex}        = "";
 
1166   $form->{exchangerate} = $exchangerate
 
1170                     $form->check_exchangerate(
 
1171                     \%myconfig, $form->{currency}, $form->{transdate}, $buysell
 
1177   $lxdebug->leave_sub();
 
1181   $lxdebug->enter_sub();
 
1182   if ($form->{second_run}) {
 
1183     $form->{print_and_post} = 0;
 
1185   map { delete $form->{$_} } qw(id printed emailed queued);
 
1187   if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
 
1188     $form->{title} = $locale->text('Add Request for Quotation');
 
1189     $form->{vc}    = 'vendor';
 
1190     $form->{type}  = 'request_quotation';
 
1193   if ($form->{script} eq 'is.pl' || $form->{type} eq 'sales_order') {
 
1194     $form->{title} = $locale->text('Add Quotation');
 
1195     $form->{vc}    = 'customer';
 
1196     $form->{type}  = 'sales_quotation';
 
1200   $form->{cp_id} *= 1;
 
1202   $form->{script} = 'oe.pl';
 
1204   $form->{shipto} = 1;
 
1206   $form->{rowcount}--;
 
1208   require "$form->{path}/$form->{script}";
 
1210   map { $form->{"select$_"} = "" } ($form->{vc}, currency);
 
1212   $currency = $form->{currency};
 
1216   $form->{currency}     = $currency;
 
1217   $form->{exchangerate} = "";
 
1218   $form->{forex}        = "";
 
1219   $form->{exchangerate} = $exchangerate
 
1223                     $form->check_exchangerate(
 
1224                     \%myconfig, $form->{currency}, $form->{transdate}, $buysell
 
1230   $lxdebug->leave_sub();
 
1233 sub request_for_quotation {
 
1238   $lxdebug->enter_sub();
 
1239   if ($form->{second_run}) {
 
1240     $form->{print_and_post} = 0;
 
1241     $form->{resubmit}       = 0;
 
1243   if ($myconfig{role} eq 'admin') {
 
1245           <th align=right nowrap=true>| . $locale->text('Bcc') . qq|</th>
 
1246           <td><input name=bcc size=30 value="$form->{bcc}"></td>
 
1250   if ($form->{formname} =~ /(pick|packing|bin)_list/) {
 
1251     $form->{email} = $form->{shiptoemail} if $form->{shiptoemail};
 
1254   $name = $form->{ $form->{vc} };
 
1256   $title = $locale->text('E-mail') . " $name";
 
1258   $form->{oldmedia} = $form->{media};
 
1259   $form->{media}    = "email";
 
1266 <form method=post action=$form->{script}>
 
1270     <th class=listtop>$title</th>
 
1272   <tr height="5"></tr>
 
1277           <th align=right nowrap>| . $locale->text('To') . qq|</th>
 
1278           <td><input name=email size=30 value="$form->{email}"></td>
 
1279           <th align=right nowrap>| . $locale->text('Cc') . qq|</th>
 
1280           <td><input name=cc size=30 value="$form->{cc}"></td>
 
1283           <th align=right nowrap>| . $locale->text('Subject') . qq|</th>
 
1284           <td><input name=subject size=30 value="$form->{subject}"></td>
 
1294           <th align=left nowrap>| . $locale->text('Message') . qq|</th>
 
1297           <td><textarea name=message rows=15 cols=60 wrap=soft>$form->{message}</textarea></td>
 
1308   map { delete $form->{$_} }
 
1309     qw(action email cc bcc subject message formname sendmode format header override);
 
1311   # save all other variables
 
1312   foreach $key (keys %$form) {
 
1313     $form->{$key} =~ s/\"/"/g;
 
1314     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
 
1321     <td><hr size=3 noshade></td>
 
1325 <input type=hidden name=nextsub value=send_email>
 
1328 <input name=action class=submit type=submit value="|
 
1329     . $locale->text('Continue') . qq|">
 
1336   $lxdebug->leave_sub();
 
1340   $lxdebug->enter_sub();
 
1342   $old_form = new Form;
 
1344   map { $old_form->{$_} = $form->{$_} } keys %$form;
 
1345   $old_form->{media} = $form->{oldmedia};
 
1347   &print_form($old_form);
 
1349   $lxdebug->leave_sub();
 
1353   $lxdebug->enter_sub();
 
1354   $form->{sendmode} = "attachment";
 
1357     $form->{"format"} ? $form->{"format"} :
 
1358     $myconfig{"template_format"} ? $myconfig{"template_format"} :
 
1362     $form->{"copies"} ? $form->{"copies"} :
 
1363     $myconfig{"copies"} ? $myconfig{"copies"} :
 
1366   $form->{PD}{ $form->{formname} } = "selected";
 
1367   $form->{DF}{ $form->{format} }   = "selected";
 
1368   $form->{OP}{ $form->{media} }    = "selected";
 
1369   $form->{SM}{ $form->{sendmode} } = "selected";
 
1371   if ($form->{type} eq 'purchase_order') {
 
1372     $type = qq|<select name=formname>
 
1373             <option value=purchase_order $form->{PD}{purchase_order}>|
 
1374       . $locale->text('Purchase Order') . qq|
 
1375             <option value=bin_list $form->{PD}{bin_list}>|
 
1376       . $locale->text('Bin List');
 
1379   if ($form->{type} eq 'credit_note') {
 
1380     $type = qq|<select name=formname>
 
1381             <option value=credit_note $form->{PD}{credit_note}>|
 
1382       . $locale->text('Credit Note');
 
1385   if ($form->{type} eq 'sales_order') {
 
1386     $type = qq|<select name=formname>
 
1387             <option value=sales_order $form->{PD}{sales_order}>|
 
1388       . $locale->text('Confirmation') . qq|
 
1389       <option value=proforma $form->{PD}{proforma}>|
 
1390       . $locale->text('Proforma Invoice') . qq|
 
1391             <option value=pick_list $form->{PD}{pick_list}>|
 
1392       . $locale->text('Pick List') . qq|
 
1393             <option value=packing_list $form->{PD}{packing_list}>|
 
1394       . $locale->text('Packing List');
 
1397   if ($form->{type} =~ /_quotation$/) {
 
1398     $type = qq|<select name=formname>
 
1399             <option value="$`_quotation" $form->{PD}{"$`_quotation"}>|
 
1400       . $locale->text('Quotation');
 
1403   if ($form->{type} eq 'invoice') {
 
1404     $type = qq|<select name=formname>
 
1405             <option value=invoice $form->{PD}{invoice}>|
 
1406       . $locale->text('Invoice') . qq|
 
1407       <option value=proforma $form->{PD}{proforma}>|
 
1408       . $locale->text('Proforma Invoice') . qq|
 
1409       <option value=packing_list $form->{PD}{packing_list}>|
 
1410       . $locale->text('Packing List');
 
1413   if ($form->{type} eq 'invoice' && $form->{storno}) {
 
1414     $type = qq|<select name=formname>
 
1415             <option value=storno_invoice $form->{PD}{storno_invoice}>|
 
1416       . $locale->text('Storno Invoice') . qq|
 
1417       <option value=storno_packing_list $form->{PD}{storno_packing_list}>|
 
1418       . $locale->text('Storno Packing List');
 
1421   if ($form->{type} eq 'credit_note') {
 
1422     $type = qq|<select name=formname>
 
1423             <option value=credit_note $form->{PD}{credit_note}>|
 
1424       . $locale->text('Credit Note');
 
1427   if ($form->{type} eq 'ship_order') {
 
1428     $type = qq|<select name=formname>
 
1429             <option value=pick_list $form->{PD}{pick_list}>|
 
1430       . $locale->text('Pick List') . qq|
 
1431             <option value=packing_list $form->{PD}{packing_list}>|
 
1432       . $locale->text('Packing List');
 
1435   if ($form->{type} eq 'receive_order') {
 
1436     $type = qq|<select name=formname>
 
1437             <option value=bin_list $form->{PD}{bin_list}>|
 
1438       . $locale->text('Bin List');
 
1441   if ($form->{media} eq 'email') {
 
1442     $media = qq|<select name=sendmode>
 
1443             <option value=attachment $form->{SM}{attachment}>|
 
1444       . $locale->text('Attachment') . qq|
 
1445             <option value=inline $form->{SM}{inline}>| . $locale->text('In-line');
 
1447     $media = qq|<select name=media>
 
1448             <option value=screen $form->{OP}{screen}>| . $locale->text('Screen');
 
1449     if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates) {
 
1451             <option value=printer $form->{OP}{printer}>|
 
1452         . $locale->text('Printer');
 
1454     if ($latex_templates) {
 
1456             <option value=queue $form->{OP}{queue}>| . $locale->text('Queue');
 
1460   $format = qq|<select name=format>|;
 
1461   if ($opendocument_templates && $openofficeorg_writer_bin &&
 
1462       $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
 
1463     $format .= qq|<option value=opendocument_pdf | .
 
1464       $form->{DF}{"opendocument_pdf"} . qq|>| .
 
1465       $locale->text("PDF (OpenDocument/OASIS)") . qq|</option>|;
 
1468   if ($latex_templates) {
 
1469     $format .= qq|<option value=pdf $form->{DF}{pdf}>| .
 
1470       $locale->text('PDF') . qq|</option>|;
 
1473   $format .= qq|<option value=html $form->{DF}{html}>HTML</option>|;
 
1475   if ($latex_templates) {
 
1476     $format .= qq|<option value=postscript $form->{DF}{postscript}>| .
 
1477       $locale->text('Postscript') . qq|</option>|;
 
1480   if ($opendocument_templates) {
 
1481     $format .= qq|<option value=opendocument $form->{DF}{opendocument}>| .
 
1482       $locale->text("OpenDocument/OASIS") . qq|</option>|;
 
1484   $format .= qq|</select>|;
 
1486   if (scalar(keys (%{ $form->{languages} })) !=0) {
 
1487     $language_select = qq|<select name=language_id>
 
1488                 <option value=""></option>}|;
 
1489     foreach $item (@{ $form->{languages} }) {
 
1490       if ($form->{language_id} eq $item->{id}) {
 
1491         $language_select .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
1493         $language_select .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
1498   if (scalar(keys (%{ $form->{printers} })) !=0) {
 
1500     $printer_select = qq|<select name=printer_id>
 
1501                   <option value=""></option>|;
 
1502     foreach $item (@{ $form->{printers} }) {
 
1503       $printer_select .= qq|<option value="$item->{id}">$item->{printer_description}</option>|;
 
1510 <table width=100% cellspacing=0 cellpadding=0>
 
1515           <td>$type</select></td>|;
 
1516   if (scalar(keys (%{ $form->{languages} })) !=0) {
 
1518           <td>${language_select}</select></td>|;
 
1521           <td>$format</select></td>
 
1522           <td>$media</select></td>|;
 
1523   if (scalar(keys (%{ $form->{printers} })) !=0) {
 
1525           <td>$printer_select</select></td>
 
1529   if (scalar(keys (%{ $form->{printers} })) !=0 && $latex_templates && $form->{media} ne 'email') {
 
1531           <td>| . $locale->text('Copies') . qq|
 
1532           <input name=copies size=2 value=$form->{copies}></td>
 
1536   $form->{groupitems} = "checked" if $form->{groupitems};
 
1539           <td>| . $locale->text('Group Items') . qq|</td>
 
1540           <td><input name=groupitems type=checkbox class=checkbox $form->{groupitems}></td>
 
1549   if ($form->{printed} =~ /$form->{formname}/) {
 
1551           <th>\|| . $locale->text('Printed') . qq|\|</th>
 
1555   if ($form->{emailed} =~ /$form->{formname}/) {
 
1557           <th>\|| . $locale->text('E-mailed') . qq|\|</th>
 
1561   if ($form->{queued} =~ /$form->{formname}/) {
 
1563           <th>\|| . $locale->text('Queued') . qq|\|</th>
 
1575   $lxdebug->leave_sub();
 
1579   $lxdebug->enter_sub();
 
1581   # if this goes to the printer pass through
 
1582   if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
 
1583     $form->error($locale->text('Select postscript or PDF!'))
 
1584       if ($form->{format} !~ /(postscript|pdf)/);
 
1586     $old_form = new Form;
 
1587     map { $old_form->{$_} = $form->{$_} } keys %$form;
 
1590   if (!$form->{id} || (($form->{formname} eq "proforma") && !$form->{proforma} && (($form->{type} =~ /_order$/) || ($form->{type} =~ /_quotation$/)))) {
 
1591     if ($form->{formname} eq "proforma") {
 
1592       $form->{proforma} = 1;
 
1594     $form->{print_and_save} = 1;
 
1595     my $formname = $form->{formname};
 
1597     $form->{formname} = $formname;
 
1602   &print_form($old_form);
 
1604   $lxdebug->leave_sub();
 
1608   $lxdebug->enter_sub();
 
1609   my ($old_form) = @_;
 
1613   $numberfld = "invnumber";
 
1616     ($form->{display_form}) ? $form->{display_form} : "display_form";
 
1618   # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
 
1619   $form->{ $form->{"formname"} . "notes" } = $form->{"notes"};
 
1621   if ($form->{formname} eq "invoice") {
 
1622     $form->{label} = $locale->text('Invoice');
 
1624   if ($form->{formname} eq "packing_list") {
 
1626     # this is from an invoice
 
1627     $form->{label} = $locale->text('Packing List');
 
1629   if ($form->{formname} eq 'sales_order') {
 
1632     $form->{"${inv}date"} = $form->{transdate};
 
1633     $form->{label}        = $locale->text('Sales Order');
 
1634     $numberfld            = "sonumber";
 
1638   if (($form->{type} eq 'invoice') && ($form->{formname} eq 'proforma') ) {
 
1641     $form->{"${inv}date"} = $form->{transdate};
 
1642     $form->{"invdate"}    = $form->{transdate};
 
1643     $form->{label}        = $locale->text('Proforma Invoice');
 
1644     $numberfld            = "sonumber";
 
1648   if (($form->{type} eq 'sales_order') && ($form->{formname} eq 'proforma') ) {
 
1651     $form->{"${inv}date"} = $form->{transdate};
 
1652     $form->{"invdate"}    = $form->{transdate};
 
1653     $form->{invnumber}    = $form->{ordnumber};
 
1654     $form->{label}        = $locale->text('Proforma Invoice');
 
1655     $numberfld            = "sonumber";
 
1659   if ($form->{formname} eq 'packing_list' && $form->{type} ne 'invoice') {
 
1661     # we use the same packing list as from an invoice
 
1664     $form->{invdate} = $form->{"${inv}date"} = $form->{transdate};
 
1665     $form->{label} = $locale->text('Packing List');
 
1667     # set invnumber for template packing_list 
 
1668     $form->{invnumber}   = $form->{ordnumber};
 
1670   if ($form->{formname} eq 'pick_list') {
 
1673     $form->{"${inv}date"} =
 
1674       ($form->{transdate}) ? $form->{transdate} : $form->{invdate};
 
1675     $form->{label} = $locale->text('Pick List');
 
1676     $order = 1 unless $form->{type} eq 'invoice';
 
1678   if ($form->{formname} eq 'purchase_order') {
 
1681     $form->{"${inv}date"} = $form->{transdate};
 
1682     $form->{label}        = $locale->text('Purchase Order');
 
1683     $numberfld            = "ponumber";
 
1686   if ($form->{formname} eq 'bin_list') {
 
1689     $form->{"${inv}date"} = $form->{transdate};
 
1690     $form->{label}        = $locale->text('Bin List');
 
1693   if ($form->{formname} eq 'sales_quotation') {
 
1696     $form->{"${inv}date"} = $form->{transdate};
 
1697     $form->{label}        = $locale->text('Quotation');
 
1698     $numberfld            = "sqnumber";
 
1702   if (($form->{type} eq 'sales_quotation') && ($form->{formname} eq 'proforma') ) {
 
1705     $form->{"${inv}date"} = $form->{transdate};
 
1706     $form->{"invdate"} = $form->{transdate};
 
1707     $form->{label}        = $locale->text('Proforma Invoice');
 
1708     $numberfld            = "sqnumber";
 
1712   if ($form->{formname} eq 'request_quotation') {
 
1715     $form->{"${inv}date"} = $form->{transdate};
 
1716     $form->{label}        = $locale->text('Quotation');
 
1717     $numberfld            = "rfqnumber";
 
1721   $form->isblank("email", $locale->text('E-mail address missing!'))
 
1722     if ($form->{media} eq 'email');
 
1723   $form->isblank("${inv}date",
 
1724                  $locale->text($form->{label} . ' Date missing!'));
 
1726   # $locale->text('Invoice Number missing!')
 
1727   # $locale->text('Invoice Date missing!')
 
1728   # $locale->text('Packing List Number missing!')
 
1729   # $locale->text('Packing List Date missing!')
 
1730   # $locale->text('Order Number missing!')
 
1731   # $locale->text('Order Date missing!')
 
1732   # $locale->text('Quotation Number missing!')
 
1733   # $locale->text('Quotation Date missing!')
 
1736   if (!$form->{"${inv}number"} && !$form->{preview}) {
 
1737     $form->{"${inv}number"} = $form->update_defaults(\%myconfig, $numberfld);
 
1738     if ($form->{media} ne 'email') {
 
1740       # get pricegroups for parts
 
1741       IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
1743       # build up html code for prices_$i
 
1744       set_pricegroup($form->{rowcount});
 
1746       $form->{rowcount}--;
 
1755   # Save the email address given in the form because it should override the setting saved for the customer/vendor.
 
1756   my ($saved_email, $saved_cc, $saved_bcc) =
 
1757     ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
 
1759   $language_saved = $form->{language_id};
 
1760   $payment_id_saved = $form->{payment_id};
 
1762   &{"$form->{vc}_details"};
 
1764   $form->{language_id} = $language_saved;
 
1765   $form->{payment_id} = $payment_id_saved;
 
1767   $form->{"email"} = $saved_email if ($saved_email);
 
1768   $form->{"cc"}    = $saved_cc    if ($saved_cc);
 
1769   $form->{"bcc"}   = $saved_bcc   if ($saved_bcc);
 
1771   my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
 
1772   if ($form->{"language_id"}) {
 
1773     ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
 
1774       AM->get_language_details(\%myconfig, $form, $form->{language_id});
 
1776     $output_dateformat = $myconfig{"dateformat"};
 
1777     $output_numberformat = $myconfig{"numberformat"};
 
1778     $output_longdates = 1;
 
1781   ($form->{employee}) = split /--/, $form->{employee};
 
1782   ($form->{warehouse}, $form->{warehouse_id}) = split /--/, $form->{warehouse};
 
1784   # create the form variables
 
1786     OE->order_details(\%myconfig, \%$form);
 
1788     IS->invoice_details(\%myconfig, \%$form, $locale);
 
1791   if ($form->{shipto_id}) {
 
1792     $form->get_shipto(\%myconfig);
 
1795   @a = qw(name street zipcode city country);
 
1799   # if there is no shipto fill it in from billto
 
1800   foreach $item (@a) {
 
1801     if ($form->{"shipto$item"}) {
 
1808     if (   $form->{formname} eq 'purchase_order'
 
1809         || $form->{formname} eq 'request_quotation') {
 
1810       $form->{shiptoname}   = $myconfig{company};
 
1811       $form->{shiptostreet} = $myconfig{address};
 
1813       map { $form->{"shipto$_"} = $form->{$_} } @a;
 
1817   $form->{notes} =~ s/^\s+//g;
 
1819   $form->{templates} = "$myconfig{templates}";
 
1821   $form->{language} = $form->get_template_language(\%myconfig);
 
1822   $form->{printer_code} = $form->get_printer_code(\%myconfig);
 
1824   if ($form->{language} ne "") {
 
1825     map({ $form->{"unit"}->[$_] =
 
1826             AM->translate_units($form, $form->{"language"},
 
1827                                 $form->{"unit"}->[$_], $form->{"qty"}->[$_]); }
 
1828         (0..scalar(@{$form->{"unit"}}) - 1));
 
1829     $form->{language} = "_" . $form->{language};
 
1833   format_dates($output_dateformat, $output_longdates,
 
1834                qw(invdate orddate quodate pldate duedate reqdate transdate
 
1835                   shippingdate deliverydate validitydate paymentdate
 
1836                   datepaid transdate_oe deliverydate_oe
 
1837                   employee_startdate employee_enddate
 
1839                grep({ /^datepaid_\d+$/ ||
 
1840                         /^transdate_oe_\d+$/ ||
 
1841                         /^deliverydate_oe_\d+$/ ||
 
1843                         /^deliverydate_\d+$/ ||
 
1847   reformat_numbers($output_numberformat, 2,
 
1848                    qw(invtotal ordtotal quototal subtotal linetotal
 
1849                       listprice sellprice netprice discount
 
1851                    grep({ /^linetotal_\d+$/ ||
 
1852                             /^listprice_\d+$/ ||
 
1853                             /^sellprice_\d+$/ ||
 
1860   reformat_numbers($output_numberformat, undef,
 
1865   if ($form->{printer_code} ne "") {
 
1866     $form->{printer_code} = "_" . $form->{printer_code};
 
1869   $form->{IN} = "$form->{formname}$form->{language}$form->{printer_code}.html";
 
1870   if ($form->{format} eq 'postscript') {
 
1871     $form->{postscript} = 1;
 
1872     $form->{IN} =~ s/html$/tex/;
 
1873   } elsif ($form->{"format"} =~ /pdf/) {
 
1875     if ($form->{"format"} =~ /opendocument/) {
 
1876       $form->{IN} =~ s/html$/odt/;
 
1878       $form->{IN} =~ s/html$/tex/;
 
1880   } elsif ($form->{"format"} =~ /opendocument/) {
 
1881     $form->{"opendocument"} = 1;
 
1882     $form->{"IN"} =~ s/html$/odt/;
 
1885   if ($form->{media} eq 'printer') {
 
1886     $form->{OUT} = "| $form->{printer_command} &>/dev/null";
 
1887     $form->{printed} .= " $form->{formname}";
 
1888     $form->{printed} =~ s/^ //;
 
1890   $printed = $form->{printed};
 
1892   if ($form->{media} eq 'email') {
 
1893     $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
 
1894       unless $form->{subject};
 
1896     $form->{OUT} = "$sendmail";
 
1898     $form->{emailed} .= " $form->{formname}";
 
1899     $form->{emailed} =~ s/^ //;
 
1901   $emailed = $form->{emailed};
 
1903   if ($form->{media} eq 'queue') {
 
1904     %queued = split / /, $form->{queued};
 
1906     if ($filename = $queued{ $form->{formname} }) {
 
1907       $form->{queued} =~ s/$form->{formname} $filename//;
 
1908       unlink "$spool/$filename";
 
1909       $filename =~ s/\..*$//g;
 
1915     $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
 
1916     $form->{OUT} = ">$spool/$filename";
 
1919     $form->{queued} .= " $form->{formname} $filename";
 
1921     $form->{queued} =~ s/^ //;
 
1923   $queued = $form->{queued};
 
1925   $form->parse_template(\%myconfig, $userspath);
 
1927   $form->{callback} = "";
 
1929   if ($form->{media} eq 'email') {
 
1930     $form->{message} = $locale->text('sent') unless $form->{message};
 
1932   $message = $form->{message};
 
1934   # if we got back here restore the previous form
 
1935   if ($form->{media} =~ /(printer|email|queue)/) {
 
1937     $form->update_status(\%myconfig)
 
1938       if ($form->{media} eq 'queue' && $form->{id});
 
1942       $old_form->{"${inv}number"} = $form->{"${inv}number"};
 
1944       # restore and display form
 
1945       map { $form->{$_} = $old_form->{$_} } keys %$old_form;
 
1947       $form->{queued}  = $queued;
 
1948       $form->{printed} = $printed;
 
1949       $form->{emailed} = $emailed;
 
1950       $form->{message} = $message;
 
1952       $form->{rowcount}--;
 
1953       map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
1954         qw(exchangerate creditlimit creditremaining);
 
1956       for $i (1 .. $form->{paidaccounts}) {
 
1958           $form->{"${_}_$i"} =
 
1959             $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
 
1960         } qw(paid exchangerate);
 
1968       ($form->{media} eq 'printer')
 
1969       ? $locale->text('sent to printer')
 
1970       : $locale->text('emailed to') . " $form->{email}";
 
1971     $form->redirect(qq|$form->{label} $form->{"${inv}number"} $msg|);
 
1973   if ($form->{printing}) {
 
1978   $lxdebug->leave_sub();
 
1981 sub customer_details {
 
1982   $lxdebug->enter_sub();
 
1983   IS->customer_details(\%myconfig, \%$form);
 
1984   $lxdebug->leave_sub();
 
1987 sub vendor_details {
 
1988   $lxdebug->enter_sub();
 
1990   IR->vendor_details(\%myconfig, \%$form);
 
1992   $lxdebug->leave_sub();
 
1996   $lxdebug->enter_sub();
 
1998   $form->{postasnew} = 1;
 
1999   map { delete $form->{$_} } qw(printed emailed queued);
 
2003   $lxdebug->leave_sub();
 
2007   $lxdebug->enter_sub();
 
2008   if ($form->{second_run}) {
 
2009     $form->{print_and_post} = 0;
 
2012   $title = $form->{title};
 
2013   $form->{title} = $locale->text('Ship to');
 
2015   map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
2016     qw(exchangerate creditlimit creditremaining);
 
2018   # get details for name
 
2019   &{"$form->{vc}_details"};
 
2022     ($form->{vc} eq 'customer')
 
2023     ? $locale->text('Customer Number')
 
2024     : $locale->text('Vendor Number');
 
2026   # get pricegroups for parts
 
2027   IS->get_pricegroups_for_parts(\%myconfig, \%$form);
 
2029   # build up html code for prices_$i
 
2030   set_pricegroup($form->{rowcount});
 
2032   $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
 
2034   $form->{rowcount}--;
 
2041 <form method=post action=$form->{script}>
 
2047         <tr class=listheading>
 
2048           <th class=listheading colspan=2 width=50%>|
 
2049     . $locale->text('Billing Address') . qq|</th>
 
2050           <th class=listheading width=50%>|
 
2051     . $locale->text('Shipping Address') . qq|</th>
 
2053         <tr height="5"></tr>
 
2055           <th align=right nowrap>$number</th>
 
2056           <td>$form->{"$form->{vc}number"}</td>
 
2059           <th align=right nowrap>| . $locale->text('Company Name') . qq|</th>
 
2060           <td>$form->{name}</td>
 
2061           <td><input name=shiptoname size=35 value="$form->{shiptoname}"></td>
 
2064           <th align=right nowrap>| . $locale->text('Department') . qq|</th>
 
2065           <td>$form->{department_1}</td>
 
2066           <td><input name=shiptodepartment_1 size=35 value="$form->{shiptodepartment_1}"></td>
 
2069           <th align=right nowrap> </th>
 
2070           <td>$form->{department_2}</td>
 
2071           <td><input name=shiptodepartment_2 size=35 value="$form->{shiptodepartment_2}"></td>
 
2074           <th align=right nowrap>| . $locale->text('Street') . qq|</th>
 
2075           <td>$form->{street}</td>
 
2076           <td><input name=shiptostreet size=35 value="$form->{shiptostreet}"></td>
 
2079           <th align=right nowrap>| . $locale->text('Zipcode') . qq|</th>
 
2080           <td>$form->{zipcode}</td>
 
2081           <td><input name=shiptozipcode size=35 value="$form->{shiptozipcode}"></td>
 
2084           <th align=right nowrap>| . $locale->text('City') . qq|</th>
 
2085           <td>$form->{city}</td>
 
2086           <td><input name=shiptocity size=35 value="$form->{shiptocity}"></td>
 
2089           <th align=right nowrap>| . $locale->text('Country') . qq|</th>
 
2090           <td>$form->{country}</td>
 
2091           <td><input name=shiptocountry size=35 value="$form->{shiptocountry}"></td>
 
2094           <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
 
2095           <td>$form->{contact}</td>
 
2096           <td><input name=shiptocontact size=35 value="$form->{shiptocontact}"></td>
 
2099           <th align=right nowrap>| . $locale->text('Phone') . qq|</th>
 
2100           <td>$form->{"$form->{vc}phone"}</td>
 
2101           <td><input name=shiptophone size=20 value="$form->{shiptophone}"></td>
 
2104           <th align=right nowrap>| . $locale->text('Fax') . qq|</th>
 
2105           <td>$form->{"$form->{vc}fax"}</td>
 
2106           <td><input name=shiptofax size=20 value="$form->{shiptofax}"></td>
 
2109           <th align=right nowrap>| . $locale->text('E-mail') . qq|</th>
 
2110           <td>$form->{email}</td>
 
2111           <td><input name=shiptoemail size=35 value="$form->{shiptoemail}"></td>
 
2118 <input type=hidden name=nextsub value=$nextsub>
 
2122   map { delete $form->{$_} }
 
2123     qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2 header);
 
2124   $form->{title} = $title;
 
2126   foreach $key (keys %$form) {
 
2127     $form->{$key} =~ s/\"/"/g;
 
2128     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
 
2136 <input class=submit type=submit name=action value="|
 
2137     . $locale->text('Continue') . qq|">
 
2144   $lxdebug->leave_sub();
 
2148   $lxdebug->enter_sub();
 
2153   $form->{old_callback} = $form->escape($form->{callback}, 1);
 
2154   $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
 
2155   $form->{old_callback} = $form->escape($form->{old_callback}, 1);
 
2158   delete $form->{action};
 
2159   $customer = $form->{customer};
 
2160   map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
 
2162   # save all other form variables in a previousform variable
 
2163   $form->{row} = $row;
 
2164   foreach $key (keys %$form) {
 
2167     $form->{$key} =~ s/&/%26/g;
 
2168     $previousform .= qq|$key=$form->{$key}&|;
 
2171   $previousform = $form->escape($previousform, 1);
 
2173   $form->{script} = "licenses.pl";
 
2175   map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
 
2176   map { $form->{$_} = $form->escape($form->{$_}, 1) }
 
2177     qw(partnumber description);
 
2179     qq|$form->{script}?login=$form->{login}&path=$form->{path}&password=$form->{password}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|;
 
2182   $lxdebug->leave_sub();
 
2185 sub relink_accounts {
 
2186   $lxdebug->enter_sub();
 
2188   $form->{"taxaccounts"} =~ s/\s*$//;
 
2189   $form->{"taxaccounts"} =~ s/^\s*//;
 
2190   foreach my $accno (split(/\s*/, $form->{"taxaccounts"})) {
 
2191     map({ delete($form->{"${accno}_${_}"}); } qw(rate description taxnumber));
 
2193   $form->{"taxaccounts"} = "";
 
2195   for (my $i = 1; $i <= $form->{"rowcount"}; $i++) {
 
2196     if ($form->{"id_$i"}) {
 
2197       IC->retrieve_accounts(\%myconfig, $form, $form->{"id_$i"}, $i, 1);
 
2201   $lxdebug->leave_sub();
 
2206   $lxdebug->enter_sub();
 
2208   $form->get_duedate(\%myconfig);
 
2211   $result = "$form->{duedate}";
 
2214   $lxdebug->leave_sub();