1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  16 # This program is free software; you can redistribute it and/or modify
 
  17 # it under the terms of the GNU General Public License as published by
 
  18 # the Free Software Foundation; either version 2 of the License, or
 
  19 # (at your option) any later version.
 
  21 # This program is distributed in the hope that it will be useful,
 
  22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  24 # GNU General Public License for more details.
 
  25 # You should have received a copy of the GNU General Public License
 
  26 # along with this program; if not, write to the Free Software
 
  27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  28 #======================================================================
 
  32 #======================================================================
 
  38 require "$form->{path}/arap.pl";
 
  44 # this is for our long dates
 
  45 # $locale->text('January')
 
  46 # $locale->text('February')
 
  47 # $locale->text('March')
 
  48 # $locale->text('April')
 
  49 # $locale->text('May ')
 
  50 # $locale->text('June')
 
  51 # $locale->text('July')
 
  52 # $locale->text('August')
 
  53 # $locale->text('September')
 
  54 # $locale->text('October')
 
  55 # $locale->text('November')
 
  56 # $locale->text('December')
 
  58 # this is for our short month
 
  59 # $locale->text('Jan')
 
  60 # $locale->text('Feb')
 
  61 # $locale->text('Mar')
 
  62 # $locale->text('Apr')
 
  63 # $locale->text('May')
 
  64 # $locale->text('Jun')
 
  65 # $locale->text('Jul')
 
  66 # $locale->text('Aug')
 
  67 # $locale->text('Sep')
 
  68 # $locale->text('Oct')
 
  69 # $locale->text('Nov')
 
  70 # $locale->text('Dec')
 
  73   $lxdebug->enter_sub();
 
  75   $form->{title} = "Add";
 
  78     "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  79     unless $form->{callback};
 
  84   $lxdebug->leave_sub();
 
  88   $lxdebug->enter_sub();
 
  90   $form->{title} = "Edit";
 
  95   $lxdebug->leave_sub();
 
  99   $lxdebug->enter_sub();
 
 104   $lxdebug->leave_sub();
 
 108   $lxdebug->enter_sub();
 
 110   $form->create_links("AP", \%myconfig, "vendor");
 
 111   $taxincluded = $form->{taxincluded};
 
 112   $duedate     = $form->{duedate};
 
 114   IR->get_vendor(\%myconfig, \%$form);
 
 116   $form->{duedate}   = $duedate if $duedate;
 
 117   $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
 
 118   $form->{rowcount}  = 1;
 
 120   # build the popup menus
 
 121   $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
 
 125       qq|<option value=\"$_->{taxkey}--$_->{rate}\">$_->{taxdescription}  |
 
 126       . ($_->{rate} * 100) . qq| %|
 
 128   $form->{taxchart}       = $tax;
 
 129   $form->{selecttaxchart} = $tax;
 
 132   @curr = split /:/, $form->{currencies};
 
 134   $form->{defaultcurrency} = $curr[0];
 
 136   map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
 
 139   if (@{ $form->{all_vendor} }) {
 
 140     $form->{vendor} = qq|$form->{vendor}--$form->{vendor_id}|;
 
 141     map { $form->{selectvendor} .= "<option>$_->{name}--$_->{id}\n" }
 
 142       (@{ $form->{all_vendor} });
 
 146   if (@{ $form->{all_departments} }) {
 
 147     $form->{selectdepartment} = "<option>\n";
 
 148     $form->{department}       = "$form->{department}--$form->{department_id}";
 
 151       $form->{selectdepartment} .=
 
 152         "<option>$_->{description}--$_->{id}\n"
 
 153     } (@{ $form->{all_departments} });
 
 156   $form->{employee} = "$form->{employee}--$form->{employee_id}";
 
 159   $form->{forex} = $form->{exchangerate};
 
 160   $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
 
 162   foreach $key (keys %{ $form->{AP_links} }) {
 
 163     foreach $ref (@{ $form->{AP_links}{$key} }) {
 
 164       if ($key eq "AP_paid") {
 
 165         $form->{"select$key"} .=
 
 166           "<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
 
 168         $form->{"select$key"} .=
 
 169           "<option value=\"$ref->{accno}--$ref->{taxkey}\">$ref->{accno}--$ref->{description}</option>\n";
 
 173     $form->{$key} = $form->{"select$key"};
 
 175     # if there is a value we have an old entry
 
 179     for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
 
 181       if ($key eq "AP_paid") {
 
 183         $form->{"AP_paid_$j"} =
 
 184           "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
 
 185         $form->{"paid_$j"}     = $form->{acc_trans}{$key}->[$i - 1]->{amount};
 
 186         $form->{"datepaid_$j"} =
 
 187           $form->{acc_trans}{$key}->[$i - 1]->{transdate};
 
 188         $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
 
 189         $form->{"memo_$j"}   = $form->{acc_trans}{$key}->[$i - 1]->{memo};
 
 191         $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
 
 192           $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
 
 193         $form->{"AP_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
 
 194         $form->{paidaccounts}++;
 
 200         if (($key eq "AP_tax") || ($key eq "AR_tax")) {
 
 201           $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
 
 202             "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
 
 203           $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
 
 205                   $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
 
 208           if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
 
 210               $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
 
 212               $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
 
 215               $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
 
 217               $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
 
 219           $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
 
 220           $form->{"tax_$index"} =
 
 221             $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
 
 222           $totaltax += $form->{"tax_$index"};
 
 226           $form->{"${akey}_$k"} =
 
 228                   $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
 
 230           if ($akey eq 'amount') {
 
 232             $form->{"${akey}_$i"} *= -1;
 
 233             $totalamount += $form->{"${akey}_$i"};
 
 234             $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
 
 235             $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
 
 236               "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
 
 237             $form->{"project_id_$k"} =
 
 238               "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
 
 240           $form->{"${key}_$k"} =
 
 241             "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
 
 242           $form->{"select${key}"} =~
 
 243             /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}<\/option>\n/;
 
 245           $form->{"${key}_$k"} = $1;
 
 246           if ($akey eq 'amount') {
 
 247             $form->{"taxchart_$k"} = $form->{taxchart};
 
 248             $form->{"taxchart_$k"} =~
 
 249               /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{taxkey}--[^\"]*)/;
 
 250             $form->{"taxchart_$k"} = $1;
 
 257   $form->{taxincluded}  = $taxincluded if ($form->{id});
 
 258   $form->{paidaccounts} = 1            if not defined $form->{paidaccounts};
 
 260   if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
 
 262     # add tax to amounts and invtotal
 
 263     for $i (1 .. $form->{rowcount}) {
 
 265         ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
 
 266       $tax = $form->round_amount($taxamount, 2);
 
 267       $diff                += ($taxamount - $tax);
 
 268       $form->{"amount_$i"} += $form->{"tax_$i"};
 
 270     $form->{amount_1} += $form->round_amount($diff, 2);
 
 273   $taxamount = $form->round_amount($taxamount, 2);
 
 275   $form->{invtotal} = $totalamount + $totaltax;
 
 278     ($form->datetonum($form->{transdate}, \%myconfig) <=
 
 279      $form->datetonum($form->{closedto}, \%myconfig));
 
 281   $lxdebug->leave_sub();
 
 285   $lxdebug->enter_sub();
 
 287   $title = $form->{title};
 
 288   $form->{title} = $locale->text("$title Accounts Payables Transaction");
 
 290   $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
 
 292   # type=submit $locale->text('Add Accounts Payables Transaction')
 
 293   # type=submit $locale->text('Edit Accounts Payables Transaction')
 
 295   $form->{javascript} = qq|<script type="text/javascript">
 
 297   function setTaxkey(accno, row) {
 
 298     var taxkey = accno.options[accno.selectedIndex].value;
 
 299     var reg = /--([0-9])*/;
 
 300     var found = reg.exec(taxkey);
 
 301     var index = found[1];
 
 302     index = parseInt(index);
 
 303     var tax = 'taxchart_' + row;
 
 304     for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
 
 305       var reg2 = new RegExp("^"+ index, "");
 
 306       if (reg2.exec(document.getElementById(tax).options[i].value)) {
 
 307         document.getElementById(tax).options[i].selected = true;
 
 315   # set option selected
 
 316   foreach $item (qw(vendor currency department)) {
 
 317     $form->{"select$item"} =~ s/ selected//;
 
 318     $form->{"select$item"} =~
 
 319       s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
 
 321   $readonly = ($form->{id}) ? "readonly" : "";
 
 324     ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
 
 325   $readonly                 = ($form->{radier}) ? "" : $readonly;
 
 326   $selectAP_amount_unquoted = $form->{selectAP_amount};
 
 327   $taxchart                 = $form->{taxchart};
 
 328   map { $form->{$_} =~ s/\"/"/g }
 
 329     qw(AP_amount selectAP_amount AP taxchart);
 
 332   $form->{exchangerate} =
 
 333     $form->format_amount(\%myconfig, $form->{exchangerate});
 
 335   $form->{creditlimit} =
 
 336     $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
 
 337   $form->{creditremaining} =
 
 338     $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
 
 341 <input type=hidden name=forex value=$form->{forex}>
 
 343   if ($form->{currency} ne $form->{defaultcurrency}) {
 
 344     if ($form->{forex}) {
 
 347               <th align=right>| . $locale->text('Exchangerate') . qq|</th>
 
 348               <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
 
 353              <th align=right>| . $locale->text('Exchangerate') . qq|</th>
 
 354              <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
 
 363               <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
 
 364               <th align=left nowrap>|
 
 365     . $locale->text('Tax Included') . qq|</th>
 
 369   if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
 
 373     qq|<textarea name=notes rows=$rows cols=50 wrap=soft $readonly>$form->{notes}</textarea>|;
 
 377                 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
 
 378                 <td colspan=3><select name=department>$form->{selectdepartment}</select>
 
 379                 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
 
 382 | if $form->{selectdepartment};
 
 384   $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
 
 387     ($form->{selectvendor})
 
 388     ? qq|<select name=vendor>$form->{selectvendor}</select>|
 
 389     : qq|<input name=vendor value="$form->{vendor}" size=35>|;
 
 391   # use JavaScript Calendar or not
 
 392   $form->{jsscript} = $jscalendar;
 
 394   if ($form->{jsscript}) {
 
 396     # with JavaScript Calendar
 
 398        <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}> $readonly</td>
 
 399        <td><input type=button name=transdate id="trigger1" value=|
 
 400       . $locale->text('button') . qq|></td>
 
 403        <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}> $readonly</td>
 
 404        <td><input type=button name=duedate id="trigger2" value=|
 
 405       . $locale->text('button') . qq|></td></td>
 
 410       Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
 
 411                           "duedate", "BL", "trigger2");
 
 414     # without JavaScript Calendar
 
 416       qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}> $readonly</td>|;
 
 418       qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}> $readonly</td>|;
 
 426 <form method=post action=$form->{script}>
 
 428 <input type=hidden name=id value=$form->{id}>
 
 429 <input type=hidden name=sort value=$form->{sort}>
 
 430 <input type=hidden name=closedto value=$form->{closedto}>
 
 431 <input type=hidden name=locked value=$form->{locked}>
 
 432 <input type=hidden name=title value="$title">
 
 436     <th class=listtop>$form->{title}</th>
 
 446                 <th align=right nowrap>| . $locale->text('Vendor') . qq|</th>
 
 447                 <td colspan=3>$vendor</td>
 
 448                 <input type=hidden name=selectvendor value="$form->{selectvendor}">
 
 449                 <input type=hidden name=oldvendor value="$form->{oldvendor}">
 
 450                 <input type=hidden name=vendor_id value="$form->{vendor_id}">
 
 451                 <input type=hidden name=terms value=$form->{terms}>
 
 458                       <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
 
 459                       <td>$form->{creditlimit}</td>
 
 460                       <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
 
 461                       <td class="plus$n">$form->{creditremaining}</td>
 
 462                       <input type=hidden name=creditlimit value=$form->{creditlimit}>
 
 463                       <input type=hidden name=creditremaining value=$form->{creditremaining}>
 
 468                 <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
 
 469                 <td><select name=currency>$form->{selectcurrency}</select></td>
 
 470                 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
 
 471                 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
 
 472                 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
 
 473                 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
 
 483                 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
 
 484                 <td><input name=invnumber size=11 value="$form->{invnumber}" $readonly></td>
 
 487                 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
 
 488                 <td><input name=ordnumber size=11 value="$form->{ordnumber}" $readonly></td>
 
 491                 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
 
 495                 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
 
 508   <input type=hidden name=selectAP_amount value="$form->{selectAP_amount}">
 
 509   <input type=hidden name=AP_amount value="$form->{AP_amount}">
 
 510   <input type=hidden name=taxchart value="$form->{taxchart}">
 
 511   <input type=hidden name=rowcount value=$form->{rowcount}>
 
 515            <tr class=listheading>
 
 516           <th class=listheading style="width:15%">|
 
 517     . $locale->text('Account') . qq|</th>
 
 518           <th class=listheading style="width:10%">|
 
 519     . $locale->text('Amount') . qq|</th>
 
 520           <th class=listheading style="width:10%">|
 
 521     . $locale->text('Tax') . qq|</th>
 
 522           <th class=listheading style="width:5%">|
 
 523     . $locale->text('Korrektur') . qq|</th>
 
 524           <th class=listheading style="width:10%">|
 
 525     . $locale->text('Taxkey') . qq|</th>
 
 526           <th class=listheading style="width:10%">|
 
 527     . $locale->text('Project') . qq|</th>
 
 531   $amount  = $locale->text('Amount');
 
 532   $project = $locale->text('Project');
 
 534   for $i (1 .. $form->{rowcount}) {
 
 537     $form->{"amount_$i"} =
 
 538       $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
 
 539     $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
 
 540     $selectAP_amount = $selectAP_amount_unquoted;
 
 541     $re_amount = quotemeta($form->{"AP_amount_$i"});
 
 543       s/option value=\"${re_amount}\"/option value=\"$form->{"AP_amount_$i"}\" selected/;
 
 545     $tax_selected = $form->{"taxchart_$i"};
 
 546     $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
 
 548       qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
 
 550     my $korrektur = $form->{"korrektur_$i"} ? 'checked' : '';
 
 554           <td width=50%><select name="AP_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAP_amount</select></td>
 
 555           <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
 
 556           <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
 
 557           <td><input type="checkbox" name="korrektur_$i" value="1" "$korrektur"></td>
 
 559           <td><input name="projectnumber_$i" size=20 value="$form->{"projectnumber_$i"}">
 
 560               <input type=hidden name="project_id_$i" value=$form->{"project_id_$i"}>
 
 561               <input type=hidden name="oldprojectnumber_$i" value="$form->{"oldprojectnumber_$i"}"></td>
 
 569     ($form->{taxincluded})
 
 570     ? $locale->text('Tax Included')
 
 571     : $locale->text('Tax');
 
 573   $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
 
 582           <td><select name=APselected>$form->{selectAP}</select></td>
 
 583           <input type=hidden name=AP value="$form->{AP}">
 
 584           <th align=left>$form->{invtotal}</th>
 
 586           <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
 
 587           <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
 
 589           <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
 
 602           <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
 
 603           <td align=left>$notes</td>
 
 611         <tr class=listheading>
 
 612           <th class=listheading colspan=6>| . $locale->text('Payments') . qq|</th>
 
 616   if ($form->{currency} eq $form->{defaultcurrency}) {
 
 617     @column_index = qw(datepaid source memo paid AP_paid);
 
 619     @column_index = qw(datepaid source memo paid exchangerate AP_paid);
 
 622   $column_data{datepaid}     = "<th>" . $locale->text('Date') . "</th>";
 
 623   $column_data{paid}         = "<th>" . $locale->text('Amount') . "</th>";
 
 624   $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
 
 625   $column_data{AP_paid}      = "<th>" . $locale->text('Account') . "</th>";
 
 626   $column_data{source}       = "<th>" . $locale->text('Source') . "</th>";
 
 627   $column_data{memo}         = "<th>" . $locale->text('Memo') . "</th>";
 
 632   map { print "$column_data{$_}\n" } @column_index;
 
 637   $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
 
 638   for $i (1 .. $form->{paidaccounts}) {
 
 643     $form->{"selectAP_paid_$i"} = $form->{selectAP_paid};
 
 644     $form->{"selectAP_paid_$i"} =~
 
 645       s/option value=\"$form->{"AP_paid_$i"}\">/option value=\"$form->{"AP_paid_$i"}\" selected>/;
 
 649       $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
 
 650     $form->{"exchangerate_$i"} =
 
 651       $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
 
 653     $exchangerate = qq| |;
 
 654     if ($form->{currency} ne $form->{defaultcurrency}) {
 
 655       if ($form->{"forex_$i"}) {
 
 657           qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
 
 660           qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
 
 665 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
 
 668     $column_data{"paid_$i"} =
 
 669       qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
 
 670     $column_data{"AP_paid_$i"} =
 
 671       qq|<td align=center><select name="AP_paid_$i">$form->{"selectAP_paid_$i"}</select></td>|;
 
 672     $column_data{"exchangerate_$i"} = qq|<td align=center>$exchangerate</td>|;
 
 673     $column_data{"datepaid_$i"}     =
 
 674       qq|<td align=center><input name="datepaid_$i" size=11 title="($myconfig{'dateformat'})" value=$form->{"datepaid_$i"}></td>|;
 
 675     $column_data{"source_$i"} =
 
 676       qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
 
 677     $column_data{"memo_$i"} =
 
 678       qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
 
 680     map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
 
 686   map { $form->{$_} =~ s/\"/"/g } qw(selectAP_paid);
 
 688     <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
 
 689     <input type=hidden name=selectAP_paid value="$form->{selectAP_paid}">
 
 695     <td><hr size=3 noshade></td>
 
 700   $lxdebug->leave_sub();
 
 704   $lxdebug->enter_sub();
 
 708 <input name=callback type=hidden value="$form->{callback}">
 
 710 <input type=hidden name=path value=$form->{path}>
 
 711 <input type=hidden name=login value=$form->{login}>
 
 712 <input type=hidden name=password value=$form->{password}>
 
 717   $transdate = $form->datetonum($form->{transdate}, \%myconfig);
 
 718   $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
 
 720   if ($form->{id} && $form->{radier}) {
 
 722     #     print qq|<input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
 
 725     if (!$form->{revtrans}) {
 
 726       if (!$form->{locked}) {
 
 728         <input class=submit type=submit name=action value="|
 
 729           . $locale->text('Post') . qq|">
 
 730         <input class=submit type=submit name=action value="|
 
 731           . $locale->text('Delete') . qq|">
 
 736     if ($transdate > $closedto) {
 
 738 <input class=submit type=submit name=action value="|
 
 739         . $locale->text('Post as new') . qq|">
 
 744     if (($transdate > $closedto) && !$form->{id}) {
 
 745       print qq|<input class=submit type=submit name=action value="|
 
 746         . $locale->text('Update') . qq|">
 
 747       <input class=submit type=submit name=action value="|
 
 748         . $locale->text('Post') . qq|">|;
 
 752   if ($form->{menubar}) {
 
 753     require "$form->{path}/menu.pl";
 
 764   $lxdebug->leave_sub();
 
 768   $lxdebug->enter_sub();
 
 776   $form->{invtotal} = 0;
 
 778   #   $form->{selectAP_amount} = $form->{AP_amount};
 
 779   #   $form->{selectAP_amount} =~
 
 780   #     s/value=\"$form->{AP_amountselected}\"/value=\"$form->{AP_amountselected}\" selected/;
 
 782   $form->{selectAP} = $form->{AP};
 
 784     s/value=\"$form->{APselected}\"/value=\"$form->{APselected}\" selected/;
 
 786   ($AP_amountaccno, $AP_amounttaxkey) =
 
 787     split(/--/, $form->{AP_amountselected});
 
 788   $form->{selecttaxchart} = $form->{taxchart};
 
 789   $form->{selecttaxchart} =~
 
 790     s/value=\"$AP_amounttaxkey--([^\"]*)\"/value=\"$AP_amounttaxkey--$1\" selected/;
 
 794   map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
 795     qw(exchangerate creditlimit creditremaining);
 
 797   @flds  = qw(amount AP_amount projectnumber oldprojectnumber project_id);
 
 799   for $i (1 .. $form->{rowcount}) {
 
 800     $form->{"amount_$i"} =
 
 801       $form->parse_amount(\%myconfig, $form->{"amount_$i"});
 
 802     $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
 
 803     if ($form->{"amount_$i"}) {
 
 806       if (!$form->{"korrektur_$i"}) {
 
 807         ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
 
 809           if ($form->{taxincluded}) {
 
 810             $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
 
 812             $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
 
 815           $form->{"tax_$i"} = 0;
 
 818       $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
 
 820       $totaltax += $form->{"tax_$i"};
 
 821       map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
 
 825   $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
 
 827   map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
 
 829   $form->{exchangerate} = $exchangerate
 
 833                       $form->check_exchangerate(
 
 834                       \%myconfig, $form->{currency}, $form->{transdate}, 'sell'
 
 837   $form->{invdate} = $form->{transdate};
 
 838   $save_AP = $form->{AP};
 
 840   $form->{AP} = $save_AP;
 
 843   $form->{rowcount} = $count + 1;
 
 846     ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
 
 848   for $i (1 .. $form->{paidaccounts}) {
 
 849     if ($form->{"paid_$i"}) {
 
 852           $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
 
 853       } qw(paid exchangerate);
 
 855       $totalpaid += $form->{"paid_$i"};
 
 857       $form->{"exchangerate_$i"} = $exchangerate
 
 859             $form->{"forex_$i"} = (
 
 861                   $form->check_exchangerate(
 
 862                   \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'
 
 867   $form->{creditremaining} -=
 
 868     ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
 
 869      $form->{oldinvtotal});
 
 870   $form->{oldinvtotal}  = $form->{invtotal};
 
 871   $form->{oldtotalpaid} = $totalpaid;
 
 875   $lxdebug->leave_sub();
 
 879   $lxdebug->enter_sub();
 
 881   # check if there is a vendor, invoice and due date
 
 882   $form->isblank("transdate", $locale->text("Invoice Date missing!"));
 
 883   $form->isblank("duedate",   $locale->text("Due Date missing!"));
 
 884   $form->isblank("vendor",    $locale->text('Vendor missing!'));
 
 886   $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
 
 887   $transdate = $form->datetonum($form->{transdate}, \%myconfig);
 
 889   $form->error($locale->text('Cannot post transaction for a closed period!'))
 
 890     if ($transdate <= $closedto);
 
 892   $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
 
 893     if ($form->{currency} ne $form->{defaultcurrency});
 
 896   for $i (1 .. $form->{paidaccounts}) {
 
 897     if ($form->{"paid_$i"}) {
 
 898       $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
 
 900       $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
 
 902       $form->error($locale->text('Cannot post payment for a closed period!'))
 
 903         if ($datepaid <= $closedto);
 
 905       if ($form->{currency} ne $form->{defaultcurrency}) {
 
 906         $form->{"exchangerate_$i"} = $form->{exchangerate}
 
 907           if ($transdate == $datepaid);
 
 908         $form->isblank("exchangerate_$i",
 
 909                        $locale->text('Exchangerate for payment missing!'));
 
 915   # if old vendor ne vendor redo form
 
 916   ($vendor) = split /--/, $form->{vendor};
 
 917   if ($form->{oldvendor} ne "$vendor--$form->{vendor_id}") {
 
 921   ($debitaccno,    $debittaxkey)    = split /--/, $form->{AP_amountselected};
 
 922   ($taxkey,        $NULL)           = split /--/, $form->{taxchartselected};
 
 923   ($payablesaccno, $payablestaxkey) = split /--/, $form->{APselected};
 
 924   $form->{AP}{amount_1} = $debitaccno;
 
 925   $form->{AP}{payables} = $payablesaccno;
 
 926   $form->{taxkey}       = $taxkey;
 
 928   $form->{id} = 0 if $form->{postasnew};
 
 930   $form->redirect($locale->text('Transaction posted!'))
 
 931     if (AP->post_transaction(\%myconfig, \%$form));
 
 932   $form->error($locale->text('Cannot post transaction!'));
 
 934   $lxdebug->leave_sub();
 
 938   $lxdebug->enter_sub();
 
 940   $form->{postasnew} = 1;
 
 943   $lxdebug->leave_sub();
 
 947   $lxdebug->enter_sub();
 
 949   $form->{title} = $locale->text('Confirm!');
 
 953   delete $form->{header};
 
 958 <form method=post action=$form->{script}>
 
 961   foreach $key (keys %$form) {
 
 962     $form->{$key} =~ s/\"/"/g;
 
 963     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
 
 967 <h2 class=confirm>$form->{title}</h2>
 
 970     . $locale->text('Are you sure you want to delete Transaction')
 
 971     . qq| $form->{invnumber}</h4>
 
 973 <input name=action class=submit type=submit value="|
 
 974     . $locale->text('Yes') . qq|">
 
 981   $lxdebug->leave_sub();
 
 985   $lxdebug->enter_sub();
 
 987   $form->redirect($locale->text('Transaction deleted!'))
 
 988     if (AP->delete_transaction(\%myconfig, \%$form, $spool));
 
 989   $form->error($locale->text('Cannot delete transaction!'));
 
 991   $lxdebug->leave_sub();
 
 995   $lxdebug->enter_sub();
 
 997   # setup vendor selection
 
 998   $form->all_vc(\%myconfig, "vendor", "AP");
 
1000   if (@{ $form->{all_vendor} }) {
 
1001     map { $vendor .= "<option>$_->{name}--$_->{id}\n" }
 
1002       @{ $form->{all_vendor} };
 
1003     $vendor = qq|<select name=vendor><option>\n$vendor\n</select>|;
 
1005     $vendor = qq|<input name=vendor size=35>|;
 
1009   if (@{ $form->{all_departments} }) {
 
1010     $form->{selectdepartment} = "<option>\n";
 
1013       $form->{selectdepartment} .=
 
1014         "<option>$_->{description}--$_->{id}\n"
 
1015     } (@{ $form->{all_departments} });
 
1020           <th align=right nowrap>| . $locale->text('Department') . qq|</th>
 
1021           <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
 
1023 | if $form->{selectdepartment};
 
1025   $form->{title} = $locale->text('AP Transactions');
 
1027   # use JavaScript Calendar or not
 
1028   $form->{jsscript} = $jscalendar;
 
1030   if ($form->{jsscript}) {
 
1032     # with JavaScript Calendar
 
1034        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
 
1035        <input type=button name=transdatefrom id="trigger1" value=|
 
1036       . $locale->text('button') . qq|></td>
 
1039        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
 
1040        <input type=button name=transdateto name=transdateto id="trigger2" value=|
 
1041       . $locale->text('button') . qq|></td>
 
1046       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
 
1047                           "transdateto", "BL", "trigger2");
 
1050     # without JavaScript Calendar
 
1052                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
1054                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
 
1062 <form method=post action=$form->{script}>
 
1066     <th class=listtop>$form->{title}</th>
 
1068   <tr height="5"></tr>
 
1073           <th align=right>| . $locale->text('Vendor') . qq|</th>
 
1074           <td colspan=3>$vendor</td>
 
1078           <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
 
1079           <td colspan=3><input name=invnumber size=20></td>
 
1082           <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
 
1083           <td colspan=3><input name=ordnumber size=20></td>
 
1086           <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
 
1087           <td colspan=3><input name=notes size=40></td>
 
1090           <th align=right nowrap>| . $locale->text('From') . qq|</th>
 
1092           <th align=right>| . $locale->text('Bis') . qq|</th>
 
1095         <input type=hidden name=sort value=transdate>
 
1103           <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
 
1107                 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
 
1108                 <td nowrap>| . $locale->text('Open') . qq|</td>
 
1109                 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
 
1110                 <td nowrap>| . $locale->text('Closed') . qq|</td>
 
1113                 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
 
1114                 <td nowrap>| . $locale->text('ID') . qq|</td>
 
1115                 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
 
1116                 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
 
1117                 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
 
1118                 <td nowrap>| . $locale->text('Order Number') . qq|</td>
 
1121                 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
 
1122                 <td nowrap>| . $locale->text('Vendor') . qq|</td>
 
1123                 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
 
1124                 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
 
1125                 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
 
1126                 <td nowrap>| . $locale->text('Amount') . qq|</td>
 
1129                 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
 
1130                 <td nowrap>| . $locale->text('Tax') . qq|</td>
 
1131                 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
 
1132                 <td nowrap>| . $locale->text('Total') . qq|</td>
 
1133                 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
 
1134                 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
 
1137                 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
 
1138                 <td nowrap>| . $locale->text('Paid') . qq|</td>
 
1139                 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
 
1140                 <td nowrap>| . $locale->text('Due Date') . qq|</td>
 
1141                 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
 
1142                 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
 
1145                 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
 
1146                 <td nowrap>| . $locale->text('Notes') . qq|</td>
 
1147                 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
 
1148                 <td nowrap>| . $locale->text('Employee') . qq|</td>
 
1151                 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
 
1152                 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
 
1161     <td><hr size=3 noshade></td>
 
1168 <input type=hidden name=nextsub value=$form->{nextsub}>
 
1169 <input type=hidden name=path value=$form->{path}>
 
1170 <input type=hidden name=login value=$form->{login}>
 
1171 <input type=hidden name=password value=$form->{password}>
 
1173 <input class=submit type=submit name=action value="|
 
1174     . $locale->text('Continue') . qq|">
 
1181   $lxdebug->leave_sub();
 
1184 sub ap_transactions {
 
1185   $lxdebug->enter_sub();
 
1187   $form->{vendor} = $form->unescape($form->{vendor});
 
1188   ($form->{vendor}, $form->{vendor_id}) = split(/--/, $form->{vendor});
 
1190   AP->ap_transactions(\%myconfig, \%$form);
 
1193     "$form->{script}?action=ap_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1196   if ($form->{vendor}) {
 
1197     $callback .= "&vendor=" . $form->escape($form->{vendor}, 1);
 
1198     $href .= "&vendor=" . $form->escape($form->{vendor});
 
1199     $option .= $locale->text('Vendor') . " : $form->{vendor}";
 
1201   if ($form->{department}) {
 
1202     $callback .= "&department=" . $form->escape($form->{department}, 1);
 
1203     $href .= "&department=" . $form->escape($form->{department});
 
1204     ($department) = split /--/, $form->{department};
 
1205     $option .= "\n<br>" if ($option);
 
1206     $option .= $locale->text('Department') . " : $department";
 
1208   if ($form->{invnumber}) {
 
1209     $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
 
1210     $href .= "&invnumber=" . $form->escape($form->{invnumber});
 
1211     $option .= "\n<br>" if ($option);
 
1212     $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
 
1214   if ($form->{ordnumber}) {
 
1215     $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
 
1216     $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
 
1217     $option .= "\n<br>" if ($option);
 
1218     $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
 
1220   if ($form->{notes}) {
 
1221     $callback .= "¬es=" . $form->escape($form->{notes}, 1);
 
1222     $href .= "¬es=" . $form->escape($form->{notes});
 
1223     $option .= "\n<br>" if $option;
 
1224     $option .= $locale->text('Notes') . " : $form->{notes}";
 
1227   if ($form->{transdatefrom}) {
 
1228     $callback .= "&transdatefrom=$form->{transdatefrom}";
 
1229     $href     .= "&transdatefrom=$form->{transdatefrom}";
 
1230     $option   .= "\n<br>" if ($option);
 
1232         $locale->text('From') . " "
 
1233       . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1235   if ($form->{transdateto}) {
 
1236     $callback .= "&transdateto=$form->{transdateto}";
 
1237     $href     .= "&transdateto=$form->{transdateto}";
 
1238     $option   .= "\n<br>" if ($option);
 
1240         $locale->text('Bis') . " "
 
1241       . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1243   if ($form->{open}) {
 
1244     $callback .= "&open=$form->{open}";
 
1245     $href     .= "&open=$form->{open}";
 
1246     $option   .= "\n<br>" if ($option);
 
1247     $option   .= $locale->text('Open');
 
1249   if ($form->{closed}) {
 
1250     $callback .= "&closed=$form->{closed}";
 
1251     $href     .= "&closed=$form->{closed}";
 
1252     $option   .= "\n<br>" if ($option);
 
1253     $option   .= $locale->text('Closed');
 
1256   @columns = $form->sort_columns(
 
1257     qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee)
 
1260   foreach $item (@columns) {
 
1261     if ($form->{"l_$item"} eq "Y") {
 
1262       push @column_index, $item;
 
1264       # add column to href and callback
 
1265       $callback .= "&l_$item=Y";
 
1266       $href     .= "&l_$item=Y";
 
1270   if ($form->{l_subtotal} eq 'Y') {
 
1271     $callback .= "&l_subtotal=Y";
 
1272     $href     .= "&l_subtotal=Y";
 
1275   $column_header{id} =
 
1276       qq|<th><a class=listheading href=$href&sort=id>|
 
1277     . $locale->text('ID')
 
1279   $column_header{transdate} =
 
1280       qq|<th><a class=listheading href=$href&sort=transdate>|
 
1281     . $locale->text('Date')
 
1283   $column_header{duedate} =
 
1284       qq|<th><a class=listheading href=$href&sort=duedate>|
 
1285     . $locale->text('Due Date')
 
1287   $column_header{due} =
 
1288     qq|<th class=listheading>| . $locale->text('Amount Due') . qq|</th>|;
 
1289   $column_header{invnumber} =
 
1290       qq|<th><a class=listheading href=$href&sort=invnumber>|
 
1291     . $locale->text('Invoice')
 
1293   $column_header{ordnumber} =
 
1294       qq|<th><a class=listheading href=$href&sort=ordnumber>|
 
1295     . $locale->text('Order')
 
1297   $column_header{name} =
 
1298       qq|<th><a class=listheading href=$href&sort=name>|
 
1299     . $locale->text('Vendor')
 
1301   $column_header{netamount} =
 
1302     qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
 
1303   $column_header{tax} =
 
1304     qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
 
1305   $column_header{amount} =
 
1306     qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
 
1307   $column_header{paid} =
 
1308     qq|<th class=listheading>| . $locale->text('Paid') . qq|</th>|;
 
1309   $column_header{datepaid} =
 
1310       qq|<th><a class=listheading href=$href&sort=datepaid>|
 
1311     . $locale->text('Date Paid')
 
1313   $column_header{notes} =
 
1314     qq|<th class=listheading>| . $locale->text('Notes') . qq|</th>|;
 
1315   $column_header{employee} =
 
1316     "<th><a class=listheading href=$href&sort=employee>"
 
1317     . $locale->text('Employee') . "</th>";
 
1319   $form->{title} = $locale->text('AP Transactions');
 
1328     <th class=listtop>$form->{title}</th>
 
1330   <tr height="5"></tr>
 
1337         <tr class=listheading>
 
1340   map { print "\n$column_header{$_}" } @column_index;
 
1346   # add sort and escape callback
 
1347   $form->{callback} = "$callback&sort=$form->{sort}";
 
1348   $callback = $form->escape($form->{callback});
 
1350   if (@{ $form->{AP} }) {
 
1351     $sameitem = $form->{AP}->[0]->{ $form->{sort} };
 
1354   # sums and tax on reports by Antonio Gallardo
 
1356   foreach $ap (@{ $form->{AP} }) {
 
1358     if ($form->{l_subtotal} eq 'Y') {
 
1359       if ($sameitem ne $ap->{ $form->{sort} }) {
 
1361         $sameitem = $ap->{ $form->{sort} };
 
1365     $column_data{netamount} =
 
1367       . $form->format_amount(\%myconfig, $ap->{netamount}, 2, " ")
 
1369     $column_data{tax} = "<td align=right>"
 
1370       . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{netamount},
 
1373     $column_data{amount} =
 
1375       . $form->format_amount(\%myconfig, $ap->{amount}, 2, " ") . "</td>";
 
1376     $column_data{paid} =
 
1378       . $form->format_amount(\%myconfig, $ap->{paid}, 2, " ") . "</td>";
 
1379     $column_data{due} = "<td align=right>"
 
1380       . $form->format_amount(\%myconfig, $ap->{amount} - $ap->{paid},
 
1384     $totalnetamount += $ap->{netamount};
 
1385     $totalamount    += $ap->{amount};
 
1386     $totalpaid      += $ap->{paid};
 
1387     $totaldue       += ($ap->{amount} - $ap->{paid});
 
1389     $subtotalnetamount += $ap->{netamount};
 
1390     $subtotalamount    += $ap->{amount};
 
1391     $subtotalpaid      += $ap->{paid};
 
1392     $subtotaldue       += ($ap->{amount} - $ap->{paid});
 
1394     $column_data{transdate} = "<td>$ap->{transdate} </td>";
 
1395     $column_data{duedate}   = "<td>$ap->{duedate} </td>";
 
1396     $column_data{datepaid}  = "<td>$ap->{datepaid} </td>";
 
1398     $module = ($ap->{invoice}) ? "ir.pl" : $form->{script};
 
1400     $column_data{invnumber} =
 
1401       qq|<td><a href="$module?action=edit&path=$form->{path}&id=$ap->{id}&login=$form->{login}&password=$form->{password}&callback=$callback">$ap->{invnumber}</a></td>|;
 
1402     $column_data{id}        = "<td>$ap->{id}</td>";
 
1403     $column_data{ordnumber} = "<td>$ap->{ordnumber} </td>";
 
1404     $column_data{name}      = "<td>$ap->{name}</td>";
 
1405     $ap->{notes} =~ s/\r\n/<br>/g;
 
1406     $column_data{notes}    = "<td>$ap->{notes} </td>";
 
1407     $column_data{employee} = "<td>$ap->{employee} </td>";
 
1412         <tr class=listrow$i >
 
1415     map { print "\n$column_data{$_}" } @column_index;
 
1423   if ($form->{l_subtotal} eq 'Y') {
 
1429         <tr class=listtotal>
 
1432   map { $column_data{$_} = "<td> </td>" } @column_index;
 
1434   $column_data{netamount} =
 
1435     "<th class=listtotal align=right>"
 
1436     . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
 
1437   $column_data{tax} = "<th class=listtotal align=right>"
 
1438     . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
 
1441   $column_data{amount} =
 
1442     "<th class=listtotal align=right>"
 
1443     . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
 
1444   $column_data{paid} =
 
1445     "<th class=listtotal align=right>"
 
1446     . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
 
1448     "<th class=listtotal align=right>"
 
1449     . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
 
1451   map { print "$column_data{$_}\n" } @column_index;
 
1459     <td><hr size=3 noshade></td>
 
1464 <form method=post action=$form->{script}>
 
1466 <input name=callback type=hidden value="$form->{callback}">
 
1468 <input type=hidden name=path value=$form->{path}>
 
1469 <input type=hidden name=login value=$form->{login}>
 
1470 <input type=hidden name=password value=$form->{password}>
 
1472 <input class=submit type=submit name=action value="|
 
1473     . $locale->text('AP Transaction') . qq|">
 
1475 <input class=submit type=submit name=action value="|
 
1476     . $locale->text('Vendor Invoice') . qq|">|;
 
1478   if ($form->{menubar}) {
 
1479     require "$form->{path}/menu.pl";
 
1490   $lxdebug->leave_sub();
 
1494   $lxdebug->enter_sub();
 
1496   map { $column_data{$_} = "<td> </td>" } @column_index;
 
1498   $column_data{netamount} =
 
1499       "<th class=listsubtotal align=right>"
 
1500     . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
 
1502   $column_data{tax} = "<th class=listsubtotal align=right>"
 
1503     . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
 
1506   $column_data{amount} =
 
1507     "<th class=listsubtotal align=right>"
 
1508     . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
 
1509   $column_data{paid} =
 
1510     "<th class=listsubtotal align=right>"
 
1511     . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
 
1513     "<th class=listsubtotal align=right>"
 
1514     . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
 
1516   $subtotalnetamount = 0;
 
1517   $subtotalamount    = 0;
 
1521   print "<tr class=listsubtotal>";
 
1523   map { print "\n$column_data{$_}" } @column_index;
 
1529   $lxdebug->leave_sub();