Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b6dc5623

Von Sven Schöling vor etwa 17 Jahren hinzugefügt

  • ID b6dc5623d93c1be1c54248d4512e80f495af2899
  • Vorgänger ac517355
  • Nachfolger 270df900
  • Auslagerung der OE-Masken in Templates *

Diese Patch ist ein Merge der Revisionen
2866, 5349, 5365, 5370, 5408, 5413, 5470, 5473, 5475, 5519, 5520, 5521, 5524, 5526, 5591, 5618, 5622, 5814, 5881, 5882 und 5961
in das Unstable.

Hintergrund ist die Auslagerung der OE-Masken, das heisst aller Masken, die fuer Auftraege, Angebote und teilweise Rechnungen zustaendig sind.
Dadurch vereinfacht sich der Code an vielen Stellen deutlich, ausserdem konnten viele Berechnungen verkleinert werden, weil der Code fuer Angebote/Auftraege jetzt getrennt von Rechnungen liegt.

Ein Grossteil der bin/mozilla/io.pl wurde dafuer dubliziert, die Methoden die fuer Auftraege noetig sind liegen jetzt in der bin/mozilla/oe.pl (vor allem display_form und display_row, aber auch ein paar andere), ihr jeweiliges Pendant fuer Rechnungen wurde unveraendert in eine Datei invoice_io.pl ausgelagert die von den Skripten die sie benoetigen zusaetzlich zur io.pl eingelesen wird.

Wie der Name der Templates andeutet ist der Patch im Verkaufsbaum entstanden, im Verlauf der Programmierung habe cih aber nicht genug Unterschiede gefunden um separate Templates fuer Verkauf und Einkauf zu rechtfertigen. Eventuell werden die Templates noch umbenannt.

Komplexe Maskenaenderungen wie der Austausch von Drop-Down Menues bei zu grosser Anzahl durch Eingabefelder werden ebenfalls noch manuell gemacht.
Auch das wird in der naechsten Version ausgelagert um den Backend Code schlanker zu machen.

Die Berechnung fuer Units und Steuern wurde vereinfacht, und dabei einige unschoene Bugs gefixt, die aus der unvollstaendigen Abdeckung von Verzweigungen resultierten.

Zuletzt wurden noch fast alle serverseitigen Datenformatierungen ausgelagert in ein Templateplugin, welches Zahlen waehrend des Templatings formatiert (mehr dazu in der Dakumentation zu Template.pm).

Der Patch beinhaltet ausserdem die ueblichen Codekosmetika.

Unterschiede anzeigen:

SL/AM.pm
1880 1880
  $main::lxdebug->leave_sub();
1881 1881
}
1882 1882

  
1883
# if $a is translatable to $b, return the factor between them.
1884
# else return 1
1885
sub convert_unit {
1886
  $main::lxdebug->enter_sub(2);
1887
  ($this, $a, $b, $all_units) = @_;
1888

  
1889
  $main::lxdebug->leave_sub(2) and return 0 unless $all_units->{$a} && $all_units->{$b};
1890
  $main::lxdebug->leave_sub(2) and return 0 unless $all_units->{$a}{base_unit} eq $all_units->{$b}{base_unit};
1891
  $main::lxdebug->leave_sub(2) and return $all_units->{$a}{factor} / $all_units->{$b}{factor}; 
1892
}
1893

  
1883 1894
sub unit_select_data {
1884 1895
  $main::lxdebug->enter_sub();
1885 1896

  
SL/Form.pm
586 586
                                 'EVAL_PERL'   => 0,
587 587
                                 'ABSOLUTE'    => 1,
588 588
                                 'CACHE_SIZE'  => 0,
589
                                 'PLUGIN_BASE' => 'SL::Template::Plugin',
589 590
                               }) || die;
590 591

  
591 592
  map { $additional_params->{$_} ||= $self->{$_} } keys %{ $self };
......
1865 1866
sub _get_customers {
1866 1867
  $main::lxdebug->enter_sub();
1867 1868

  
1868
  my ($self, $dbh, $key) = @_;
1869
  my ($self, $dbh, $key, $limit) = @_;
1869 1870

  
1870 1871
  $key = "all_customers" unless ($key);
1872
  $limit_clause = "LIMIT $limit" if $limit;
1871 1873

  
1872
  my $query = qq|SELECT * FROM customer WHERE NOT obsolete ORDER BY name|;
1874
  my $query = qq|SELECT * FROM customer WHERE NOT obsolete ORDER BY name $limit_clause|;
1873 1875

  
1874 1876
  $self->{$key} = selectall_hashref_query($self, $dbh, $query);
1875 1877

  
......
1985 1987
  }
1986 1988
  
1987 1989
  if($params{"customers"}) {
1988
    $self->_get_customers($dbh, $params{"customers"});
1990
    if (ref $params{"customers"} eq 'HASH') {
1991
      $self->_get_customers($dbh, $params{"customers"}{key}, $params{"customers"}{limit});
1992
    } else {
1993
      $self->_get_customers($dbh, $params{"customers"});
1994
    }
1989 1995
  }
1990 1996
  
1991 1997
  if($params{"vendors"}) {
1992
    $self->_get_vendors($dbh, $params{"vendors"});
1998
    if (ref $params{"vendors"} eq 'HASH') {
1999
      $self->_get_vendors($dbh, $params{"vendors"}{key}, $params{"vendors"}{limit});
2000
    } else {
2001
      $self->_get_vendors($dbh, $params{"vendors"});
2002
    }
1993 2003
  }
1994 2004
  
1995 2005
  if($params{"payments"}) {
SL/IC.pm
930 930

  
931 931
  my @sort_cols = (@simple_filters, qw(id bin priceupdate onhand invnumber ordnumber quonumber name serialnumber soldtotal deliverydate));
932 932
  $form->{sort} = 'id' unless grep { $form->{"l_$_"} } grep { $form->{sort} eq $_ } @sort_cols;
933
  my $order_clause = " ORDER BY $form->{sort} " . ($form->{revers} ? 'DESC' : 'ASC');
933

  
934
  my $sort_order = ($form->{revers} ? ' DESC' : ' ASC');
935

  
936
  # special case: sorting by partnumber
937
  # since partnumbers are expected to be prefixed integers, a special sorting is implemented sorting first lexically by prefix and then by suffix.
938
  # and yes, that expression is designed to hold that array of regexes only once, so the map is kinda messy, sorry about that.
939
  # ToDO: implement proper functional sorting
940
  $form->{sort} = join ', ', map { push @select_tokens, $_; ($table_prefix{$_} = "substring(partnumber,'[") . $_ } qw|^[:digit:]]+') [:digit:]]+')::INTEGER|
941
    if $form->{sort} eq 'partnumber';
942

  
943
  my $order_clause = " ORDER BY $form->{sort} $sort_order";
934 944

  
935 945
  my $limit_clause = " LIMIT 100" if $form->{top100};
936 946

  
......
980 990

  
981 991
  #============= build query ================#
