Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 088b52b5

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

  • ID 088b52b58c46f3c8b0f9a795d6ab840ec127cf0d
  • Vorgänger 8f35ef1f
  • Nachfolger 27309ff1

ap strict

Unterschiede anzeigen:

bin/mozilla/ap.pl
46 46
require "bin/mozilla/drafts.pl";
47 47
require "bin/mozilla/reportgenerator.pl";
48 48

  
49
use strict;
50

  
49 51
1;
50 52

  
51 53
# end of main
......
79 81
# $locale->text('Dec')
80 82

  
81 83
sub add {
82
  $lxdebug->enter_sub();
84
  $main::lxdebug->enter_sub();
85

  
86
  my $form     = $main::form;
87
  my %myconfig = %main::myconfig;
83 88

  
84
  $auth->assert('general_ledger');
89
  $main::auth->assert('general_ledger');
85 90

  
86
  return $lxdebug->leave_sub() if (load_draft_maybe());
91
  return $main::lxdebug->leave_sub() if (load_draft_maybe());
87 92

  
88 93
  $form->{title} = "Add";
89 94

  
......
95 100
  $form->{transdate} = $form->{initial_transdate};
96 101
  &display_form;
97 102

  
98
  $lxdebug->leave_sub();
103
  $main::lxdebug->leave_sub();
99 104
}
100 105

  
101 106
sub edit {
102
  $lxdebug->enter_sub();
107
  $main::lxdebug->enter_sub();
108

  
109
  my $form     = $main::form;
103 110

  
104
  $auth->assert('general_ledger');
111
  $main::auth->assert('general_ledger');
105 112

  
106 113
  $form->{title} = "Edit";
107 114

  
108 115
  &create_links;
109 116
  &display_form;
110 117

  
111
  $lxdebug->leave_sub();
118
  $main::lxdebug->leave_sub();
112 119
}
113 120

  
114 121
sub display_form {
115
  $lxdebug->enter_sub();
122
  $main::lxdebug->enter_sub();
116 123

  
117
  $auth->assert('general_ledger');
124
  my $form     = $main::form;
125

  
126
  $main::auth->assert('general_ledger');
118 127

  
119 128
  &form_header;
120 129
  &form_footer;
121 130

  
122
  $lxdebug->leave_sub();
131
  $main::lxdebug->leave_sub();
123 132
}
124 133

  
125 134
sub create_links {
126
  $lxdebug->enter_sub();
135
  $main::lxdebug->enter_sub();
136

  
137
  my $form     = $main::form;
138
  my %myconfig = %main::myconfig;
127 139

  
128
  $auth->assert('general_ledger');
140
  $main::auth->assert('general_ledger');
129 141

  
130 142
  $form->create_links("AP", \%myconfig, "vendor");
131
  $taxincluded = $form->{taxincluded};
132
  $duedate     = $form->{duedate};
143
  my $taxincluded = $form->{taxincluded};
144
  my $duedate     = $form->{duedate};
133 145

  
134 146
  IR->get_vendor(\%myconfig, \%$form);
135 147
  $form->{taxincluded} = $taxincluded;
......
144 156
  $form->{notes} = $form->{intnotes} unless $form->{notes};
145 157

  
146 158
  # currencies
147
  @curr = split(/:/, $form->{currencies});
159
  my @curr = split(/:/, $form->{currencies});
148 160
  chomp $curr[0];
149 161
  $form->{defaultcurrency} = $curr[0];
150 162

  
......
176 188
    ($form->datetonum($form->{transdate}, \%myconfig) <=
177 189
     $form->datetonum($form->{closedto}, \%myconfig));
178 190

  
179
  $lxdebug->leave_sub();
191
  $main::lxdebug->leave_sub();
180 192
}
181 193

  
182 194
sub form_header {
183
  $lxdebug->enter_sub();
195
  $main::lxdebug->enter_sub();
184 196

  
185
  $auth->assert('general_ledger');
197
  my $form     = $main::form;
198
  my %myconfig = %main::myconfig;
199
  my $locale   = $main::locale;
200
  my $cgi      = $main::cgi;
186 201

  
187
  $title = $form->{title};
202
  $main::auth->assert('general_ledger');
203

  
204
  my $title = $form->{title};
188 205
  $form->{title} = $locale->text("$title Accounts Payables Transaction");
189 206

  
190 207
  $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
......
216 233
  #/show hhistory button
217 234

  
218 235
  # set option selected
219
  foreach $item (qw(vendor currency department)) {
236
  foreach my $item (qw(vendor currency department)) {
220 237
    $form->{"select$item"} =~ s/ selected//;
221 238
    $form->{"select$item"} =~
222 239
      s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
223 240
  }
224
  $readonly = ($form->{id}) ? "readonly" : "";
241
  my $readonly = ($form->{id}) ? "readonly" : "";
225 242

  
226 243
  $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
227 244
  $readonly       = ($form->{radier}) ? "" : $readonly;
......
241 258
  $form->{creditremaining} =
242 259
    $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
243 260

  
244
  $exchangerate = qq|
261
  my $exchangerate = qq|
245 262
<input type=hidden name=forex value=$form->{forex}>
246 263
|;
247 264
  if ($form->{currency} ne $form->{defaultcurrency}) {
......
260 277
    }
261 278
  }
262 279

  
263
  $taxincluded = "";
280
  my $taxincluded = "";
264 281

  
265 282
  $taxincluded = qq|
266 283
            <tr>
......
270 287
            </tr>
271 288
|;
272 289

  
290
  my $rows;
273 291
  if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
274 292
    $rows = 2;
275 293
  }
