Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9da3e39b

Von Sven Schöling vor fast 15 Jahren hinzugefügt

  • ID 9da3e39b72311b5a22fd79c3ca97b5fbe871092f
  • Vorgänger 3ef788be
  • Nachfolger dc3d3e70

io strict

Unterschiede anzeigen:

bin/mozilla/io.pl
48 48

  
49 49
require "bin/mozilla/common.pl";
50 50

  
51
use strict;
52

  
51 53
# any custom scripts for this one
52 54
if (-f "bin/mozilla/custom_io.pl") {
53 55
  eval { require "bin/mozilla/custom_io.pl"; };
......
103 105
# neue Optik im Rechnungsformular      #
104 106
########################################
105 107
sub display_row {
106
  $lxdebug->enter_sub();
108
  $main::lxdebug->enter_sub();
107 109

  
108 110
  _check_io_auth();
109 111

  
112
  my $form     = $main::form;
113
  my %myconfig = %main::myconfig;
114
  my $locale   = $main::locale;
115
  my $cgi      = $main::cgi;
116

  
110 117
  my $numrows = shift;
111 118

  
112 119
  my ($readonly, $stock_in_out, $stock_in_out_title);
......
169 176

  
170 177
  # translations, unused commented out
171 178
#  $runningnumber = $locale->text('No.');
172
  $deliverydate  = $locale->text('Delivery Date');
173
  $serialnumber  = $locale->text('Serial No.');
174
  $projectnumber = $locale->text('Project');
179
#  my $deliverydate  = $locale->text('Delivery Date');
180
  my $serialnumber  = $locale->text('Serial No.');
181
  my $projectnumber = $locale->text('Project');
175 182
#  $partsgroup    = $locale->text('Group');
176
  $reqdate       = $locale->text('Reqdate');
177
  $deliverydate  = $locale->text('Required by');
183
  my $reqdate       = $locale->text('Reqdate');
184
  my $deliverydate  = $locale->text('Required by');
178 185

  
179 186
  # special alignings
180 187
  my %align  = map { $_ => 'right' } qw(qty ship right sellprice_pg discount linetotal stock_in_out);
......
196 203
  _update_custom_variables();
197 204

  
198 205
  # rows
199
  for $i (1 .. $numrows) {
206

  
207
  my @ROWS;
208
  for my $i (1 .. $numrows) {
200 209
    my %column_data = ();
201 210

  
202 211
    # undo formatting
......
237 246
# / unit ending
238 247

  
239 248
    $form->{"sellprice_$i"} =~ /\.(\d+)/;
240
    $decimalplaces = max 2, length $1;
249
    my $decimalplaces = max 2, length $1;
241 250

  
242
    $price_factor   = $price_factors{$form->{"price_factor_id_$i"}} || 1;
243
    $discount       = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} *        $form->{"discount_$i"}  / 100 / $price_factor, 2);
244
    $linetotal      = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2);
251
    my $price_factor   = $price_factors{$form->{"price_factor_id_$i"}} || 1;
252
    my $discount       = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} *        $form->{"discount_$i"}  / 100 / $price_factor, 2);
253
    my $linetotal      = $form->round_amount($form->{"qty_$i"} * $form->{"sellprice_$i"} * (100 - $form->{"discount_$i"}) / 100 / $price_factor, 2);
254
    my $rows            = $form->numtextrows($form->{"description_$i"}, 30, 6);
245 255

  
246 256
    $column_data{runningnumber} = $cgi->textfield(-name => "runningnumber_$i", -size => 5,  -value => $i);    # HuT
247 257
    $column_data{partnumber}    = $cgi->textfield(-name => "partnumber_$i",    -size => 12, -value => $form->{"partnumber_$i"});