982 992

  
983
  my %table_prefix = (
993
  %table_prefix = (
994
     %table_prefix,
984 995
     deliverydate => 'apoe.', serialnumber => 'ioi.',
985 996
     transdate    => 'apoe.', trans_id     => 'ioi.',
986 997
     module       => 'apoe.', name         => 'cv.',
SL/IR.pm
811 811
sub get_vendor {
812 812
  $main::lxdebug->enter_sub();
813 813

  
814
  my ($self, $myconfig, $form) = @_;
814
  my ($self, $myconfig, $form, $params) = @_;
815

  
816
  $params = $form unless defined $params && ref $params eq "HASH";
817
  $main::lxdebug->message(0, Dumper($params));
815 818

  
816 819
  # connect to database
817 820
  my $dbh = $form->dbconnect($myconfig);
......
819 822
  my $dateformat = $myconfig->{dateformat};
820 823
  $dateformat .= "yy" if $myconfig->{dateformat} !~ /^y/;
821 824

  
822
  my $vid = conv_i($form->{vendor_id});
825
  my $vid = conv_i($params->{vendor_id});
826
  my $vnr = conv_i($params->{vendornumber});
823 827

  
824 828
  my $duedate =
825
    ($form->{invdate})
826
    ? "to_date(" . $dbh->quote($form->{invdate}) . ", '$dateformat')"
829
    ($params->{invdate})
830
    ? "to_date(" . $dbh->quote($params->{invdate}) . ", '$dateformat')"
827 831
    : "current_date";
828 832

  
829 833
  # get vendor
834
  @values = ();
835
  if ($vid) {
836
    $where .= 'AND v.id = ?';
837
    push @values, $vid;
838
  }
839
  if ($vnr) {
840
    $where .= 'AND v.vendornumber = ?';
841
    push @values, $vnr;
842
  }
830 843
  my $query =
831 844
    qq|SELECT
832
         v.name AS vendor, v.creditlimit, v.terms, v.notes AS intnotes,
845
         v.id, v.name AS vendor, v.creditlimit, v.terms, v.notes AS intnotes,
833 846
         v.email, v.cc, v.bcc, v.language_id, v.payment_id,
834 847
         v.street, v.zipcode, v.city, v.country, v.taxzone_id,
835 848
         $duedate + COALESCE(pt.terms_netto, 0) AS duedate,
......
837 850
       FROM vendor v
838 851
       LEFT JOIN business b       ON (b.id = v.business_id)
839 852
       LEFT JOIN payment_terms pt ON (v.payment_id = pt.id)
840
       WHERE v.id = ?|;
841
  $ref = selectfirst_hashref_query($form, $dbh, $query, $vid);
842
  map { $form->{$_} = $ref->{$_} } keys %$ref;
853
       WHERE 1=1 $where|;
854
  $ref = selectfirst_hashref_query($form, $dbh, $query, @values);
855
  map { $params->{$_} = $ref->{$_} } keys %$ref;
843 856

  
844
  $form->{creditremaining} = $form->{creditlimit};
857
  $params->{creditremaining} = $params->{creditlimit};
845 858

  
846 859
  $query = qq|SELECT SUM(amount - paid) FROM ap WHERE vendor_id = ?|;
847 860
  my ($unpaid_invoices) = selectfirst_array_query($form, $dbh, $query, $vid);
848
  $form->{creditremaining} -= $unpaid_invoices;
861
  $params->{creditremaining} -= $unpaid_invoices;
849 862

  
850 863
  $query = qq|SELECT o.amount,
851 864
                (SELECT e.sell
......
857 870
  my $sth = prepare_execute_query($form, $dbh, $query, $vid);
858 871
  while (my ($amount, $exch) = $sth->fetchrow_array()) {
859 872
    $exch = 1 unless $exch;
860
    $form->{creditremaining} -= $amount * $exch;
873
    $params->{creditremaining} -= $amount * $exch;
861 874
  }
862 875
  $sth->finish();
863 876

  
864 877
  # get shipto if we do not convert an order or invoice
865
  if (!$form->{shipto}) {
866
    delete @{$form}{qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail)};
878
  if (!$params->{shipto}) {
879
    delete @{$params}{qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail)};
867 880

  
868 881
    $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module= 'CT')|;
869 882
    $ref = selectfirst_hashref_query($form, $dbh, $query, $vid);
870
    @{$form}{keys %$ref} = @{$ref}{keys %$ref};
871
    map { $form->{$_} = $ref->{$_} } keys %$ref;
883
    @{$params}{keys %$ref} = @{$ref}{keys %$ref};
884
    map { $params->{$_} = $ref->{$_} } keys %$ref;
872 885
  }
873 886

  
874
  if (!$form->{id} && $form->{type} !~ /_(order|quotation)/) {
887
  if (!$params->{id} && $params->{type} !~ /_(order|quotation)/) {
875 888
    # setup last accounts used
876 889
    $query =
877 890
      qq|SELECT c.id, c.accno, c.description, c.link, c.category
......
888 901
      if ($ref->{category} eq 'E') {
889 902
        $i++;
890 903

  
891
        if ($form->{initial_transdate}) {
904
        if ($params->{initial_transdate}) {
892 905
          my $tax_query = qq|SELECT tk.tax_id, t.rate FROM taxkeys tk
893 906
                             LEFT JOIN tax t ON (tk.tax_id = t.id)
894 907
                             WHERE (tk.chart_id = ?) AND (startdate <= ?)
895 908
                             ORDER BY tk.startdate DESC
896 909
                             LIMIT 1|;
897
          my ($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $form->{initial_transdate});
898
          $form->{"taxchart_$i"} = "${tax_id}--${rate}";
910
          my ($tax_id, $rate) = selectrow_query($form, $dbh, $tax_query, $ref->{id}, $params->{initial_transdate});
911
          $params->{"taxchart_$i"} = "${tax_id}--${rate}";
899 912
        }
900 913

  
901
        $form->{"AP_amount_$i"} = "$ref->{accno}--$tax_id";
914
        $params->{"AP_amount_$i"} = "$ref->{accno}--$tax_id";
902 915
      }
903 916

  
904 917
      if ($ref->{category} eq 'L') {
905
        $form->{APselected} = $form->{AP_1} = $ref->{accno};
918
        $params->{APselected} = $params->{AP_1} = $ref->{accno};
906 919
      }
907 920
    }
908
    $form->{rowcount} = $i if ($i && !$form->{type});
921
    $params->{rowcount} = $i if ($i && !$params->{type});
909 922
  }
910 923

  
911 924
  $dbh->disconnect();
SL/OE.pm
244 244

  
245 245
  for my $i (1 .. $form->{rowcount}) {
246 246

  
247
    map({ $form->{"${_}_$i"} =
248
            $form->parse_amount($myconfig, $form->{"${_}_$i"}) } qw(qty ship));
247
    map({ $form->{"${_}_$i"} = $form->parse_amount($myconfig, $form->{"${_}_$i"}) } qw(qty ship));
249 248

  
250 249
    if ($form->{"id_$i"}) {
251 250

  
......
256 255
      my $basefactor = 1;
257 256
      if (defined($all_units->{$item_unit}->{factor}) &&
258 257
          (($all_units->{$item_unit}->{factor} * 1) != 0)) {
259
        $basefactor = $all_units->{$form->{"unit_$i"}}->{factor} /
260
          $all_units->{$item_unit}->{factor};
258
        $basefactor = $all_units->{$form->{"unit_$i"}}->{factor} / $all_units->{$item_unit}->{factor};
261 259
      }
262 260
      my $baseqty = $form->{"qty_$i"} * $basefactor;
263 261

  
......
266 264
      $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1;
267 265

  
268 266
      # set values to 0 if nothing entered
269
      $form->{"discount_$i"} =
270
        $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
267
      $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
271 268

  
272
      $form->{"sellprice_$i"} =
273
        $form->parse_amount($myconfig, $form->{"sellprice_$i"});
269
      $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
274 270
      $fxsellprice = $form->{"sellprice_$i"};
275 271

  
276 272
      my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
277 273
      $dec = length($dec);
278 274
      my $decimalplaces = ($dec > 2) ? $dec : 2;
279 275

  
280
      $discount =
281
        $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"},
282
                            $decimalplaces);
283
      $form->{"sellprice_$i"} =
284
        $form->round_amount($form->{"sellprice_$i"} - $discount,
285
                            $decimalplaces);
276
      $discount = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"}, $decimalplaces);
277
      $form->{"sellprice_$i"} = $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
286 278

  
287 279
      $form->{"inventory_accno_$i"} *= 1;
288 280
      $form->{"expense_accno_$i"}   *= 1;
......
311 303
      if ($form->round_amount($taxrate, 7) == 0) {
312 304
        if ($form->{taxincluded}) {
313 305
          foreach $item (@taxaccounts) {
314
            $taxamount =
315
              $form->round_amount($linetotal * $form->{"${item}_rate"} /
316
                                    (1 + abs($form->{"${item}_rate"})),
317
                                  2);
318

  
306
            $taxamount = $form->round_amount($linetotal * $form->{"${item}_rate"} / (1 + abs($form->{"${item}_rate"})), 2);
319 307
            $taxaccounts{$item} += $taxamount;
320 308
            $taxdiff            += $taxamount;
321

  
322
            $taxbase{$item} += $taxbase;
309
            $taxbase{$item}     += $taxbase;
323 310
          }
324 311
          $taxaccounts{ $taxaccounts[0] } += $taxdiff;
325 312
        } else {
......
330 317
        }
331 318
      } else {
332 319
        foreach $item (@taxaccounts) {
333
          $taxaccounts{$item} +=
334
            $taxamount * $form->{"${item}_rate"} / $taxrate;
320
          $taxaccounts{$item} += $taxamount * $form->{"${item}_rate"} / $taxrate;
335 321
          $taxbase{$item} += $taxbase;
336 322
        }
337 323
      }
338 324

  
339 325
      $netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor;
340 326

  
341
      $reqdate =
342
        ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
327
      $reqdate = ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
343 328

  
344 329
      # get pricegroup_id and save ist
345 330
      ($null, my $pricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"});
......
362 347
      }
363 348
      $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
364 349
                   (SELECT factor FROM price_factors WHERE id = ?), ?)|;
365
		  push(@values,
350
        push(@values,
366 351
           conv_i($form->{id}), conv_i($form->{"id_$i"}),
367 352
           $form->{"description_$i"}, $form->{"longdescription_$i"},
368 353
           $form->{"qty_$i"}, $baseqty,
......
394 379
  if ($form->{currency} eq $form->{defaultcurrency}) {
395 380
    $form->{exchangerate} = 1;
396 381
  } else {
397
    $exchangerate =
398
      $form->check_exchangerate($myconfig,
399
                                $form->{currency},
400
                                $form->{transdate},
401
                                ($form->{vc} eq 'customer') ? 'buy' : 'sell');
382
    $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, ($form->{vc} eq 'customer') ? 'buy' : 'sell');
402 383
  }
403 384

  
404
  $form->{exchangerate} =
405
    ($exchangerate)
406
    ? $exchangerate
407
    : $form->parse_amount($myconfig, $form->{exchangerate});
385
  $form->{exchangerate} = ($exchangerate) ? $exchangerate : $form->parse_amount($myconfig, $form->{exchangerate});
408 386

  
409 387
  my $quotation = $form->{type} =~ /_order$/ ? 'f' : 't';
410 388

  
......
456 434

  
457 435
  if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
458 436
    if ($form->{vc} eq 'customer') {
459
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate},
460
                                 $form->{exchangerate}, 0);
437
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0);
461 438
    }
462 439
    if ($form->{vc} eq 'vendor') {
463
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate},
464
                                 0, $form->{exchangerate});
