- }
-
- $form->{l_lastcost} = ""
- if ($form->{searchitems} eq 'assembly' && !$form->{bom});
-
- foreach $item (@columns) {
- if ($form->{"l_$item"} eq "Y") {
- push @column_index, $item;
-
- # add column to callback
- $callback .= "&l_$item=Y";
- }
- }
-
- if ($form->{l_subtotal} eq 'Y') {
- $callback .= "&l_subtotal=Y";
- }
- $column_header{partnumber} =
- qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
- . $locale->text('Part Number')
- . qq|</a></th>|;
- $column_header{description} =
- qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
- . $locale->text('Part Description')
- . qq|</a></th>|;
- $column_header{partsgroup} =
- qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
- . $locale->text('Group')
- . qq|</a></th>|;
- $column_header{bin} =
- qq|<th><a class=listheading href=$callback&sort=bin>|
- . $locale->text('Bin')
- . qq|</a></th>|;
- $column_header{priceupdate} =
- qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
- . $locale->text('Updated')
- . qq|</a></th>|;
- $column_header{onhand} =
- qq|<th nowrap><a class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
- . $locale->text('Qty')
- . qq|</th>|;
- $column_header{unit} =
- qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
- $column_header{listprice} =
- qq|<th class=listheading nowrap>|
- . $locale->text('List Price')
- . qq|</th>|;
- $column_header{lastcost} =
- qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
- $column_header{rop} =
- qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
- $column_header{weight} =
- qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
-
- $column_header{invnumber} =
- qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
- . $locale->text('Invoice Number')
- . qq|</a></th>|;
- $column_header{ordnumber} =
- qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
- . $locale->text('Order Number')
- . qq|</a></th>|;
- $column_header{quonumber} =
- qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
- . $locale->text('Quotation')
- . qq|</a></th>|;
-
- $column_header{name} =
- qq|<th nowrap><a class=listheading href=$callback&sort=name>|
- . $locale->text('Name')
- . qq|</a></th>|;
-
- $column_header{sellprice} =
- qq|<th class=listheading nowrap>|
- . $locale->text('Sell Price')
- . qq|</th>|;
- $column_header{linetotalsellprice} =
- qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
- $column_header{linetotallastcost} =
- qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
- $column_header{linetotallistprice} =
- qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
-
- $column_header{image} =
- qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
- $column_header{drawing} =
- qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
- . $locale->text('Drawing')
- . qq|</a></th>|;
- $column_header{microfiche} =
- qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
- . $locale->text('Microfiche')
- . qq|</a></th>|;
-
- $column_header{serialnumber} =
- qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
- . $locale->text('Serial Number')
- . qq|</a></th>|;
- $column_header{soldtotal} =
- qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
- . $locale->text('soldtotal')
- . qq|</a></th>|;
-
- $form->header;
- $colspan = $#column_index + 1;
-
- print qq|
-<body>
-
-<table width=100%>
- <tr>
- <th class=listtop colspan=$colspan>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
-
- <tr><td colspan=$colspan>$option</td></tr>
-
- <tr class=listheading>
-|;
-
- map { print "\n$column_header{$_}" } @column_index;
-
- print qq|
- </tr>
- |;
-
- # add order to callback
- $form->{callback} = $callback .= "&sort=$form->{sort}";
-
- # escape callback for href
- $callback = $form->escape($callback);
-
- if (@{ $form->{parts} }) {
- $sameitem = $form->{parts}->[0]->{ $form->{sort} };
- }
-
- foreach $ref (@{ $form->{parts} }) {
-
- if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
- if ($sameitem ne $ref->{ $form->{sort} }) {
- &parts_subtotal;
- $sameitem = $ref->{ $form->{sort} };
- }
- }
-
- $ref->{exchangerate} = 1 unless $ref->{exchangerate};
- $ref->{sellprice} *= $ref->{exchangerate};
- $ref->{listprice} *= $ref->{exchangerate};
- $ref->{lastcost} *= $ref->{exchangerate};
-
- # use this for assemblies
- $onhand = $ref->{onhand};
-
- $align = "left";
- if ($ref->{assemblyitem}) {
- $align = "right";
- $onhand = 0 if ($form->{sold});
- }
-
- $ref->{description} =~ s/
-/<br>/g;
-
- $column_data{partnumber} =
- "<td align=$align><a href=$form->{script}?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partnumber} </a></td>";
- $column_data{description} = "<td>$ref->{description} </td>";
- $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
-
- $column_data{onhand} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
- . "</td>";
- $column_data{sellprice} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
- . "</td>";
- $column_data{listprice} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{listprice}, 2, " ")
- . "</td>";
- $column_data{lastcost} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{lastcost}, 2, " ")
- . "</td>";
-
- $column_data{linetotalsellprice} = "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice},
- 2, " ")
- . "</td>";
- $column_data{linetotallastcost} = "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost},
- 2, " ")
- . "</td>";
- $column_data{linetotallistprice} = "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice},
- 2, " ")
- . "</td>";
-
- if (!$ref->{assemblyitem}) {
- $totalsellprice += $onhand * $ref->{sellprice};
- $totallastcost += $onhand * $ref->{lastcost};
- $totallistprice += $onhand * $ref->{listprice};
-
- $subtotalonhand += $onhand;
- $subtotalsellprice += $onhand * $ref->{sellprice};
- $subtotallastcost += $onhand * $ref->{lastcost};
- $subtotallistprice += $onhand * $ref->{listprice};
- }
-
- $column_data{rop} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{rop}, '', " ") . "</td>";
- $column_data{weight} =
- "<td align=right>"
- . $form->format_amount(\%myconfig, $ref->{weight}, '', " ")
- . "</td>";
- $column_data{unit} = "<td>$ref->{unit} </td>";
- $column_data{bin} = "<td>$ref->{bin} </td>";
- $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
-
- $column_data{invnumber} =
- ($ref->{module} ne 'oe')
- ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
- : "<td>$ref->{invnumber}</td>";
- $column_data{ordnumber} =
- ($ref->{module} eq 'oe')
- ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
- : "<td>$ref->{ordnumber}</td>";
- $column_data{quonumber} =
- ($ref->{module} eq 'oe' && !$ref->{ordnumber})
- ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
- : "<td>$ref->{quonumber}</td>";
-
- $column_data{name} = "<td>$ref->{name}</td>";
-
- $column_data{image} =
- ($ref->{image})
- ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
- : "<td> </td>";
- $column_data{drawing} =
- ($ref->{drawing})
- ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
- : "<td> </td>";
- $column_data{microfiche} =
- ($ref->{microfiche})
- ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
- : "<td> </td>";