276
  $notes =
294
  my $notes =
277 295
    qq|<textarea name=notes rows=$rows cols=50 wrap=soft $readonly>$form->{notes}</textarea>|;
278 296

  
279
  $department = qq|
297
  my $department = qq|
280 298
              <tr>
281 299
	        <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
282 300
		<td colspan=3><select name=department>$form->{selectdepartment}</select>
......
285 303
	      </tr>
286 304
| if $form->{selectdepartment};
287 305

  
288
  $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
306
  my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
289 307

  
290
  $vendor =
308
  my $vendor =
291 309
    ($form->{selectvendor})
292
    ? qq|<select name="vendor"
293
onchange="document.getElementById('update_button').click();">$form->{
294
selectvendor } </select>|
310
    ? qq|<select name="vendor" onchange="document.getElementById('update_button').click();">$form->{selectvendor} </select>|
295 311
    : qq|<input name=vendor value="$form->{vendor}" size=35>|;
296 312

  
297 313
  my @old_project_ids = ();
......
357 373

  
358 374
  # use JavaScript Calendar or not
359 375
  $form->{jsscript} = 1;
360
  $jsscript = "";
376
  my $jsscript = "";
377
  my ($button1, $button2);
361 378
  if ($form->{jsscript}) {
362 379

  
363 380
    # with JavaScript Calendar
......
394 411
  $form->{javascript} .= qq|<script type="text/javascript" src="js/follow_up.js"></script>|;
395 412

  
396 413
  $form->header;
397
  $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
414
  my $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
398 415
  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
399 416
  print qq|
400 417
<body onLoad="$onload">
......
506 523
	</tr>
507 524
|;
508 525

  
509
  $amount  = $locale->text('Amount');
510
  $project = $locale->text('Project');
526
  my $amount  = $locale->text('Amount');
527
  my $project = $locale->text('Project');
511 528

  
512
  for $i (1 .. $form->{rowcount}) {
529
  for my $i (1 .. $form->{rowcount}) {
513 530

  
514 531
    # format amounts
515 532
    $form->{"amount_$i"} =
......
534 551

  
535 552
    $selected_taxchart = $taxchart_init unless ($form->{"taxchart_$i"});
536 553

  
537
    $selectAP_amount =
554
    my $selectAP_amount =
538 555
      NTI($cgi->popup_menu('-name' => "AP_amount_$i",
539 556
                           '-id' => "AP_amount_$i",
540 557
                           '-style' => 'width:400px',
......
545 562
      . $cgi->hidden('-name' => "previous_AP_amount_$i",
546 563
                     '-default' => $selected_accno_full);
547 564

  
548
    $tax = qq|<td>| .
565
    my $tax = qq|<td>| .
549 566
      NTI($cgi->popup_menu('-name' => "taxchart_$i",
550 567
                           '-id' => "taxchart_$i",
551 568
                           '-style' => 'width:200px',
......
573 590
    $project = "";
574 591
  }
575 592

  
576
  $taxlabel =
593
  my $taxlabel =
577 594
    ($form->{taxincluded})
578 595
    ? $locale->text('Tax Included')
579 596
    : $locale->text('Tax');
......
581 598
  $form->{invtotal_unformatted} = $form->{invtotal};
582 599
  $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
583 600

  
584
  $APselected =
601
  my $APselected =
585 602
    NTI($cgi->popup_menu('-name' => "APselected", '-id' => "APselected",
586 603
                         '-style' => 'width:400px',
587 604
                         '-values' => \@AP_values, '-labels' => \%AP_labels,
......
626 643
	</tr>
627 644
|;
628 645

  
646
  my @column_index;
629 647
  if ($form->{currency} eq $form->{defaultcurrency}) {
630 648
    @column_index = qw(datepaid source memo paid AP_paid paid_project_id);
631 649
  } else {
632 650
    @column_index = qw(datepaid source memo paid exchangerate AP_paid paid_project_id);
633 651
  }
634 652

  
653
  my %column_data;
635 654
  $column_data{datepaid}     = "<th>" . $locale->text('Date') . "</th>";
636 655
  $column_data{paid}         = "<th>" . $locale->text('Amount') . "</th>";
637 656
  $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
......
652 671
  my $totalpaid = 0;
653 672

  
654 673
  $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
655
  for $i (1 .. $form->{paidaccounts}) {
674
  for my $i (1 .. $form->{paidaccounts}) {
656 675
    print "
657 676
        <tr>
658 677
";
659 678

  
660
    $selectAP_paid =
679
    my $selectAP_paid =
661 680
      NTI($cgi->popup_menu('-name' => "AP_paid_$i",
662 681
                           '-id' => "AP_paid_$i",
663 682
                           '-values' => \@AP_paid_values,
......
748 767
</table>
749 768
|;
750 769

  
751
  $lxdebug->leave_sub();
770
  $main::lxdebug->leave_sub();
752 771
}
753 772

  
754 773
sub form_footer {
755
  $lxdebug->enter_sub();
774
  $main::lxdebug->enter_sub();
775

  
776
  my $form     = $main::form;
777
  my %myconfig = %main::myconfig;
778
  my $locale   = $main::locale;
779
  my $cgi      = $main::cgi;
756 780

  
757
  $auth->assert('general_ledger');
781
  $main::auth->assert('general_ledger');
758 782

  
759 783
  my $follow_ups_block;
760 784
  if ($form->{id}) {
......
789 813
          qq|</label><br>|);
790 814
  }
791 815

  
792
  $transdate = $form->datetonum($form->{transdate}, \%myconfig);
793
  $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
816
  my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
817
  my $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
794 818

  
795 819
  print qq|<input class="submit" type="submit" name="action" id="update_button" value="| . $locale->text('Update') . qq|">|;
796 820

  
......
801 825
|;
802 826
    }
803 827
    # ToDO: - insert a global check for stornos, so that a storno is only possible a limited time after saving it
828
    our $total_paid;
804 829
    print qq| <input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|"> |
805 830
      if ($form->{id} && !IS->has_storno(\%myconfig, $form, 'ap') && !IS->is_storno(\%myconfig, $form, 'ap', $form->{id}) && (($total_paid == 0) || ($total_paid eq "")));
806 831

  
......
830 855
</html>
831 856
";
832 857

  
833
  $lxdebug->leave_sub();
858
  $main::lxdebug->leave_sub();
834 859
}
835 860

  
836 861
sub mark_as_paid {
837
  $lxdebug->enter_sub();
862
  $main::lxdebug->enter_sub();
863

  
864
  my $form     = $main::form;
865
  my %myconfig = %main::myconfig;
838 866

  
839
  $auth->assert('general_ledger');
867
  $main::auth->assert('general_ledger');
840 868

  
841 869
  &mark_as_paid_common(\%myconfig,"ap");
842 870

  
843
  $lxdebug->leave_sub();
871
  $main::lxdebug->leave_sub();
844 872
}
845 873

  
846 874
sub update {
847
  $lxdebug->enter_sub();
875
  $main::lxdebug->enter_sub();
848 876

  
849
  $auth->assert('general_ledger');
877
  my $form     = $main::form;
878
  my %myconfig = %main::myconfig;
879

  
880
  $main::auth->assert('general_ledger');
850 881

  
851 882
  my $display = shift;
852 883

  
......
857 888
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
858 889
    qw(exchangerate creditlimit creditremaining);
859 890

  
860
  @flds  = qw(amount AP_amount projectnumber oldprojectnumber project_id taxchart);
861
  $count = 0;
862
  for $i (1 .. $form->{rowcount}) {
891
  my @flds  = qw(amount AP_amount projectnumber oldprojectnumber project_id taxchart);
892
  my $count = 0;
893
  my (@a, $j, $totaltax);
894
  for my $i (1 .. $form->{rowcount}) {
863 895
    $form->{"amount_$i"} =
864 896
      $form->parse_amount(\%myconfig, $form->{"amount_$i"});
865 897
    $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
866 898
    if ($form->{"amount_$i"}) {
867 899
      push @a, {};
868 900
      $j = $#a;
869
      ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
901
      my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
870 902
      if ($taxkey > 1) {
871 903
        if ($form->{taxincluded}) {
872 904
          $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
......
907 939
  $form->{invtotal} =
908 940
    ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
909 941

  
910
  for $i (1 .. $form->{paidaccounts}) {
942
  my $totalpaid;
943
  for my $i (1 .. $form->{paidaccounts}) {
911 944
    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
912 945
      map {
913 946
        $form->{"${_}_$i"} =
......
932 965

  
933 966
  &display_form;
934 967

  
935
  $lxdebug->leave_sub();
968
  $main::lxdebug->leave_sub();
936 969
}
937 970

  
938 971

  
939 972
sub post_payment {
940
  $lxdebug->enter_sub();
973
  $main::lxdebug->enter_sub();
974

  
975
  my $form     = $main::form;
976
  my %myconfig = %main::myconfig;
977
  my $locale   = $main::locale;
941 978

  
942
  $auth->assert('general_ledger');
979
  $main::auth->assert('general_ledger');
943 980

  
944 981
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
945 982

  
946
  for $i (1 .. $form->{paidaccounts}) {
983
  our $invdate;
984
  for my $i (1 .. $form->{paidaccounts}) {
947 985
    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
948
      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
986
      my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
949 987

  
950 988
      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
951 989

  
......
968 1006
    $form->error($locale->text('Cannot post payment!'));
969 1007

  
970 1008

  
971
  $lxdebug->leave_sub();
1009
  $main::lxdebug->leave_sub();
972 1010
}
973 1011

  
974 1012

  
975 1013
sub post {
976
  $lxdebug->enter_sub();
1014
  $main::lxdebug->enter_sub();
977 1015

  
978
  $auth->assert('general_ledger');
1016
  my $form     = $main::form;
1017
  my %myconfig = %main::myconfig;
1018
  my $locale   = $main::locale;
1019

  
1020
  $main::auth->assert('general_ledger');
979 1021

  
980 1022
  # check if there is a vendor, invoice and due date
981 1023
  $form->isblank("transdate", $locale->text("Invoice Date missing!"));
982 1024
  $form->isblank("duedate",   $locale->text("Due Date missing!"));
983 1025
  $form->isblank("vendor",    $locale->text('Vendor missing!'));
984 1026

  
985
  $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
986
  $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1027
  my $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
1028
  my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
987 1029
  $form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig));
988 1030

  
989 1031
  my $zero_amount_posting = 1;
990
  for $i (1 .. $form->{rowcount}) {
1032
  for my $i (1 .. $form->{rowcount}) {
991 1033
    if ($form->parse_amount(\%myconfig, $form->{"amount_$i"})) {
992 1034
      $zero_amount_posting = 0;
993 1035
      last;
......
1000 1042
    if ($form->{currency} ne $form->{defaultcurrency});
1001 1043
  delete($form->{AP});
1002 1044

  
1003
  for $i (1 .. $form->{paidaccounts}) {
1045
  for my $i (1 .. $form->{paidaccounts}) {
1004 1046
    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1005
      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1047
      my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1006 1048

  
1007 1049
      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1008 1050

  
......
1020 1062
  }
1021 1063

  
1022 1064
  # if old vendor ne vendor redo form
1023
  ($vendor) = split /--/, $form->{vendor};
1065
  my ($vendor) = split /--/, $form->{vendor};
1024 1066
  if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
1025 1067
    &update;
1026 1068
    exit;
1027 1069
  }
1028
  ($debitaccno,    $debittaxkey)    = split /--/, $form->{AP_amountselected};
1029
  ($taxkey,        $NULL)           = split /--/, $form->{taxchartselected};
1030
  ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
1070
  my ($debitaccno,    $debittaxkey)    = split /--/, $form->{AP_amountselected};
1071
  my ($taxkey,        $NULL)           = split /--/, $form->{taxchartselected};
1072
  my ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
1031 1073
  $form->{AP}{amount_1} = $debitaccno;
1032 1074
  $form->{AP}{payables} = $payablesaccno;
1033 1075
  $form->{taxkey}       = $taxkey;
......
1048 1090
  }
1049 1091
  $form->error($locale->text('Cannot post transaction!'));
1050 1092

  
1051
  $lxdebug->leave_sub();
1093
  $main::lxdebug->leave_sub();
1052 1094
}
1053 1095

  
1054 1096
sub post_as_new {
1055
  $lxdebug->enter_sub();
1097
  $main::lxdebug->enter_sub();
1098

  
1099
  my $form     = $main::form;
1100
  my %myconfig = %main::myconfig;
1056 1101

  
1057
  $auth->assert('general_ledger');
1102
  $main::auth->assert('general_ledger');
1058 1103

  
1059 1104
  $form->{postasnew} = 1;
1060 1105
  # saving the history
......
1066 1111
  # /saving the history
1067 1112
  &post;
1068 1113

  
1069
  $lxdebug->leave_sub();
1114
  $main::lxdebug->leave_sub();
1070 1115
}
1071 1116

  
1072 1117
sub use_as_template {
1073
  $lxdebug->enter_sub();
1118
  $main::lxdebug->enter_sub();
1119

  
1120
  my $form     = $main::form;
1121
  my %myconfig = %main::myconfig;
1074 1122

  
1075
  $auth->assert('general_ledger');
1123
  $main::auth->assert('general_ledger');
1076 1124

  
1077 1125
  map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
1078 1126
  $form->{paidaccounts} = 1;
......
1080 1128
  $form->{invdate} = $form->current_date(\%myconfig);
1081 1129
  &update;
1082 1130

  
1083
  $lxdebug->leave_sub();
1131
  $main::lxdebug->leave_sub();
1084 1132
}
1085 1133

  
1086 1134
sub delete {
1087
  $lxdebug->enter_sub();
1135
  $main::lxdebug->enter_sub();
1088 1136

  
1089
  $auth->assert('general_ledger');
1137
  my $form     = $main::form;
1138
  my $locale   = $main::locale;
1139

  
1140
  $main::auth->assert('general_ledger');
1090 1141

  
1091 1142
  $form->{title} = $locale->text('Confirm!');
1092 1143

  
......
1100 1151
<form method=post action=$form->{script}>
1101 1152
|;
1102 1153

  
1103
  foreach $key (keys %$form) {
1154
  foreach my $key (keys %$form) {
1104 1155
    next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
1105 1156
    $form->{$key} =~ s/\"/&quot;/g;
1106 1157
    print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
......
1121 1172
</html>
1122 1173
|;
1123 1174

  
1124
  $lxdebug->leave_sub();
1175
  $main::lxdebug->leave_sub();
1125 1176
}
1126 1177

  
1127 1178
sub yes {
1128
  $lxdebug->enter_sub();
1179
  $main::lxdebug->enter_sub();
1180

  
1181
  my $form     = $main::form;
1182
  my %myconfig = %main::myconfig;
1183
  my $locale   = $main::locale;
1129 1184

  
1130
  $auth->assert('general_ledger');
1185
  $main::auth->assert('general_ledger');
1131 1186

  
1132
  if (AP->delete_transaction(\%myconfig, \%$form, $spool)) {
1187
  if (AP->delete_transaction(\%myconfig, \%$form, $main::spool)) {
1133 1188
    # saving the history
1134 1189
    if(!exists $form->{addition}) {
1135 1190
      $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
......
1141 1196
  }
1142 1197
  $form->error($locale->text('Cannot delete transaction!'));
1143 1198

  
1144
  $lxdebug->leave_sub();
1199
  $main::lxdebug->leave_sub();
1145 1200
}
1146 1201

  
1147 1202
sub search {
1148
  $lxdebug->enter_sub();
1203
  $main::lxdebug->enter_sub();
1149 1204

  
1150
  $auth->assert('general_ledger | vendor_invoice_edit');
1205
  my $form     = $main::form;
1206
  my %myconfig = %main::myconfig;
1207
  my $locale   = $main::locale;
1208
  my $cgi      = $main::cgi;
1209

  
1210
  $main::auth->assert('general_ledger | vendor_invoice_edit');
1151 1211

  
1152 1212
  # setup vendor selection
1153 1213
  $form->all_vc(\%myconfig, "vendor", "AP");
1154 1214

  
1215
  my $vendor;
1155 1216
  if (@{ $form->{all_vendor} }) {
1156 1217
    map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
1157 1218
      @{ $form->{all_vendor} };
......
1170 1231
    } (@{ $form->{all_departments} });
1171 1232
  }
1172 1233

  
1173
  $department = qq|
1234
  my $department = qq|
1174 1235
	<tr>
1175 1236
	  <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1176 1237
	  <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
......
1181 1242

  
1182 1243
  # use JavaScript Calendar or not
1183 1244
  $form->{jsscript} = 1;
1184
  $jsscript = "";
1245
  my $jsscript = "";
1246
  my ($button1, $button2);
1185 1247
  if ($form->{jsscript}) {
1186 1248

  
1187 1249
    # with JavaScript Calendar
......
1223 1285
                         '-labels' => \%labels));
1224 1286
  $form->{javascript} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
1225 1287
  $form->header;
1226
  $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
1288
  my $onload = qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
1227 1289
  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
1228 1290
  print qq|
1229 1291
<body onLoad="$onload">
......
1369 1431
</html>
1370 1432
|;
1371 1433

  
1372
  $lxdebug->leave_sub();
1434
  $main::lxdebug->leave_sub();
1373 1435
}
1374 1436

  
1375 1437
sub create_subtotal_row {
1376
  $lxdebug->enter_sub();
1438
  $main::lxdebug->enter_sub();
1377 1439

  
1378 1440
  my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_;
1379 1441

  
1442
  my $form     = $main::form;
1443
  my %myconfig = %main::myconfig;
1444

  
1380 1445
  my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
1381 1446

  
1382 1447
  map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns };
......
1385 1450

  
1386 1451
  map { $totals->{$_} = 0 } @{ $subtotal_columns };
1387 1452

  
1388
  $lxdebug->leave_sub();
1453
  $main::lxdebug->leave_sub();
1389 1454

  
1390 1455
  return $row;
1391 1456
}
1392 1457

  
1393 1458
sub ap_transactions {
1394
  $lxdebug->enter_sub();
1459
  $main::lxdebug->enter_sub();
1395 1460

  
1396
  $auth->assert('general_ledger | vendor_invoice_edit');
1461
  my $form     = $main::form;
1462
  my %myconfig = %main::myconfig;
1463
  my $locale   = $main::locale;
1464

  
1465
  $main::auth->assert('general_ledger | vendor_invoice_edit');
1397 1466

  
1398 1467
  ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
1399 1468

  
......
1482 1551
  $form->{callback} = $href .= "&sort=$form->{sort}";
1483 1552

  
1484 1553
  # escape callback for href
1485
  $callback = $form->escape($href);
1554
  my $callback = $form->escape($href);
1486 1555

  
1487 1556
  my @subtotal_columns = qw(netamount amount paid due);
1488 1557

  
......
1491 1560

  
1492 1561
  my $idx = 0;
1493 1562

  
1494
  foreach $ap (@{ $form->{AP} }) {
1563
  foreach my $ap (@{ $form->{AP} }) {
1495 1564
    $ap->{tax} = $ap->{amount} - $ap->{netamount};
1496 1565
    $ap->{due} = $ap->{amount} - $ap->{paid};
1497 1566

  
......
1545 1614

  
1546 1615
  $report->generate_with_headers();
1547 1616

  
1548
  $lxdebug->leave_sub();
1617
  $main::lxdebug->leave_sub();
1549 1618
}
1550 1619

  
1551 1620
sub storno {
1552
  $lxdebug->enter_sub();
1621
  $main::lxdebug->enter_sub();
1622

  
1623
  my $form     = $main::form;
1624
  my %myconfig = %main::myconfig;
1625
  my $locale   = $main::locale;
1553 1626

  
1554
  $auth->assert('general_ledger');
1627
  $main::auth->assert('general_ledger');
1555 1628

  
1556 1629
  if (IS->has_storno(\%myconfig, $form, 'ap')) {
1557 1630
    $form->{title} = $locale->text("Cancel Accounts Payables Transaction");
......
1570 1643

  
1571 1644
  $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id});
1572 1645

  
1573
  $lxdebug->leave_sub();
1646
  $main::lxdebug->leave_sub();
1574 1647
}

Auch abrufbar als: Unified diff