440
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, 0, $form->{exchangerate});
465 441
    }
466 442
  }
467 443

  
......
471 447
    &adj_onhand($dbh, $form, $ml * -1);
472 448
  }
473 449

  
474
  my $rc = $dbh->commit;
475
  $dbh->disconnect;
476

  
477 450
  $form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ?
478 451
                                       "quonumber" : "ordnumber"};
479 452

  
480 453
  Common::webdav_folder($form) if ($main::webdav);
481 454

  
455
  my $rc = $dbh->commit;
456
  $dbh->disconnect;
457

  
482 458
  $main::lxdebug->leave_sub();
483 459

  
484 460
  return $rc;
......
918 894
    $sth->finish();
919 895
  }
920 896

  
921
  $form->{"globalprojectnumber"} =
922
    $projectnumbers{$form->{"globalproject_id"}};
897
  $form->{"globalprojectnumber"} = $projectnumbers{$form->{"globalproject_id"}};
923 898

  
924 899
  my @arrays =
925 900
    qw(runningnumber number description longdescription qty ship unit bin
......
1041 1016

  
1042 1017
      if ($taxamount != 0) {
1043 1018
        foreach my $item (split / /, $form->{"taxaccounts_$i"}) {
1044
          $taxaccounts{$item} +=
1045
            $taxamount * $form->{"${item}_rate"} / $taxrate;
1046
          $taxbase{$item} += $taxbase;
1019
          $taxaccounts{$item} += $taxamount * $form->{"${item}_rate"} / $taxrate;
1020
          $taxbase{$item}     += $taxbase;
1047 1021
        }
1048 1022
      }
1049 1023

  
......
1056 1030
        # get parts and push them onto the stack
1057 1031
        my $sortorder = "";
1058 1032
        if ($form->{groupitems}) {
1059
          $sortorder =
1060
            qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|;
1033
          $sortorder = qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|;
1061 1034
        } else {
1062 1035
          $sortorder = qq|ORDER BY a.$oid{$myconfig->{dbdriver}}|;
1063 1036
        }
......
1075 1048

  
1076 1049
        while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1077 1050
          if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
1078
            map({ push(@{ $form->{$_} }, "") }
1079
                grep({ $_ ne "description" } @arrays));
1051
            map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
1080 1052
            $sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
1081 1053
            push(@{ $form->{description} }, $sameitem);
1082 1054
          }
1083 1055

  
1084
          push(@{ $form->{description} },
1085
               $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}
1086
                 )
1087
                 . qq|, $ref->{partnumber}, $ref->{description}|);
1088

  
1089
          map({ push(@{ $form->{$_} }, "") }
1090
              grep({ $_ ne "description" } @arrays));
1056
          push(@{ $form->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|); 
1057
          map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
1091 1058
        }
1092 1059
        $sth->finish;
1093 1060
      }
......
1195 1162
      my ($item_unit) = selectrow_query($form, $dbh, $query, $ref->{parts_id});
1196 1163

  
1197 1164
      my $basefactor = 1;
1198
      if (defined($all_units->{$item_unit}->{factor}) &&
1199
          (($all_units->{$item_unit}->{factor} * 1) != 0)) {
1200
        $basefactor = $all_units->{$ref->{unit}}->{factor} /
1201
          $all_units->{$item_unit}->{factor};
1165
      if (defined($all_units->{$item_unit}->{factor}) && (($all_units->{$item_unit}->{factor} * 1) != 0)) {
1166
        $basefactor = $all_units->{$ref->{unit}}->{factor} / $all_units->{$item_unit}->{factor};
1202 1167
      }
1203 1168
      my $baseqty = $ref->{ship} * $basefactor;
1204 1169

  
1205 1170
      # adjust onhand in parts table
1206
      $form->update_balance($dbh, "parts", "onhand",
1207
                            qq|id = $ref->{parts_id}|,
1208
                            $baseqty * $ml);
1171
      $form->update_balance($dbh, "parts", "onhand", qq|id = $ref->{parts_id}|, $baseqty * $ml);
1209 1172
    }
1210 1173
  }
1211 1174

  
am.pl
47 47
use SL::LXDebug;
48 48
$lxdebug = LXDebug->new();
49 49

  
50
use CGI;
50
use CGI qw( -no_xhtml);
51 51
use SL::Form;
52 52
use SL::Locale;
53 53

  
......
64 64
$form = new Form;
65 65
$cgi = new CGI('');
66 66

  
67
# this prevents most of the tabindexes being created by CGI.
68
# note: most. popup menus and selecttables will still have tabindexes
69
# use common.pl's NTI function to get rid of those
70
local $CGI::TABINDEX = 0;
71

  
67 72
# name of this script
68 73
$0 =~ tr/\\/\//;
69 74
$pos = rindex $0, '/';
bin/mozilla/ic.pl
46 46
our ($form, $locale, %myconfig, $lxdebug);
47 47

  
48 48
require "bin/mozilla/io.pl";
49
require "bin/mozilla/invoice_io.pl";
49 50
require "bin/mozilla/common.pl";
50 51
require "bin/mozilla/reportgenerator.pl";
51 52

  
......
109 110
     |;
110 111

  
111 112
    #write Trigger
112
    $jsscript =
113
      Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
114
                          "transdateto", "BL", "trigger2");
113
    $jsscript = Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1", "transdateto", "BL", "trigger2");
115 114
  } else {
116 115

  
117 116
    # without JavaScript Calendar
118
    $button1 = qq|
119
                              <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
120
    $button2 = qq|
121
                              <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
117
    $button1 = qq| <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
118
    $button2 = qq| <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
122 119
  }
