summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/favicon.pm
blob: 7169c58c342f9ef97defe60a1004aebab8f98555 (plain)
  1. #!/usr/bin/perl
  2. # favicon plugin.
  3. package IkiWiki::Plugin::favicon;
  4. use warnings;
  5. use strict;
  6. use IkiWiki 2.00;
  7. sub import { #{{{
  8. hook(type => "pagetemplate", id => "favicon", call => \&pagetemplate);
  9. } # }}}
  10. sub pagetemplate (@) { #{{{
  11. my %params=@_;
  12. my $template=$params{template};
  13. if ($template->query(name => "favicon")) {
  14. $template->param(favicon => "favicon.ico");
  15. }
  16. } # }}}
  17. 1
d="n_35" class="hl"># along with this program; if not, write to the Free Software
  • # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  • #======================================================================
  • #
  • # Inventory Control module
  • #
  • #======================================================================
  • use LedgerSMB::IC;
  • require "$form->{path}/io.pl";
  • 1;
  • # end of main
  • sub add {
  • %label = ( part => 'Part',
  • service => 'Service',
  • assembly => 'Assembly',
  • labor => 'Labor/Overhead', );
  • # $locale->text('Add Part')
  • # $locale->text('Add Service')
  • # $locale->text('Add Assembly')
  • # $locale->text('Add Labor/Overhead')
  • $label = "Add $label{$form->{item}}";
  • $form->{title} = $locale->text($label);
  • $form->{callback} = "$form->{script}?action=add&item=$form->{item}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback};
  • $form->{orphaned} = 1;
  • if ($form->{previousform}) {
  • $form->{callback} = "";
  • }
  • &link_part;
  • &display_form;
  • }
  • sub edit {
  • %label = ( part => 'Part',
  • service => 'Service',
  • assembly => 'Assembly',
  • labor => 'Labor/Overhead', );
  • # $locale->text('Edit Part')
  • # $locale->text('Edit Service')
  • # $locale->text('Edit Assembly')
  • # $locale->text('Edit Labor/Overhead')
  • IC->get_part(\%myconfig, \%$form);
  • $label = "Edit $label{$form->{item}}";
  • $form->{title} = $locale->text($label);
  • $form->{previousform} = $form->escape($form->{previousform}, 1) if $form->{previousform};
  • &link_part;
  • &display_form;
  • }
  • sub link_part {
  • IC->create_links("IC", \%myconfig, \%$form);
  • # currencies
  • $form->{selectcurrency} = "";
  • for (split /:/, $form->{currencies}) { $form->{selectcurrency} .= "<option>$_\n" }
  • # readonly
  • if ($form->{item} eq 'part') {
  • $form->{readonly} = 1 if $myconfig{acs} =~ /Goods \& Services--Add Part/;
  • $form->error($locale->text('Cannot create Part').";".$locale->text('Inventory account does not exist!')) if ! @{ $form->{IC_links}{IC} };
  • $form->error($locale->text('Cannot create Part').";".$locale->text('Income account does not exist!')) if ! @{ $form->{IC_links}{IC_sale} };
  • $form->error($locale->text('Cannot create Part').";".$locale->text('COGS account does not exist!')) if ! @{ $form->{IC_links}{IC_cogs} };
  • }
  • if ($form->{item} eq 'service') {
  • $form->{readonly} = 1 if $myconfig{acs} =~ /Goods \& Services--Add Service/;
  • $form->error($locale->text('Cannot create Service').";".$locale->text('Income account does not exist!')) if ! @{ $form->{IC_links}{IC_income} };
  • $form->error($locale->text('Cannot create Service').";".$locale->text('Expense account does not exist!')) if ! @{ $form->{IC_links}{IC_expense} };
  • }
  • if ($form->{item} eq 'assembly') {
  • $form->{readonly} = 1 if $myconfig{acs} =~ /Goods \& Services--Add Assembly/;
  • $form->error($locale->text('Cannot create Assembly').";".$locale->text('Income account does not exist!')) if ! @{ $form->{IC_links}{IC_income} };
  • }
  • if ($form->{item} eq 'labor') {
  • $form->{readonly} = 1 if $myconfig{acs} =~ /Goods \& Services--Add Labor\/Overhead/;
  • $form->error($locale->text('Cannot create Labor').";".$locale->text('Inventory account does not exist!')) if ! @{ $form->{IC_links}{IC} };
  • $form->error($locale->text('Cannot create Labor').";".$locale->text('COGS account does not exist!')) if ! @{ $form->{IC_links}{IC_cogs} };
  • }
  • # parts, assemblies , labor and overhead have the same links
  • $taxpart = ($form->{item} eq 'service') ? "service" : "part";
  • # build the popup menus
  • $form->{taxaccounts} = "";
  • foreach $key (keys %{ $form->{IC_links} }) {
  • $form->{"select$key"} = "";
  • foreach $ref (@{ $form->{IC_links}{$key} }) {
  • # if this is a tax field
  • if ($key =~ /IC_tax/) {
  • if ($key =~ /$taxpart/) {
  • $form->{taxaccounts} .= "$ref->{accno} ";
  • $form->{"IC_tax_$ref->{accno}_description"} = "$ref->{accno}--$ref->{description}";
  • if ($form->{id}) {
  • if ($form->{amount}{$ref->{accno}}) {
  • $form->{"IC_tax_$ref->{accno}"} = "checked";
  • }
  • } else {
  • $form->{"IC_tax_$ref->{accno}"} = "checked";
  • }
  • }
  • } else {
  • $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
  • }
  • }
  • }
  • chop $form->{taxaccounts};
  • if ($form->{item} !~ /service/) {
  • $form->{selectIC_inventory} = $form->{selectIC};
  • $form->{selectIC_income} = $form->{selectIC_sale};
  • $form->{selectIC_expense} = $form->{selectIC_cogs};
  • $form->{IC_income} = $form->{IC_sale};
  • $form->{IC_expense} = $form->{IC_cogs};
  • }
  • # set option
  • for (qw(IC_inventory IC_income IC_expense)) { $form->{$_} = "$form->{amount}{$_}{accno}--$form->{amount}{$_}{description}" if $form->{amount}{$_}{accno} }
  • delete $form->{IC_links};
  • delete $form->{amount};
  • $form->get_partsgroup(\%myconfig, {all => 1});
  • if ($form->{partsgroup}) {
  • $form->{partsgroup} = $form->quote($form->{partsgroup})."--$form->{partsgroup_id}";
  • }
  • if (@{ $form->{all_partsgroup} }) {
  • $form->{selectpartsgroup} = qq|<option>\n|;
  • for (@{ $form->{all_partsgroup} }) { $form->{selectpartsgroup} .= qq|<option value="|.$form->quote($_->{partsgroup}).qq|--$_->{id}">$_->{partsgroup}\n| }
  • delete $form->{all_partsgroup};
  • }
  • if ($form->{item} eq 'assembly') {
  • for (1 .. $form->{assembly_rows}) {
  • if ($form->{"partsgroup_id_$_"}) {
  • $form->{"partsgroup_$_"} = qq|$form->{"partsgroup_$_"}--$form->{"partsgroup_id_$_"}|;
  • }
  • }
  • $form->get_partsgroup(\%myconfig);
  • if (@{ $form->{all_partsgroup} }) {
  • $form->{selectassemblypartsgroup} = qq|<option>\n|;
  • for (@{ $form->{all_partsgroup} }) { $form->{selectassemblypartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| }
  • delete $form->{all_partsgroup};
  • }
  • }
  • # setup make and models
  • $i = 1;
  • foreach $ref (@{ $form->{makemodels} }) {
  • for (qw(make model)) { $form->{"${_}_$i"} = $ref->{$_} }
  • $i++;
  • }
  • $form->{makemodel_rows} = $i - 1;
  • delete $form->{makemodels};
  • # setup vendors
  • if (@{ $form->{all_vendor} }) {
  • $form->{selectvendor} = "<option>\n";
  • for (@{ $form->{all_vendor} }) { $form->{selectvendor} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  • delete $form->{all_vendor};
  • }
  • # vendor matrix
  • $i = 1;
  • foreach $ref (@{ $form->{vendormatrix} }) {
  • $form->{"vendor_$i"} = qq|$ref->{name}--$ref->{id}|;
  • for (qw(partnumber lastcost leadtime vendorcurr)) { $form->{"${_}_$i"} = $ref->{$_} }
  • $i++;
  • }
  • $form->{vendor_rows} = $i - 1;
  • delete $form->{vendormatrix};
  • # setup customers and groups
  • if (@{ $form->{all_customer} }) {
  • $form->{selectcustomer} = "<option>\n";
  • for (@{ $form->{all_customer} }) { $form->{selectcustomer} .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
  • delete $form->{all_customer};
  • }
  • if (@{ $form->{all_pricegroup} }) {
  • $form->{selectpricegroup} = "<option>\n";
  • for (@{ $form->{all_pricegroup} }) { $form->{selectpricegroup} .= qq|<option value="$_->{pricegroup}--$_->{id}">$_->{pricegroup}\n| }
  • delete $form->{all_pricegroup};
  • }
  • $i = 1;
  • # customer matrix
  • foreach $ref (@{ $form->{customermatrix} }) {
  • $form->{"customer_$i"} = "$ref->{name}--$ref->{cid}" if $ref->{cid};
  • $form->{"pricegroup_$i"} = "$ref->{pricegroup}--$ref->{gid}" if $ref->{gid};
  • for (qw(validfrom validto pricebreak customerprice customercurr)) { $form->{"${_}_$i"} = $ref->{$_} }
  • $i++;
  • }
  • $form->{customer_rows} = $i - 1;
  • delete $form->{customermatrix};
  • }
  • sub form_header {
  • if ($form->{lastcost} > 0) {
  • $markup = $form->round_amount((($form->{sellprice}/$form->{lastcost} - 1) * 100), 1);
  • $form->{markup} = $form->format_amount(\%myconfig, $markup, 1);
  • }
  • ($dec) = ($form->{sellprice} =~ /\.(\d+)/);
  • $dec = length $dec;
  • $decimalplaces = ($dec > 2) ? $dec : 2;
  • for (qw(listprice sellprice)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces) }
  • ($dec) = ($form->{lastcost} =~ /\.(\d+)/);
  • $dec = length $dec;
  • $decimalplaces = ($dec > 2) ? $dec : 2;
  • for (qw(lastcost avgcost)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces) }
  • for (qw(weight rop stock)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) }
  • for (qw(partnumber description unit notes)) { $form->{$_} = $form->quote($form->{$_}) }
  • if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
  • $rows = 2;
  • }
  • $notes = qq|<textarea name=notes rows=$rows cols=40 wrap=soft>$form->{notes}</textarea>|;
  • if (($rows = $form->numtextrows($form->{description}, 40)) > 1) {
  • $description = qq|<textarea name="description" rows=$rows cols=40 wrap=soft>$form->{description}</textarea>|;
  • } else {
  • $description = qq|<input name=description size=40 value="$form->{description}">|;
  • }
  • for (split / /, $form->{taxaccounts}) { $form->{"IC_tax_$_"} = ($form->{"IC_tax_$_"}) ? "checked" : "" }
  • $form->{selectIC_inventory} = $form->{selectIC};
  • # set option
  • for (qw(IC_inventory IC_income IC_expense)) {
  • if ($form->{$_}) {
  • if ($form->{orphaned}) {
  • $form->{"select$_"} =~ s/ selected//;
  • $form->{"select$_"} =~ s/option>\Q$form->{$_}\E/option selected>$form->{$_}/;
  • } else {
  • $form->{"select$_"} = qq|<option selected>$form->{$_}|;
  • }
  • }
  • }
  • if ($form->{selectpartsgroup}) {
  • $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
  • $partsgroup = qq|<input type=hidden name=selectpartsgroup value="|.$form->escape($form->{selectpartsgroup},1).qq|">|;
  • $form->{partsgroup} = $form->quote($form->{partsgroup});
  • $form->{selectpartsgroup} =~ s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
  • $partsgroup .= qq|\n<select name=partsgroup>$form->{selectpartsgroup}</select>|;
  • $group = $locale->text('Group');
  • }
  • # tax fields
  • foreach $item (split / /, $form->{taxaccounts}) {
  • $tax .= qq|
  • <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}>&nbsp;<b>$form->{"IC_tax_${item}_description"}</b>
  • <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
  • |;
  • }
  • $sellprice = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Sell Price').qq|</th>
  • <td><input name=sellprice size=11 value=$form->{sellprice}></td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('List Price').qq|</th>
  • <td><input name=listprice size=11 value=$form->{listprice}></td>
  • </tr>
  • |;
  • $avgcost = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Average Cost').qq|</th>
  • <td><input type=hidden name=avgcost value=$form->{avgcost}>$form->{avgcost}</td>
  • </tr>
  • |;
  • $lastcost = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Last Cost').qq|</th>
  • <td><input name=lastcost size=11 value=$form->{lastcost}></td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Markup').qq| %</th>
  • <td><input name=markup size=5 value=$form->{markup}></td>
  • <input type=hidden name=oldmarkup value=$markup>
  • </tr>
  • |;
  • if ($form->{item} =~ /(part|assembly)/) {
  • $n = ($form->{onhand} > 0) ? "1" : "0";
  • $onhand = qq|
  • <tr>
  • <th align="right" nowrap>|.$locale->text('On Hand').qq|</th>
  • <th align=left nowrap class="plus$n">&nbsp;|.$form->format_amount(\%myconfig, $form->{onhand}).qq|</th>
  • </tr>
  • |;
  • $rop = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('ROP').qq|</th>
  • <td><input name=rop size=10 value=$form->{rop}></td>
  • </tr>
  • |;
  • $bin = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Bin').qq|</th>
  • <td><input name=bin size=10 value="$form->{bin}"></td>
  • </tr>
  • |;
  • $imagelinks = qq|
  • <tr>
  • <td>
  • <table width=100%>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Image').qq|</th>
  • <td><input name=image size=40 value="$form->{image}"></td>
  • <th align=right nowrap>|.$locale->text('Microfiche').qq|</th>
  • <td><input name=microfiche size=20 value="$form->{microfiche}"></td>
  • </tr>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Drawing').qq|</th>
  • <td><input name=drawing size=40 value="$form->{drawing}"></td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • }
  • if ($form->{item} eq "part") {
  • $linkaccounts = qq|
  • <tr>
  • <th align=right>|.$locale->text('Inventory').qq|</th>
  • <td><select name=IC_inventory>$form->{selectIC_inventory}</select></td>
  • <input name=selectIC type=hidden value="$form->{selectIC}">
  • </tr>
  • <tr>
  • <th align=right>|.$locale->text('Income').qq|</th>
  • <td><select name=IC_income>$form->{selectIC_income}</select></td>
  • <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
  • </tr>
  • <tr>
  • <th align=right>|.$locale->text('COGS').qq|</th>
  • <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
  • <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
  • </tr>
  • |;
  • if ($tax) {
  • $linkaccounts .= qq|
  • <tr>
  • <th align=right>|.$locale->text('Tax').qq|</th>
  • <td>$tax</td>
  • </tr>
  • |;
  • }
  • $weight = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Weight').qq|</th>
  • <td>
  • <table>
  • <tr>
  • <td>
  • <input name=weight size=10 value=$form->{weight}>
  • </td>
  • <th>
  • &nbsp;
  • $form->{weightunit}
  • <input type=hidden name=weightunit value=$form->{weightunit}>
  • </th>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • }
  • if ($form->{item} eq "assembly") {
  • $avgcost = "";
  • if ($form->{project_id}) {
  • $weight = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Weight').qq|</th>
  • <td>
  • <table>
  • <tr>
  • <td>
  • <input name=weight size=10 value=$form->{weight}>
  • </td>
  • <th>
  • &nbsp;
  • $form->{weightunit}
  • <input type=hidden name=weightunit value=$form->{weightunit}>
  • </th>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • } else {
  • $weight = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Weight').qq|</th>
  • <td>
  • <table>
  • <tr>
  • <td>
  • &nbsp;$form->{weight}
  • <input type=hidden name=weight value=$form->{weight}>
  • </td>
  • <th>
  • &nbsp;
  • $form->{weightunit}
  • <input type=hidden name=weightunit value=$form->{weightunit}>
  • </th>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • }
  • if ($form->{project_id}) {
  • $lastcost = "";
  • $avgcost = "";
  • $onhand = "";
  • $rop = "";
  • $form->{isassemblyitem} = 1;
  • } else {
  • $stock = qq|
  • <tr>
  • <th align="right" nowrap>|.$locale->text('Stock').qq|</th>
  • <td><input name=stock size=10 value=$form->{stock}></td>
  • </tr>
  • |;
  • $lastcost = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Last Cost').qq|</th>
  • <td><input type=hidden name=lastcost value=$form->{lastcost}>$form->{lastcost}</td>
  • </tr>
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Markup').qq| %</th>
  • <td><input name=markup size=5 value=$form->{markup}></td>
  • <input type=hidden name=oldmarkup value=$markup>
  • </tr>
  • |;
  • }
  • $linkaccounts = qq|
  • <tr>
  • <th align=right>|.$locale->text('Income').qq|</th>
  • <td><select name=IC_income>$form->{selectIC_income}</select></td>
  • <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
  • </tr>
  • |;
  • if ($tax) {
  • $linkaccounts .= qq|
  • <tr>
  • <th align=right>|.$locale->text('Tax').qq|</th>
  • <td>$tax</td>
  • </tr>
  • |;
  • }
  • }
  • if ($form->{item} eq "service") {
  • $avgcost = "";
  • $linkaccounts = qq|
  • <tr>
  • <th align=right>|.$locale->text('Income').qq|</th>
  • <td><select name=IC_income>$form->{selectIC_income}</select></td>
  • <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
  • </tr>
  • <tr>
  • <th align=right>|.$locale->text('Expense').qq|</th>
  • <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
  • <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
  • </tr>
  • |;
  • if ($tax) {
  • $linkaccounts .= qq|
  • <tr>
  • <th align=right>|.$locale->text('Tax').qq|</th>
  • <td>$tax</td>
  • </tr>
  • |;
  • }
  • }
  • if ($form->{item} eq 'labor') {
  • $avgcost = "";
  • $n = ($form->{onhand} > 0) ? "1" : "0";
  • $onhand = qq|
  • <tr>
  • <th align="right" nowrap>|.$locale->text('On Hand').qq|</th>
  • <th align=left nowrap class="plus$n">&nbsp;|.$form->format_amount(\%myconfig, $form->{onhand}).qq|</th>
  • </tr>
  • |;
  • $linkaccounts = qq|
  • <tr>
  • <th align=right>|.$locale->text('Labor/Overhead').qq|</th>
  • <td><select name=IC_inventory>$form->{selectIC_inventory}</select></td>
  • <input name=selectIC type=hidden value="$form->{selectIC}">
  • </tr>
  • <tr>
  • <th align=right>|.$locale->text('COGS').qq|</th>
  • <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
  • <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
  • </tr>
  • |;
  • }
  • if ($form->{id}) {
  • $checked = ($form->{obsolete}) ? "checked" : "";
  • $obsolete = qq|
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Obsolete').qq|</th>
  • <td><input name=obsolete type=checkbox class=checkbox value=1 $checked></td>
  • </tr>
  • |;
  • $obsolete = "<input type=hidden name=obsolete value=$form->{obsolete}>" if $form->{project_id};
  • }
  • # type=submit $locale->text('Edit Part')
  • # type=submit $locale->text('Edit Service')
  • # type=submit $locale->text('Edit Assembly')
  • $form->header;
  • print qq|
  • <body>
  • <form method=post action="$form->{script}">
  • |;
  • $form->hide_form(qw(id item title makemodel alternate onhand orphaned taxaccounts rowcount baseassembly project_id));
  • print qq|
  • <table width="100%">
  • <tr>
  • <th class=listtop>$form->{title}</th>
  • </tr>
  • <tr height="5"></tr>
  • <tr>
  • <td>
  • <table width="100%">
  • <tr valign=top>
  • <th align=left>|.$locale->text('Number').qq|</th>
  • <th align=left>|.$locale->text('Description').qq|</th>
  • <th align=left>$group</th>
  • </tr>
  • <tr valign=top>
  • <td><input name=partnumber value="$form->{partnumber}" size=20></td>
  • <td>$description</td>
  • <td>$partsgroup</td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • <tr>
  • <td>
  • <table width="100%" height="100%">
  • <tr valign=top>
  • <td width=70%>
  • <table width="100%" height="100%">
  • <tr class="listheading">
  • <th class="listheading" align="center" colspan=2>|.$locale->text('Link Accounts').qq|</th>
  • </tr>
  • $linkaccounts
  • <tr>
  • <th align="left">|.$locale->text('Notes').qq|</th>
  • </tr>
  • <tr>
  • <td colspan=2>
  • $notes
  • </td>
  • </tr>
  • </table>
  • </td>
  • <td width="30%">
  • <table width="100%">
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Updated').qq|</th>
  • <td><input name=priceupdate size=11 title="$myconfig{dateformat}" value=$form->{priceupdate}></td>
  • </tr>
  • $sellprice
  • $lastcost
  • $avgcost
  • <tr>
  • <th align="right" nowrap="true">|.$locale->text('Unit').qq|</th>
  • <td><input name=unit size=5 value="$form->{unit}"></td>
  • </tr>
  • $weight
  • $onhand
  • $stock
  • $rop
  • $bin
  • $obsolete
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • $imagelinks
  • |;
  • }
  • sub form_footer {
  • print qq|
  • <tr>
  • <td><hr size=3 noshade></td>
  • </tr>
  • </table>
  • |;
  • $form->hide_form(qw(customer_rows));
  • if ($form->{item} =~ /(part|assembly)/) {
  • $form->hide_form(qw(makemodel_rows));
  • }
  • if ($form->{item} =~ /(part|service)/) {
  • $form->hide_form(qw(vendor_rows));
  • }
  • # type=submit $locale->text('Update')
  • # type=submit $locale->text('Save')
  • # type=submit $locale->text('Save as new')
  • # type=submit $locale->text('Delete')
  • if (! $form->{readonly}) {
  • %button = ('Update' => { ndx => 1, key => 'U', value => $locale->text('Update') },
  • 'Save' => { ndx => 3, key => 'S', value => $locale->text('Save') },
  • );
  • if ($form->{id}) {
  • if (!$form->{isassemblyitem}) {
  • $button{'Save as new'} = { ndx => 7, key => 'N', value => $locale->text('Save as new') };
  • }
  • if ($form->{orphaned}) {
  • $button{'Delete'} = { ndx => 16, key => 'D', value => $locale->text('Delete') };
  • }
  • }
  • %button = () if $form->{isassemblyitem} && $form->{item} eq 'assembly';
  • for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
  • }
  • if ($form->{menubar}) {
  • require "$form->{path}/menu.pl";
  • &menubar;
  • }
  • &assembly_row(++$form->{assembly_rows}) if $form->{item} eq 'assembly';
  • $form->hide_form(qw(login path sessionid callback previousform isassemblyitem));
  • print qq|
  • </form>
  • </body>
  • </html>
  • |;
  • }
  • sub search {
  • $form->get_partsgroup(\%myconfig, { searchitems => $form->{searchitems}});
  • IC->get_warehouses(\%myconfig, \%$form) unless $form->{searchitems} =~ /(service|labor)/;
  • if (@{ $form->{all_partsgroup} }) {
  • $partsgroup = qq|<option>\n|;
  • for (@{ $form->{all_partsgroup} }) { $partsgroup .= qq|<option value="|.$form->quote($_->{partsgroup}).qq|--$_->{id}">$_->{partsgroup}\n| }
  • $partsgroup = qq|
  • <th align=right nowrap>|.$locale->text('Group').qq|</th>
  • <td><select name=partsgroup>$partsgroup</select></td>
  • |;
  • $l_partsgroup = qq|<input name=l_partsgroup class=checkbox type=checkbox value=Y> |.$locale->text('Group');
  • }
  • $l_listprice = qq|<input name=l_listprice class=checkbox type=checkbox value=Y> |.$locale->text('List Price');
  • $l_sellprice = qq|<input name=l_sellprice class=checkbox type=checkbox value=Y checked> |.$locale->text('Sell Price');
  • $l_lastcost = qq|<input name=l_lastcost class=checkbox type=checkbox value=Y checked> |.$locale->text('Last Cost');
  • $l_avgcost = qq|<input name=l_avgcost class=checkbox type=checkbox value=Y checked> |.$locale->text('Average Cost');
  • $l_linetotal = qq|<input name=l_linetotal class=checkbox type=checkbox value=Y> |.$locale->text('Line Total');
  • $l_markup = qq|<input name=l_markup class=checkbox type=checkbox value=Y> |.$locale->text('Markup');
  • $l_account = qq|<input name=l_account class=checkbox type=checkbox value=Y> |.$locale->text('Accounts');
  • $bought = qq|
  • <td>
  • <table>
  • <tr>
  • <td><input name=bought class=checkbox type=checkbox value=1></td>
  • <td nowrap>|.$locale->text('Vendor Invoices').qq|</td>
  • </tr>
  • <tr>
  • <td><input name=onorder class=checkbox type=checkbox value=1></td>
  • <td nowrap>|.$locale->text('Purchase Orders').qq|</td>
  • </tr>
  • <tr>
  • <td><input name=rfq class=checkbox type=checkbox value=1></td>
  • <td nowrap>|.$locale->text('RFQ').qq|</td>
  • </tr>
  • </table>
  • </td>
  • |;
  • $sold = qq|
  • <td>
  • <table>
  • <tr>
  • <td><input name=sold class=checkbox type=checkbox value=1></td>
  • <td nowrap>|.$locale->text('Sales Invoices').qq|</td>
  • </tr>
  • <tr>
  • <td><input name=ordered class=checkbox type=checkbox value=1></td>
  • <td nowrap>|.$locale->text('Sales Orders').qq|</td>
  • </tr>
  • <tr>
  • <td><input name=quoted class=checkbox type=checkbox value=1></td>
  • <td nowrap>|.$locale->text('Quotations').qq|</td>
  • </tr>
  • </table>
  • </td>
  • |;
  • $fromto = qq|
  • <td>
  • <table>
  • <tr>
  • <td nowrap><b>|.$locale->text('From').qq|</b>
  • <input name=transdatefrom size=11 title="$myconfig{dateformat}">
  • <b>|.$locale->text('To').qq|</b>
  • <input name=transdateto size=11 title="$myconfig{dateformat}"></td>
  • </tr>
  • <tr>
  • <td nowrap><input name=method class=radio type=radio value=accrual checked>|.$locale->text('Accrual').qq|
  • <input name=method class=radio type=radio value=cash>|.$locale->text('Cash').qq|</td>
  • </tr>
  • <tr>
  • <td nowrap>
  • <input name=open class=checkbox type=checkbox value=1 checked> |.$locale->text('Open').qq|
  • <input name=closed class=checkbox type=checkbox> |.$locale->text('Closed').qq|
  • <input name=summary type=radio class=radio value=1> |.$locale->text('Summary').qq|
  • <input name=summary type=radio class=radio value=0 checked> |.$locale->text('Detail').qq|
  • </td>
  • </tr>
  • </table>
  • </td>
  • |;
  • $l_name = qq|<input name=l_name class=checkbox type=checkbox value=Y> |.$locale->text('Name');
  • $l_curr = qq|<input name=l_curr class=checkbox type=checkbox value=Y> |.$locale->text('Currency');
  • $l_employee = qq|<input name=l_employee class=checkbox type=checkbox value=Y> |.$locale->text('Employee');
  • $l_serialnumber = qq|<input name=l_serialnumber class=checkbox type=checkbox value=Y> |.$locale->text('Serial Number');
  • $serialnumber = qq|
  • <th align=right nowrap>|.$locale->text('Serial Number').qq|</th>
  • <td><input name=serialnumber size=20></td>
  • |;
  • $orphaned = qq|
  • <input name=itemstatus class=radio type=radio value=orphaned>&nbsp;|.$locale->text('Orphaned');
  • if ($form->{searchitems} =~ /(all|part|assembly)/) {
  • $onhand = qq|
  • <input name=itemstatus class=radio type=radio value=onhand>&nbsp;|.$locale->text('On Hand').qq|
  • <input name=itemstatus class=radio type=radio value=short>&nbsp;|.$locale->text('Short').qq|
  • |;
  • $makemodel = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Make').qq|</th>
  • <td><input name=make size=20></td>
  • <th align=right nowrap>|.$locale->text('Model').qq|</th>
  • <td><input name=model size=20></td>
  • </tr>
  • |;
  • $l_make = qq|<input name=l_make class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Make');
  • $l_model = qq|<input name=l_model class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Model');
  • $l_bin = qq|<input name=l_bin class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Bin');
  • $l_rop = qq|<input name=l_rop class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('ROP');
  • $l_weight = qq|<input name=l_weight class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Weight');
  • if (@{ $form->{all_warehouse} }) {
  • $selectwarehouse = "<option>\n";
  • for (@{ $form->{all_warehouse} }) { $selectwarehouse .= qq|<option value="$_->{description}--$_->{id}">$_->{description}\n| }
  • $warehouse = qq|
  • <th align=right nowrap>|.$locale->text('Warehouse').qq|</th>
  • <td><select name=warehouse>$selectwarehouse</select></td>
  • |;
  • $l_warehouse = qq|<input name=l_warehouse class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Warehouse');
  • }
  • $drawing = qq|
  • <tr>
  • <th align=right nowrap>|.$locale->text('Drawing').qq|</th>
  • <td><input name=drawing size=20></td>
  • <th align=right nowrap>|.$locale->text('Microfiche').qq|</th>
  • <td><input name=microfiche size=20></td>
  • </tr>
  • |;
  • $l_image = qq|<input name=l_image class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Image');
  • $l_drawing = qq|<input name=l_drawing class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Drawing');
  • $l_microfiche = qq|<input name=l_microfiche class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Microfiche');
  • }
  • if ($form->{searchitems} eq 'assembly') {
  • $bought = "";
  • $toplevel = qq|
  • <tr>
  • <td></td>
  • <td colspan=3>
  • <input name=null class=radio type=radio checked>&nbsp;|.$locale->text('Top Level').qq|
  • <input name=individual class=checkbox type=checkbox value=1>&nbsp;|.$locale->text('Individual Items').qq|
  • </td>
  • </tr>
  • |;
  • $bom = qq|<input name=itemstatus type=radio value=bom>&nbsp;|.$locale->text('BOM');
  • } elsif ($form->{searchitems} eq 'component') {
  • $bought = "";
  • $sold = "";
  • $fromto = "";
  • $l_name = "";
  • $l_curr = "";
  • $l_employee = "";
  • $l_serialnumber = "";
  • $warehouse = "";
  • $serialnumber = "";
  • $orphaned = "";
  • $l_warehouse = "";
  • $l_account = "";
  • } elsif ($form->{searchitems} eq 'labor') {
  • $sold = "";
  • $warehouse = "";
  • $serialnumber = "";
  • $l_avgcost = "";
  • }
  • @a = ();
  • push @a, qq|<input name=l_runningnumber class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('No.');
  • push @a, qq|<input name=l_partnumber class=checkbox type=checkbox value=Y checked>&nbsp;|.$locale->text('Number');
  • push @a, qq|<input name=l_description class=checkbox type=checkbox value=Y checked>&nbsp;|.$locale->text('Description');
  • push @a, qq|<input name=l_qty class=checkbox type=checkbox value=Y checked>&nbsp;|.$locale->text('Qty');
  • push @a, qq|<input name=l_unit class=checkbox type=checkbox value=Y checked>&nbsp;|.$locale->text('Unit');
  • push @a, qq|<input name=l_priceupdate class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Updated');
  • push @a, $l_partsgroup if $l_partsgroup;
  • push @a, $l_listprice if $l_listprice;
  • push @a, $l_sellprice if $l_sellprice;
  • push @a, $l_lastcost if $l_lastcost;
  • push @a, $l_avgcost if $l_avgcost;
  • push @a, $l_linetotal if $l_linetotal;
  • push @a, $l_markup if $l_markup;
  • push @a, $l_bin if $l_bin;
  • push @a, $l_rop if $l_rop;
  • push @a, $l_weight if $l_weight;
  • push @a, qq|<input name=l_notes class=checkbox type=checkbox value=Y>&nbsp;|.$locale->text('Notes');
  • push @a, $l_image if $l_image;
  • push @a, $l_drawing if $l_drawing;
  • push @a, $l_microfiche if $l_microfiche;
  • push @a, $l_make if $l_make;
  • push @a, $l_model if $l_model;
  • push @a, $l_warehouse if $l_warehouse;
  • push @a, $l_account if $l_account;
  • push @a, $l_name if $l_name;
  • push @a, $l_curr if $l_curr;
  • push @a, $l_employee if $l_employee;
  • push @a, $l_serialnumber if $l_serialnumber;
  • %title = ( all => 'Items',
  • part => 'Parts',
  • labor => 'Labor/Overhead',
  • service => 'Services',
  • assembly => 'Assemblies',
  • component => 'Components'
  • );
  • # $locale->text('Items')
  • # $locale->text('Parts')
  • # $locale->text('Labor/Overhead')
  • # $locale->text('Services')
  • # $locale->text('Assemblies')
  • # $locale->text('Components')
  • $form->{title} = $locale->text($title{$form->{searchitems}});
  • $form->header;
  • print qq|
  • <body>
  • <form method=post action=$form->{script}>
  • |;
  • $form->hide_form(qw(searchitems title));
  • print qq|
  • <table width="100%">
  • <tr><th class=listtop>$form->{title}</th></tr>
  • <tr height="5"></tr>
  • <tr valign=top>
  • <td>
  • <table>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Number').qq|</th>
  • <td><input name=partnumber size=20></td>
  • </tr>
  • <tr>
  • <th align=right nowrap>|.$locale->text('Description').qq|</th>
  • <td colspan=3><input name=description size=40></td>
  • </tr>
  • <tr>
  • $warehouse
  • </tr>
  • <tr>
  • $partsgroup
  • $serialnumber
  • </tr>
  • $makemodel
  • $drawing
  • $toplevel
  • <tr>
  • <td></td>
  • <td colspan=3>