248
    $column_data{description} = ((($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) # if description is too large, use a textbox instead
258
    $column_data{description} = (($rows > 1) # if description is too large, use a textbox instead
249 259
                                ? $cgi->textarea( -name => "description_$i", -default => $form->{"description_$i"}, -rows => $rows, -columns => 30)
250 260
                                : $cgi->textfield(-name => "description_$i",   -size => 30, -value => $form->{"description_$i"}))
251 261
                                . $cgi->button(-value => $locale->text('L'), -onClick => "set_longdescription_window('longdescription_$i')");
......
385 395
    $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;
386 396
  }
387 397

  
388
  $lxdebug->leave_sub();
398
  $main::lxdebug->leave_sub();
389 399
}
390 400

  
391 401
##################################################
392 402
# build html-code for pricegroups in variable $form->{prices_$j}
393 403

  
394 404
sub set_pricegroup {
395
  $lxdebug->enter_sub();
405
  $main::lxdebug->enter_sub();
406

  
407
  my $form     = $main::form;
408
  my $locale   = $main::locale;
409
  my $cgi      = $main::cgi;
396 410

  
397 411
  _check_io_auth();
398 412

  
399 413
  my $rowcount = shift;
400
  for $j (1 .. $rowcount) {
414
  for my $j (1 .. $rowcount) {
401 415
    next unless $form->{PRICES}{$j};
402 416
    # build drop down list for pricegroups
403 417
    my $option_tmpl = qq|<option value="%s--%s" %s>%s</option>|;
404 418
    $form->{"prices_$j"}  = join '', map { sprintf $option_tmpl, @$_{qw(price pricegroup_id selected pricegroup)} }
405 419
                                         (+{ pricegroup => $locale->text("none (pricegroup)") }, @{ $form->{PRICES}{$j} });
406 420

  
407
    foreach $item (@{ $form->{PRICES}{$j} }) {
421
    foreach my $item (@{ $form->{PRICES}{$j} }) {
408 422
      # set new selectedpricegroup_id and prices for "Preis"
409 423
      $form->{"pricegroup_old_$j"} = $item->{pricegroup_id}   if $item->{selected} &&  $item->{pricegroup_id};
410 424
      $form->{"sellprice_$j"}      = $item->{price}           if $item->{selected} &&  $item->{pricegroup_id};
411 425
      $form->{"price_new_$j"}      = $form->{"sellprice_$j"}  if $item->{selected} || !$item->{pricegroup_id};
412 426
    }
413 427
  }
414
  $lxdebug->leave_sub();
428
  $main::lxdebug->leave_sub();
415 429
}
416 430

  
417 431
sub select_item {
418
  $lxdebug->enter_sub();
432
  $main::lxdebug->enter_sub();
433

  
434
  my $form     = $main::form;
435
  my %myconfig = %main::myconfig;
436
  my $locale   = $main::locale;
437
  my $cgi      = $main::cgi;
438

  
419 439
# diese variable kommt schon in der methode display_row vor, kann man die besser wiederverwenden? @mb fragen.  ich check das jetzt erstmal so ein
420 440
  my $is_purchase        = (first { $_ eq $form->{type} } qw(request_quotation purchase_order purchase_delivery_order)) || ($form->{script} eq 'ir.pl');
421 441
  _check_io_auth();
422 442

  
423
  @column_index = qw(ndx partnumber description rop onhand unit sellprice);
424

  
443
  my @column_index = qw(ndx partnumber description rop onhand unit sellprice);
444
  my %column_data;
425 445
  $column_data{ndx}        = qq|<th>&nbsp;</th>|;
426 446
  $column_data{partnumber} =
427 447
    qq|<th class="listheading">| . $locale->text('Number') . qq|</th>|;
......
440 460
  # list items with radio button on a form
441 461
  $form->header;
442 462

  
443
  $title   = $locale->text('Select from one of the items below');
444
  $colspan = $#column_index + 1;
463
  my $title   = $locale->text('Select from one of the items below');
464
  my $colspan = $#column_index + 1;
445 465

  
446 466
  print qq|
447 467
  <body>
......
463 483
    qw(bin listprice inventory_accno income_accno expense_accno unit weight
464 484
       assembly taxaccounts partsgroup formel longdescription not_discountable
465 485
       part_payment_id partnotes id lastcost price_factor_id price_factor);
466
  push @new_fields, "lizenzen" if ($lizenzen);
486
  push @new_fields, "lizenzen" if ($main::lizenzen);
467 487
  push @new_fields, grep { m/^ic_cvar_/ } keys %{ $form->{item_list}->[0] };
468 488

  
469 489
  my $i = 0;
470
  foreach $ref (@{ $form->{item_list} }) {
471
    $checked = ($i++) ? "" : "checked";
490
  my $j;
491
  foreach my $ref (@{ $form->{item_list} }) {
492
    my $checked = ($i++) ? "" : "checked";
472 493

  
473
    if ($lizenzen) {
494
    if ($main::lizenzen) {
474 495
      if ($ref->{inventory_accno} > 0) {
475 496
        $ref->{"lizenzen"} = qq|<option></option>|;
476
        foreach $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
497
        foreach my $item (@{ $form->{LIZENZEN}{ $ref->{"id"} } }) {
477 498
          $ref->{"lizenzen"} .=
478 499
            qq|<option value=\"$item->{"id"}\">$item->{"licensenumber"}</option>|;
479 500
        }
......
535 556
  map { delete $form->{$_} } qw(action item_list header);
536 557

  
537 558
  # save all other form variables
538
  foreach $key (keys %${form}) {
559
  foreach my $key (keys %${form}) {
539 560
    next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
540 561
    $form->{$key} =~ s/\"/&quot;/g;
541 562
    print qq|<input name="$key" type="hidden" value="$form->{$key}">\n|;
......
553 574
</html>
554 575
|;
555 576

  
556
  $lxdebug->leave_sub();
577
  $main::lxdebug->leave_sub();
557 578
}
558 579

  
559 580
sub item_selected {
560
  $lxdebug->enter_sub();
581
  $main::lxdebug->enter_sub();
582

  
583
  my $form     = $main::form;
584
  my %myconfig = %main::myconfig;
561 585

  
562 586
  _check_io_auth();
563 587

  
564 588
  # replace the last row with the checked row
565
  $i = $form->{rowcount};
589
  my $i = $form->{rowcount};
566 590
  $i = $form->{assembly_rows} if ($form->{item} eq 'assembly');
567 591

  
568 592
  # index for new item
569
  $j = $form->{ndx};
593
  my $j = $form->{ndx};
570 594

  
571 595
  #sk
572 596
  #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"};
573 597
  #$form->{"sellprice_$i"} = $form->{"sellprice_$i"};
574 598

  
575 599
  # if there was a price entered, override it
576
  $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
600
  my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
577 601

  
578 602
  my @new_fields =
579 603
    qw(id partnumber description sellprice listprice inventory_accno
......
592 616
    $form->{payment_id} = $form->{"part_payment_id_$i"};
593 617
  }
594 618

  
595
  if ($lizenzen) {
619
  if ($main::lizenzen) {
596 620
    map { $form->{"${_}_$i"} = $form->{"new_${_}_$j"} } qw(lizenzen);
597 621
  }
598 622

  
599
  ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
623
  my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
600 624
  $dec           = length $dec;
601
  $decimalplaces = ($dec > 2) ? $dec : 2;
625
  my $decimalplaces = ($dec > 2) ? $dec : 2;
602 626

  
603 627
  if ($sellprice) {
604 628
    $form->{"sellprice_$i"} = $sellprice;
......
622 646
    $form->{"discount_$i"} = 0;
623 647
  }
624 648

  
625
  $amount =
649
  my $amount =
626 650
    $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
627 651
    $form->{"qty_$i"};
628 652
  map { $form->{"${_}_base"} += $amount }
......
656 680

  
657 681
  &display_form;
658 682

  
659
  $lxdebug->leave_sub();
683
  $main::lxdebug->leave_sub();
660 684
}
661 685

  
662 686
sub new_item {
663
  $lxdebug->enter_sub();
687
  $main::lxdebug->enter_sub();
688

  
689
  my $form     = $main::form;
690
  my %myconfig = %main::myconfig;
664 691

  
665 692
  _check_io_auth();
666 693

  
......
673 700
  # save all form variables except action in a previousform variable
674 701
  my $previousform = join '&', map { my $value = $form->{$_}; $value =~ s/&/%26/; "$_=$value" } grep { !/action/ } keys %$form;
675 702

  
703
  my @HIDDENS;
676 704
  push @HIDDENS,      { 'name' => 'previousform', 'value' => $form->escape($previousform, 1) };
677 705
  push @HIDDENS, map +{ 'name' => $_,             'value' => $form->{$_} },                       qw(rowcount vc);
678 706
  push @HIDDENS, map +{ 'name' => $_,             'value' => $form->{"${_}_$form->{rowcount}"} }, qw(partnumber description unit);
......
683 711
  $form->header();
684 712
  print $form->parse_html_template("generic/new_item", { HIDDENS => [ sort { $a->{name} cmp $b->{name} } @HIDDENS ] } );
685 713

  
686
  $lxdebug->leave_sub();
714
  $main::lxdebug->leave_sub();
687 715
}
688 716

  
689 717
sub check_form {
690
  $lxdebug->enter_sub();
718
  $main::lxdebug->enter_sub();
719

  
720
  my $form     = $main::form;
721
  my %myconfig = %main::myconfig;
691 722

  
692 723
  _check_io_auth();
693 724

  
......
759 790

  
760 791
          map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
761 792
          $count++;
762
          if ($lizenzen) {
793
          if ($main::lizenzen) {
763 794
            if ($form->{"licensenumber_$i"} == -1) {
764 795
              &new_license($i);
765 796
              exit;
......
793 824

  
794 825
  &display_form;
795 826

  
796
  $lxdebug->leave_sub();
827
  $main::lxdebug->leave_sub();
797 828
}
798 829

  
799 830
sub invoicetotal {
800
  $lxdebug->enter_sub();
831
  $main::lxdebug->enter_sub();
832

  
833
  my $form     = $main::form;
834
  my %myconfig = %main::myconfig;
801 835

  
802 836
  _check_io_auth();
803 837

  
......
826 860
    if !$form->{taxincluded};
827 861

  
828 862
  $form->{oldtotalpaid} = 0;
829
  for $i (1 .. $form->{paidaccounts}) {
863
  for my $i (1 .. $form->{paidaccounts}) {
830 864
    $form->{oldtotalpaid} += $form->{"paid_$i"};
831 865
  }
832 866

  
833
  $lxdebug->leave_sub();
867
  $main::lxdebug->leave_sub();
834 868

  
835 869
  # return total
836 870
  return ($form->{oldinvtotal} - $form->{oldtotalpaid});
837 871
}
838 872

  
839 873
sub validate_items {
840
  $lxdebug->enter_sub();
874
  $main::lxdebug->enter_sub();
875

  
876
  my $form     = $main::form;
877
  my $locale   = $main::locale;
841 878

  
842 879
  _check_io_auth();
843 880

  
......
847 884
    exit;
848 885
  }
849 886

  
850
  for $i (1 .. $form->{rowcount} - 1) {
887
  for my $i (1 .. $form->{rowcount} - 1) {
851 888
    $form->isblank("partnumber_$i",
852 889
                   $locale->text('Number missing in Row') . " $i");
853 890
  }
854 891

  
855
  $lxdebug->leave_sub();
892
  $main::lxdebug->leave_sub();
856 893
}
857 894

  
858 895
sub order {
859
  $lxdebug->enter_sub();
896
  $main::lxdebug->enter_sub();
897

  
898
  my $form     = $main::form;
899
  my %myconfig = %main::myconfig;
900
  my $locale   = $main::locale;
860 901

  
861 902
  _check_io_auth();
862 903

  
......
869 910
  $form->{old_salesman_id} = $form->{salesman_id};
870 911

  
871 912
  map { delete $form->{$_} } qw(id printed emailed queued);
913
  my $buysell;
872 914
  if ($form->{script} eq 'ir.pl' || $form->{type} eq 'request_quotation') {
873 915
    $form->{title} = $locale->text('Add Purchase Order');
874 916
    $form->{vc}    = 'vendor';
......
893 935
  my $script = $form->{"script"};
894 936
  $script =~ s|.*/||;
895 937
  $script =~ s|.pl$||;
896
  $locale = new Locale($language, $script);
938
  $locale = new Locale($main::language, $script);
897 939

  
898 940
  map { $form->{"select$_"} = "" } ($form->{vc}, "currency");
899 941

  
900
  $currency = $form->{currency};
942
  my $currency = $form->{currency};
901 943

  
902 944
  &order_links;
903 945

  
......
905 947
  $form->{forex}        = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell);
906 948
  $form->{exchangerate} = $form->{forex} || '';
907 949

  
908
  for $i (1 .. $form->{rowcount}) {
950
  for my $i (1 .. $form->{rowcount}) {
909 951
    map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"})
910 952
            if ($form->{"${_}_${i}"}) }
911 953
        qw(ship qty sellprice listprice basefactor discount));
......
914 956
  &prepare_order;
915 957
  &display_form;
916 958

  
917
  $lxdebug->leave_sub();
959
  $main::lxdebug->leave_sub();
918 960
}
919 961

  
920 962
sub quotation {
921
  $lxdebug->enter_sub();
963
  $main::lxdebug->enter_sub();
964

  
965
  my $form     = $main::form;
966
  my %myconfig = %main::myconfig;
967
  my $locale   = $main::locale;
922 968

  
923 969
  _check_io_auth();
924 970

  
......
927 973
  }
928 974
  map { delete $form->{$_} } qw(id printed emailed queued);
929 975

  
976
  my $buysell;
930 977
  if ($form->{script} eq 'ir.pl' || $form->{type} eq 'purchase_order') {
931 978
    $form->{title} = $locale->text('Add Request for Quotation');
932 979
    $form->{vc}    = 'vendor';
......
952 999

  
953 1000
  map { $form->{"select$_"} = "" } ($form->{vc}, "currency");
954 1001

  
955
  $currency = $form->{currency};
1002
  my $currency = $form->{currency};
956 1003

  
957 1004
  &order_links;
958 1005

  
......
960 1007
  $form->{forex}        = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{transdate}, $buysell);
961 1008
  $form->{exchangerate} = $form->{forex} || '';
962 1009

  
963
  for $i (1 .. $form->{rowcount}) {
1010
  for my $i (1 .. $form->{rowcount}) {
964 1011
    map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
965 1012
                                                     $form->{"${_}_${i}"})
966 1013
            if ($form->{"${_}_${i}"}) }
......
970 1017
  &prepare_order;
971 1018
  &display_form;
972 1019

  
973
  $lxdebug->leave_sub();
1020
  $main::lxdebug->leave_sub();
974 1021
}
975 1022

  
976 1023
sub request_for_quotation {
......
978 1025
}
979 1026

  
980 1027
sub edit_e_mail {
981
  $lxdebug->enter_sub();
1028
  $main::lxdebug->enter_sub();
1029

  
1030
  my $form     = $main::form;
1031
  my %myconfig = %main::myconfig;
1032
  my $locale   = $main::locale;
982 1033

  
983 1034
  _check_io_auth();
984 1035

  
......
994 1045
    $form->{"email"} = $form->{"cp_email"};
995 1046
  }
996 1047

  
997
  $title = $locale->text('E-mail') . " " . $form->get_formname_translation();
1048
  my $title = $locale->text('E-mail') . " " . $form->get_formname_translation();
998 1049

  
999 1050
  $form->{oldmedia} = $form->{media};
1000 1051
  $form->{media}    = "email";
......
1018 1069
                                     HIDDEN        => [ map +{ name => $_, value => $form->{$_} }, @hidden_keys ],
1019 1070
                                     SHOW_BCC      => $myconfig{role} eq 'admin' });
1020 1071

  
1021
  $lxdebug->leave_sub();
1072
  $main::lxdebug->leave_sub();
1022 1073
}
1023 1074

  
1024 1075
sub send_email {
1025
  $lxdebug->enter_sub();
1076
  $main::lxdebug->enter_sub();
1077

  
1078
  my $form     = $main::form;
1079
  my %myconfig = %main::myconfig;
1026 1080

  
1027 1081
  _check_io_auth();
1028 1082

  
......
1036 1090
  $form->{callback} = $callback;
1037 1091
  $form->redirect();
1038 1092

  
1039
  $lxdebug->leave_sub();
1093
  $main::lxdebug->leave_sub();
1040 1094
}
1041 1095

  
1042 1096
# generate the printing options displayed at the bottom of oe and is forms.
......
1049 1103
#
1050 1104
# the inline options is untested, but intended to be used later in metatemplating
1051 1105
sub print_options {
1052
  $lxdebug->enter_sub();
1106
  $main::lxdebug->enter_sub();
1107

  
1108
  my $form     = $main::form;
1109
  my %myconfig = %main::myconfig;
1110
  my $locale   = $main::locale;
1053 1111

  
1054 1112
  _check_io_auth();
1055 1113

  
......
1057 1115

  
1058 1116
  # names 3 parameters and returns a hashref, for use in templates
1059 1117
  sub opthash { +{ value => shift, selected => shift, oname => shift } }
1060
  (@FORMNAME, @FORMNAME, @LANGUAGE_ID, @FORMAT, @SENDMODE, @MEDIA, @PRINTER_ID, @SELECTS) = ();
1118
  my (@FORMNAME, @LANGUAGE_ID, @FORMAT, @SENDMODE, @MEDIA, @PRINTER_ID, @SELECTS) = ();
1061 1119

  
1062 1120
  # note: "||"-selection is only correct for values where "0" is _not_ a correct entry
1063 1121
  $form->{sendmode}   = "attachment";
......
1107 1165

  
1108 1166
  push @MEDIA, grep $_,
1109 1167
      opthash("screen",              $form->{OP}{screen},              $locale->text('Screen')),
1110
    (scalar @{ $form->{printers} } && $latex_templates) ?
1168
    (scalar @{ $form->{printers} } && $main::latex_templates) ?
1111 1169
      opthash("printer",             $form->{OP}{printer},             $locale->text('Printer')) : undef,
1112
    ($latex_templates && !$options{no_queue}) ?
1170
    ($main::latex_templates && !$options{no_queue}) ?
1113 1171
      opthash("queue",               $form->{OP}{queue},               $locale->text('Queue')) : undef
1114 1172
        if ($form->{media} ne 'email');
1115 1173

  
1116 1174
  push @FORMAT, grep $_,
1117
    ($opendocument_templates && $openofficeorg_writer_bin && $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)
1175
    ($main::opendocument_templates &&     $main::openofficeorg_writer_bin  &&     $main::xvfb_bin
1176
                                   && (-x $main::openofficeorg_writer_bin) && (-x $main::xvfb_bin)
1118 1177
     && !$options{no_opendocument_pdf}) ?
1119 1178
      opthash("opendocument_pdf",    $form->{DF}{"opendocument_pdf"},  $locale->text("PDF (OpenDocument/OASIS)")) : undef,
1120
    ($latex_templates) ?
1179
    ($main::latex_templates) ?
1121 1180
      opthash("pdf",                 $form->{DF}{pdf},                 $locale->text('PDF')) : undef,
1122
    ($latex_templates && !$options{no_postscript}) ?
1181
    ($main::latex_templates && !$options{no_postscript}) ?
1123 1182
      opthash("postscript",          $form->{DF}{postscript},          $locale->text('Postscript')) : undef,
1124 1183
    (!$options{no_html}) ?
1125 1184
      opthash("html", $form->{DF}{html}, "HTML") : undef,
1126
    ($opendocument_templates && !$options{no_opendocument}) ?
1185
    ($main::opendocument_templates && !$options{no_opendocument}) ?
1127 1186
      opthash("opendocument",        $form->{DF}{opendocument},        $locale->text("OpenDocument/OASIS")) : undef;
1128 1187

  
1129 1188
  push @LANGUAGE_ID,
......
1134 1193
    map { opthash($_->{id}, ($_->{id} eq $form->{printer_id} ? 'selected' : ''), $_->{printer_description}) } +{}, @{ $form->{printers} }
1135 1194
      if ((ref $form->{printers} eq 'ARRAY') && scalar @{ $form->{printers } });
1136 1195

  
1137
  @SELECTS = map { sname => lc $_, DATA => \@$_, show => !$options{"hide_" . lc($_)} && scalar @$_ }, qw(FORMNAME LANGUAGE_ID FORMAT SENDMODE MEDIA PRINTER_ID);
1196
  {
1197
    no strict 'refs';
1198
    @SELECTS = map { sname => lc $_, DATA => \@$_, show => !$options{"hide_" . lc($_)} && scalar @$_ }, qw(FORMNAME LANGUAGE_ID FORMAT SENDMODE MEDIA PRINTER_ID);
1199
  }
1138 1200

  
1139 1201
  my %dont_display_groupitems = (
1140 1202
    'dunning' => 1,
1141 1203
    );
1142 1204

  
1143
  %template_vars = (
1144
    display_copies       => scalar @{ $form->{printers} } && $latex_templates && $form->{media} ne 'email',
1205
  my %template_vars = (
1206
    display_copies       => scalar @{ $form->{printers} } && $main::latex_templates && $form->{media} ne 'email',
1145 1207
    display_remove_draft => (!$form->{id} && $form->{draft_id}),
1146 1208
    display_groupitems   => !$dont_display_groupitems{$form->{type}},
1147 1209
    groupitems_checked   => $form->{groupitems} ? "checked" : '',
......
1151 1213
  my $print_options = $form->parse_html_template("generic/print_options", { SELECTS  => \@SELECTS, %template_vars } );
1152 1214

  
1153 1215
  if ($options{inline}) {
1154
    $lxdebug->leave_sub();
1216
    $main::lxdebug->leave_sub();
1155 1217
    return $print_options;
1156 1218
  }
1157 1219

  
1158 1220
  print $print_options;
1159 1221

  
1160
  $lxdebug->leave_sub();
1222
  $main::lxdebug->leave_sub();
1161 1223
}
1162 1224

  
1163 1225
sub print {
1164
  $lxdebug->enter_sub();
1226
  $main::lxdebug->enter_sub();
1227

  
1228
  my $form     = $main::form;
1229
  my $locale   = $main::locale;
1165 1230

  
1166 1231
  _check_io_auth();
1167 1232

  
1168 1233
  if ($form->{print_nextsub}) {
1169 1234
    call_sub($form->{print_nextsub});
1170
    $lxdebug->leave_sub();
1235
    $main::lxdebug->leave_sub();
1171 1236
    return;
1172 1237
  }
1173 1238

  
1174 1239
  # if this goes to the printer pass through
1240
  my $old_form;
1175 1241
  if ($form->{media} eq 'printer' || $form->{media} eq 'queue') {
1176 1242
    $form->error($locale->text('Select postscript or PDF!'))
1177 1243
      if ($form->{format} !~ /(postscript|pdf)/);
......
1194 1260

  
1195 1261
  &print_form($old_form);
1196 1262

  
1197
  $lxdebug->leave_sub();
1263
  $main::lxdebug->leave_sub();
1198 1264
}
1199 1265

  
1200 1266
sub print_form {
1201
  $lxdebug->enter_sub();
1267
  $main::lxdebug->enter_sub();
1268

  
1269
  my $form     = $main::form;
1270
  my %myconfig = %main::myconfig;
1271
  my $locale   = $main::locale;
1202 1272

  
1203 1273
  _check_io_auth();
1204 1274

  
1205 1275
  my ($old_form) = @_;
1206 1276

  
1207
  $inv       = "inv";
1208
  $due       = "due";
1209
  $numberfld = "invnumber";
1277
  my $inv       = "inv";
1278
  my $due       = "due";
1279
  my $numberfld = "invnumber";
1280
  my $order;
1210 1281

  
1211
  $display_form =
1282
  my $display_form =
1212 1283
    ($form->{display_form}) ? $form->{display_form} : "display_form";
1213 1284

  
1214 1285
  # $form->{"notes"} will be overridden by the customer's/vendor's "notes" field. So save it here.
......
1361 1432
  my ($saved_email, $saved_cc, $saved_bcc) =
1362 1433
    ($form->{"email"}, $form->{"cc"}, $form->{"bcc"});
1363 1434

  
1364
  $language_saved = $form->{language_id};
1365
  $payment_id_saved = $form->{payment_id};
1366
  $salesman_id_saved = $form->{salesman_id};
1367
  $cp_id_saved = $form->{cp_id};
1435
  my $language_saved = $form->{language_id};
1436
  my $payment_id_saved = $form->{payment_id};
1437
  my $salesman_id_saved = $form->{salesman_id};
1438
  my $cp_id_saved = $form->{cp_id};
1368 1439

  
1369 1440
  call_sub("$form->{vc}_details") if ($form->{vc});
1370 1441

  
......
1410 1481
    $form->get_shipto(\%myconfig);
1411 1482
  }
1412 1483

  
1413
  @a = qw(name street zipcode city country contact);
1484
  my @a = qw(name street zipcode city country contact);
1414 1485

  
1415
  $shipto = 1;
1486
  my $shipto = 1;
1416 1487

  
1417 1488
  # if there is no shipto fill it in from billto
1418
  foreach $item (@a) {
1489
  foreach my $item (@a) {
1419 1490
    if ($form->{"shipto$item"}) {
1420 1491
      $shipto = 0;
1421 1492
      last;
......
1527 1598
    $form->{printed} .= " $form->{formname}";
1528 1599
    $form->{printed} =~ s/^ //;
1529 1600
  }
1530
  $printed = $form->{printed};
1601
  my $printed = $form->{printed};
1531 1602

  
1532 1603
  if ($form->{media} eq 'email') {
1533 1604
    $form->{subject} = qq|$form->{label} $form->{"${inv}number"}|
......
1536 1607
    $form->{emailed} .= " $form->{formname}";
1537 1608
    $form->{emailed} =~ s/^ //;
1538 1609
  }
1539
  $emailed = $form->{emailed};
1610
  my $emailed = $form->{emailed};
1540 1611

  
1541 1612
  if ($form->{media} eq 'queue') {
1542
    %queued = map { s|.*/|| } split / /, $form->{queued};
1613
    my %queued = map { s|.*/|| } split / /, $form->{queued};
1543 1614

  
1615
    my $filename;
1544 1616
    if ($filename = $queued{ $form->{formname} }) {
1545 1617
      $form->{queued} =~ s/\Q$form->{formname} $filename\E//;
1546
      unlink "$spool/$filename";
1618
      unlink "$main::spool/$filename";
1547 1619
      $filename =~ s/\..*$//g;
1548 1620
    } else {
1549 1621
      $filename = time;
......
1551 1623
    }
1552 1624

  
1553 1625
    $filename .= ($form->{postscript}) ? '.ps' : '.pdf';
1554
    $form->{OUT} = ">$spool/$filename";
1626
    $form->{OUT} = ">$main::spool/$filename";
1555 1627

  
1556 1628
    # add type
1557 1629
    $form->{queued} .= " $form->{formname} $filename";
1558 1630

  
1559 1631
    $form->{queued} =~ s/^ //;
1560 1632
  }
1561
  $queued = $form->{queued};
1633
  my $queued = $form->{queued};
1562 1634

  
1563 1635
# saving the history
1564 1636
  if(!exists $form->{addition}) {
......
1579 1651
  }
1580 1652
  # /saving the history
1581 1653

  
1582
  $form->parse_template(\%myconfig, $userspath);
1654
  $form->parse_template(\%myconfig, $main::userspath);
1583 1655

  
1584 1656
  $form->{callback} = "";
1585 1657

  
1586 1658
  if ($form->{media} eq 'email') {
1587 1659
    $form->{message} = $locale->text('sent') unless $form->{message};
1588 1660
  }
1589
  $message = $form->{message};
1661
  my $message = $form->{message};
1590 1662

  
1591 1663
  # if we got back here restore the previous form
1592 1664
  if ($form->{media} =~ /(printer|email|queue)/) {
......
1594 1666
    $form->update_status(\%myconfig)
1595 1667
      if ($form->{media} eq 'queue' && $form->{id});
1596 1668

  
1597
    return $lxdebug->leave_sub() if ($old_form eq "return");
1669
    return $main::lxdebug->leave_sub() if ($old_form eq "return");
1598 1670

  
1599 1671
    if ($old_form) {
1600 1672

  
......
1612 1684
      map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1613 1685
        qw(exchangerate creditlimit creditremaining);
1614 1686

  
1615
      for $i (1 .. $form->{paidaccounts}) {
1687
      for my $i (1 .. $form->{paidaccounts}) {
1616 1688
        map {
1617 1689
          $form->{"${_}_$i"} =
1618 1690
            $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
......
1623 1695
      exit;
1624 1696
    }
1625 1697

  
1626
    $msg =
1698
    my $msg =
1627 1699
      ($form->{media} eq 'printer')
1628 1700
      ? $locale->text('sent to printer')
1629 1701
      : $locale->text('emailed to') . " $form->{email}";
......
1634 1706
   exit;
1635 1707
  }
1636 1708

  
1637
  $lxdebug->leave_sub();
1709
  $main::lxdebug->leave_sub();
1638 1710
}
1639 1711

  
1640 1712
sub customer_details {
1641
  $lxdebug->enter_sub();
1713
  $main::lxdebug->enter_sub();
1714

  
1715
  my $form     = $main::form;
1716
  my %myconfig = %main::myconfig;
1642 1717

  
1643 1718
  IS->customer_details(\%myconfig, \%$form, @_);
1644 1719

  
1645
  $lxdebug->leave_sub();
1720
  $main::lxdebug->leave_sub();
1646 1721
}
1647 1722

  
1648 1723
sub vendor_details {
1649
  $lxdebug->enter_sub();
1724
  $main::lxdebug->enter_sub();
1725

  
1726
  my $form     = $main::form;
1727
  my %myconfig = %main::myconfig;
1650 1728

  
1651 1729
  IR->vendor_details(\%myconfig, \%$form, @_);
1652 1730

  
1653
  $lxdebug->leave_sub();
1731
  $main::lxdebug->leave_sub();
1654 1732
}
1655 1733

  
1656 1734
sub post_as_new {
1657
  $lxdebug->enter_sub();
1735
  $main::lxdebug->enter_sub();
1736

  
1737
  my $form     = $main::form;
1658 1738

  
1659 1739
  _check_io_auth();
1660 1740

  
......
1663 1743

  
1664 1744
  &post;
1665 1745

  
1666
  $lxdebug->leave_sub();
1746
  $main::lxdebug->leave_sub();
1667 1747
}
1668 1748

  
1669 1749
sub ship_to {
1670
  $lxdebug->enter_sub();
1750
  $main::lxdebug->enter_sub();
1751

  
1752
  my $form     = $main::form;
1753
  my %myconfig = %main::myconfig;
1754
  my $locale   = $main::locale;
1755
  my $cgi      = $main::cgi;
1671 1756

  
1672 1757
  _check_io_auth();
1673 1758

  
......
1675 1760
    $form->{print_and_post} = 0;
1676 1761
  }
1677 1762

  
1678
  $title = $form->{title};
1763
  my $title = $form->{title};
1679 1764
  $form->{title} = $locale->text('Ship to');
1680 1765

  
1681 1766
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
......
1693 1778
  # get details for name
1694 1779
  call_sub("$form->{vc}_details", @addr_vars);
1695 1780

  
1696
  $number =
1781
  my $number =
1697 1782
    ($form->{vc} eq 'customer')
1698 1783
    ? $locale->text('Customer Number')
1699 1784
    : $locale->text('Vendor Number');
......
1704 1789
  # build up html code for prices_$i
1705 1790
  set_pricegroup($form->{rowcount});
1706 1791

  
1707
  $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1792
  my $nextsub = ($form->{display_form}) ? $form->{display_form} : "display_form";
1708 1793

  
1709 1794
  $form->{rowcount}--;
1710 1795

  
......
1798 1883
  map({ delete $form->{$_} } (@shipto_vars, qw(header)));
1799 1884
  $form->{title} = $title;
1800 1885

  
1801
  foreach $key (keys %$form) {
1886
  foreach my $key (keys %$form) {
1802 1887
    next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
1803 1888
    $form->{$key} =~ s/\"/&quot;/g;
1804 1889
    print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
......
1817 1902
</html>
1818 1903
|;
1819 1904

  
1820
  $lxdebug->leave_sub();
1905
  $main::lxdebug->leave_sub();
1821 1906
}
1822 1907

  
1823 1908
sub new_license {
1824
  $lxdebug->enter_sub();
1909
  $main::lxdebug->enter_sub();
1910

  
1911
  my $form     = $main::form;
1825 1912

  
1826 1913
  _check_io_auth();
1827 1914

  
......
1834 1921

  
1835 1922
  # delete action
1836 1923
  delete $form->{action};
1837
  $customer = $form->{customer};
1924
  my $customer = $form->{customer};
1838 1925
  map { $form->{"old_$_"} = $form->{"${_}_$row"} } qw(partnumber description);
1839 1926

  
1840 1927
  # save all other form variables in a previousform variable
1841 1928
  $form->{row} = $row;
1842
  foreach $key (keys %$form) {
1929
  my $previousform;
1930
  foreach my $key (keys %$form) {
1843 1931
    next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
1844 1932

  
1845 1933
    # escape ampersands
......
1851 1939

  
1852 1940
  $form->{script} = "licenses.pl";
1853 1941

  
1942
  our $name;
1943

  
1854 1944
  map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description);
1855 1945
  map { $form->{$_} = $form->escape($form->{$_}, 1) }
1856 1946
    qw(partnumber description);
......
1858 1948
    qq|$form->{script}?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|;
1859 1949
  $form->redirect;
1860 1950

  
1861
  $lxdebug->leave_sub();
1951
  $main::lxdebug->leave_sub();
1862 1952
}
1863 1953

  
1864 1954
sub relink_accounts {
1865
  $lxdebug->enter_sub();
1955
  $main::lxdebug->enter_sub();
1956

  
1957
  my $form     = $main::form;
1958
  my %myconfig = %main::myconfig;
1866 1959

  
1867 1960
  _check_io_auth();
1868 1961

  
......
1879 1972
    }
1880 1973
  }
1881 1974

  
1882
  $lxdebug->leave_sub();
1975
  $main::lxdebug->leave_sub();
1883 1976
}
1884 1977

  
1885 1978
sub set_duedate {
1886
  $lxdebug->enter_sub();
1979
  $main::lxdebug->enter_sub();
1980

  
1981
  my $form     = $main::form;
1982
  my %myconfig = %main::myconfig;
1887 1983

  
1888 1984
  _check_io_auth();
1889 1985

  
......
1892 1988

  
1893 1989
  print $form->ajax_response_header() . $duedate;
1894 1990

  
1895
  $lxdebug->leave_sub();
1991
  $main::lxdebug->leave_sub();
1896 1992
}
1897 1993

  
1898 1994
sub _update_part_information {
1899
  $lxdebug->enter_sub();
1995
  $main::lxdebug->enter_sub();
1996

  
1997
  my $form     = $main::form;
1900 1998

  
1901 1999
  my %part_information = IC->get_basic_part_info('id'        => [ grep { $_ } map { $form->{"id_${_}"} } (1..$form->{rowcount}) ],
1902 2000
                                                 'vendor_id' => $form->{vendor_id});
......
1910 2008
    $form->{"partunit_${i}"} = $info->{unit};
1911 2009
  }
1912 2010

  
1913
  $lxdebug->leave_sub();
2011
  $main::lxdebug->leave_sub();
1914 2012
}
1915 2013

  
1916 2014
sub _update_ship {
1917
  $lxdebug->enter_sub();
2015
  $main::lxdebug->enter_sub();
2016

  
2017
  my $form     = $main::form;
2018
  my %myconfig = %main::myconfig;
1918 2019

  
1919 2020
  if (!$form->{ordnumber} || !$form->{id}) {
1920 2021
    map { $form->{"ship_$_"} = 0 } (1..$form->{rowcount});
1921
    $lxdebug->leave_sub();
2022
    $main::lxdebug->leave_sub();
1922 2023
    return;
1923 2024
  }
1924 2025

  
1925
  AM->retrieve_all_units();
2026
  my $all_units = AM->retrieve_all_units();
1926 2027

  
1927 2028
  my %ship = DO->get_shipped_qty('type'  => ($form->{type} eq 'purchase_order') ? 'purchase' : 'sales',
1928 2029
                                 'oe_id' => $form->{id},);
......
1956 2057
    $ship_entry->{qty}  = 0;
1957 2058
  }
1958 2059

  
1959
  $lxdebug->leave_sub();
2060
  $main::lxdebug->leave_sub();
1960 2061
}
1961 2062

  
1962 2063
sub _update_custom_variables {
1963
  $lxdebug->enter_sub();
2064
  $main::lxdebug->enter_sub();
2065

  
2066
  my $form     = $main::form;
1964 2067

  
1965 2068
  $form->{CVAR_CONFIGS}       ||= { };
1966 2069
  $form->{CVAR_CONFIGS}->{IC}   = CVar->get_configs(module => 'IC');
1967 2070

  
1968
  $lxdebug->leave_sub();
2071
  $main::lxdebug->leave_sub();
1969 2072
}
1970 2073

  
1971 2074
sub _render_custom_variables_inputs {
1972
  $lxdebug->enter_sub();
2075
  $main::lxdebug->enter_sub();
2076

  
2077
  my $form     = $main::form;
1973 2078

  
1974 2079
  my %params = @_;
1975 2080

  
1976 2081
  if (!$form->{CVAR_CONFIGS}->{IC}) {
1977
    $lxdebug->leave_sub();
2082
    $main::lxdebug->leave_sub();
1978 2083
    return;
1979 2084
  }
1980 2085

  
......
2004 2109
                             };
2005 2110
  }
2006 2111

  
2007
  $lxdebug->leave_sub();
2112
  $main::lxdebug->leave_sub();
2008 2113
}

Auch abrufbar als: Unified diff