123 120

  
124 121
  unless ($form->{searchitems} eq 'service') {
125 122

  
126
    $onhand = qq|
127
            <input name=itemstatus class=radio type=radio value=onhand>&nbsp;|
128
      . $locale->text('On Hand') . qq|
129
            <input name=itemstatus class=radio type=radio value=short>&nbsp;|
130
      . $locale->text('Short') . qq|
123
    $onhand = qq| <input name=itemstatus class=radio type=radio value=onhand>&nbsp;| . $locale->text('On Hand') . qq|
124
                  <input name=itemstatus class=radio type=radio value=short>&nbsp;| . $locale->text('Short') . qq|
131 125
|;
132 126

  
133 127
    $makemodel = qq|
134 128
        <tr>
135
          <th align=right nowrap>| . $locale->text('Make') . qq|</th>
136
          <td><input name=make size=20></td>
137
          <th align=right nowrap>| . $locale->text('Model') . qq|</th>
138
          <td><input name=model size=20></td>
129
          <th align=right nowrap>| . $locale->text('Make') . qq|</th> <td><input name=make size=20></td>
130
          <th align=right nowrap>| . $locale->text('Model') . qq|</th> <td><input name=model size=20></td>
139 131
        </tr>
140 132
|;
141 133

  
142 134
    $serialnumber = qq|
143
          <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
144
          <td><input name=serialnumber size=20></td>
135
          <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th> <td><input name=serialnumber size=20></td>
145 136
|;
146 137

  
147 138
    $l_serialnumber = qq|
148
        <td><input name=l_serialnumber class=checkbox type=checkbox value=Y>&nbsp;|
149
      . $locale->text('Serial Number') . qq|</td>
139
        <td><input name=l_serialnumber class=checkbox type=checkbox value=Y>&nbsp;| . $locale->text('Serial Number') . qq|</td>
150 140
|;
151 141

  
152 142
  }
bin/mozilla/io.pl
90 90
# Eintrag fuer Version 2.2.0 geaendert #
91 91
# neue Optik im Rechnungsformular      #
92 92
########################################
93
sub display_row {
94
  $lxdebug->enter_sub();
95
  my $numrows = shift;
96

  
97
  my $is_sales =
98
    (substr($form->{type}, 0, 6) eq "sales_")
99
    || (($form->{type} eq "invoice") && ($form->{script} eq "is.pl"))
100
    || ($form->{type} eq 'credit_note');
101

  
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);
107
    } else {
108
      @column_index = (runningnumber, partnumber, description, qty);
109
    }
110
  } else {
111
    if (   ($form->{type} =~ /purchase_order/)
112
        || ($form->{type} =~ /sales_order/)) {
113
      @column_index = (runningnumber, partnumber, description, ship, qty);
114
        } else {
115
      @column_index = (runningnumber, partnumber, description, qty);
116
    }
117
  }
118
############## ENDE Neueintrag ##################
119

  
120
  my $dimension_units = AM->retrieve_units(\%myconfig, $form, "dimension");
121
  my $service_units = AM->retrieve_units(\%myconfig, $form, "service");
122
  my $all_units = AM->retrieve_units(\%myconfig, $form);
123

  
124
  my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
125

  
126
  push @column_index, qw(unit);
127

  
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);
134
  }
135

  
136
  push @column_index, qw(sellprice);
137

  
138
  if ($form->{vc} eq 'customer') {
139
    push @column_index, qw(discount);
140
  }
141

  
142
  push @column_index, "linetotal";
143

  
144
  my $colspan = $#column_index + 1;
145

  
146
  $form->{invsubtotal} = 0;
147
  map { $form->{"${_}_base"} = 0 } (split(/ /, $form->{taxaccounts}));
148

  
149
########################################
150
  # Eintrag fuer Version 2.2.0 geaendert #
151
  # neue Optik im Rechnungsformular      #
152
########################################
153
  $column_data{runningnumber} =
154
      qq|<th align="left" nowrap width="5" class="listheading">|
155
    . $locale->text('No.')
156
    . qq|</th>|;
157
  $column_data{partnumber} =
158
      qq|<th align="left" nowrap width="12" class="listheading">|
159
    . $locale->text('Number')
160
    . qq|</th>|;
161
  $column_data{description} =
162
      qq|<th align="left" nowrap width="30" class="listheading">|
163
    . $locale->text('Part Description')
164
    . qq|</th>|;
165
  if ($form->{"type"} eq "purchase_order") {
166
    $column_data{ship} =
167
      qq|<th align="left" nowrap width="5" class="listheading">|
168
      . $locale->text('Ship rcvd')
169
      . qq|</th>|;
170
  } else {
171
    $column_data{ship} =
172
      qq|<th align="left" nowrap width="5" class="listheading">|
173
      . $locale->text('Ship')
174
      . qq|</th>|;
175
  }
176
  $column_data{qty} =
177
      qq|<th align="left" nowrap width="5" class="listheading">|
178
    . $locale->text('Qty')
179
    . qq|</th>|;
180
  $column_data{unit} =
181
      qq|<th align="left" nowrap width="5" class="listheading">|
182
    . $locale->text('Unit')
183
    . qq|</th>|;
184
  $column_data{license} =
185
      qq|<th align="left" nowrap width="10" class="listheading">|
186
    . $locale->text('License')
187
    . qq|</th>|;
188
  $column_data{serialnr} =
189
      qq|<th align="left" nowrap width="10" class="listheading">|
190
    . $locale->text('Serial No.')
191
    . qq|</th>|;
192
  $column_data{projectnr} =
193
      qq|<th align="left" nowrap width="10" class="listheading">|
194
    . $locale->text('Project')
195
    . qq|</th>|;
196
  $column_data{sellprice} =
197
      qq|<th align="left" nowrap width="15" class="listheading">|
198
    . $locale->text('Price')
199
    . qq|</th>|;
200
  $column_data{sellprice_pg} =
201
      qq|<th align="left" nowrap width="15" class="listheading">|
202
    . $locale->text('Pricegroup')
203
    . qq|</th>|;
204
  $column_data{discount} =
205
      qq|<th align="left" class="listheading">|
206
    . $locale->text('Discount')
207
    . qq|</th>|;
208
  $column_data{linetotal} =
209
      qq|<th align="left" nowrap width="10" class="listheading">|
210
    . $locale->text('Extended')
211
    . qq|</th>|;
212
  $column_data{bin} =
213
      qq|<th align="left" nowrap width="10" class="listheading">|
214
    . $locale->text('Bin')
215
    . qq|</th>|;
216
############## ENDE Neueintrag ##################
217

  
218
  $myconfig{"show_form_details"} = 1
219
    unless (defined($myconfig{"show_form_details"}));
220
  $form->{"show_details"} = $myconfig{"show_form_details"}
221
    unless (defined($form->{"show_details"}));
222
  $form->{"show_details"} = $form->{"show_details"} ? 1 : 0;
223
  my $show_details_new = 1 - $form->{"show_details"};
224
  my $show_details_checked = $form->{"show_details"} ? "checked" : "";
225

  
226
  print qq|
227
  <tr>
228
    <td>| . $cgi->hidden("-name" => "show_details", "-value" => $form->{show_details}) . qq|
229
      <input type="checkbox" id="cb_show_details" onclick="show_form_details($show_details_new);" $show_details_checked>
230
      <label for="cb_show_details">| . $locale->text("Show details") . qq|</label><br>
231
      <table width="100%">
232
	<tr class="listheading">|;
233

  
234
  map { print "\n$column_data{$_}" } @column_index;
235

  
236
  print qq|
237
        </tr>
238
|;
239

  
240
  $runningnumber = $locale->text('No.');
241
  $deliverydate  = $locale->text('Delivery Date');
242
  $serialnumber  = $locale->text('Serial No.');
243
  $projectnumber = $locale->text('Project');
244
  $partsgroup    = $locale->text('Group');
245
  $reqdate       = $locale->text('Reqdate');
246

  
247
  $delvar = 'deliverydate';
248

  
249
  if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
250
    $deliverydate = $locale->text('Required by');
251
    $delvar       = 'reqdate';
252
  }
