32 |
32 |
#======================================================================
|
33 |
33 |
#$locale->text('ea');
|
34 |
34 |
|
|
35 |
use POSIX qw(strftime);
|
|
36 |
|
35 |
37 |
use SL::IC;
|
|
38 |
use SL::ReportGenerator;
|
36 |
39 |
|
37 |
40 |
#use SL::PE;
|
38 |
41 |
|
... | ... | |
44 |
47 |
|
45 |
48 |
require "bin/mozilla/io.pl";
|
46 |
49 |
require "bin/mozilla/common.pl";
|
|
50 |
require "bin/mozilla/reportgenerator.pl";
|
47 |
51 |
|
48 |
52 |
1;
|
49 |
53 |
|
... | ... | |
1509 |
1513 |
$lxdebug->enter_sub();
|
1510 |
1514 |
|
1511 |
1515 |
my ($revers, $lastsort, $description);
|
1512 |
|
my (@column_index, %column_header, %column_data, @columns, @options, @callbacks);
|
1513 |
|
my ($totalsellprice, $totallastcost, $totallistprice, $subtotalonhand, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
|
1514 |
|
my ($colspan, $sameitem, $onhand, $align);
|
1515 |
1516 |
|
1516 |
|
$revers = $form->{revers};
|
1517 |
|
$lastsort = $form->{lastsort};
|
|
1517 |
$form->{title} = (ucfirst $form->{searchitems}) . "s";
|
|
1518 |
$form->{title} = $locale->text($form->{title});
|
|
1519 |
|
|
1520 |
my $revers = $form->{revers};
|
|
1521 |
my $lastsort = $form->{lastsort};
|
1518 |
1522 |
|
1519 |
1523 |
# sorting and direction of sorting
|
1520 |
1524 |
# ToDO: change this to the simpler field+direction method
|
... | ... | |
1586 |
1590 |
l_soldtotal => $locale->text('soldtotal'),
|
1587 |
1591 |
);
|
1588 |
1592 |
|
1589 |
|
# this local subfunction generates a callback token from the input key.
|
1590 |
|
# easy to join into a callback later
|
1591 |
|
sub callback_token {
|
1592 |
|
map { /\w+$/; return "&$&=$form->{$&}" } @_;
|
1593 |
|
}
|
1594 |
|
|
1595 |
1593 |
my @itemstatus_keys = qw(active obsolete orphaned onhand short);
|
1596 |
|
my @callback_keys = qw(onorder ordered rfq quoted bought sold partnumber partsgroup serialnumber description make model
|
1597 |
|
drawing microfiche l_soldtotal l_deliverydate transdatefrom transdateto);
|
1598 |
|
my $callback = "$form->{script}?action=generate_report";
|
1599 |
|
map { $callback .= "&$_=" . $form->escape($form->{$_}) } qw(login password searchitems itemstatus bom l_linetotal title);
|
1600 |
|
|
|
1594 |
my @callback_keys = qw(onorder ordered rfq quoted bought sold partnumber partsgroup serialnumber description make model
|
|
1595 |
drawing microfiche l_soldtotal l_deliverydate transdatefrom transdateto ean);
|
|
1596 |
|
1601 |
1597 |
# calculate dependencies
|
1602 |
|
for (@itemstatus_keys, @callback_keys) {
|
|
1598 |
for (@itemstatus_keys, @callback_keys) {
|
1603 |
1599 |
next if ($form->{itemstatus} ne $_ && !$form->{$_});
|
1604 |
1600 |
map { $form->{$_} = 'Y' } @{ $dependencies{$_} } if $dependencies{$_};
|
1605 |
1601 |
}
|
1606 |
1602 |
|
1607 |
1603 |
# generate callback and optionstrings
|
|
1604 |
my @options;
|
1608 |
1605 |
for my $key (@itemstatus_keys, @callback_keys) {
|
1609 |
1606 |
next if ($form->{itemstatus} ne $key && !$form->{$key});
|
1610 |
1607 |
push @options, $optiontexts{$key};
|
1611 |
|
push @callbacks, callback_token($key) if grep { $_ eq $key } @callback_keys;;
|
1612 |
1608 |
}
|
1613 |
|
my $option = $locale->text('Options') . ': ' . join(', ', grep $_, @options) . '<br>';
|
1614 |
|
$callback .= join '', grep $_, @callbacks;
|
1615 |
|
|
1616 |
|
$lxdebug->message(0, $callback);
|
1617 |
1609 |
|
1618 |
1610 |
IC->all_parts(\%myconfig, \%$form);
|
1619 |
1611 |
|
... | ... | |
1625 |
1617 |
$description =~ s/\n/<br>/g;
|
1626 |
1618 |
}
|
1627 |
1619 |
|
1628 |
|
@columns = $form->sort_columns(
|
1629 |
|
qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice
|
1630 |
|
lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate)
|
1631 |
|
);
|
1632 |
|
|
1633 |
1620 |
if ($form->{l_linetotal}) {
|
1634 |
1621 |
$form->{l_onhand} = "Y";
|
1635 |
1622 |
$form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
|
... | ... | |
1663 |
1650 |
}
|
1664 |
1651 |
}
|
1665 |
1652 |
|
1666 |
|
$form->{l_lastcost} = ""
|
1667 |
|
if ($form->{searchitems} eq 'assembly' && !$form->{bom});
|
1668 |
|
|
1669 |
|
foreach my $item (@columns) {
|
1670 |
|
if ($form->{"l_$item"} eq "Y") {
|
1671 |
|
push @column_index, $item;
|
1672 |
|
|
1673 |
|
# add column to callback
|
1674 |
|
$callback .= "&l_$item=Y";
|
1675 |
|
}
|
1676 |
|
}
|
1677 |
|
|
1678 |
|
if ($form->{l_subtotal} eq 'Y') {
|
1679 |
|
$callback .= "&l_subtotal=Y";
|
1680 |
|
}
|
1681 |
|
$column_header{partnumber} =
|
1682 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
|
1683 |
|
. $locale->text('Part Number')
|
1684 |
|
. qq|</a></th>|;
|
1685 |
|
$column_header{description} =
|
1686 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
|
1687 |
|
. $locale->text('Part Description')
|
1688 |
|
. qq|</a></th>|;
|
1689 |
|
$column_header{partsgroup} =
|
1690 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
|
1691 |
|
. $locale->text('Group')
|
1692 |
|
. qq|</a></th>|;
|
1693 |
|
$column_header{bin} =
|
1694 |
|
qq|<th><a class=listheading href=$callback&sort=bin>|
|
1695 |
|
. $locale->text('Bin')
|
1696 |
|
. qq|</a></th>|;
|
1697 |
|
$column_header{priceupdate} =
|
1698 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
|
1699 |
|
. $locale->text('Updated')
|
1700 |
|
. qq|</a></th>|;
|
1701 |
|
$column_header{onhand} =
|
1702 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
|
1703 |
|
. $locale->text('Qty')
|
1704 |
|
. qq|</th>|;
|
1705 |
|
$column_header{unit} =
|
1706 |
|
qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
|
1707 |
|
$column_header{listprice} =
|
1708 |
|
qq|<th class=listheading nowrap>|
|
1709 |
|
. $locale->text('List Price')
|
1710 |
|
. qq|</th>|;
|
1711 |
|
$column_header{lastcost} =
|
1712 |
|
qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
|
1713 |
|
$column_header{rop} =
|
1714 |
|
qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
|
1715 |
|
$column_header{weight} =
|
1716 |
|
qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
|
1717 |
|
|
1718 |
|
$column_header{invnumber} =
|
1719 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
|
1720 |
|
. $locale->text('Invoice Number')
|
1721 |
|
. qq|</a></th>|;
|
1722 |
|
$column_header{ordnumber} =
|
1723 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
|
1724 |
|
. $locale->text('Order Number')
|
1725 |
|
. qq|</a></th>|;
|
1726 |
|
$column_header{quonumber} =
|
1727 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
|
1728 |
|
. $locale->text('Quotation')
|
1729 |
|
. qq|</a></th>|;
|
|
1653 |
$form->{l_lastcost} = "" if ($form->{searchitems} eq 'assembly' && !$form->{bom});
|
|
1654 |
|
|
1655 |
my @columns =
|
|
1656 |
qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost
|
|
1657 |
priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate);
|
|
1658 |
|
|
1659 |
my %column_defs = (
|
|
1660 |
'bin' => { 'text' => $locale->text('Bin'), },
|
|
1661 |
'deliverydate' => { 'text' => $locale->text('deliverydate'), },
|
|
1662 |
'description' => { 'text' => $locale->text('Part Description'), },
|
|
1663 |
'drawing' => { 'text' => $locale->text('Drawing'), },
|
|
1664 |
'image' => { 'text' => $locale->text('Image'), },
|
|
1665 |
'invnumber' => { 'text' => $locale->text('Invoice Number'), },
|
|
1666 |
'lastcost' => { 'text' => $locale->text('Last Cost'), },
|
|
1667 |
'linetotallastcost' => { 'text' => $locale->text('Extended'), },
|
|
1668 |
'linetotallistprice' => { 'text' => $locale->text('Extended'), },
|
|
1669 |
'linetotalsellprice' => { 'text' => $locale->text('Extended'), },
|
|
1670 |
'listprice' => { 'text' => $locale->text('List Price'), },
|
|
1671 |
'microfiche' => { 'text' => $locale->text('Microfiche'), },
|
|
1672 |
'name' => { 'text' => $locale->text('Name'), },
|
|
1673 |
'onhand' => { 'text' => $locale->text('Qty'), },
|
|
1674 |
'ordnumber' => { 'text' => $locale->text('Order Number'), },
|
|
1675 |
'partnumber' => { 'text' => $locale->text('Part Number'), },
|
|
1676 |
'partsgroup' => { 'text' => $locale->text('Group'), },
|
|
1677 |
'priceupdate' => { 'text' => $locale->text('Updated'), },
|
|
1678 |
'quonumber' => { 'text' => $locale->text('Quotation'), },
|
|
1679 |
'rop' => { 'text' => $locale->text('ROP'), },
|
|
1680 |
'sellprice' => { 'text' => $locale->text('Sell Price'), },
|
|
1681 |
'serialnumber' => { 'text' => $locale->text('Serial Number'), },
|
|
1682 |
'soldtotal' => { 'text' => $locale->text('soldtotal'), },
|
|
1683 |
'unit' => { 'text' => $locale->text('Unit'), },
|
|
1684 |
'weight' => { 'text' => $locale->text('Weight'), },
|
|
1685 |
);
|
1730 |
1686 |
|
1731 |
|
$column_header{name} =
|
1732 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=name>|
|
1733 |
|
. $locale->text('Name')
|
1734 |
|
. qq|</a></th>|;
|
|
1687 |
map { $column_defs{$_}->{visible} = $form->{"l_$_"} ? 1 : 0 } @columns;
|
1735 |
1688 |
|
1736 |
|
$column_header{sellprice} =
|
1737 |
|
qq|<th class=listheading nowrap>|
|
1738 |
|
. $locale->text('Sell Price')
|
1739 |
|
. qq|</th>|;
|
1740 |
|
$column_header{linetotalsellprice} =
|
1741 |
|
qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
|
1742 |
|
$column_header{linetotallastcost} =
|
1743 |
|
qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
|
1744 |
|
$column_header{linetotallistprice} =
|
1745 |
|
qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
|
|
1689 |
my %column_alignment = map { $_ => 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal);
|
1746 |
1690 |
|
1747 |
|
$column_header{image} =
|
1748 |
|
qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
|
1749 |
|
$column_header{drawing} =
|
1750 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
|
1751 |
|
. $locale->text('Drawing')
|
1752 |
|
. qq|</a></th>|;
|
1753 |
|
$column_header{microfiche} =
|
1754 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
|
1755 |
|
. $locale->text('Microfiche')
|
1756 |
|
. qq|</a></th>|;
|
|
1691 |
my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, map { "l_$_" } @columns);
|
|
1692 |
my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
|
1757 |
1693 |
|
1758 |
|
$column_header{serialnumber} =
|
1759 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
|
1760 |
|
. $locale->text('Serial Number')
|
1761 |
|
. qq|</a></th>|;
|
1762 |
|
$column_header{soldtotal} =
|
1763 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
|
1764 |
|
. $locale->text('soldtotal')
|
1765 |
|
. qq|</a></th>|;
|
|
1694 |
my @sort_full = qw(partnumber description onhand soldtotal deliverydate);
|
|
1695 |
my @sort_no_revers = qw(partsgroup bin priceupdate invnumber ordnumber quonumber name image drawing serialnumber);
|
1766 |
1696 |
|
1767 |
|
$column_header{deliverydate} =
|
1768 |
|
qq|<th nowrap><a class=listheading href=$callback&sort=deliverydate&revers=$form->{revers}&lastsort=$form->{lastsort}>|
|
1769 |
|
. $locale->text('deliverydate')
|
1770 |
|
. qq|</a></th>|;
|
1771 |
|
|
1772 |
|
$form->header;
|
1773 |
|
$colspan = $#column_index + 1;
|
1774 |
|
|
1775 |
|
print qq|
|
1776 |
|
<body>
|
|
1697 |
foreach my $col (@sort_full) {
|
|
1698 |
$column_defs{$col}->{link} = join '&', $callback, "sort=$col", map { "$_=" . E($form->{$_}) } qw(revers lastsort);
|
|
1699 |
}
|
|
1700 |
map { $column_defs{$_}->{link} = "${callback}&sort=$_" } @sort_no_revers;
|
1777 |
1701 |
|
1778 |
|
<table width=100%>
|
1779 |
|
<tr>
|
1780 |
|
<th class=listtop colspan=$colspan>$form->{title}</th>
|
1781 |
|
</tr>
|
1782 |
|
<tr height="5"></tr>
|
|
1702 |
# add order to callback
|
|
1703 |
$form->{callback} = join '&', ($callback, map { "${_}=" . E($form->{$_}) } qw(sort revers));
|
1783 |
1704 |
|
1784 |
|
<tr><td colspan=$colspan>$option</td></tr>
|
|
1705 |
my $report = SL::ReportGenerator->new(\%myconfig, $form);
|
1785 |
1706 |
|
1786 |
|
<tr class=listheading>
|
1787 |
|
|;
|
|
1707 |
my %attachment_basenames = (
|
|
1708 |
'part' => $locale->text('part_list'),
|
|
1709 |
'service' => $locale->text('service_list'),
|
|
1710 |
'assembly' => $locale->text('assembly_list'),
|
|
1711 |
);
|
1788 |
1712 |
|
1789 |
|
map { print "\n$column_header{$_}" } @column_index;
|
|
1713 |
$report->set_options('top_info_text' => $locale->text('Options') . ': ' . join(', ', grep $_, @options),
|
|
1714 |
'raw_bottom_info_text' => $form->parse_html_template2('ic/generate_report_bottom'),
|
|
1715 |
'output_format' => 'HTML',
|
|
1716 |
'title' => $form->{title},
|
|
1717 |
'attachment_basename' => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
|
|
1718 |
);
|
|
1719 |
$report->set_options_from_form();
|
1790 |
1720 |
|
1791 |
|
print qq|
|
1792 |
|
</tr>
|
1793 |
|
|;
|
|
1721 |
$report->set_columns(%column_defs);
|
|
1722 |
$report->set_column_order(@columns);
|
1794 |
1723 |
|
1795 |
|
# add order to callback
|
1796 |
|
$form->{callback} = $callback .= "&sort=$form->{sort}";
|
|
1724 |
$report->set_export_options('generate_report', @hidden_variables, qw(sort revers));
|
1797 |
1725 |
|
1798 |
|
# escape callback for href
|
1799 |
|
$callback = $form->escape($callback);
|
|
1726 |
$report->set_sort_indicator($form->{sort}, $form->{revers} ? 0 : 1);
|
1800 |
1727 |
|
1801 |
|
if (@{ $form->{parts} }) {
|
1802 |
|
$sameitem = $form->{parts}->[0]->{ $form->{sort} };
|
1803 |
|
}
|
|
1728 |
my @subtotal_columns = qw(sellprice listprice lastcost);
|
|
1729 |
my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns);
|
|
1730 |
my %totals = map { $_ => 0 } @subtotal_columns;
|
|
1731 |
my $idx = 0;
|
1804 |
1732 |
|
1805 |
1733 |
foreach my $ref (@{ $form->{parts} }) {
|
1806 |
|
my $i = 0;
|
|
1734 |
my $row = { };
|
1807 |
1735 |
|
1808 |
|
if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
|
1809 |
|
if ($sameitem ne $ref->{ $form->{sort} }) {
|
1810 |
|
&parts_subtotal;
|
1811 |
|
$sameitem = $ref->{ $form->{sort} };
|
1812 |
|
}
|
|
1736 |
foreach (@columns) {
|
|
1737 |
$row->{$_} = {
|
|
1738 |
'align' => $column_alignment{$_},
|
|
1739 |
'data' => $ref->{$_},
|
|
1740 |
};
|
1813 |
1741 |
}
|
1814 |
1742 |
|
1815 |
|
$ref->{exchangerate} = 1 unless $ref->{exchangerate};
|
1816 |
|
$ref->{sellprice} *= $ref->{exchangerate};
|
1817 |
|
$ref->{listprice} *= $ref->{exchangerate};
|
1818 |
|
$ref->{lastcost} *= $ref->{exchangerate};
|
|
1743 |
$ref->{exchangerate} = 1 unless $ref->{exchangerate};
|
|
1744 |
$ref->{sellprice} *= $ref->{exchangerate};
|
|
1745 |
$ref->{listprice} *= $ref->{exchangerate};
|
|
1746 |
$ref->{lastcost} *= $ref->{exchangerate};
|
1819 |
1747 |
|
1820 |
1748 |
# use this for assemblies
|
1821 |
|
$onhand = $ref->{onhand};
|
|
1749 |
my $onhand = $ref->{onhand};
|
1822 |
1750 |
|
1823 |
|
$align = "left";
|
1824 |
1751 |
if ($ref->{assemblyitem}) {
|
1825 |
|
$align = "right";
|
1826 |
|
$onhand = 0 if ($form->{sold});
|
|
1752 |
$row->{partnumber}->{align} = 'right';
|
|
1753 |
$row->{onhand}->{data} = 0;
|
|
1754 |
$onhand = 0 if ($form->{sold});
|
1827 |
1755 |
}
|
1828 |
1756 |
|
1829 |
|
$ref->{description} =~ s/
|
1830 |
|
/<br>/g;
|
|
1757 |
my $edit_link = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback');
|
|
1758 |
$row->{partnumber}->{link} = $edit_link;
|
|
1759 |
$row->{description}->{link} = $edit_link;
|
1831 |
1760 |
|
1832 |
|
$column_data{partnumber} =
|
1833 |
|
"<td align=$align><a href=$form->{script}?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partnumber} </a></td>";
|
1834 |
|
$column_data{description} = "<td><a href=$form->{script}?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description} </a></td>";
|
1835 |
|
$column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
|
|
1761 |
foreach (qw(sellprice listprice lastcost)) {
|
|
1762 |
$row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}, -2);
|
|
1763 |
$row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{$_}, 2);
|
|
1764 |
}
|
1836 |
1765 |
|
1837 |
|
$column_data{onhand} =
|
1838 |
|
"<td align=right>"
|
1839 |
|
. $form->format_amount(\%myconfig, $ref->{onhand})
|
1840 |
|
. "</td>";
|
1841 |
|
$column_data{sellprice} =
|
1842 |
|
"<td align=right>"
|
1843 |
|
. $form->format_amount(\%myconfig, $ref->{sellprice}, -2)
|
1844 |
|
. "</td>";
|
1845 |
|
$column_data{listprice} =
|
1846 |
|
"<td align=right>"
|
1847 |
|
. $form->format_amount(\%myconfig, $ref->{listprice}, -2)
|
1848 |
|
. "</td>";
|
1849 |
|
$column_data{lastcost} =
|
1850 |
|
"<td align=right>"
|
1851 |
|
. $form->format_amount(\%myconfig, $ref->{lastcost}, -2)
|
1852 |
|
. "</td>";
|
1853 |
|
|
1854 |
|
$column_data{linetotalsellprice} = "<td align=right>"
|
1855 |
|
. $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
|
1856 |
|
. "</td>";
|
1857 |
|
$column_data{linetotallastcost} = "<td align=right>"
|
1858 |
|
. $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
|
1859 |
|
. "</td>";
|
1860 |
|
$column_data{linetotallistprice} = "<td align=right>"
|
1861 |
|
. $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
|
1862 |
|
. "</td>";
|
|
1766 |
map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}); } qw(onhand rop weight soldtotal);
|
1863 |
1767 |
|
1864 |
1768 |
if (!$ref->{assemblyitem}) {
|
1865 |
|
$totalsellprice += $onhand * $ref->{sellprice};
|
1866 |
|
$totallastcost += $onhand * $ref->{lastcost};
|
1867 |
|
$totallistprice += $onhand * $ref->{listprice};
|
|
1769 |
foreach my $col (@subtotal_columns) {
|
|
1770 |
$totals{$col} += $onhand * $ref->{$col};
|
|
1771 |
$subtotals{$col} += $onhand * $ref->{$col};
|
|
1772 |
}
|
1868 |
1773 |
|
1869 |
|
$subtotalonhand += $onhand;
|
1870 |
|
$subtotalsellprice += $onhand * $ref->{sellprice};
|
1871 |
|
$subtotallastcost += $onhand * $ref->{lastcost};
|
1872 |
|
$subtotallistprice += $onhand * $ref->{listprice};
|
|
1774 |
$subtotals{onhand} += $onhand;
|
1873 |
1775 |
}
|
1874 |
1776 |
|
1875 |
|
$column_data{rop} =
|
1876 |
|
"<td align=right>"
|
1877 |
|
. $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
|
1878 |
|
$column_data{weight} =
|
1879 |
|
"<td align=right>"
|
1880 |
|
. $form->format_amount(\%myconfig, $ref->{weight})
|
1881 |
|
. "</td>";
|
1882 |
|
$column_data{unit} = "<td>$ref->{unit} </td>";
|
1883 |
|
$column_data{bin} = "<td>$ref->{bin} </td>";
|
1884 |
|
$column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
|
1885 |
|
|
1886 |
|
$column_data{invnumber} =
|
1887 |
|
($ref->{module} ne 'oe')
|
1888 |
|
? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
|
1889 |
|
: "<td>$ref->{invnumber}</td>";
|
1890 |
|
$column_data{ordnumber} =
|
1891 |
|
($ref->{module} eq 'oe')
|
1892 |
|
? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
|
1893 |
|
: "<td>$ref->{ordnumber}</td>";
|
1894 |
|
$column_data{quonumber} =
|
1895 |
|
($ref->{module} eq 'oe' && !$ref->{ordnumber})
|
1896 |
|
? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
|
1897 |
|
: "<td>$ref->{quonumber}</td>";
|
1898 |
|
|
1899 |
|
$column_data{name} = "<td>$ref->{name}</td>";
|
|
1777 |
if ($ref->{module} eq 'oe') {
|
|
1778 |
my $edit_oe_link = build_std_url("script=oe.pl", 'action=edit', 'type=' . E($ref->{type}), 'id=' . E($ref->{trans_id}), 'callback');
|
|
1779 |
$row->{ordnumber}->{link} = $edit_oe_link;
|
|
1780 |
$row->{quonumber}->{link} = $edit_oe_link if (!$ref->{ordnumber});
|
1900 |
1781 |
|
1901 |
|
$column_data{image} =
|
1902 |
|
($ref->{image})
|
1903 |
|
? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
|
1904 |
|
: "<td> </td>";
|
1905 |
|
$column_data{drawing} =
|
1906 |
|
($ref->{drawing})
|
1907 |
|
? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
|
1908 |
|
: "<td> </td>";
|
1909 |
|
$column_data{microfiche} =
|
1910 |
|
($ref->{microfiche})
|
1911 |
|
? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
|
1912 |
|
: "<td> </td>";
|
|
1782 |
} else {
|
|
1783 |
$row->{invnumber}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'type=invoice', 'id=' . E($ref->{trans_id}), 'callback');
|
|
1784 |
}
|
1913 |
1785 |
|
1914 |
|
$column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
|
|
1786 |
if ($ref->{image} && (lc $report->{options}->{output_format} eq 'html')) {
|
|
1787 |
$row->{image}->{data} = '';
|
|
1788 |
$row->{image}->{raw_data} = '<a href="' . H($ref->{image}) . '"><img src="' . H($ref->{image}) . '" height="32" border="0"></a>';
|
|
1789 |
}
|
|
1790 |
map { $row->{$_}->{link} = $ref->{$_} } qw(drawing microfiche);
|
1915 |
1791 |
|
1916 |
|
$column_data{soldtotal} =
|
1917 |
|
"<td align=right>"
|
1918 |
|
. $form->format_amount(\%myconfig, $ref->{soldtotal})
|
1919 |
|
. "</td>";
|
|
1792 |
$report->add_data($row);
|
1920 |
1793 |
|
1921 |
|
$column_data{deliverydate} = "<td>$ref->{deliverydate}</td>";
|
|
1794 |
my $next_ref = $form->{parts}->[$idx + 1];
|
1922 |
1795 |
|
1923 |
|
$i++;
|
1924 |
|
$i %= 2;
|
1925 |
|
print "<tr class=listrow$i>";
|
|
1796 |
if (($form->{l_subtotal} eq 'Y') &&
|
|
1797 |
(!$next_ref ||
|
|
1798 |
(!$next_ref->{assemblyitem} && ($ref->{$form->{sort}} ne $next_ref->{$form->{sort}})))) {
|
|
1799 |
my $row = { map { $_ => { 'class' => 'listsubtotal', 'align' => 'right' } } @columns };
|
1926 |
1800 |
|
1927 |
|
map { print "\n$column_data{$_}" } @column_index;
|
|
1801 |
if (($form->{searchitems} ne 'assembly') || !$form->{bom}) {
|
|
1802 |
$row->{onhand}->{data} = $form->format_amount(\%myconfig, $subtotals{onhand});
|
|
1803 |
}
|
1928 |
1804 |
|
1929 |
|
print qq|
|
1930 |
|
</tr>
|
1931 |
|
|;
|
|
1805 |
map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $subtotals{$_}, 2) } @subtotal_columns;
|
|
1806 |
map { $subtotals{$_} = 0 } ('onhand', @subtotal_columns);
|
1932 |
1807 |
|
1933 |
|
}
|
|
1808 |
$report->add_data($row);
|
|
1809 |
}
|
1934 |
1810 |
|
1935 |
|
if ($form->{l_subtotal} eq 'Y') {
|
1936 |
|
&parts_subtotal;
|
|
1811 |
$idx++;
|
1937 |
1812 |
}
|
1938 |
1813 |
|
1939 |
1814 |
if ($form->{"l_linetotal"}) {
|
1940 |
|
map { $column_data{$_} = "<td> </td>" } @column_index;
|
1941 |
|
$column_data{linetotalsellprice} =
|
1942 |
|
"<th class=listtotal align=right>"
|
1943 |
|
. $form->format_amount(\%myconfig, $totalsellprice, 2)
|
1944 |
|
. "</th>";
|
1945 |
|
$column_data{linetotallastcost} =
|
1946 |
|
"<th class=listtotal align=right>"
|
1947 |
|
. $form->format_amount(\%myconfig, $totallastcost, 2)
|
1948 |
|
. "</th>";
|
1949 |
|
$column_data{linetotallistprice} =
|
1950 |
|
"<th class=listtotal align=right>"
|
1951 |
|
. $form->format_amount(\%myconfig, $totallistprice, 2)
|
1952 |
|
. "</th>";
|
1953 |
|
|
1954 |
|
print "<tr class=listtotal>";
|
|
1815 |
my $row = { map { $_ => { 'class' => 'listtotal', 'align' => 'right' } } @columns };
|
1955 |
1816 |
|
1956 |
|
map { print "\n$column_data{$_}" } @column_index;
|
|
1817 |
map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $totals{$_}, 2) } @subtotal_columns;
|
1957 |
1818 |
|
1958 |
|
print qq|</tr>
|
1959 |
|
|;
|
|
1819 |
$report->add_separator();
|
|
1820 |
$report->add_data($row);
|
1960 |
1821 |
}
|
1961 |
1822 |
|
1962 |
|
print qq|
|
1963 |
|
<tr><td colspan=$colspan><hr size=3 noshade></td></tr>
|
1964 |
|
</table>
|
1965 |
|
|
1966 |
|
|;
|
1967 |
|
|
1968 |
|
print qq|
|
1969 |
|
|
1970 |
|
<br>
|
1971 |
|
|
1972 |
|
<form method=post action=$form->{script}>
|
1973 |
|
|
1974 |
|
<input name=callback type=hidden value="$form->{callback}">
|
1975 |
|
|
1976 |
|
<input type=hidden name=item value=$form->{searchitems}>
|
1977 |
|
|
1978 |
|
<input type=hidden name=login value=$form->{login}>
|
1979 |
|
<input type=hidden name=password value=$form->{password}>|;
|
1980 |
|
|
1981 |
|
print qq|
|
1982 |
|
<input class=submit type=submit name=action value="|
|
1983 |
|
. $locale->text('Add') . qq|">
|
1984 |
|
|
1985 |
|
</form>
|
1986 |
|
|
1987 |
|
</body>
|
1988 |
|
</html>
|
1989 |
|
|;
|
|
1823 |
$report->generate_with_headers();
|
1990 |
1824 |
|
1991 |
1825 |
$lxdebug->leave_sub();
|
1992 |
1826 |
} #end generate_report
|
Waren-/Dienstleistungs-/Erzeugnisberichte auf die Verwendung von ReportGenerator umgestellt.