30 |
30 |
# Order entry module
|
31 |
31 |
# Quotation module
|
32 |
32 |
#======================================================================
|
33 |
|
use Data::Dumper;
|
|
33 |
|
|
34 |
use POSIX qw(strftime);
|
34 |
35 |
|
35 |
36 |
use SL::OE;
|
36 |
37 |
use SL::IR;
|
37 |
38 |
use SL::IS;
|
38 |
39 |
use SL::PE;
|
|
40 |
use SL::ReportGenerator;
|
39 |
41 |
|
40 |
42 |
require "bin/mozilla/io.pl";
|
41 |
43 |
require "bin/mozilla/arap.pl";
|
|
44 |
require "bin/mozilla/report_generator.pl";
|
42 |
45 |
|
43 |
46 |
1;
|
44 |
47 |
|
... | ... | |
1569 |
1572 |
$lxdebug->leave_sub();
|
1570 |
1573 |
}
|
1571 |
1574 |
|
|
1575 |
sub create_subtotal_row {
|
|
1576 |
$lxdebug->enter_sub();
|
|
1577 |
|
|
1578 |
my ($totals, $columns, $column_alignment, $subtotal_columns, $class) = @_;
|
|
1579 |
|
|
1580 |
my $row = { map { $_ => { 'data' => '', 'class' => $class, 'align' => $column_alignment->{$_}, } } @{ $columns } };
|
|
1581 |
|
|
1582 |
map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $totals->{$_}, 2) } @{ $subtotal_columns };
|
|
1583 |
|
|
1584 |
$row->{tax}->{data} = $form->format_amount(\%myconfig, $totals->{amount} - $totals->{netamount}, 2);
|
|
1585 |
|
|
1586 |
map { $totals->{$_} = 0 } @{ $subtotal_columns };
|
|
1587 |
|
|
1588 |
$lxdebug->leave_sub();
|
|
1589 |
|
|
1590 |
return $row;
|
|
1591 |
}
|
|
1592 |
|
1572 |
1593 |
sub orders {
|
1573 |
1594 |
$lxdebug->enter_sub();
|
1574 |
1595 |
|
1575 |
1596 |
$ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
|
1576 |
1597 |
|
1577 |
|
# construct href
|
1578 |
|
my @fields =
|
1579 |
|
qw(type vc login password transdatefrom transdateto
|
1580 |
|
open closed notdelivered delivered department
|
1581 |
|
transaction_description);
|
1582 |
|
push @fields, $form->{vc};
|
1583 |
|
$href = "$form->{script}?action=orders&"
|
1584 |
|
. join("&", map { "${_}=" . E($form->{$_}) } @fields)
|
1585 |
|
. "&${ordnumber}=" . E($form->{$ordnumber});
|
1586 |
|
$callback = $href;
|
1587 |
|
|
1588 |
|
# split vendor / customer
|
1589 |
|
($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
|
1590 |
|
split(/--/, $form->{ $form->{vc} });
|
|
1598 |
($form->{ $form->{vc} }, $form->{"${form->{vc}}_id"}) = split(/--/, $form->{ $form->{vc} });
|
|
1599 |
|
|
1600 |
$form->{sort} ||= 'transdate';
|
1591 |
1601 |
|
1592 |
1602 |
OE->transactions(\%myconfig, \%$form);
|
1593 |
1603 |
|
1594 |
|
@columns = (
|
|
1604 |
$form->{rowcount} = scalar @{ $form->{OE} };
|
|
1605 |
|
|
1606 |
my @columns = (
|
1595 |
1607 |
"transdate", "reqdate",
|
1596 |
|
"id", "$ordnumber",
|
|
1608 |
"id", $ordnumber,
|
1597 |
1609 |
"name", "netamount",
|
1598 |
1610 |
"tax", "amount",
|
1599 |
1611 |
"curr", "employee",
|
1600 |
1612 |
"shipvia", "globalprojectnumber",
|
1601 |
1613 |
"transaction_description", "open",
|
1602 |
|
"closed", "delivered"
|
|
1614 |
"delivered"
|
1603 |
1615 |
);
|
1604 |
1616 |
|
1605 |
|
$form->{l_open} = $form->{l_closed} = "Y"
|
1606 |
|
if ($form->{open} && $form->{closed});
|
1607 |
|
|
1608 |
|
$form->{"l_delivered"} = "Y"
|
1609 |
|
if ($form->{"delivered"} && $form->{"notdelivered"});
|
1610 |
|
|
1611 |
|
foreach $item (@columns) {
|
1612 |
|
if ($form->{"l_$item"} eq "Y") {
|
1613 |
|
push @column_index, $item;
|
1614 |
|
|
1615 |
|
# add column to href and callback
|
1616 |
|
$callback .= "&l_$item=Y";
|
1617 |
|
$href .= "&l_$item=Y";
|
1618 |
|
}
|
1619 |
|
}
|
1620 |
|
|
1621 |
1617 |
# only show checkboxes if gotten here via sales_order form.
|
1622 |
|
if ($form->{type} =~ /sales_order/) {
|
1623 |
|
unshift @column_index, "ids";
|
|
1618 |
my $allow_multiple_orders = $form->{type} eq 'sales_order';
|
|
1619 |
if ($allow_multiple_orders) {
|
|
1620 |
unshift @columns, "ids";
|
1624 |
1621 |
}
|
1625 |
1622 |
|
1626 |
|
if ($form->{l_subtotal} eq 'Y') {
|
1627 |
|
$callback .= "&l_subtotal=Y";
|
1628 |
|
$href .= "&l_subtotal=Y";
|
1629 |
|
}
|
|
1623 |
$form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed});
|
|
1624 |
$form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered});
|
1630 |
1625 |
|
|
1626 |
my $attachment_basename;
|
1631 |
1627 |
if ($form->{vc} eq 'vendor') {
|
1632 |
1628 |
if ($form->{type} eq 'purchase_order') {
|
1633 |
|
$form->{title} = $locale->text('Purchase Orders');
|
|
1629 |
$form->{title} = $locale->text('Purchase Orders');
|
|
1630 |
$attachment_basename = $locale->text('purchase_order_list');
|
1634 |
1631 |
} else {
|
1635 |
|
$form->{title} = $locale->text('Request for Quotations');
|
|
1632 |
$form->{title} = $locale->text('Request for Quotations');
|
|
1633 |
$attachment_basename = $locale->text('rfq_list');
|
1636 |
1634 |
}
|
1637 |
|
$name = $locale->text('Vendor');
|
1638 |
|
$employee = $locale->text('Employee');
|
1639 |
|
}
|
1640 |
|
if ($form->{vc} eq 'customer') {
|
|
1635 |
|
|
1636 |
} else {
|
1641 |
1637 |
if ($form->{type} eq 'sales_order') {
|
1642 |
|
$form->{title} = $locale->text('Sales Orders');
|
|
1638 |
$form->{title} = $locale->text('Sales Orders');
|
|
1639 |
$attachment_basename = $locale->text('sales_order_list');
|
1643 |
1640 |
} else {
|
1644 |
|
$form->{title} = $locale->text('Quotations');
|
|
1641 |
$form->{title} = $locale->text('Quotations');
|
|
1642 |
$attachment_basename = $locale->text('quotation_list');
|
1645 |
1643 |
}
|
1646 |
|
$employee = $locale->text('Employee');
|
1647 |
|
$name = $locale->text('Customer');
|
1648 |
|
}
|
1649 |
|
|
1650 |
|
$column_header{id} =
|
1651 |
|
qq|<th><a class=listheading href=$href&sort=id>|
|
1652 |
|
. $locale->text('ID')
|
1653 |
|
. qq|</a></th>|;
|
1654 |
|
$column_header{transdate} =
|
1655 |
|
qq|<th><a class=listheading href=$href&sort=transdate>|
|
1656 |
|
. $locale->text('Date')
|
1657 |
|
. qq|</a></th>|;
|
1658 |
|
$column_header{reqdate} =
|
1659 |
|
qq|<th><a class=listheading href=$href&sort=reqdate>|
|
1660 |
|
. $locale->text('Required by')
|
1661 |
|
. qq|</a></th>|;
|
1662 |
|
$column_header{ordnumber} =
|
1663 |
|
qq|<th><a class=listheading href=$href&sort=ordnumber>|
|
1664 |
|
. $locale->text('Order')
|
1665 |
|
. qq|</a></th>|;
|
1666 |
|
$column_header{quonumber} =
|
1667 |
|
qq|<th><a class=listheading href=$href&sort=quonumber>|
|
1668 |
|
. ($form->{"type"} eq "request_quotation" ?
|
1669 |
|
$locale->text('RFQ') :
|
1670 |
|
$locale->text('Quotation'))
|
1671 |
|
. qq|</a></th>|;
|
1672 |
|
$column_header{name} =
|
1673 |
|
qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
|
1674 |
|
$column_header{netamount} =
|
1675 |
|
qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
|
1676 |
|
$column_header{tax} =
|
1677 |
|
qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
|
1678 |
|
$column_header{amount} =
|
1679 |
|
qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
|
1680 |
|
$column_header{curr} =
|
1681 |
|
qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
|
1682 |
|
$column_header{shipvia} =
|
1683 |
|
qq|<th><a class=listheading href=$href&sort=shipvia>|
|
1684 |
|
. $locale->text('Ship via')
|
1685 |
|
. qq|</a></th>|;
|
1686 |
|
$column_header{globalprojectnumber} =
|
1687 |
|
qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
|
1688 |
|
$column_header{open} =
|
1689 |
|
qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
|
1690 |
|
$column_header{closed} =
|
1691 |
|
qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
|
1692 |
|
$column_header{"delivered"} =
|
1693 |
|
qq|<th class="listheading">| . $locale->text("Delivered") . qq|</th>|;
|
1694 |
|
|
1695 |
|
$column_header{employee} =
|
1696 |
|
qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
|
1697 |
|
$column_header{transaction_description} =
|
1698 |
|
qq|<th><a class=listheading href="$href&sort=transaction_description">|
|
1699 |
|
. $locale->text("Transaction description") . qq|</a></th>|;
|
1700 |
|
|
1701 |
|
$column_header{ids} = qq|<th></th>|;
|
1702 |
|
|
1703 |
|
if ($form->{ $form->{vc} }) {
|
1704 |
|
$option = $locale->text(ucfirst $form->{vc});
|
1705 |
|
$option .= " : $form->{$form->{vc}}";
|
|
1644 |
}
|
|
1645 |
|
|
1646 |
my $report = SL::ReportGenerator->new(\%myconfig, $form);
|
|
1647 |
|
|
1648 |
my @hidden_variables = map { "l_${_}" } @columns;
|
|
1649 |
push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
|
|
1650 |
transaction_description transdatefrom transdateto type vc);
|
|
1651 |
|
|
1652 |
my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
|
|
1653 |
|
|
1654 |
my %column_defs = (
|
|
1655 |
'ids' => { 'text' => '', },
|
|
1656 |
'transdate' => { 'text' => $locale->text('Date'), },
|
|
1657 |
'reqdate' => { 'text' => $locale->text('Required by'), },
|
|
1658 |
'id' => { 'text' => $locale->text('ID'), },
|
|
1659 |
'ordnumber' => { 'text' => $locale->text('Order'), },
|
|
1660 |
'quonumber' => { 'text' => $form->{type} eq "request_quotation" ? $locale->text('RFQ') : $locale->text('Quotation'), },
|
|
1661 |
'name' => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer') : $locale->text('Vendor'), },
|
|
1662 |
'netamount' => { 'text' => $locale->text('Amount'), },
|
|
1663 |
'tax' => { 'text' => $locale->text('Tax'), },
|
|
1664 |
'amount' => { 'text' => $locale->text('Total'), },
|
|
1665 |
'curr' => { 'text' => $locale->text('Curr'), },
|
|
1666 |
'employee' => { 'text' => $locale->text('Salesperson'), },
|
|
1667 |
'shipvia' => { 'text' => $locale->text('Ship via'), },
|
|
1668 |
'globalprojectnumber' => { 'text' => $locale->text('Project Number'), },
|
|
1669 |
'transaction_description' => { 'text' => $locale->text('Transaction description'), },
|
|
1670 |
'open' => { 'text' => $locale->text('Open'), },
|
|
1671 |
'delivered' => { 'text' => $locale->text('Delivered'), },
|
|
1672 |
);
|
|
1673 |
|
|
1674 |
foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee shipvia)) {
|
|
1675 |
$column_defs{$name}->{link} = $href . "&sort=$name";
|
|
1676 |
}
|
|
1677 |
|
|
1678 |
my %column_alignment = map { $_ => 'right' } qw(netamount tax amount curr);
|
|
1679 |
|
|
1680 |
$form->{"l_type"} = "Y";
|
|
1681 |
map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
|
|
1682 |
$column_defs{ids}->{visible} = $allow_multiple_orders ? 'HTML' : 0;
|
|
1683 |
|
|
1684 |
$report->set_columns(%column_defs);
|
|
1685 |
$report->set_column_order(@columns);
|
|
1686 |
|
|
1687 |
$report->set_export_options('orders', @hidden_variables);
|
|
1688 |
|
|
1689 |
my @options;
|
|
1690 |
if ($form->{customer}) {
|
|
1691 |
push @options, $locale->text('Customer') . " : $form->{customer}";
|
|
1692 |
}
|
|
1693 |
if ($form->{vendor}) {
|
|
1694 |
push @options, $locale->text('Vendor') . " : $form->{vendor}";
|
1706 |
1695 |
}
|
1707 |
1696 |
if ($form->{department}) {
|
1708 |
|
$option .= "\n<br>" if ($option);
|
1709 |
1697 |
($department) = split /--/, $form->{department};
|
1710 |
|
$option .= $locale->text('Department') . " : $department";
|
|
1698 |
push @options, $locale->text('Department') . " : $department";
|
|
1699 |
}
|
|
1700 |
if ($form->{ordnumber}) {
|
|
1701 |
push @options, $locale->text('Order Number') . " : $form->{ordnumber}";
|
|
1702 |
}
|
|
1703 |
if ($form->{notes}) {
|
|
1704 |
push @options, $locale->text('Notes') . " : $form->{notes}";
|
|
1705 |
}
|
|
1706 |
if ($form->{transaction_description}) {
|
|
1707 |
push @options, $locale->text('Transaction description') . " : $form->{transaction_description}";
|
1711 |
1708 |
}
|
1712 |
1709 |
if ($form->{transdatefrom}) {
|
1713 |
|
$option .= "\n<br>"
|
1714 |
|
. $locale->text('From') . " "
|
1715 |
|
. $locale->date(\%myconfig, $form->{transdatefrom}, 1);
|
|
1710 |
push @options, $locale->text('From') . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
|
1716 |
1711 |
}
|
1717 |
1712 |
if ($form->{transdateto}) {
|
1718 |
|
$option .= "\n<br>"
|
1719 |
|
. $locale->text('Bis') . " "
|
1720 |
|
. $locale->date(\%myconfig, $form->{transdateto}, 1);
|
|
1713 |
push @options, $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{transdateto}, 1);
|
1721 |
1714 |
}
|
1722 |
1715 |
if ($form->{open}) {
|
1723 |
|
$option .= "\n<br>" if ($option);
|
1724 |
|
$option .= $locale->text('Open');
|
|
1716 |
push @options, $locale->text('Open');
|
1725 |
1717 |
}
|
1726 |
1718 |
if ($form->{closed}) {
|
1727 |
|
$option .= "\n<br>" if ($option);
|
1728 |
|
$option .= $locale->text('Closed');
|
|
1719 |
push @options, $locale->text('Closed');
|
1729 |
1720 |
}
|
1730 |
|
|
1731 |
|
$form->header;
|
1732 |
|
|
1733 |
|
print qq|
|
1734 |
|
<body>
|
1735 |
|
|
1736 |
|
<form method="post" action="oe.pl">
|
1737 |
|
<table width=100%>
|
1738 |
|
<tr>
|
1739 |
|
<th class=listtop>$form->{title}</th>
|
1740 |
|
</tr>
|
1741 |
|
<tr height="5"></tr>
|
1742 |
|
<tr>
|
1743 |
|
<td>$option</td>
|
1744 |
|
</tr>
|
1745 |
|
<tr>
|
1746 |
|
<td>
|
1747 |
|
<table width=100%>
|
1748 |
|
<tr class=listheading>|;
|
1749 |
|
|
1750 |
|
map { print "\n$column_header{$_}" } @column_index;
|
1751 |
|
|
1752 |
|
print qq|
|
1753 |
|
</tr>
|
1754 |
|
|;
|
1755 |
|
|
1756 |
|
# add sort and escape callback
|
1757 |
|
$callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
|
1758 |
|
|
1759 |
|
if (@{ $form->{OE} }) {
|
1760 |
|
$sameitem = $form->{OE}->[0]->{ $form->{sort} };
|
|
1721 |
if ($form->{delivered}) {
|
|
1722 |
push @options, $locale->text('Delivered');
|
1761 |
1723 |
}
|
1762 |
|
|
1763 |
|
$action = "edit";
|
1764 |
|
|
1765 |
|
foreach $oe (@{ $form->{OE} }) {
|
1766 |
|
$form->{rowcount} = ++$j;
|
1767 |
|
|
1768 |
|
if ($form->{l_subtotal} eq 'Y') {
|
1769 |
|
if ($sameitem ne $oe->{ $form->{sort} }) {
|
1770 |
|
&subtotal;
|
1771 |
|
$sameitem = $oe->{ $form->{sort} };
|
1772 |
|
}
|
1773 |
|
}
|
1774 |
|
|
1775 |
|
map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
|
1776 |
|
|
1777 |
|
$column_data{netamount} =
|
1778 |
|
"<td align=right>"
|
1779 |
|
. $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
|
1780 |
|
. "</td>";
|
1781 |
|
$column_data{tax} = "<td align=right>"
|
1782 |
|
. $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
|
1783 |
|
2, " ")
|
1784 |
|
. "</td>";
|
1785 |
|
$column_data{amount} =
|
1786 |
|
"<td align=right>"
|
1787 |
|
. $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
|
1788 |
|
|
1789 |
|
$totalnetamount += $oe->{netamount};
|
1790 |
|
$totalamount += $oe->{amount};
|
1791 |
|
|
1792 |
|
$subtotalnetamount += $oe->{netamount};
|
1793 |
|
$subtotalamount += $oe->{amount};
|
1794 |
|
|
1795 |
|
$column_data{ids} =
|
1796 |
|
qq|<td><input name="multi_id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
|
1797 |
|
$column_data{id} = "<td>$oe->{id}</td>";
|
1798 |
|
$column_data{transdate} = "<td>$oe->{transdate} </td>";
|
1799 |
|
$column_data{reqdate} = "<td>$oe->{reqdate} </td>";
|
1800 |
|
|
1801 |
|
$column_data{$ordnumber} =
|
1802 |
|
"<td><a href=oe.pl?action=$action&type=$form->{type}&id=$oe->{id}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
|
1803 |
|
$column_data{name} = "<td>$oe->{name}</td>";
|
1804 |
|
|
1805 |
|
$column_data{employee} = "<td>$oe->{employee} </td>";
|
1806 |
|
$column_data{shipvia} = "<td>$oe->{shipvia} </td>";
|
1807 |
|
$column_data{globalprojectnumber} = "<td>" . H($oe->{globalprojectnumber}) . "</td>";
|
1808 |
|
|
1809 |
|
if ($oe->{closed}) {
|
1810 |
|
$column_data{closed} = "<td align=center>X</td>";
|
1811 |
|
$column_data{open} = "<td> </td>";
|
1812 |
|
} else {
|
1813 |
|
$column_data{closed} = "<td> </td>";
|
1814 |
|
$column_data{open} = "<td align=center>X</td>";
|
1815 |
|
}
|
1816 |
|
$column_data{"delivered"} = "<td>" .
|
1817 |
|
($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
|
1818 |
|
"</td>";
|
1819 |
|
$column_data{transaction_description} = "<td>" . H($oe->{transaction_description}) . "</td>";
|
1820 |
|
|
1821 |
|
$i++;
|
1822 |
|
$i %= 2;
|
1823 |
|
print "
|
1824 |
|
<tr class=listrow$i>";
|
1825 |
|
|
1826 |
|
map { print "\n$column_data{$_}" } @column_index;
|
1827 |
|
|
1828 |
|
print qq|
|
1829 |
|
</tr>
|
1830 |
|
|;
|
1831 |
|
|
|
1724 |
if ($form->{notdelivered}) {
|
|
1725 |
push @options, $locale->text('Not delivered');
|
1832 |
1726 |
}
|
1833 |
1727 |
|
1834 |
|
if ($form->{l_subtotal} eq 'Y') {
|
1835 |
|
&subtotal;
|
1836 |
|
}
|
|
1728 |
$report->set_options('top_info_text' => join("\n", @options),
|
|
1729 |
'raw_top_info_text' => $form->parse_html_template('oe/orders_top'),
|
|
1730 |
'raw_bottom_info_text' => $form->parse_html_template('oe/orders_bottom', { 'SHOW_CONTINUE_BUTTON' => $allow_multiple_orders }),
|
|
1731 |
'output_format' => 'HTML',
|
|
1732 |
'title' => $form->{title},
|
|
1733 |
'attachment_basename' => $attachment_basename . strftime('_%Y%m%d', localtime time),
|
|
1734 |
);
|
|
1735 |
$report->set_options_from_form();
|
1837 |
1736 |
|
1838 |
|
# print totals
|
1839 |
|
print qq|
|
1840 |
|
<tr class=listtotal>|;
|
|
1737 |
# add sort and escape callback, this one we use for the add sub
|
|
1738 |
$form->{callback} = $href .= "&sort=$form->{sort}";
|
1841 |
1739 |
|
1842 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
|
1740 |
# escape callback for href
|
|
1741 |
$callback = $form->escape($href);
|
1843 |
1742 |
|
1844 |
|
$column_data{netamount} =
|
1845 |
|
"<th class=listtotal align=right>"
|
1846 |
|
. $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
|
1847 |
|
$column_data{tax} = "<th class=listtotal align=right>"
|
1848 |
|
. $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
|
1849 |
|
2, " ")
|
1850 |
|
. "</th>";
|
1851 |
|
$column_data{amount} =
|
1852 |
|
"<th class=listtotal align=right>"
|
1853 |
|
. $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
|
|
1743 |
my @subtotal_columns = qw(netamount amount);
|
1854 |
1744 |
|
1855 |
|
map { print "\n$column_data{$_}" } @column_index;
|
|
1745 |
my %totals = map { $_ => 0 } @subtotal_columns;
|
|
1746 |
my %subtotals = map { $_ => 0 } @subtotal_columns;
|
1856 |
1747 |
|
1857 |
|
print qq|
|
1858 |
|
</tr>
|
1859 |
|
</td>
|
1860 |
|
</table>
|
1861 |
|
</tr>
|
1862 |
|
<tr>
|
1863 |
|
<td><hr size=3 noshade></td>
|
1864 |
|
</tr>
|
1865 |
|
</table>|;
|
1866 |
|
|
1867 |
|
# multiple invoice edit button only if gotten there via sales_order form.
|
|
1748 |
my $idx = 0;
|
1868 |
1749 |
|
1869 |
|
if ($form->{type} =~ /sales_order/) {
|
1870 |
|
print qq|
|
1871 |
|
<input class"submit" type="submit" name="action" value="|
|
1872 |
|
. $locale->text('Continue') . qq|">
|
1873 |
|
<input type="hidden" name="nextsub" value="edit">
|
1874 |
|
<input type="hidden" name="type" value="$form->{type}">
|
1875 |
|
<input type="hidden" name="vc" value="$form->{vc}">
|
1876 |
|
<input type="hidden" name="login" value="$form->{login}">
|
1877 |
|
<input type="hidden" name="password" value="$form->{password}">
|
1878 |
|
<input type="hidden" name="callback" value="$callback">
|
1879 |
|
<input type="hidden" name="rowcount" value="$form->{rowcount}">|;
|
1880 |
|
}
|
1881 |
|
|
1882 |
|
print qq|
|
1883 |
|
</form>
|
|
1750 |
my $edit_url = build_std_url('action=edit', 'type', 'vc');
|
1884 |
1751 |
|
1885 |
|
<br>
|
1886 |
|
<form method=post action=$form->{script}>
|
|
1752 |
foreach $oe (@{ $form->{OE} }) {
|
|
1753 |
map { $oe->{$_} *= $oe->{exchangerate} } @subtotal_columns;
|
1887 |
1754 |
|
1888 |
|
<input name=callback type=hidden value="$form->{callback}">
|
|
1755 |
$oe->{tax} = $oe->{amount} - $oe->{netamount};
|
|
1756 |
$oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes');
|
|
1757 |
$oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No');
|
1889 |
1758 |
|
1890 |
|
<input type=hidden name=type value=$form->{type}>
|
1891 |
|
<input type=hidden name=vc value=$form->{vc}>
|
|
1759 |
map { $subtotals{$_} += $oe->{$_};
|
|
1760 |
$totals{$_} += $oe->{$_} } @subtotal_columns;
|
1892 |
1761 |
|
1893 |
|
<input type=hidden name=login value=$form->{login}>
|
1894 |
|
<input type=hidden name=password value=$form->{password}>
|
|
1762 |
map { $oe->{$_} = $form->format_amount(\%myconfig, $oe->{$_}, 2) } qw(netamount tax amount);
|
1895 |
1763 |
|
1896 |
|
</form>
|
|
1764 |
my $row = { };
|
1897 |
1765 |
|
1898 |
|
</body>
|
1899 |
|
</html>
|
1900 |
|
|;
|
|
1766 |
foreach my $column (@columns) {
|
|
1767 |
next if ($column eq 'ids');
|
|
1768 |
$row->{$column} = {
|
|
1769 |
'data' => $oe->{$column},
|
|
1770 |
'align' => $column_alignment{$column},
|
|
1771 |
};
|
|
1772 |
}
|
1901 |
1773 |
|
1902 |
|
$lxdebug->leave_sub();
|
1903 |
|
}
|
|
1774 |
$row->{ids} = {
|
|
1775 |
'raw_data' => $cgi->hidden('-name' => "trans_id_${idx}", '-value' => $oe->{id})
|
|
1776 |
. $cgi->checkbox('-name' => "multi_id_${idx}", '-value' => 1, '-label' => ''),
|
|
1777 |
'valign' => 'center',
|
|
1778 |
'align' => 'center',
|
|
1779 |
};
|
1904 |
1780 |
|
1905 |
|
sub subtotal {
|
1906 |
|
$lxdebug->enter_sub();
|
|
1781 |
$row->{$ordnumber}->{link} = $edit_url . "&id=" . E($oe->{id}) . "&callback=${callback}";
|
1907 |
1782 |
|
1908 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
|
1783 |
my $row_set = [ $row ];
|
1909 |
1784 |
|
1910 |
|
$column_data{netamount} =
|
1911 |
|
"<th class=listsubtotal align=right>"
|
1912 |
|
. $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
|
1913 |
|
. "</th>";
|
1914 |
|
$column_data{tax} = "<td class=listsubtotal align=right>"
|
1915 |
|
. $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
|
1916 |
|
2, " ")
|
1917 |
|
. "</th>";
|
1918 |
|
$column_data{amount} =
|
1919 |
|
"<th class=listsubtotal align=right>"
|
1920 |
|
. $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
|
|
1785 |
if (($form->{l_subtotal} eq 'Y')
|
|
1786 |
&& (($idx == (scalar @{ $form->{OE} } - 1))
|
|
1787 |
|| ($oe->{ $form->{sort} } ne $form->{OE}->[$idx + 1]->{ $form->{sort} }))) {
|
|
1788 |
push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, \@subtotal_columns, 'listsubtotal');
|
|
1789 |
}
|
1921 |
1790 |
|
1922 |
|
$subtotalnetamount = 0;
|
1923 |
|
$subtotalamount = 0;
|
|
1791 |
$report->add_data($row_set);
|
1924 |
1792 |
|
1925 |
|
print "
|
1926 |
|
<tr class=listsubtotal>
|
1927 |
|
";
|
|
1793 |
$idx++;
|
|
1794 |
}
|
1928 |
1795 |
|
1929 |
|
map { print "\n$column_data{$_}" } @column_index;
|
|
1796 |
$report->add_separator();
|
|
1797 |
$report->add_data(create_subtotal_row(\%totals, \@columns, \%column_alignment, \@subtotal_columns, 'listtotal'));
|
1930 |
1798 |
|
1931 |
|
print qq|
|
1932 |
|
</tr>
|
1933 |
|
|;
|
|
1799 |
$report->generate_with_headers();
|
1934 |
1800 |
|
1935 |
1801 |
$lxdebug->leave_sub();
|
1936 |
1802 |
}
|
Die Berichtsoptionen in oe.pl (Anfragen, Aufträge, Angebote) auf die Verwendung von ReportGenerator umgestellt.