253

  
254
  $form->{marge_total} = 0;
255
  $form->{sellprice_total} = 0;
256
  $form->{lastcost_total} = 0;
257
  my %projectnumber_labels = ();
258
  my @projectnumber_values = ("");
259
  foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
260
    push(@projectnumber_values, $item->{"id"});
261
    $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
262
  }
263

  
264
  for $i (1 .. $numrows) {
265

  
266
    # undo formatting
267
    map {
268
      $form->{"${_}_$i"} =
269
        $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
270
    } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
271

  
272
    if (!$form->{"unit_old_$i"}) {
273
      # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
274
      # Einheit, wie sie in den Stammdaten hinterlegt wurde.
275
      # Es sollte also angenommen werden, dass diese ausgewaehlt war.
276
      $form->{"unit_old_$i"} = $form->{"unit_$i"};
277
    }
278

  
279
    # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
280
    # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
281
    $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
282

  
283
    my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
284
    if (!$check_units->{$form->{"selected_unit_$i"}} ||
285
        ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
286
         $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
287
      # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
288
      # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
289
      # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
290
      $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
291
    }
292
    if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
293
      if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
294
        my $basefactor = 1;
295
        if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
296
            $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
297
          $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
298
            $all_units->{$form->{"unit_old_$i"}}->{"factor"};
299
        }
300
        $form->{"sellprice_$i"} *= $basefactor;
301
        $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
302
      }
303
    }
304

  
305
    ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
306
    $decimalplaces = max length($dec), 2;
307

  
308
    $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1;
309
    $discount     = (100 - $form->{"discount_$i"} * 1) / 100;
310

  
311
    $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces);
312

  
313
    my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor;
314

  
315
    # marge calculations
316
    my ($marge_font_start, $marge_font_end);
317

  
318
    $form->{"lastcost_$i"} *= 1;
319

  
320
    $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1;
321

  
322
    if ($real_sellprice && ($form->{"qty_$i"} * 1)) {
323
      $form->{"marge_percent_$i"}     = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
324
      $myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"}));
325

  
326
      if ($form->{"id_$i"} &&
327
          ($form->{"marge_percent_$i"} < (1 * $myconfig{"marge_percent_warn"}))) {
328
        $marge_font_start = "<font color=\"#ff0000\">";
329
        $marge_font_end   = "</font>";
330
      }
331

  
332
    } else {
333
      $form->{"marge_percent_$i"} = 0;
334
    }
335

  
336
    my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
337
    $form->{"marge_total_$i"}  = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
338
    $form->{"marge_total"}      += $form->{"marge_total_$i"};
339
    $form->{"lastcost_total"}   += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
340
    $form->{"sellprice_total"}  += $real_sellprice * $form->{"qty_$i"};
341

  
342
    map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_total marge_percent);
343

  
344
    # convert " to &quot;
345
    map { $form->{"${_}_$i"} =~ s/\"/&quot;/g }
346
      qw(partnumber description unit unit_old);
347

  
348
########################################
349
    # Eintrag fuer Version 2.2.0 geaendert #
350
    # neue Optik im Rechnungsformular      #
351
########################################
352
    $column_data{runningnumber} =
353
      qq|<td><input name="runningnumber_$i" size="5" value="$i"></td>|;    # HuT
354
############## ENDE Neueintrag ##################
355

  
356
    $column_data{partnumber} =
357
      qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
358

  
359
    if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
360
      $column_data{description} =
361
        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>|;
362
    } else {
363
      $column_data{description} =
364
        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>|;
365
    }
366

  
367
    (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
368
    $qty_dec = length $qty_dec;
369

  
370
    $column_data{qty} =
371
        qq|<td align="right"><input name="qty_$i" size="5" value="|
372
      . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|">|;
373
    if ($form->{"formel_$i"}) {
374
      $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>|
375
        . $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"});
376
    }
377
    $column_data{qty} .= qq|</td>|;
378
    $column_data{ship} =
379
        qq|<td align="right"><input name="ship_$i" size=5 value="|
380
      . $form->format_amount(\%myconfig, $form->{"ship_$i"})
381
      . qq|"></td>|;
382

  
383
    my $is_part     = $form->{"inventory_accno_$i"};
384
    my $is_assembly = $form->{"assembly_$i"};
385
    my $is_assigned = $form->{"id_$i"};
386
    my $this_unit = $form->{"unit_$i"};
387
    if ($form->{"selected_unit_$i"} && $this_unit &&
388
        $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
389
        ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
390
      $this_unit = $form->{"selected_unit_$i"};
391
    } elsif (!$is_assigned ||
392
             ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
393
      $this_unit = "kg";
394
    }
395

  
396
    my $price_factor_select;
397
    if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
398
      my @values = ('', map { $_->{id}                      } @{ $form->{ALL_PRICE_FACTORS} });
399
      my %labels =      map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
400

  
401
      $price_factor_select =
402
        NTI($cgi->popup_menu('-name'    => "price_factor_id_$i",
403
                             '-default' => $form->{"price_factor_id_$i"},
404
                             '-values'  => \@values,
405
                             '-labels'  => \%labels,
406
                             '-style'   => 'width:90px'))
407
        . ' ';
408
    }
409

  
410
    $column_data{"unit"} = "<td>" .
411
      $price_factor_select .
412
       AM->unit_select_html($is_part || $is_assembly ? $dimension_units :
413
                            $is_assigned ? $service_units : $all_units,
414
                            "unit_$i", $this_unit,
415
                            $is_assigned ? $form->{"unit_$i"} : undef)
416
      . "</td>";
417

  
418
    # build in drop down list for pricesgroups
419
    if ($form->{"prices_$i"}) {
420
      if  ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
421
        $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
422
      } else {
423
        $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
424
      }
425

  
426
      $column_data{sellprice_pg} =
427
      qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
428
      $column_data{sellprice} =
429
      qq|<td><input name="sellprice_$i" size="10" value="$price_tmp" onBlur=\"check_right_number_format(this)\"></td>|;
430
    } else {
431

  
432
      # for last row and report
433
      # set pricegroup drop down list from report menu
434
      if ($form->{"sellprice_$i"} != 0) {
435
        $prices =
436
          qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
437

  
438
        $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
439

  
440
        $column_data{sellprice_pg} =
441
          qq|<td align="right"><select name="sellprice_pg_$i">$prices</select></td>|;
442

  
443
      } else {
444

  
445
        # for last row
446
        $column_data{sellprice_pg} = qq|<td align="right">&nbsp;</td>|;
447
        }
448
        
449
      $column_data{sellprice} =
450
      qq|<td><input name="sellprice_$i" size="10" onBlur=\"check_right_number_format(this)\" value="|
451
        . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
452
                               $decimalplaces)
453
        . qq|"></td>|;
454
    }
455
    $column_data{discount} =
456
        qq|<td align="right"><input name="discount_$i" size=3 value="|
457
      . $form->format_amount(\%myconfig, $form->{"discount_$i"})
458
      . qq|"></td>|;
459
    $column_data{linetotal} =
460
        qq|<td align="right">|
461
      . $form->format_amount(\%myconfig, $linetotal, 2)
462
      . qq|</td>|;
463
    $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
464

  
465
########################################
466
    # Eintrag fuer Version 2.2.0 geaendert #
467
    # neue Optik im Rechnungsformular      #
468
########################################
469
    #     if ($lizenzen &&  $form->{type} eq "invoice" &&  $form->{vc} eq "customer") {
470
    #     $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
471
    #     }
472
    #
473
    #     if ($form->{type} !~ /_quotation/) {
474
    #     $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
475
    #     }
476
    #
477
    #     $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
478
############## ENDE Neueintrag ##################
479
    my $j = $i % 2;
480
    print qq|
481

  
482
        <tr valign="top" class="listrow$j">|;
483

  
484
    map { print "\n$column_data{$_}" } @column_index;
485

  
486
    print("</tr>\n" .
487
          $cgi->hidden("-name" => "unit_old_$i",
488
                       "-value" => $form->{"selected_unit_$i"})
489
          . "\n" .
490
          $cgi->hidden("-name" => "price_new_$i",
491
                       "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"}))
