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 #======================================================================
30 # Accounts Receivables
32 #======================================================================
39 require "$form->{path}/arap.pl";
40 require "bin/mozilla/common.pl";
46 # this is for our long dates
47 # $locale->text('January')
48 # $locale->text('February')
49 # $locale->text('March')
50 # $locale->text('April')
51 # $locale->text('May ')
52 # $locale->text('June')
53 # $locale->text('July')
54 # $locale->text('August')
55 # $locale->text('September')
56 # $locale->text('October')
57 # $locale->text('November')
58 # $locale->text('December')
60 # this is for our short month
61 # $locale->text('Jan')
62 # $locale->text('Feb')
63 # $locale->text('Mar')
64 # $locale->text('Apr')
65 # $locale->text('May')
66 # $locale->text('Jun')
67 # $locale->text('Jul')
68 # $locale->text('Aug')
69 # $locale->text('Sep')
70 # $locale->text('Oct')
71 # $locale->text('Nov')
72 # $locale->text('Dec')
75 $lxdebug->enter_sub();
78 if(!exists $form->{addition} && ($form->{id} ne "")) {
79 $form->{addition} = "ADDED";
80 $form->save_history($form->dbconnect(\%myconfig));
84 $form->{title} = "Add";
86 "$form->{script}?action=add&path=$form->{path}&login=$form->{login}&password=$form->{password}"
87 unless $form->{callback};
90 AR->get_transdate(\%myconfig, $form);
92 $lxdebug->leave_sub();
96 $lxdebug->enter_sub();
98 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
99 #/show hhistory button
101 $form->{title} = "Edit";
106 $lxdebug->leave_sub();
110 $lxdebug->enter_sub();
115 $lxdebug->leave_sub();
119 $lxdebug->enter_sub();
121 $form->create_links("AR", \%myconfig, "customer");
122 $duedate = $form->{duedate};
124 $taxincluded = $form->{taxincluded};
125 my $id = $form->{id};
126 IS->get_customer(\%myconfig, \%$form);
127 $form->{taxincluded} = $taxincluded;
130 $form->{duedate} = $duedate if $duedate;
131 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
132 $form->{rowcount} = 1;
135 @curr = split(/:/, $form->{currencies});
137 $form->{defaultcurrency} = $curr[0];
139 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
142 if (@{ $form->{all_customer} }) {
143 $form->{customer} = "$form->{customer}--$form->{customer_id}";
144 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}\n" }
145 (@{ $form->{all_customer} });
149 if (@{ $form->{all_departments} }) {
150 $form->{selectdepartment} = "<option>\n";
151 $form->{department} = "$form->{department}--$form->{department_id}";
154 $form->{selectdepartment} .=
155 "<option>$_->{description}--$_->{id}\n"
156 } (@{ $form->{all_departments} });
159 $form->{employee} = "$form->{employee}--$form->{employee_id}";
162 if (@{ $form->{all_employees} }) {
163 $form->{selectemployee} = "";
164 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
165 (@{ $form->{all_employees} });
168 # build the popup menus
169 $form->{taxincluded} = ($form->{id}) ? $form->{taxincluded} : "checked";
173 qq|<option value=\"$_->{id}--$_->{rate}\">$_->{taxdescription} |
174 . ($_->{rate} * 100) . qq| %|
176 $form->{taxchart} = $tax;
177 $form->{selecttaxchart} = $tax;
180 $form->{forex} = $form->{exchangerate};
181 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
182 foreach $key (keys %{ $form->{AR_links} }) {
184 foreach $ref (@{ $form->{AR_links}{$key} }) {
185 if ($key eq "AR_paid") {
186 $form->{"select$key"} .=
187 "<option value=\"$ref->{accno}\">$ref->{accno}--$ref->{description}</option>\n";
189 $form->{"select$key"} .=
190 "<option value=\"$ref->{accno}--$ref->{tax_id}\">$ref->{accno}--$ref->{description}</option>\n";
194 $form->{$key} = $form->{"select$key"};
196 # if there is a value we have an old entry
200 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
201 if ($key eq "AR_paid") {
203 $form->{"AR_paid_$j"} =
204 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
207 $form->{"paid_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
208 $form->{"datepaid_$j"} =
209 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
210 $form->{"source_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
211 $form->{"memo_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
213 $form->{"forex_$j"} = $form->{"exchangerate_$i"} =
214 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
215 $form->{"AR_paid_$j"} = "$form->{acc_trans}{$key}->[$i-1]->{accno}";
216 $form->{"paid_project_id_$j"} = $form->{acc_trans}{$key}->[$i - 1]->{project_id};
217 $form->{paidaccounts}++;
223 if ($key eq "AR_tax" || $key eq "AP_tax") {
224 $form->{"${key}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
225 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
226 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"} =
228 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
231 if ($form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"} > 0) {
233 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
235 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
238 $form->{"${akey}_$form->{acc_trans}{$key}->[$i-1]->{accno}"};
240 $form->{"$form->{acc_trans}{$key}->[$i-1]->{accno}_rate"};
242 $index = $form->{acc_trans}{$key}->[$i - 1]->{index};
243 $form->{"tax_$index"} = $form->{acc_trans}{$key}->[$i - 1]->{amount};
244 $totaltax += $form->{"tax_$index"};
248 $form->{"${akey}_$k"} =
250 $form->{acc_trans}{$key}->[$i - 1]->{amount} / $exchangerate,
252 if ($akey eq 'amount') {
254 $totalamount += $form->{"${akey}_$i"};
256 $form->{"oldprojectnumber_$k"} = $form->{"projectnumber_$k"} =
257 "$form->{acc_trans}{$key}->[$i-1]->{projectnumber}";
258 $form->{taxrate} = $form->{acc_trans}{$key}->[$i - 1]->{rate};
259 $form->{"project_id_$k"} =
260 "$form->{acc_trans}{$key}->[$i-1]->{project_id}";
262 $form->{"${key}_$k"} =
263 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
264 $form->{"${key}_$i"} =
265 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
266 my $q_description = quotemeta($form->{acc_trans}{$key}->[$i-1]->{description});
267 $form->{"select${key}"} =~
268 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{accno}--[^\"]*)\">$form->{acc_trans}{$key}->[$i-1]->{accno}--${q_description}<\/option>\n/;
269 $form->{"${key}_$k"} = $1;
270 if ($akey eq 'amount') {
271 $form->{"taxchart_$k"} = $form->{taxchart};
272 $form->{"taxchart_$k"} =~
273 /<option value=\"($form->{acc_trans}{$key}->[$i-1]->{id}--[^\"]*)/;
274 $form->{"taxchart_$k"} = $1;
281 $form->{taxincluded} = $taxincluded if ($form->{id});
282 $form->{paidaccounts} = 1 if not defined $form->{paidaccounts};
284 if ($form->{taxincluded} && $form->{taxrate} && $totalamount) {
286 # add tax to amounts and invtotal
287 for $i (1 .. $form->{rowcount}) {
289 ($totaltax + $totalwithholding) * $form->{"amount_$i"} / $totalamount;
290 $tax = $form->round_amount($taxamount, 2);
291 $diff += ($taxamount - $tax);
292 $form->{"amount_$i"} += $form->{"tax_$i"};
294 $form->{amount_1} += $form->round_amount($diff, 2);
297 $taxamount = $form->round_amount($taxamount, 2);
298 $form->{tax} = $taxamount;
300 $form->{invtotal} = $totalamount + $totaltax;
303 ($form->datetonum($form->{transdate}, \%myconfig) <=
304 $form->datetonum($form->{closedto}, \%myconfig));
306 $form->{"ARselected"} = $form->{"AR_1"};
308 $lxdebug->leave_sub();
312 $lxdebug->enter_sub();
314 $title = $form->{title};
315 $form->{title} = $locale->text("$title Accounts Receivables Transaction");
317 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
319 # $locale->text('Add Accounts Receivables Transaction')
320 # $locale->text('Edit Accounts Receivables Transaction')
321 $form->{javascript} = qq|<script type="text/javascript">
323 function setTaxkey(accno, row) {
324 var taxkey = accno.options[accno.selectedIndex].value;
325 var reg = /--([0-9]*)/;
326 var found = reg.exec(taxkey);
327 var index = found[1];
328 index = parseInt(index);
329 var tax = 'taxchart_' + row;
330 for (var i = 0; i < document.getElementById(tax).options.length; ++i) {
331 var reg2 = new RegExp("^"+ index, "");
332 if (reg2.exec(document.getElementById(tax).options[i].value)) {
333 document.getElementById(tax).options[i].selected = true;
340 # show history button js
341 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
342 #/show history button js
344 $readonly = ($form->{id}) ? "readonly" : "";
347 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
348 $readonly = ($form->{radier}) ? "" : $readonly;
350 my $ARselected_quoted = quotemeta($form->{"ARselected"});
351 $form->{selectAR} = $form->{AR};
353 s/value=\"${ARselected_quoted}\"/value=\"$form->{ARselected}\" selected/;
355 # set option selected
356 foreach $item (qw(customer currency department employee)) {
357 $form->{"select$item"} =~ s/ selected//;
358 $form->{"select$item"} =~
359 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
361 $selectAR_amount_unquoted = $form->{selectAR_amount};
362 $taxchart = $form->{taxchart};
363 map { $form->{$_} =~ s/\"/"/g }
364 qw(AR_amount selectAR_amount AR taxchart);
367 $form->{exchangerate} =
368 $form->format_amount(\%myconfig, $form->{exchangerate});
370 $form->{creditlimit} =
371 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
372 $form->{creditremaining} =
373 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
376 <input type=hidden name=forex value=$form->{forex}>
378 if ($form->{currency} ne $form->{defaultcurrency}) {
379 if ($form->{forex}) {
381 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
382 <td><input type=hidden name=exchangerate value=$form->{exchangerate}>$form->{exchangerate}</td>
386 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
387 <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
396 <td align=right><input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
397 <th align=left nowrap>| . $locale->text('Tax Included') . qq|</th>
401 if (($rows = $form->numtextrows($form->{notes}, 50)) < 2) {
405 qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
409 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
410 <td colspan=3><select name=department>$form->{selectdepartment}</select>
411 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
414 | if $form->{selectdepartment};
416 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
419 ($form->{selectcustomer})
420 ? qq|<select name=customer>$form->{selectcustomer}</select>|
421 : qq|<input name=customer value="$form->{customer}" size=35>|;
424 <input type=hidden name=employee value="$form->{employee}">
427 if ($form->{selectemployee}) {
430 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
431 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
432 <input type=hidden name=selectemployee value="$form->{selectemployee}">
437 my @old_project_ids = ();
438 map({ push(@old_project_ids, $form->{"project_id_$_"})
439 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
441 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
443 "old_id" => \@old_project_ids });
445 my %project_labels = ();
446 my @project_values = ("");
447 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
448 push(@project_values, $item->{"id"});
449 $project_labels{$item->{"id"}} = $item->{"projectnumber"};
452 $form->{fokus} = "arledger.customer";
454 # use JavaScript Calendar or not
455 $form->{jsscript} = $jscalendar;
457 if ($form->{jsscript}) {
459 # with JavaScript Calendar
461 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
462 <td><input type=button name=transdate id="trigger1" value=|
463 . $locale->text('button') . qq|></td>
466 <td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>
467 <td><input type=button name=duedate id="trigger2" value=|
468 . $locale->text('button') . qq|></td></td>
473 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
474 "duedate", "BL", "trigger2");
477 # without JavaScript Calendar
479 qq|<td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
481 qq|<td><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate}></td>|;
487 <body onLoad="fokus()">
489 <form method=post name="arledger" action=$form->{script}>
491 <input type=hidden name=id value=$form->{id}>
492 <input type=hidden name=sort value=$form->{sort}>
493 <input type=hidden name=closedto value=$form->{closedto}>
494 <input type=hidden name=locked value=$form->{locked}>
495 <input type=hidden name=title value="$title">
499 <th class=listtop>$form->{title}</th>
509 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
510 <td colspan=3>$customer</td>
511 <input type=hidden name=selectcustomer value="$form->{selectcustomer}">
512 <input type=hidden name=oldcustomer value="$form->{oldcustomer}">
513 <input type=hidden name=customer_id value="$form->{customer_id}">
514 <input type=hidden name=terms value=$form->{terms}>
521 <th align=left nowrap>| . $locale->text('Credit Limit') . qq|</th>
522 <td>$form->{creditlimit}</td>
523 <th align=left nowrap>| . $locale->text('Remaining') . qq|</th>
524 <td class="plus$n">$form->{creditremaining}</td>
525 <input type=hidden name=creditlimit value=$form->{creditlimit}>
526 <input type=hidden name=creditremaining value=$form->{creditremaining}>
532 <th align=right>| . $locale->text('Currency') . qq|</th>
533 <td><select name=currency>$form->{selectcurrency}</select></td>
534 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
535 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
536 <input type=hidden name=fxgain_accno value=$form->{fxgain_accno}>
537 <input type=hidden name=fxloss_accno value=$form->{fxloss_accno}>
548 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
549 <td><input name=invnumber size=11 value="$form->{invnumber}"></td>
552 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
553 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
556 <th align=right nowrap>| . $locale->text('Invoice Date') . qq|</th>
560 <th align=right nowrap>| . $locale->text('Due Date') . qq|</th>
571 <input type=hidden name=selectAR_amount value="$form->{selectAR_amount}">
572 <input type=hidden name=AR_amount value="$form->{AR_amount}">
573 <input type=hidden name=taxchart value="$form->{taxchart}">
574 <input type=hidden name=rowcount value=$form->{rowcount}>
578 <tr class=listheading>
579 <th class=listheading style="width:15%">|
580 . $locale->text('Account') . qq|</th>
581 <th class=listheading style="width:10%">|
582 . $locale->text('Amount') . qq|</th>
583 <th class=listheading style="width:10%">|
584 . $locale->text('Tax') . qq|</th>
585 <th class=listheading style="width:5%">|
586 . $locale->text('Korrektur') . qq|</th>
587 <th class=listheading style="width:10%">|
588 . $locale->text('Taxkey') . qq|</th>
589 <th class=listheading style="width:10%">|
590 . $locale->text('Project') . qq|</th>
594 $amount = $locale->text('Amount');
595 $project = $locale->text('Project');
597 for $i (1 .. $form->{rowcount}) {
600 $form->{"amount_$i"} =
601 $form->format_amount(\%myconfig, $form->{"amount_$i"}, 2);
602 $form->{"tax_$i"} = $form->format_amount(\%myconfig, $form->{"tax_$i"}, 2);
603 $selectAR_amount = $selectAR_amount_unquoted;
605 s/option value=\"$form->{"AR_amount_$i"}\"/option value=\"$form->{"AR_amount_$i"}\" selected/;
607 $tax_selected = $form->{"taxchart_$i"};
608 $tax =~ s/value=\"$tax_selected\"/value=\"$tax_selected\" selected/;
610 qq|<td><select id="taxchart_$i" name="taxchart_$i" style="width:200px">$tax</select></td>|;
611 $korrektur_checked = ($form->{"korrektur_$i"} ? 'checked' : '');
614 NTI($cgi->popup_menu('-name' => "project_id_$i",
615 '-values' => \@project_values,
616 '-labels' => \%project_labels,
617 '-default' => $form->{"project_id_$i"} ));
621 <td width=50%><select name="AR_amount_$i" onChange="setTaxkey(this, $i)" style="width:100%">$selectAR_amount</select></td>
622 <td><input name="amount_$i" size=10 value=$form->{"amount_$i"}></td>
623 <td><input name="tax_$i" size=10 value=$form->{"tax_$i"}></td>
624 <td><input type="checkbox" name="korrektur_$i" value="1" $korrektur_checked></td>
626 <td>$projectnumber</td>
633 $form->{invtotal} = $form->format_amount(\%myconfig, $form->{invtotal}, 2);
642 <td><select name=ARselected>$form->{selectAR}</select></td>
643 <input type=hidden name=AR value="$form->{AR}">
644 <th align=left>$form->{invtotal}</th>
646 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
647 <input type=hidden name=oldtotalpaid value=$form->{oldtotalpaid}>
649 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
662 <th align=left width=1%>| . $locale->text('Notes') . qq|</th>
663 <td align=left>$notes</td>
671 <tr class=listheading>
672 <th colspan=7 class=listheading>|
673 . $locale->text('Incoming Payments') . qq|</th>
677 if ($form->{currency} eq $form->{defaultcurrency}) {
678 @column_index = qw(datepaid source memo paid AR_paid paid_project_id);
680 @column_index = qw(datepaid source memo paid exchangerate AR_paid paid_project_id);
683 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
684 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
685 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
686 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
687 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
688 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
689 $column_data{paid_project_id} = "<th>" . $locale->text('Project Number') . "</th>";
694 map { print "$column_data{$_}\n" } @column_index;
700 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
701 for $i (1 .. $form->{paidaccounts}) {
706 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
707 $form->{"selectAR_paid_$i"} =~
708 s/option value=\"$form->{"AR_paid_$i"}\">/option value=\"$form->{"AR_paid_$i"}\" selected>/;
711 if ($form->{"paid_$i"}) {
713 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
715 $form->{"exchangerate_$i"} =
716 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
718 $exchangerate = qq| |;
719 if ($form->{currency} ne $form->{defaultcurrency}) {
720 if ($form->{"forex_$i"}) {
722 qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
725 qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
730 <input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
734 qq|<td align=center><input name="paid_$i" size=11 value=$form->{"paid_$i"}></td>|;
735 $column_data{AR_paid} =
736 qq|<td align=center><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
737 $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
738 $column_data{datepaid} =
739 qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value=$form->{"datepaid_$i"}>
740 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
741 $column_data{source} =
742 qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
744 qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
746 $column_data{paid_project_id} =
748 . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
749 '-values' => \@project_values,
750 '-labels' => \%project_labels,
751 '-default' => $form->{"paid_project_id_$i"} ))
754 map { print qq|$column_data{$_}\n| } @column_index;
759 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
761 map { $form->{$_} =~ s/\"/"/g } qw(selectAR_paid);
763 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
765 <input type=hidden name=paidaccounts value=$form->{paidaccounts}>
766 <input type=hidden name=selectAR_paid value="$form->{selectAR_paid}">
772 <td><hr size=3 noshade></td>
777 $lxdebug->leave_sub();
781 $lxdebug->enter_sub();
785 <input name=gldate type=hidden value="| . Q($form->{gldate}) . qq|">
787 <input name=callback type=hidden value="$form->{callback}">
789 <input type=hidden name=path value=$form->{path}>
790 <input type=hidden name=login value=$form->{login}>
791 <input type=hidden name=password value=$form->{password}>
796 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
797 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
799 print qq|<input class=submit type=submit name=action value="|
800 . $locale->text('Update') . qq|">
803 if ($form->{radier}) {
805 <input class=submit type=submit name=action value="|
806 . $locale->text('Post') . qq|">
807 <input class=submit type=submit name=action value="|
808 . $locale->text('Delete') . qq|">
811 if ($transdate > $closedto) {
813 <input class=submit type=submit name=action value="|
814 . $locale->text('Use As Template') . qq|">
818 <input class=submit type=submit name=action value="|
819 . $locale->text('Post Payment') . qq|">
823 if ($transdate > $closedto) {
824 print qq|<input class=submit type=submit name=action value="|
825 . $locale->text('Post') . qq|">|;
829 if ($form->{menubar}) {
830 require "$form->{path}/menu.pl";
833 # button for saving history
834 if($form->{id} ne "") {
836 <input type=button class=submit onclick=set_history_window(|
838 . qq|); name=history id=history value=|
839 . $locale->text('history')
842 # /button for saving history
850 $lxdebug->leave_sub();
854 $lxdebug->enter_sub();
862 $form->{invtotal} = 0;
864 # $form->{selectAR_amount} = $form->{AR_amount};
865 # $form->{selectAR_amount} =~
866 # s/value=\"$form->{AR_amountselected}\"/value=\"$form->{AR_amountselected}\" selected/;
868 ($AR_amountaccno, $AR_amounttaxkey) =
869 split(/--/, $form->{AR_amountselected});
870 $form->{selecttaxchart} = $form->{taxchart};
871 $form->{selecttaxchart} =~
872 s/value=\"$AR_amounttaxkey--([^\"]*)\"/value=\"$AR_amounttaxkey--$1\" selected/;
876 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
877 qw(exchangerate creditlimit creditremaining);
879 @flds = qw(amount AR_amount projectnumber oldprojectnumber project_id);
883 for $i (1 .. $form->{rowcount}) {
884 $form->{"amount_$i"} =
885 $form->parse_amount(\%myconfig, $form->{"amount_$i"});
886 $form->{"tax_$i"} = $form->parse_amount(\%myconfig, $form->{"tax_$i"});
887 if ($form->{"amount_$i"}) {
890 if (!$form->{"korrektur_$i"}) {
891 ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
893 if ($form->{taxincluded}) {
894 $form->{"tax_$i"} = $form->{"amount_$i"} / ($rate + 1) * $rate;
896 $form->{"tax_$i"} = $form->{"amount_$i"} * $rate;
899 $form->{"tax_$i"} = 0;
902 $form->{"tax_$i"} = $form->round_amount($form->{"tax_$i"}, 2);
904 $totaltax += $form->{"tax_$i"};
905 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
910 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
911 $form->{rowcount} = $count + 1;
912 map { $form->{invtotal} += $form->{"amount_$_"} } (1 .. $form->{rowcount});
914 $form->{exchangerate} = $exchangerate
918 $form->check_exchangerate(
919 \%myconfig, $form->{currency}, $form->{transdate}, 'buy'
922 $form->{invdate} = $form->{transdate};
923 $save_AR = $form->{AR};
924 &check_name(customer);
925 $form->{AR} = $save_AR;
928 ($form->{taxincluded}) ? $form->{invtotal} : $form->{invtotal} + $totaltax;
930 for $i (1 .. $form->{paidaccounts}) {
931 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
934 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
935 } qw(paid exchangerate);
937 $totalpaid += $form->{"paid_$i"};
939 $form->{"exchangerate_$i"} = $exchangerate
941 $form->{"forex_$i"} = (
943 $form->check_exchangerate(
944 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
949 $form->{creditremaining} -=
950 ($form->{invtotal} - $totalpaid + $form->{oldtotalpaid} -
951 $form->{oldinvtotal});
952 $form->{oldinvtotal} = $form->{invtotal};
953 $form->{oldtotalpaid} = $totalpaid;
957 $lxdebug->leave_sub();
961 $lxdebug->enter_sub();
962 for $i (1 .. $form->{paidaccounts}) {
963 if ($form->{"paid_$i"}) {
964 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
966 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
968 $form->error($locale->text('Cannot post payment for a closed period!'))
969 if ($datepaid <= $closedto);
971 if ($form->{currency} ne $form->{defaultcurrency}) {
972 $form->{"exchangerate_$i"} = $form->{exchangerate}
973 if ($invdate == $datepaid);
974 $form->isblank("exchangerate_$i",
975 $locale->text('Exchangerate for payment missing!'));
980 ($form->{AR}) = split /--/, $form->{AR};
981 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
982 $form->redirect($locale->text(' Payment posted!'))
983 if (AR->post_payment(\%myconfig, \%$form));
984 $form->error($locale->text('Cannot post payment!'));
987 $lxdebug->leave_sub();
991 $lxdebug->enter_sub();
993 # check if there is an invoice number, invoice and due date
994 $form->isblank("transdate", $locale->text('Invoice Date missing!'));
995 $form->isblank("duedate", $locale->text('Due Date missing!'));
996 $form->isblank("customer", $locale->text('Customer missing!'));
998 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
999 $transdate = $form->datetonum($form->{transdate}, \%myconfig);
1001 $form->error($locale->text('Cannot post transaction for a closed period!'))
1002 if ($transdate <= $closedto);
1004 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1005 if ($form->{currency} ne $form->{defaultcurrency});
1007 delete($form->{AR});
1009 for $i (1 .. $form->{paidaccounts}) {
1010 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1011 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1013 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1015 $form->error($locale->text('Cannot post payment for a closed period!'))
1016 if ($datepaid <= $closedto);
1018 if ($form->{currency} ne $form->{defaultcurrency}) {
1019 $form->{"exchangerate_$i"} = $form->{exchangerate}
1020 if ($transdate == $datepaid);
1021 $form->isblank("exchangerate_$i",
1022 $locale->text('Exchangerate for payment missing!'));
1027 # if oldcustomer ne customer redo form
1028 ($customer) = split /--/, $form->{customer};
1029 if ($form->{oldcustomer} ne "$customer--$form->{customer_id}") {
1034 my ($creditaccno, $credittaxkey) = split /--/, $form->{AR_amountselected};
1035 my ($taxkey, $NULL) = split /--/, $form->{taxchartselected};
1036 my ($receivablesaccno, $payablestaxkey) = split /--/, $form->{ARselected};
1037 $form->{AR}{amount_1} = $creditaccno;
1038 $form->{AR}{receivables} = $receivablesaccno;
1039 $form->{taxkey} = $taxkey;
1041 $form->{invnumber} = $form->update_defaults(\%myconfig, "invnumber")
1042 unless $form->{invnumber};
1044 $form->{id} = 0 if $form->{postasnew};
1045 if (AR->post_transaction(\%myconfig, \%$form)) {
1046 # saving the history
1047 if(!exists $form->{addition} && $form->{id} ne "") {
1048 $form->{addition} = "POSTED";
1049 $form->save_history($form->dbconnect(\%myconfig));
1051 # /saving the history
1052 $form->redirect($locale->text('Transaction posted!'));
1054 $form->error($locale->text('Cannot post transaction!'));
1056 $lxdebug->leave_sub();
1060 $lxdebug->enter_sub();
1062 $form->{postasnew} = 1;
1063 # saving the history
1064 if(!exists $form->{addition} && $form->{id} ne "") {
1065 $form->{addition} = "POSTED AS NEW";
1066 $form->save_history($form->dbconnect(\%myconfig));
1068 # /saving the history
1071 $lxdebug->leave_sub();
1074 sub use_as_template {
1075 $lxdebug->enter_sub();
1077 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 $form->{paidaccounts} = 1;
1079 $form->{rowcount}--;
1080 $form->{invdate} = $form->current_date(\%myconfig);
1083 $lxdebug->leave_sub();
1087 $lxdebug->enter_sub();
1089 $form->{title} = $locale->text('Confirm!');
1093 delete $form->{header};
1098 <form method=post action=$form->{script}>
1101 foreach $key (keys %$form) {
1102 $form->{$key} =~ s/\"/"/g;
1103 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1107 <h2 class=confirm>$form->{title}</h2>
1110 . $locale->text('Are you sure you want to delete Transaction')
1111 . qq| $form->{invnumber}</h4>
1113 <input name=action class=submit type=submit value="|
1114 . $locale->text('Yes') . qq|">
1121 $lxdebug->leave_sub();
1125 $lxdebug->enter_sub();
1126 if (AR->delete_transaction(\%myconfig, \%$form, $spool)) {
1127 # saving the history
1128 if(!exists $form->{addition}) {
1129 $form->{addition} = "DELETED";
1130 $form->save_history($form->dbconnect(\%myconfig));
1132 # /saving the history
1133 $form->redirect($locale->text('Transaction deleted!'));
1135 $form->error($locale->text('Cannot delete transaction!'));
1137 $lxdebug->leave_sub();
1141 $lxdebug->enter_sub();
1143 # setup customer selection
1144 $form->all_vc(\%myconfig, "customer", "AR");
1146 if (@{ $form->{all_customer} }) {
1147 map { $customer .= "<option>$_->{name}--$_->{id}\n" }
1148 @{ $form->{all_customer} };
1149 $customer = qq|<select name=customer><option>\n$customer</select>|;
1151 $customer = qq|<input name=customer size=35>|;
1155 if (@{ $form->{all_departments} }) {
1156 $form->{selectdepartment} = "<option>\n";
1159 $form->{selectdepartment} .=
1160 "<option>$_->{description}--$_->{id}\n"
1161 } (@{ $form->{all_departments} });
1166 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1167 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1169 | if $form->{selectdepartment};
1171 $form->{title} = $locale->text('AR Transactions');
1173 # use JavaScript Calendar or not
1174 $form->{jsscript} = $jscalendar;
1176 if ($form->{jsscript}) {
1178 # with JavaScript Calendar
1180 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1181 <input type=button name=transdatefrom id="trigger1" value=|
1182 . $locale->text('button') . qq|></td>
1185 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1186 <input type=button name=transdateto name=transdateto id="trigger2" value=|
1187 . $locale->text('button') . qq|></td>
1192 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger1",
1193 "transdateto", "BL", "trigger2");
1196 # without JavaScript Calendar
1198 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1200 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1203 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1208 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1209 push(@values, $item->{"id"});
1210 $labels{$item->{"id"}} = $item->{"projectnumber"};
1213 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1214 '-labels' => \%labels));
1216 $form->{fokus} = "search.customer";
1220 <body onLoad="fokus()">
1222 <form method=post name="search" action=$form->{script}>
1225 <tr><th class=listtop>$form->{title}</th></tr>
1226 <tr height="5"></tr>
1231 <th align=right>| . $locale->text('Customer') . qq|</th>
1232 <td colspan=3>$customer</td>
1236 <th align=right nowrap>| . $locale->text('Invoice Number') . qq|</th>
1237 <td colspan=3><input name=invnumber size=20></td>
1240 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
1241 <td colspan=3><input name=ordnumber size=20></td>
1244 <th align=right nowrap>| . $locale->text('Notes') . qq|</th>
1245 <td colspan=3><input name=notes size=40></td>
1248 <th align="right">| . $locale->text("Project Number") . qq|</th>
1249 <td colspan="3">$projectnumber</td>
1252 <th align=right nowrap>| . $locale->text('From') . qq|</th>
1254 <th align=right>| . $locale->text('Bis') . qq|</th>
1257 <input type=hidden name=sort value=transdate>
1265 <th align=right nowrap>| . $locale->text('Include in Report') . qq|</th>
1269 <td align=right><input name=open class=checkbox type=checkbox value=Y checked></td>
1270 <td nowrap>| . $locale->text('Open') . qq|</td>
1271 <td align=right><input name=closed class=checkbox type=checkbox value=Y></td>
1272 <td nowrap>| . $locale->text('Closed') . qq|</td>
1275 <td align=right><input name="l_id" class=checkbox type=checkbox value=Y></td>
1276 <td nowrap>| . $locale->text('ID') . qq|</td>
1277 <td align=right><input name="l_invnumber" class=checkbox type=checkbox value=Y checked></td>
1278 <td nowrap>| . $locale->text('Invoice Number') . qq|</td>
1279 <td align=right><input name="l_ordnumber" class=checkbox type=checkbox value=Y></td>
1280 <td nowrap>| . $locale->text('Order Number') . qq|</td>
1281 <td align=right><input name="l_transdate" class=checkbox type=checkbox value=Y checked></td>
1282 <td nowrap>| . $locale->text('Invoice Date') . qq|</td>
1285 <td align=right><input name="l_name" class=checkbox type=checkbox value=Y checked></td>
1286 <td nowrap>| . $locale->text('Customer') . qq|</td>
1287 <td align=right><input name="l_netamount" class=checkbox type=checkbox value=Y></td>
1288 <td nowrap>| . $locale->text('Amount') . qq|</td>
1289 <td align=right><input name="l_tax" class=checkbox type=checkbox value=Y></td>
1290 <td nowrap>| . $locale->text('Tax') . qq|</td>
1291 <td align=right><input name="l_amount" class=checkbox type=checkbox value=Y checked></td>
1292 <td nowrap>| . $locale->text('Total') . qq|</td>
1295 <td align=right><input name="l_datepaid" class=checkbox type=checkbox value=Y></td>
1296 <td nowrap>| . $locale->text('Date Paid') . qq|</td>
1297 <td align=right><input name="l_paid" class=checkbox type=checkbox value=Y checked></td>
1298 <td nowrap>| . $locale->text('Paid') . qq|</td>
1299 <td align=right><input name="l_duedate" class=checkbox type=checkbox value=Y></td>
1300 <td nowrap>| . $locale->text('Due Date') . qq|</td>
1301 <td align=right><input name="l_due" class=checkbox type=checkbox value=Y></td>
1302 <td nowrap>| . $locale->text('Amount Due') . qq|</td>
1305 <td align=right><input name="l_notes" class=checkbox type=checkbox value=Y></td>
1306 <td nowrap>| . $locale->text('Notes') . qq|</td>
1307 <td align=right><input name="l_employee" class=checkbox type=checkbox value=Y></td>
1308 <td nowrap>| . $locale->text('Salesperson') . qq|</td>
1309 <td align=right><input name="l_shippingpoint" class=checkbox type=checkbox value=Y></td>
1310 <td nowrap>| . $locale->text('Shipping Point') . qq|</td>
1311 <td align=right><input name="l_shipvia" class=checkbox type=checkbox value=Y></td>
1312 <td nowrap>| . $locale->text('Ship via') . qq|</td>
1315 <td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
1316 <td nowrap>| . $locale->text('Subtotal') . qq|</td>
1317 <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
1318 <td nowrap>| . $locale->text('Project Number') . qq|</td>
1327 <td><hr size=3 noshade></td>
1331 <input type=hidden name=nextsub value=$form->{nextsub}>
1333 <input type=hidden name=path value=$form->{path}>
1334 <input type=hidden name=login value=$form->{login}>
1335 <input type=hidden name=password value=$form->{password}>
1338 <input class=submit type=submit name=action value="|
1339 . $locale->text('Continue') . qq|">
1350 $lxdebug->leave_sub();
1353 sub ar_transactions {
1354 $lxdebug->enter_sub();
1356 $form->{customer} = $form->unescape($form->{customer});
1357 ($form->{customer}, $form->{customer_id}) = split(/--/, $form->{customer});
1359 AR->ar_transactions(\%myconfig, \%$form);
1362 "$form->{script}?action=ar_transactions&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1365 if ($form->{customer}) {
1366 $callback .= "&customer=" . $form->escape($form->{customer}, 1);
1367 $href .= "&customer=" . $form->escape($form->{customer});
1368 $option = $locale->text('Customer') . " : $form->{customer}";
1370 if ($form->{department}) {
1371 $callback .= "&department=" . $form->escape($form->{department}, 1);
1372 $href .= "&department=" . $form->escape($form->{department});
1373 ($department) = split /--/, $form->{department};
1374 $option .= "\n<br>" if ($option);
1375 $option .= $locale->text('Department') . " : $department";
1377 if ($form->{invnumber}) {
1378 $callback .= "&invnumber=" . $form->escape($form->{invnumber}, 1);
1379 $href .= "&invnumber=" . $form->escape($form->{invnumber});
1380 $option .= "\n<br>" if ($option);
1381 $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
1383 if ($form->{ordnumber}) {
1384 $callback .= "&ordnumber=" . $form->escape($form->{ordnumber}, 1);
1385 $href .= "&ordnumber=" . $form->escape($form->{ordnumber});
1386 $option .= "\n<br>" if ($option);
1387 $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
1389 if ($form->{notes}) {
1390 $callback .= "¬es=" . $form->escape($form->{notes}, 1);
1391 $href .= "¬es=" . $form->escape($form->{notes});
1392 $option .= "\n<br>" if $option;
1393 $option .= $locale->text('Notes') . " : $form->{notes}";
1396 if ($form->{transdatefrom}) {
1397 $callback .= "&transdatefrom=$form->{transdatefrom}";
1398 $href .= "&transdatefrom=$form->{transdatefrom}";
1399 $option .= "\n<br>" if ($option);
1401 $locale->text('From') . " "
1402 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1404 if ($form->{transdateto}) {
1405 $callback .= "&transdateto=$form->{transdateto}";
1406 $href .= "&transdateto=$form->{transdateto}";
1407 $option .= "\n<br>" if ($option);
1409 $locale->text('Bis') . " "
1410 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1412 if ($form->{open}) {
1413 $callback .= "&open=$form->{open}";
1414 $href .= "&open=$form->{open}";
1415 $option .= "\n<br>" if ($option);
1416 $option .= $locale->text('Open');
1418 if ($form->{closed}) {
1419 $callback .= "&closed=$form->{closed}";
1420 $href .= "&closed=$form->{closed}";
1421 $option .= "\n<br>" if ($option);
1422 $option .= $locale->text('Closed');
1424 if ($form->{globalproject_id}) {
1425 $callback .= "&globalproject_id=" . E($form->{globalproject_id});
1426 $href .= "&globalproject_id=" . E($form->{globalproject_id});
1430 qw(transdate id type invnumber ordnumber name netamount tax amount paid
1431 datepaid due duedate notes employee shippingpoint shipvia
1432 globalprojectnumber);
1434 $form->{"l_type"} = "Y";
1436 foreach $item (@columns) {
1437 if ($form->{"l_$item"} eq "Y") {
1438 push @column_index, $item;
1440 # add column to href and callback
1441 $callback .= "&l_$item=Y";
1442 $href .= "&l_$item=Y";
1446 if ($form->{l_subtotal} eq 'Y') {
1447 $callback .= "&l_subtotal=Y";
1448 $href .= "&l_subtotal=Y";
1451 $column_header{id} =
1452 "<th><a class=listheading href=$href&sort=id>"
1453 . $locale->text('ID')
1455 $column_header{transdate} =
1456 "<th><a class=listheading href=$href&sort=transdate>"
1457 . $locale->text('Date')
1459 $column_header{duedate} =
1460 "<th><a class=listheading href=$href&sort=duedate>"
1461 . $locale->text('Due Date')
1463 $column_header{type} =
1464 "<th class=\"listheading\">" . $locale->text('Type') . "</th>";
1465 $column_header{invnumber} =
1466 "<th><a class=listheading href=$href&sort=invnumber>"
1467 . $locale->text('Invoice')
1469 $column_header{ordnumber} =
1470 "<th><a class=listheading href=$href&sort=ordnumber>"
1471 . $locale->text('Order')
1473 $column_header{name} =
1474 "<th><a class=listheading href=$href&sort=name>"
1475 . $locale->text('Customer')
1477 $column_header{netamount} =
1478 "<th class=listheading>" . $locale->text('Amount') . "</th>";
1479 $column_header{tax} =
1480 "<th class=listheading>" . $locale->text('Tax') . "</th>";
1481 $column_header{amount} =
1482 "<th class=listheading>" . $locale->text('Total') . "</th>";
1483 $column_header{paid} =
1484 "<th class=listheading>" . $locale->text('Paid') . "</th>";
1485 $column_header{datepaid} =
1486 "<th><a class=listheading href=$href&sort=datepaid>"
1487 . $locale->text('Date Paid')
1489 $column_header{due} =
1490 "<th class=listheading>" . $locale->text('Amount Due') . "</th>";
1491 $column_header{notes} =
1492 "<th class=listheading>" . $locale->text('Notes') . "</th>";
1493 $column_header{employee} =
1494 "<th><a class=listheading href=$href&sort=employee>"
1495 . $locale->text('Salesperson') . "</th>";
1497 $column_header{shippingpoint} =
1498 "<th><a class=listheading href=$href&sort=shippingpoint>"
1499 . $locale->text('Shipping Point')
1501 $column_header{shipvia} =
1502 "<th><a class=listheading href=$href&sort=shipvia>"
1503 . $locale->text('Ship via')
1505 $column_header{globalprojectnumber} =
1506 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1508 $form->{title} = $locale->text('AR Transactions');
1517 <th class=listtop>$form->{title}</th>
1519 <tr height="5"></tr>
1526 <tr class=listheading>
1529 map { print "\n$column_header{$_}" } @column_index;
1535 # add sort and escape callback, this one we use for the add sub
1536 $form->{callback} = $callback .= "&sort=$form->{sort}";
1538 # escape callback for href
1539 $callback = $form->escape($callback);
1541 if (@{ $form->{AR} }) {
1542 $sameitem = $form->{AR}->[0]->{ $form->{sort} };
1545 # sums and tax on reports by Antonio Gallardo
1547 foreach $ar (@{ $form->{AR} }) {
1549 if ($form->{l_subtotal} eq 'Y') {
1550 if ($sameitem ne $ar->{ $form->{sort} }) {
1555 $column_data{netamount} =
1557 . $form->format_amount(\%myconfig, $ar->{netamount}, 2, " ")
1559 $column_data{tax} = "<td align=right>"
1560 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{netamount},
1563 $column_data{amount} =
1565 . $form->format_amount(\%myconfig, $ar->{amount}, 2, " ") . "</td>";
1566 $column_data{paid} =
1568 . $form->format_amount(\%myconfig, $ar->{paid}, 2, " ") . "</td>";
1569 $column_data{due} = "<td align=right>"
1570 . $form->format_amount(\%myconfig, $ar->{amount} - $ar->{paid},
1574 $subtotalnetamount += $ar->{netamount};
1575 $subtotalamount += $ar->{amount};
1576 $subtotalpaid += $ar->{paid};
1577 $subtotaldue += $ar->{amount} - $ar->{paid};
1579 $totalnetamount += $ar->{netamount};
1580 $totalamount += $ar->{amount};
1581 $totalpaid += $ar->{paid};
1582 $totaldue += ($ar->{amount} - $ar->{paid});
1584 $column_data{transdate} = "<td>$ar->{transdate} </td>";
1585 $column_data{id} = "<td>$ar->{id}</td>";
1586 $column_data{datepaid} = "<td>$ar->{datepaid} </td>";
1587 $column_data{duedate} = "<td>$ar->{duedate} </td>";
1589 $module = ($ar->{invoice}) ? "is.pl" : $form->{script};
1591 $column_data{invnumber} =
1592 "<td><a href=$module?action=edit&id=$ar->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ar->{invnumber}</a></td>";
1593 $column_data{type} = "<td>" .
1594 ($ar->{storno} ? $locale->text("Storno (one letter abbreviation)") :
1596 $locale->text("Credit note (one letter abbreviation)") :
1597 $locale->text("Invoice (one letter abbreviation)")) . "</td>";
1598 $column_data{ordnumber} = "<td>$ar->{ordnumber} </td>";
1599 $column_data{name} = "<td>$ar->{name}</td>";
1600 $ar->{notes} =~ s/\r\n/<br>/g;
1601 $column_data{notes} = "<td>$ar->{notes} </td>";
1602 $column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
1603 $column_data{shipvia} = "<td>$ar->{shipvia} </td>";
1604 $column_data{employee} = "<td>$ar->{employee} </td>";
1605 $column_data{globalprojectnumber} =
1606 "<td>" . H($ar->{globalprojectnumber}) . "</td>";
1611 <tr class=listrow$i>
1614 map { print "\n$column_data{$_}" } @column_index;
1622 if ($form->{l_subtotal} eq 'Y') {
1628 <tr class=listtotal>
1631 map { $column_data{$_} = "<td> </td>" } @column_index;
1633 $column_data{netamount} =
1634 "<th class=listtotal align=right>"
1635 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1636 $column_data{tax} = "<th class=listtotal align=right>"
1637 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1640 $column_data{amount} =
1641 "<th class=listtotal align=right>"
1642 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1643 $column_data{paid} =
1644 "<th class=listtotal align=right>"
1645 . $form->format_amount(\%myconfig, $totalpaid, 2, " ") . "</th>";
1647 "<th class=listtotal align=right>"
1648 . $form->format_amount(\%myconfig, $totaldue, 2, " ") . "</th>";
1650 map { print "\n$column_data{$_}" } @column_index;
1658 <td><hr size=3 noshade></td>
1663 <form method=post action=$form->{script}>
1665 <input name=callback type=hidden value="$form->{callback}">
1667 <input type=hidden name=path value=$form->{path}>
1668 <input type=hidden name=login value=$form->{login}>
1669 <input type=hidden name=password value=$form->{password}>
1671 <input class=submit type=submit name=action value="|
1672 . $locale->text('AR Transaction') . qq|">
1673 <input class=submit type=submit name=action value="|
1674 . $locale->text('Sales Invoice') . qq|">
1682 $lxdebug->leave_sub();
1686 $lxdebug->enter_sub();
1688 map { $column_data{$_} = "<td> </td>" } @column_index;
1690 $column_data{tax} = "<th class=listsubtotal align=right>"
1691 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1694 $column_data{amount} =
1695 "<th class=listsubtotal align=right>"
1696 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1697 $column_data{paid} =
1698 "<th class=listsubtotal align=right>"
1699 . $form->format_amount(\%myconfig, $subtotalpaid, 2, " ") . "</th>";
1701 "<th class=listsubtotal align=right>"
1702 . $form->format_amount(\%myconfig, $subtotaldue, 2, " ") . "</th>";
1704 $subtotalnetamount = 0;
1705 $subtotalamount = 0;
1709 $sameitem = $ar->{ $form->{sort} };
1711 print "<tr class=listsubtotal>";
1713 map { print "\n$column_data{$_}" } @column_index;
1719 $lxdebug->leave_sub();