492
          . "\n");
493
    map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_}) . "\n"); }
494
        ("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i",
495
         "id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i",
496
         "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i",
497
         "taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i",
498
         "longdescription_$i", "basefactor_$i", "marge_total_$i", "marge_percent_$i", "lastcost_$i",
499
         "marge_price_factor_$i"));
500

  
501
########################################
502
    # Eintrag fuer Version 2.2.0 geaendert #
503
    # neue Optik im Rechnungsformular      #
504
########################################
505

  
506
    my $row_style_attr =
507
      'style="display:none;"' if (!$form->{"show_details"});
508

  
509
    # print second row
510
    print qq|
511
        <tr  class="listrow$j" $row_style_attr>
512
	  <td colspan="$colspan">
513
|;
514
    if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
515
      my $selected = $form->{"licensenumber_$i"};
516
      my $lizenzen_quoted;
517
      $form->{"lizenzen_$i"} =~ s/ selected//g;
518
      $form->{"lizenzen_$i"} =~
519
        s/value="${selected}"\>/value="${selected}" selected\>/;
520
      $lizenzen_quoted = $form->{"lizenzen_$i"};
521
      $lizenzen_quoted =~ s/\"/&quot;/g;
522
      print qq|
523
	<b>Lizenz\#</b>&nbsp;<select name="licensenumber_$i" size="1">
524
	$form->{"lizenzen_$i"}
525
        </select>
526
	<input type="hidden" name="lizenzen_$i" value="${lizenzen_quoted}">
527
|;
528
    }
529
    if ($form->{type} !~ /_quotation/) {
530
      print qq|
531
          <b>$serialnumber</b>&nbsp;<input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|;
532
    }
533

  
534
    print qq|<b>$projectnumber</b>&nbsp;| .
535
      NTI($cgi->popup_menu('-name' => "project_id_$i",
536
                           '-values' => \@projectnumber_values,
537
                           '-labels' => \%projectnumber_labels,
538
                           '-default' => $form->{"project_id_$i"}));
539

  
540
    if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
541
      my $reqdate_term =
542
        ($form->{type} eq 'invoice')
543
        ? 'deliverydate'
544
        : 'reqdate';    # invoice uses a different term for the same thing.
545
      print qq|
546
        <b>${$reqdate_term}</b>&nbsp;<input name="${reqdate_term}_$i" size="11" onBlur="check_right_date_format(this)" value="$form->{"${reqdate_term}_$i"}">
547
|;
548
    }
549
    my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
550
    print qq|
551
          <b>|.$locale->text('Subtotal').qq|</b>&nbsp;<input type="checkbox" name="subtotal_$i" value="1" $subtotalchecked>
552
|;
553

  
554
    if ($form->{"id_$i"} && $is_sales) {
555
      my $marge_price_factor;
556

  
557
      $form->{"marge_price_factor_$i"} *= 1;
558

  
559
      if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) {
560
        $marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"});
561
      }
562

  
563
      print qq|
564
          ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b>&nbsp;$form->{"marge_total_$i"}&nbsp;$form->{"marge_percent_$i"} % ${marge_font_end}|;
565
   }
566
   print qq|
567
          &nbsp;<b>| . $locale->text('LP') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
568
          &nbsp;<b>| . $locale->text('EK') . qq|</b>&nbsp;| . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor;
569

  
570

  
571
    print qq|
572
	  </td>
573
	</tr>
574
|;
575

  
576
############## ENDE Neueintrag ##################
577

  
578
    map { $form->{"${_}_base"} += $linetotal }
579
      (split(/ /, $form->{"taxaccounts_$i"}));
580

  
581
    $form->{invsubtotal} += $linetotal;
582
  }
583

  
584
  print qq|
585
      </table>
586
    </td>
587
  </tr>
588
|;
589

  
590
  if (0 != ($form->{sellprice_total} * 1)) {
591
    $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;
592
  }
593

  
594
  $lxdebug->leave_sub();
595
}
596 93

  
597 94
##################################################
598 95
# build html-code for pricegroups in variable $form->{prices_$j}
......
601 98
  $lxdebug->enter_sub();
602 99
  my $rowcount = shift;
603 100
  for $j (1 .. $rowcount) {
604
    my $pricegroup_old = $form->{"pricegroup_old_$i"};
605
    if ($form->{PRICES}{$j}) {
606
      $len    = 0;
607
      $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
608
      $price  = 0;
609
      foreach $item (@{ $form->{PRICES}{$j} }) {
610

  
611
        #$price = $form->round_amount($myconfig,  $item->{price}, 5);
612
        #$price = $form->format_amount($myconfig, $item->{price}, 2);
613
        $price         = $item->{price};
614
        $pricegroup_id = $item->{pricegroup_id};
615
        $pricegroup    = $item->{pricegroup};
616

  
617
        # build drop down list for pricegroups
618
        $prices .=
619
          qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
620

  
621
        $len += 1;
622

  
623
        #        map {
624
        #               $form->{"${_}_$j"} =
625
        #               $form->format_amount(\%myconfig, $form->{"${_}_$j"})
626
        #              } qw(sellprice price_new price_old);
627

  
628
        # set new selectedpricegroup_id and prices for "Preis"
629
        if ($item->{selected} && ($pricegroup_id != 0)) {
630
          $form->{"pricegroup_old_$j"} = $pricegroup_id;
631
          $form->{"price_new_$j"}      = $price;
632
          $form->{"sellprice_$j"}      = $price;
633
        }
634
        if ($pricegroup_id == 0) {
635
          $form->{"price_new_$j"} = $form->{"sellprice_$j"};
636
        }
637
      }
638
      $form->{"prices_$j"} = $prices;
101
    next unless $form->{PRICES}{$j};
102
    # build drop down list for pricegroups
103
    my $option_tmpl = qq|<option value="%s--%s" %s>%s</option>|;
104
    $form->{"prices_$j"}  = join '', map { sprintf $option_tmpl, @$_{qw(price pricegroup_id selected pricegroup)} } 
105
                                         (+{ pricegroup => $locale->text("none (pricegroup)") }, @{ $form->{PRICES}{$j} });
106

  
107
    foreach $item (@{ $form->{PRICES}{$j} }) {
108
      # set new selectedpricegroup_id and prices for "Preis"
109
      $form->{"pricegroup_old_$j"} = $item->{pricegroup_id}   if $item->{selected} &&  $item->{pricegroup_id};
110
      $form->{"sellprice_$j"}      = $item->{price}           if $item->{selected} &&  $item->{pricegroup_id};
111
      $form->{"price_new_$j"}      = $form->{"sellprice_$j"}  if $item->{selected} || !$item->{pricegroup_id};
639 112
    }
640 113
  }
641 114
  $lxdebug->leave_sub();
......
870 343

  
871 344
  # change callback
872 345
  $form->{old_callback} = $form->escape($form->{callback}, 1);
873
  $form->{callback} = $form->escape("$form->{script}?action=display_form", 1);
874

  
875
  # delete action
876
  delete $form->{action};
877

  
878
  # save all other form variables in a previousform variable
879
  foreach $key (keys %$form) {
346
  $form->{callback}     = $form->escape("$form->{script}?action=display_form", 1);
880 347

  
881
    # escape ampersands
882
    $form->{$key} =~ s/&/%26/g;
883
    $previousform .= qq|$key=$form->{$key}&|;
884
  }
885
  chop $previousform;
886
  $previousform = $form->escape($previousform, 1);
348
  # save all form variables except action in a previousform variable
349
  my $previousform = join '&', map { $form->{$_} =~ s/&/%26/; "$_=$form->{$_}" } grep { !/action/ } keys %$form;
887 350

  
888
  $i = $form->{rowcount};
889
  map { $form->{"${_}_$i"} =~ s/\"/&quot;/g } qw(partnumber description);
351
  map { $form->{"${_}_$form->{rowcount}"} =~ s/\"/&quot;/g } qw(partnumber description);
890 352

  
891 353
  $form->header;
892 354

  
893
  print qq|
894
<body>
895

  
896
<h4 class="error">| . $locale->text('Item not on file!') . qq|
897

  
898
<p>
899
| . $locale->text('What type of item is this?') . qq|</h4>
900

  
901
<form method="post" action="ic.pl">
902

  
903
<p>
904

  
905
  <input class="radio" type="radio" name="item" value="part" checked>&nbsp;|
906
    . $locale->text('Part') . qq|<br>
907
  <input class="radio" type="radio" name="item" value="service">&nbsp;|
908
    . $locale->text('Service');
909

  
910
  print $cgi->hidden("-name" => "previousform", "-value" => $previousform);
911
  map { print $cgi->hidden("-name" => $_, "-value" => $form->{$_}); }        qw(rowcount vc login password);
912
  map { print $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$i"}); } qw(partnumber description unit sellprice price_factor_id);
913
  print $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts});
914

  
915
print qq|
916
<input type="hidden" name="nextsub" value="add">
917

  
918
<p>
919
<input class="submit" type="submit" name="action" value="|
920
    . $locale->text('Continue') . qq|">
921
</form>
922

  
923
</body>
924
</html>
925
|;
926

  
927
  $lxdebug->leave_sub();
928
}
929

  
930
sub display_form {
931
  $lxdebug->enter_sub();
932

  
933
  relink_accounts();
934

  
935
  my $new_rowcount = $form->{"rowcount"} * 1 + 1;
936
  $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
937

  
938
  $form->language_payment(\%myconfig);
939

  
940
  # if we have a display_form
941
  if ($form->{display_form}) {
942
    call_sub($form->{"display_form"});
943
    exit;
944
  }
945

  
946
  Common::webdav_folder($form) if ($webdav);
947

  
948
  #   if (   $form->{print_and_post}
949
  #       && $form->{second_run}
950
  #       && ($form->{action} eq "display_form")) {
951
  #     for (keys %$form) { $old_form->{$_} = $form->{$_} }
952
  #     $old_form->{rowcount}++;
953
  #
954
  #     #$form->{rowcount}--;
955
  #     #$form->{rowcount}--;
956
  #
957
  #     $form->{print_and_post} = 0;
958
  #
959
  #     &print_form($old_form);
960
  #     exit;
961
  #   }
962
  #
963
  #   $form->{action}   = "";
964
  #   $form->{resubmit} = 0;
965
  #
966
  #   if ($form->{print_and_post} && !$form->{second_run}) {
967
  #     $form->{second_run} = 1;
968
  #     $form->{action}     = "display_form";
969
  #     $form->{rowcount}--;
970
  #     my $rowcount = $form->{rowcount};
971
  #
972
  #     # get pricegroups for parts
973
  #     IS->get_pricegroups_for_parts(\%myconfig, \%$form);
974
  #
975
  #     # build up html code for prices_$i
976
  #     set_pricegroup($rowcount);
977
  #
978
  #     $form->{resubmit} = 1;
979
  #
980
  #   }
981
  &form_header;
982

  
983
  $numrows    = ++$form->{rowcount};
984
  $subroutine = "display_row";
985

  
986
  if ($form->{item} eq 'part') {
987

  
988
    #set preisgruppenanzahl
989
    $numrows    = $form->{price_rows};
990
    $subroutine = "price_row";
991

  
992
    &{$subroutine}($numrows);
993

  
994
    $numrows    = ++$form->{makemodel_rows};
995
    $subroutine = "makemodel_row";
996
  }
997
  if ($form->{item} eq 'assembly') {
998
    $numrows    = $form->{price_rows};
999
    $subroutine = "price_row";
1000

  
1001
    &{$subroutine}($numrows);
1002

  
1003
    $numrows    = ++$form->{makemodel_rows};
1004
    $subroutine = "makemodel_row";
1005

  
1006
    # create makemodel rows
1007
    &{$subroutine}($numrows);
1008

  
1009
    $numrows    = ++$form->{assembly_rows};
1010
    $subroutine = "assembly_row";
1011
  }
1012
  if ($form->{item} eq 'service') {
1013
    $numrows    = $form->{price_rows};
1014
    $subroutine = "price_row";
1015

  
1016
    &{$subroutine}($numrows);
1017

  
1018
    $numrows = 0;
1019
  }
1020

  
1021
  # create rows
1022
  &{$subroutine}($numrows) if $numrows;
355
  push @HIDDENS, { value => $cgi->hidden("-name" => "previousform", "-value" => $form->escape($previousform, 1)) };
356
  push @HIDDENS, map +{ value => $cgi->hidden("-name" => $_, "-value" => $form->{$_}) },                       qw(rowcount vc login password);
357
  push @HIDDENS, map +{ value => $cgi->hidden("-name" => $_, "-value" => $form->{"${_}_$form->{rowcount}"}) }, qw(partnumber description unit sellprice);
358
  push @HIDDENS, { value => $cgi->hidden("-name" => "taxaccount2", "-value" => $form->{taxaccounts}) };
1023 359

  
1024
  &form_footer;
360
  print $form->parse_html_template("generic/new_item", { HIDDENS => \@HIDDENS} );
1025 361

  
1026 362
  $lxdebug->leave_sub();
1027 363
}
......
1415 751
  # note: "||"-selection is only correct for values where "0" is _not_ a correct entry
1416 752
  $form->{sendmode}   = "attachment";
1417 753
  $form->{format}     = $form->{format} || $myconfig{template_format} || "pdf";
1418
  $form->{copies}     = $form->{copies} || $myconfig{copies} || 3;
1419
  $form->{media}      = $form->{media} || $myconfig{default_media} || "screen";
754
  $form->{copies}     = $form->{copies} || $myconfig{copies}          || 3;
755
  $form->{media}      = $form->{media}  || $myconfig{default_media}   || "screen";
1420 756
  $form->{printer_id} = defined $form->{printer_id}           ? $form->{printer_id} :
1421 757
                        defined $myconfig{default_printer_id} ? $myconfig{default_printer_id} : "";
1422 758

  
......
1427 763

  
1428 764
  push @FORMNAME, grep $_,
1429 765
    ($form->{type} eq 'purchase_order') ? (
1430
      opthash("purchase_order", $form->{PD}{purchase_order}, $locale->text('Purchase Order')),
1431
      opthash("bin_list", $form->{PD}{bin_list}, $locale->text('Bin List')) 
766
      opthash("purchase_order",      $form->{PD}{purchase_order},      $locale->text('Purchase Order')),
767
      opthash("bin_list",            $form->{PD}{bin_list},            $locale->text('Bin List')) 
1432 768
    ) : undef,
1433 769
    ($form->{type} eq 'credit_note') ?
1434
      opthash("credit_note", $form->{PD}{credit_note}, $locale->text('Credit Note')) : undef,
770
      opthash("credit_note",         $form->{PD}{credit_note},         $locale->text('Credit Note')) : undef,
1435 771
    ($form->{type} eq 'sales_order') ? (
1436
      opthash("sales_order", $form->{PD}{sales_order}, $locale->text('Confirmation')),
1437
      opthash("proforma", $form->{PD}{proforma}, $locale->text('Proforma Invoice')),
1438
      opthash("pick_list", $form->{PD}{pick_list}, $locale->text('Pick List')),
1439
      opthash("packing_list", $form->{PD}{packing_list}, $locale->text('Packing List')) 
772
      opthash("sales_order",         $form->{PD}{sales_order},         $locale->text('Confirmation')),
773
      opthash("proforma",            $form->{PD}{proforma},            $locale->text('Proforma Invoice')),
774
      opthash("pick_list",           $form->{PD}{pick_list},           $locale->text('Pick List')),
775
      opthash("packing_list",        $form->{PD}{packing_list},        $locale->text('Packing List')) 
1440 776
    ) : undef,
1441 777
    ($form->{type} =~ /_quotation$/) ?
1442
      opthash("$`_quotation", $form->{PD}{"$`_quotation"}, $locale->text('Quotation')) : undef,
778
      opthash("$`_quotation",        $form->{PD}{"$`_quotation"},      $locale->text('Quotation')) : undef,
1443 779
    ($form->{type} eq 'invoice') ? (
1444
      opthash("invoice", $form->{PD}{invoice}, $locale->text('Invoice')),
1445
      opthash("proforma", $form->{PD}{proforma}, $locale->text('Proforma Invoice')),
1446
      opthash("packing_list", $form->{PD}{packing_list}, $locale->text('Packing List'))
780
      opthash("invoice",             $form->{PD}{invoice},             $locale->text('Invoice')),
781
      opthash("proforma",            $form->{PD}{proforma},            $locale->text('Proforma Invoice')),
782
      opthash("packing_list",        $form->{PD}{packing_list},        $locale->text('Packing List'))
1447 783
    ) : undef,
1448 784
    ($form->{type} eq 'invoice' && $form->{storno}) ? (
1449
      opthash("storno_invoice", $form->{PD}{storno_invoice}, $locale->text('Storno Invoice')),
785
      opthash("storno_invoice",      $form->{PD}{storno_invoice},      $locale->text('Storno Invoice')),
1450 786
      opthash("storno_packing_list", $form->{PD}{storno_packing_list}, $locale->text('Storno Packing List')) 
1451 787
    ) : undef,
1452 788
    ($form->{type} eq 'credit_note') ?
1453
      opthash("credit_note", $form->{PD}{credit_note}, $locale->text('Credit Note')) : undef;
789
      opthash("credit_note",         $form->{PD}{credit_note},         $locale->text('Credit Note')) : undef;
1454 790

  
1455 791
  push @SENDMODE, 
1456
    opthash("attachment", $form->{SM}{attachment}, $locale->text('Attachment')),
1457
    opthash("inline", $form->{SM}{inline}, $locale->text('In-line'))
792
    opthash("attachment",            $form->{SM}{attachment},          $locale->text('Attachment')),
793
    opthash("inline",                $form->{SM}{inline},              $locale->text('In-line'))
1458 794
      if ($form->{media} eq 'email');
1459 795

  
1460 796
  push @MEDIA, grep $_,
1461
      opthash("screen", $form->{OP}{screen}, $locale->text('Screen')),
797
      opthash("screen",              $form->{OP}{screen},              $locale->text('Screen')),
1462 798
    (scalar @{ $form->{printers} } && $latex_templates) ?
1463
      opthash("printer", $form->{OP}{printer}, $locale->text('Printer')) : undef,
1464
    ($latex_templates && !$options{no_queue}) ?
1465
      opthash("queue", $form->{OP}{queue}, $locale->text('Queue')) : undef
799
      opthash("printer",             $form->{OP}{printer},             $locale->text('Printer')) : undef,
800
    ($latex_templates && !$options->{no_queue}) ?
801
      opthash("queue",               $form->{OP}{queue},               $locale->text('Queue')) : undef
1466 802
        if ($form->{media} ne 'email');
1467 803

  
1468 804
  push @FORMAT, grep $_,
1469 805
    ($opendocument_templates && $openofficeorg_writer_bin && $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)
1470
     && !$options{no_opendocument_pdf}) ?
1471
      opthash("opendocument_pdf", $form->{DF}{"opendocument_pdf"}, $locale->text("PDF (OpenDocument/OASIS)")) : undef,
806
     && !$options->{no_opendocument_pdf}) ?
807
      opthash("opendocument_pdf",    $form->{DF}{"opendocument_pdf"},  $locale->text("PDF (OpenDocument/OASIS)")) : undef,
1472 808
    ($latex_templates) ?
1473
      opthash("pdf", $form->{DF}{pdf}, $locale->text('PDF')) : undef,
1474
    ($latex_templates && !$options{no_postscript}) ?
1475
      opthash("postscript", $form->{DF}{postscript}, $locale->text('Postscript')) : undef,
1476
    (!$options{no_html}) ?
809
      opthash("pdf",                 $form->{DF}{pdf},                 $locale->text('PDF')) : undef,
810
    ($latex_templates && !$options->{no_postscript}) ?
811
      opthash("postscript",          $form->{DF}{postscript},          $locale->text('Postscript')) : undef,
812
    (!$options->{no_html}) ?
1477 813
      opthash("html", $form->{DF}{html}, "HTML") : undef,
1478
    ($opendocument_templates && !$options{no_opendocument}) ?
1479
      opthash("opendocument", $form->{DF}{opendocument}, $locale->text("OpenDocument/OASIS")) : undef;
814
    ($opendocument_templates && !$options->{no_opendocument}) ?
815
      opthash("opendocument",        $form->{DF}{opendocument},        $locale->text("OpenDocument/OASIS")) : undef;
1480 816

  
1481 817
  push @LANGUAGE_ID, 
1482 818
    map { opthash($_->{id}, ($_->{id} eq $form->{language_id} ? 'selected' : ''), $_->{description}) } +{}, @{ $form->{languages} }
bin/mozilla/ir.pl
37 37
use List::Util qw(max);
38 38

  
39 39
require "bin/mozilla/io.pl";
40
require "bin/mozilla/invoice_io.pl";
40 41
require "bin/mozilla/arap.pl";
41 42
require "bin/mozilla/common.pl";
42 43
require "bin/mozilla/drafts.pl";
bin/mozilla/is.pl
37 37
use List::Util qw(max);
38 38

  
39 39
require "bin/mozilla/io.pl";
40
require "bin/mozilla/invoice_io.pl";
40 41
require "bin/mozilla/arap.pl";
41 42
require "bin/mozilla/drafts.pl";
42 43

  
bin/mozilla/oe.pl
1
# #=====================================================================
1
#=====================================================================
2 2
# LX-Office ERP
3 3
# Copyright (C) 2004
4 4
# Based on SQL-Ledger Version 2.1.9
......
38 38
use SL::IS;
39 39
use SL::PE;
40 40
use SL::ReportGenerator;
41
use List::Util qw(max);
41
use List::Util qw(max reduce);
42 42

  
43 43
require "bin/mozilla/io.pl";
44 44
require "bin/mozilla/arap.pl";
......
162 162
sub order_links {
163 163
  $lxdebug->enter_sub();
164 164
  # get customer/vendor
165
  $form->all_vc(\%myconfig, $form->{vc},
166
                ($form->{vc} eq 'customer') ? "AR" : "AP");
165
  $form->all_vc(\%myconfig, $form->{vc}, ($form->{vc} eq 'customer') ? "AR" : "AP");
167 166

  
168 167
  # retrieve order/quotation
169 168
  $form->{webdav}   = $webdav;
......
245 244
  }
246 245
  $form->{intnotes} = $intnotes if $intnotes;
247 246
  ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
248
  $form->{"old$form->{vc}"} =
249
    qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
247
  $form->{"old$form->{vc}"} = qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
250 248

  
251 249
  # build the popup menus
252 250
  if (@{ $form->{"all_$form->{vc}"} }) {
......
265 263
    $form->{department}       = "$form->{department}--$form->{department_id}";
266 264

  
267 265
    map {
268
      $form->{selectdepartment} .=
269
        "<option>$_->{description}--$_->{id}</option>\n"
270
    } (@{ $form->{all_departments} });
266
      $form->{selectdepartment} .= "<option>$_->{description}--$_->{id}</option>\n"
267
    } @{ $form->{all_departments} };
271 268
  }
272 269

  
273 270
  $form->{employee} = "$form->{employee}--$form->{employee_id}";
......
287 284
  my $i = 0;
288 285
  foreach $ref (@{ $form->{form_details} }) {
289 286
    $form->{rowcount} = ++$i;
290

  
291 287
    map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
292 288
  }
293 289
  for my $i (1 .. $form->{rowcount}) {
294
    if ($form->{id}) {
295
      $form->{"discount_$i"} =
296
        $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
297
    } else {
298
      $form->{"discount_$i"} =
299
        $form->format_amount(\%myconfig, $form->{"discount_$i"});
300
    }
301
    ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
302
    $dec           = length $dec;
303
    $decimalplaces = ($dec > 2) ? $dec : 2;
304

  
305
    # copy reqdate from deliverydate for invoice -> order conversion
... Dieser Diff wurde abgeschnitten, weil er die maximale Anzahl anzuzeigender Zeilen überschreitet.

Auch abrufbar als: Unified diff