summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2005-12-11 19:23:05 +0000
committerJonas Smedegaard <dr@jones.dk>2005-12-11 19:23:05 +0000
commit295d945d8b4018bb54c8b522fc7b64b21a2a7e6f (patch)
tree15aa1c2d4da22891c5f726f3510e79ccc14557ae
parent19a6bc42222006b304f32fc1db945b1abbc61de8 (diff)
Actually generate the 'local' files.
-rw-r--r--logcheck/ignore.d.server/local19
-rw-r--r--logcheck/violations.ignore.d/local15
2 files changed, 14 insertions, 20 deletions
diff --git a/logcheck/ignore.d.server/local b/logcheck/ignore.d.server/local
index dc6916b..a5f3187 100644
--- a/logcheck/ignore.d.server/local
+++ b/logcheck/ignore.d.server/local
@@ -63,13 +63,6 @@
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhclient(-2.2.x)?: DHCP(ACK|OFFER) from [\.0-9]+$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhclient(-2.2.x)?: bound to [\.0-9]+ -- renewal in [0-9]+ seconds\.$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhclient(-2.2.x)?: irda0: unknown hardware address type 783$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: Abandoning IP address [\.0-9]+: (declined\.|pinged before offer) ?$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: BOOT(DISCOVER|REQUEST) from [0-9a-f:]+ via eth[0-9]+ (\(non-rfc1048)\) ?$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: BOOTREPLY for [\.0-9]+ to [^[:space:]]+ \([0-9a-f:]+\) via eth[0-9]+ ?$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCP(ACK|NAK|OFFER) on [\.0-9]+ to [0-9a-f:]+ via eth[0-9]+ ?$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCP(DECLINE on|RELEASE of|REQUEST for) [\.0-9]+ from [0-9a-f:]+( \([^[:space:]]+\))? via eth[0-9]+ \((not )?found\) ?$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCPINFORM from [\.0-9]+ ?$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCPREQUEST for [\.0-9]+ from [0-9a-f:]+( \([^[:space:]]+\))? via eth[0-9]+: wrong network\. ?$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd: Abandoning IP address [\.0-9]+: pinged before offer ?$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd: BOOTREQUEST from [0-9a-f:]+ ?$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd: DHCP(ACK|NAK|OFFER) on [\.0-9]+ to [0-9a-f:]+( \([^\)]+\))? via eth[0-9]+ ?$
@@ -82,6 +75,13 @@
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd: Wrote [0-9]+ (leases|deleted host decls|new dynamic host decls) to leases file\. ?$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd: accepting packet with data after udp payload. ?$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd: ip length 576 disagrees with bytes received 590. ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: Abandoning IP address [\.0-9]+: (declined\.|pinged before offer) ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: BOOT(DISCOVER|REQUEST) from [0-9a-f:]+ via eth[0-9]+ (\(non-rfc1048)\) ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: BOOTREPLY for [\.0-9]+ to [^[:space:]]+ \([0-9a-f:]+\) via eth[0-9]+ ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCP(ACK|NAK|OFFER) on [\.0-9]+ to [0-9a-f:]+ via eth[0-9]+ ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCP(DECLINE on|RELEASE of|REQUEST for) [\.0-9]+ from [0-9a-f:]+( \([^[:space:]]+\))? via eth[0-9]+ \((not )?found\) ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCPINFORM from [\.0-9]+ ?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ dhcpd-2.2.x: DHCPREQUEST for [\.0-9]+ from [0-9a-f:]+( \([^[:space:]]+\))? via eth[0-9]+: wrong network\. ?$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ gdm\[[0-9]+\]: run_pictures: Directory [^[:space:]] does not exist\.$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ gdm\[[0-9]+\]: Pingning af.* mislykkedes, deaktiver terminal!
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ gdm\[[0-9]+\]: \(child [0-9]+\) gdm_slave_xioerror_handler: Fatal X-fejl - genstarter [0-9:\.]*$
@@ -182,17 +182,14 @@
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: SSL_connect error to [^[:space:]]+: -1
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: [A-Z0-9]+: enabling PIX <CRLF>\.<CRLF> workaround for [^[:space:]]+\[[\.0-9]+\]$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: [^[:space:]]+ status=deferred \(connect to [^[:space:]]+\[[\.0-9]+\]: (Connection refused|server refused mail service)\)$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: connect to [^[:space:]]+\[[\.0-9]+\]: (Connection (refused|reset by peer|timed out)|read timeout|server (refused mail service|dropped connection)|No route to host) \(port 25\)$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: verify error:num=10:certificate has expired$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: connect to [^[:space:]]+\[[\.0-9]+\]: (Connection (refused|reset by peer|timed out)|read timeout|server (refused mail service|dropped connection|refused to talk to me: .*)|No route to host) \(port 25\)$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: warning: bad size limit "truncates" in EHLO reply from [^[:space:]]+$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: warning: host [^[:space:]]+\[[\.0-9]+\] (greeted me|replied to HELO/EHLO) with my own hostname [^[:space:]]+$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: warning: no MX host for [^[:space:]]+ has a valid A record$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: (Unv|V)erified: subject_CN=.*, issuer=.*$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: TLS connection established (from|to) [^[:space:]]+: (SSL|TLS)v[123] with cipher [^[:space:]]+ \([0-9/]+ bits\)$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: cert has expired$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: fingerprint=[0-9A-F:]+$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: setting up TLS connection (from|to) [^[:space:]]+\[[\.0-9]+\]$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: verify error:num=(7:certificate signature failure|10:certificate has expired|18:self signed certificate|19:self signed certificate in certificate chain)$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: verify error:num=(20:unable to get local issuer certificate|21:unable to verify the first certificate|26:unsupported certificate purpose|27:certificate not trusted)$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: warning: (numeric|malformed) domain name in resource data of MX record for [^[:space:]]+: [^[:space:]]*$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtpd?\[[0-9]+\]: warning: valid_hostname: (empty hostname|invalid character [0-9]+\(decimal\): [^[:space:]]+)$
diff --git a/logcheck/violations.ignore.d/local b/logcheck/violations.ignore.d/local
index aecded7..49dfe30 100644
--- a/logcheck/violations.ignore.d/local
+++ b/logcheck/violations.ignore.d/local
@@ -47,12 +47,14 @@
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/cleanup\[[0-9]+\]: [^[:space:]]+: message-id=<[^>]*>$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/local\[[0-9]+\]: warning: unable to create lock file /var/mail/[[:alnum:]]+\.lock: Permission denied$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/nqmgr\[[0-9]+\]: [^[:space:]]+: from=<[^>]*>, size=[0-9]+, nrcpt=[0-9]+ \(queue active\)$
+
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: [^[:space:]]+: Could not start TLS: client failure$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: (Unv|V)erified: subject_CN=.*, issuer=.*
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: Peer verification: CommonName in certificate does not match: [^!]* != [^[:space:]]+$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: certificate peer name verification failed for [^[:space:]]+: (CommonName mis-match: .+|[0-9]+ dNSNames in certificate found, but none matches)$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: certificate verification failed for [^[:space:]]+:( num=10:)?certificate has expired$
+
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: connect to [^[:space:]]+\[[\.0-9]+\]: (Connection refused|server refused mail service) \(port 25\)$
-#^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/(qmgr|smtp)\[[0-9]+\]: [^[:space:]]+: host [^[:space:]]+\[[\.0-9]+\] refused to talk to me: ([^[:space:]]+ 550 ERROR: Mail Refused - [\.0-9]+ - See http://security.rr.com/mail_blocks.htm|550 Host [\.0-9]+ is reject as in dynamic reject list \(dynamic.reject\))$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: connect to [^[:space:]]+\[[\.0-9]+\]: server refused to talk to me: ([^[:space:]]+ 550 ERROR: Mail Refused - [\.0-9]+ - See http://security.rr.com/cgi-bin/block-lookup\?[\.0-9]+|554 Client host rejected: cannot find your hostname, \[[\.0-9]+\]) \(port 25\)$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/(qmgr|smtp)\[[0-9]+\]: [^[:space:]]+: host [^[:space:]]+\[[\.0-9]+\] refused to talk to me: ([^[:space:]]+ 550 ERROR: Mail Refused - [\.0-9]+ - See http://security.rr.com/mail_blocks.htm|550 Host [\.0-9]+ is reject as in dynamic reject list \(dynamic.reject\))$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/qmgr\[[0-9]+\]: [^[:space:]]+: to=<[^>]*>, relay=none, delay=[0-9]+, status=deferred \(delivery temporarily suspended: host [^[:space:]]+\[[\.0-9]+\] refused to talk to me: ([^[:space:]]+ 550 ERROR: Mail Refused - [\.0-9]+ - See http://security.rr.com/mail_blocks.htm\)|550 Host [\.0-9]+ is reject as in dynamic reject list \(dynamic.reject\))$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/smtp\[[0-9]+\]: [^[:space:]]+: host [^[:space:]]+\[[\.0-9]+\] refused to talk to me: ([^[:space:]]+ 550 ERROR: Mail Refused - [\.0-9]+ - See http://security.rr.com/mail_blocks.htm|550 Host [\.0-9]+ is reject as in dynamic reject list \(dynamic.reject\)|554 <[^[:space:]]+\[[\.0-9]+\]>: Client host rejected: No mail accepted from you)$
@@ -100,9 +102,4 @@
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ IMP\[[0-9]+\]: FAILED [^[:space:]]+ to [^[:space:]]+:143 as [^[:space:]]+$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ i(map|pop3)d\[[0-9]+\]: (AUTHENTICATE (LOGIN|PLAIN) failure|Login failed)( user=[^[:space:]]*)?( auth=[^[:space:]]*)? host=([^[:space:]]* )?\[[^[:space:]]+\]$
^\w{3} [ :0-9]{11} [._[:alnum:]-]+ mod_auth_shadow: VALIDATE: user: [^[:space:]]+, Authentication failure$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sshd\[[0-9]+\]: \(pam_unix\) (authentication failure|2 more authentication failures); logname= uid=0 euid=0 tty=ssh ruser= rhost=81.19.251.(69|74) user=sm$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sshd\[[0-9]+\]: error: PAM: Authentication failure for sm from 81.19.251.(69|74)$
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sshd\[[0-9]+\]: Failed (keyboard-interactive/pam|password) for sm from ::ffff:81.19.251.(69|74) port [[:digit:]]+ ssh2$
-
-# Cracking attempts are too common, so clutters more than it helps to warn about them
-^\w{3} [ :0-9]{11} [._[:alnum:]-]+ sshd\[[0-9]+\]: (Failed password for illegal|Illegal) user [[:alnum:]]+ from [\.0-9]+( port [0-9]+ ssh2)?$
+^\w{3} [ :0-9]{11} [._[:alnum:]-]+ amavis\[[0-9]+\]: \([-0-9]+\) do_executable/do_unzip failed, ignoring: format error: bad signature: 0x00905a4d at offset 0 in file /var/lib/amavis/amavis-[-0-9]+/parts/part-00003$
order/quotation
  • OE->retrieve( \%myconfig, \%$form );
  • # get customer/vendor
  • $form->all_vc( \%myconfig, $form->{vc},
  • ( $form->{vc} eq 'customer' ) ? "AR" : "AP",
  • undef, $form->{transdate}, 1 );
  • # currencies
  • @curr = split /:/, $form->{currencies};
  • $form->{defaultcurrency} = $curr[0];
  • chomp $form->{defaultcurrency};
  • $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
  • for (@curr) { $form->{selectcurrency} .= "<option>$_\n" }
  • $form->{oldlanguage_code} = $form->{language_code};
  • $l{language_code} = $form->{language_code};
  • $l{searchitems} = 'nolabor' if $form->{vc} eq 'customer';
  • $form->get_partsgroup( \%myconfig, \%l );
  • if ( @{ $form->{all_partsgroup} } ) {
  • $form->{selectpartsgroup} = "<option>\n";
  • foreach $ref ( @{ $form->{all_partsgroup} } ) {
  • if ( $ref->{translation} ) {
  • $form->{selectpartsgroup} .=
  • qq|<option value="$ref->{partsgroup}--$ref->{id}">$ref->{translation}\n|;
  • }
  • else {
  • $form->{selectpartsgroup} .=
  • qq|<option value="$ref->{partsgroup}--$ref->{id}">$ref->{partsgroup}\n|;
  • }
  • }
  • }
  • if ( @{ $form->{all_project} } ) {
  • $form->{selectprojectnumber} = "<option>\n";
  • for ( @{ $form->{all_project} } ) {
  • $form->{selectprojectnumber} .=
  • qq|<option value="$_->{projectnumber}--$_->{id}">$_->{projectnumber}\n|;
  • }
  • }
  • if ( @{ $form->{"all_$form->{vc}"} } ) {
  • unless ( $form->{"$form->{vc}_id"} ) {
  • $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
  • }
  • }
  • for (qw(terms taxincluded)) { $temp{$_} = $form->{$_} }
  • $form->{shipto} = 1 if $form->{id};
  • # get customer / vendor
  • AA->get_name( \%myconfig, \%$form );
  • if ( $form->{id} ) {
  • for (qw(terms taxincluded)) { $form->{$_} = $temp{$_} }
  • }
  • ( $form->{ $form->{vc} } ) = split /--/, $form->{ $form->{vc} };
  • $form->{"old$form->{vc}"} =
  • qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
  • # build selection list
  • $form->{"select$form->{vc}"} = "";
  • if ( @{ $form->{"all_$form->{vc}"} } ) {
  • $form->{ $form->{vc} } =
  • qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
  • for ( @{ $form->{"all_$form->{vc}"} } ) {
  • $form->{"select$form->{vc}"} .=
  • qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  • }
  • }
  • # departments
  • if ( @{ $form->{all_department} } ) {
  • $form->{selectdepartment} = "<option>\n";
  • $form->{department} = "$form->{department}--$form->{department_id}"
  • if $form->{department_id};
  • for ( @{ $form->{all_department} } ) {
  • $form->{selectdepartment} .=
  • qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
  • }
  • }
  • $form->{employee} = "$form->{employee}--$form->{employee_id}";
  • # sales staff
  • if ( @{ $form->{all_employee} } ) {
  • $form->{selectemployee} = "";
  • for ( @{ $form->{all_employee} } ) {
  • $form->{selectemployee} .=
  • qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  • }
  • }
  • if ( @{ $form->{all_language} } ) {
  • $form->{selectlanguage} = "<option>\n";
  • for ( @{ $form->{all_language} } ) {
  • $form->{selectlanguage} .=
  • qq|<option value="$_->{code}">$_->{description}\n|;
  • }
  • }
  • # forex
  • $form->{forex} = $form->{exchangerate};
  • }
  • sub prepare_order {
  • $form->{format} = "postscript" if $myconfig{printer};
  • $form->{media} = $myconfig{printer};
  • $form->{formname} = $form->{type};
  • $form->{sortby} ||= "runningnumber";
  • $form->{currency} =~ s/ //g;
  • $form->{oldcurrency} = $form->{currency};
  • if ( $form->{id} ) {
  • for (
  • qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptoaddress1 shiptoaddress2 shiptocity shiptostate shiptozipcode shiptocountry shiptocontact)
  • )
  • {
  • $form->{$_} = $form->quote( $form->{$_} );
  • }
  • my $i;
  • foreach $ref ( @{ $form->{form_details} } ) {
  • $i++;
  • for ( keys %$ref ) { $form->{"${_}_$i"} = $ref->{$_} }
  • $form->{"projectnumber_$i"} =
  • qq|$ref->{projectnumber}--$ref->{project_id}|
  • if $ref->{project_id};
  • $form->{"partsgroup_$i"} =
  • qq|$ref->{partsgroup}--$ref->{partsgroup_id}|
  • if $ref->{partsgroup_id};
  • $form->{"discount_$i"} =
  • $form->format_amount( \%myconfig, $form->{"discount_$i"} * 100 );
  • ($dec) = ( $form->{"sellprice_$i"} =~ /\.(\d+)/ );
  • $dec = length $dec;
  • $decimalplaces = ( $dec > 2 ) ? $dec : 2;
  • for ( map { "${_}_$i" } qw(sellprice listprice) ) {
  • $form->{$_} =
  • $form->format_amount( \%myconfig, $form->{$_},
  • $decimalplaces );
  • }
  • ($dec) = ( $form->{"lastcost_$i"} =~ /\.(\d+)/ );
  • $dec = length $dec;
  • $decimalplaces = ( $dec > 2 ) ? $dec : 2;
  • $form->{"lastcost_$i"} =
  • $form->format_amount( \%myconfig, $form->{"lastcost_$i"},
  • $decimalplaces );
  • $form->{"qty_$i"} =
  • $form->format_amount( \%myconfig, $form->{"qty_$i"} );
  • $form->{"oldqty_$i"} = $form->{"qty_$i"};
  • for (qw(partnumber sku description unit)) {
  • $form->{"${_}_$i"} = $form->quote( $form->{"${_}_$i"} );
  • }
  • $form->{rowcount} = $i;
  • }
  • }
  • $form->{oldtransdate} = $form->{transdate};
  • if ( $form->{type} eq 'sales_quotation' ) {
  • if ( !$form->{readonly} ) {
  • $form->{readonly} = 1 if $myconfig{acs} =~ /Quotations--Quotation/;
  • }
  • $form->{selectformname} =
  • qq|<option value="sales_quotation">| . $locale->text('Quotation');
  • }
  • if ( $form->{type} eq 'request_quotation' ) {
  • if ( !$form->{readonly} ) {
  • $form->{readonly} = 1 if $myconfig{acs} =~ /Quotations--RFQ/;
  • }
  • $form->{selectformname} =
  • qq|<option value="request_quotation">| . $locale->text('RFQ');
  • }
  • if ( $form->{type} eq 'sales_order' ) {
  • if ( !$form->{readonly} ) {
  • $form->{readonly} = 1
  • if $myconfig{acs} =~ /Order Entry--Sales Order/;
  • }
  • $form->{selectformname} =
  • qq|<option value="sales_order">|
  • . $locale->text('Sales Order') . qq|
  • <option value="work_order">| . $locale->text('Work Order') . qq|
  • <option value="pick_list">| . $locale->text('Pick List') . qq|
  • <option value="packing_list">| . $locale->text('Packing List');
  • }
  • if ( $form->{type} eq 'purchase_order' ) {
  • if ( !$form->{readonly} ) {
  • $form->{readonly} = 1
  • if $myconfig{acs} =~ /Order Entry--Purchase Order/;
  • }
  • $form->{selectformname} =
  • qq|<option value="purchase_order">|
  • . $locale->text('Purchase Order') . qq|
  • <option value="bin_list">| . $locale->text('Bin List');
  • }
  • if ( $form->{type} eq 'ship_order' ) {
  • $form->{selectformname} =
  • qq|<option value="pick_list">|
  • . $locale->text('Pick List') . qq|
  • <option value="packing_list">| . $locale->text('Packing List');
  • }
  • if ( $form->{type} eq 'receive_order' ) {
  • $form->{selectformname} =
  • qq|<option value="bin_list">| . $locale->text('Bin List');
  • }
  • }
  • sub form_header {
  • $checkedopen = ( $form->{closed} ) ? "" : "checked";
  • $checkedclosed = ( $form->{closed} ) ? "checked" : "";
  • if ( $form->{id} ) {
  • $openclosed = qq|
  • <tr>
  • <th nowrap align=right><input name=closed type=radio class=radio value=0 $checkedopen> |
  • . $locale->text('Open')
  • . qq|</th>
  • <th nowrap align=left><input name=closed type=radio class=radio value=1 $checkedclosed> |
  • . $locale->text('Closed')
  • . qq|</th>
  • </tr>
  • |;
  • }
  • # set option selected
  • $form->{selectcurrency} =~ s/ selected//;
  • $form->{selectcurrency} =~
  • s/option>\Q$form->{currency}\E/option selected>$form->{currency}/;
  • for ( "$form->{vc}", "department", "employee" ) {
  • $form->{"select$_"} = $form->unescape( $form->{"select$_"} );
  • $form->{"select$_"} =~ s/ selected//;
  • $form->{"select$_"} =~ s/(<option value="\Q$form->{$_}\E")/$1 selected/;
  • }
  • $form->{exchangerate} =
  • $form->format_amount( \%myconfig, $form->{exchangerate} );
  • $exchangerate = qq|<tr>|;
  • $exchangerate .= qq|
  • <th align=right nowrap>| . $locale->text('Currency') . qq|</th>
  • <td><select name=currency>$form->{selectcurrency}</select></td> |
  • if $form->{defaultcurrency};
  • $exchangerate .= qq|
  • <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
  • <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
  • |;
  • if ( $form->{defaultcurrency}
  • && $form->{currency} ne $form->{defaultcurrency} )
  • {
  • if ( $form->{forex} ) {
  • $exchangerate .=
  • qq|<th align=right>|
  • . $locale->text('Exchange Rate')
  • . qq|</th><td>$form->{exchangerate}</td>
  • <input type=hidden name=exchangerate value=$form->{exchangerate}>
  • |;
  • }
  • else {
  • $exchangerate .=
  • qq|<th align=right>|
  • . $locale->text('Exchange Rate')
  • . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
  • }
  • }
  • $exchangerate .= qq|
  • <input type=hidden name=forex value=$form->{forex}>
  • </tr>
  • |;
  • $vclabel = ucfirst $form->{vc};
  • $vclabel = $locale->text($vclabel);
  • $terms = qq|
  • <tr>
  • <th align=right nowrap>| . $locale->text('Terms') . qq|</th>
  • <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
  • . $locale->text('days')
  • . qq|</td>
  • </tr>
  • |;
  • if ( $form->{business} ) {
  • $business = qq|
  • <tr>
  • <th align=right nowrap>| . $locale->text('Business') . qq|</th>
  • <td colspan=3>$form->{business}
  • &nbsp;&nbsp;&nbsp;|;
  • $business .= qq|
  • <b>| . $locale->text('Trade Discount') . qq|</b>
  • | . $form->format_amount( \%myconfig, $form->{tradediscount} * 100 ) . qq| %|
  • if $form->{vc} eq 'customer';
  • $business .= qq|</td>
  • </tr>
  • |;
  • }
  • if ( $form->{type} !~ /_quotation$/ ) {
  • $ordnumber = qq|
  • <tr>
  • <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
  • <td><input name=ordnumber size=20 value="$form->{ordnumber}"></td>
  • <input type=hidden name=quonumber value="$form->{quonumber}">
  • </tr>
  • <tr>
  • <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
  • <td><input class="date" name=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
  • </tr>
  • <tr>
  • <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
  • <td><input class="date" name=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
  • </tr>
  • <tr>
  • <th align=right nowrap>| . $locale->text('PO Number') . qq|</th>
  • <td><input name=ponumber size=20 value="$form->{ponumber}"></td>
  • </tr>
  • |;
  • $n = ( $form->{creditremaining} < 0 ) ? "0" : "1";
  • $creditremaining = qq|
  • <tr>
  • <td></td>
  • <td colspan=3>
  • <table>
  • <tr>
  • <th align=right nowrap>| . $locale->text('Credit Limit') . qq|</th>
  • <td>|
  • . $form->format_amount( \%myconfig, $form->{creditlimit}, 0, "0" )
  • . qq|</td>
  • <td width=10></td>
  • <th align=right nowrap>| . $locale->text('Remaining') . qq|</th>
  • <td class="plus$n" nowrap>|
  • . $form->format_amount( \%myconfig, $form->{creditremaining}, 0, "0" )
  • . qq|</td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • }
  • else {
  • $reqlabel =
  • ( $form->{type} eq 'sales_quotation' )
  • ? $locale->text('Valid until')
  • : $locale->text('Required by');
  • if ( $form->{type} eq 'sales_quotation' ) {
  • $ordnumber = qq|
  • <tr>
  • <th width=70% align=right nowrap>|
  • . $locale->text('Quotation Number')
  • . qq|</th>
  • <td><input name=quonumber size=20 value="$form->{quonumber}"></td>
  • <input type=hidden name=ordnumber value="$form->{ordnumber}">
  • </tr>
  • |;
  • }
  • else {
  • $ordnumber = qq|
  • <tr>
  • <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
  • <td><input name=quonumber size=20 value="$form->{quonumber}"></td>
  • <input type=hidden name=ordnumber value="$form->{ordnumber}">
  • </tr>
  • |;
  • $terms = "";
  • }
  • $ordnumber .= qq|
  • <tr>
  • <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
  • <td><input class="date" name=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
  • </tr>
  • <tr>
  • <th align=right nowrap=true>$reqlabel</th>
  • <td><input class="date" name=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
  • </tr>
  • |;
  • }
  • $ordnumber .= qq|
  • <input type=hidden name=oldtransdate value=$form->{oldtransdate}>|;
  • if ( $form->{"select$form->{vc}"} ) {
  • $vc = qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>
  • <input type=hidden name="select$form->{vc}" value="|
  • . $form->escape( $form->{"select$form->{vc}"}, 1 ) . qq|">|;
  • }
  • else {
  • $vc = qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
  • }
  • $department = qq|
  • <tr>
  • <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
  • <td colspan=3><select name=department>$form->{selectdepartment}</select>
  • <input type=hidden name=selectdepartment value="|
  • . $form->escape( $form->{selectdepartment}, 1 ) . qq|">
  • </td>
  • </tr>
  • | if $form->{selectdepartment};
  • $employee = qq|
  • <input type=hidden name=employee value="$form->{employee}">
  • |;
  • if ( $form->{type} eq 'sales_order' ) {
  • if ( $form->{selectemployee} ) {
  • $employee = qq|
  • <tr>
  • <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
  • <td><select name=employee>$form->{selectemployee}</select></td>
  • <input type=hidden name=selectemployee value="|
  • . $form->escape( $form->{selectemployee}, 1 ) . qq|"
  • </tr>
  • |;
  • }
  • }
  • else {
  • if ( $form->{selectemployee} ) {
  • $employee = qq|
  • <tr>
  • <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
  • <td><select name=employee>$form->{selectemployee}</select></td>
  • <input type=hidden name=selectemployee value="|
  • . $form->escape( $form->{selectemployee}, 1 ) . qq|"
  • </tr>
  • |;
  • }
  • }
  • $i = $form->{rowcount} + 1;
  • $focus = "partnumber_$i";
  • $form->header;
  • print qq|
  • <body onLoad="document.forms[0].${focus}.focus()" />
  • <form method=post action="$form->{script}">
  • |;
  • $form->hide_form(
  • qw(id type formname media format printed emailed queued vc title discount creditlimit creditremaining tradediscount business recurring)
  • );
  • print qq|
  • <table width=100%>
  • <tr class=listtop>
  • <th class=listtop>$form->{title}</th>
  • </tr>
  • <tr height="5"></tr>
  • <tr>
  • <td>
  • <table width="100%">
  • <tr valign=top>
  • <td>
  • <table width=100%>
  • <tr>
  • <th align=right>$vclabel</th>
  • <td colspan=3>$vc</td>
  • <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
  • <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
  • </tr>
  • $creditremaining
  • $business
  • $department
  • $exchangerate
  • <tr>
  • <th align=right>| . $locale->text('Shipping Point') . qq|</th>
  • <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
  • </tr>
  • <tr>
  • <th align=right>| . $locale->text('Ship via') . qq|</th>
  • <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
  • </tr>
  • </table>
  • </td>
  • <td align=right>
  • <table>
  • $openclosed
  • $employee
  • $ordnumber
  • $terms
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • |;
  • $form->hide_form(
  • qw(shiptoname shiptoaddress1 shiptoaddress2 shiptocity shiptostate shiptozipcode shiptocountry shiptocontact shiptophone shiptofax shiptoemail message email subject cc bcc taxaccounts)
  • );
  • for ( split / /, $form->{taxaccounts} ) {
  • print qq|
  • <input type=hidden name="${_}_rate" value=$form->{"${_}_rate"}>
  • <input type=hidden name="${_}_description" value="$form->{"${_}_description"}">
  • |;
  • }
  • }
  • sub form_footer {
  • $form->{invtotal} = $form->{invsubtotal};
  • if ( ( $rows = $form->numtextrows( $form->{notes}, 35, 8 ) ) < 2 ) {
  • $rows = 2;
  • }
  • if ( ( $introws = $form->numtextrows( $form->{intnotes}, 35, 8 ) ) < 2 ) {
  • $introws = 2;
  • }
  • $rows = ( $rows > $introws ) ? $rows : $introws;
  • $notes =
  • qq|<textarea name=notes rows=$rows cols=35 wrap=soft>$form->{notes}</textarea>|;
  • $intnotes =
  • qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
  • $form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
  • $taxincluded = "";
  • if ( $form->{taxaccounts} ) {
  • $taxincluded = qq|
  • <tr height="5"></tr>
  • <tr>
  • <td align=right>
  • <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}></td>
  • <th align=left>| . $locale->text('Tax Included') . qq|</th>
  • </tr>
  • |;
  • }
  • if ( !$form->{taxincluded} ) {
  • my @taxes = Tax::init_taxes( $form, $form->{taxaccounts} );
  • foreach my $item (@taxes) {
  • my $taccno = $item->account;
  • $form->{invtotal} += $form->round_amount(
  • $form->{"${taccno}_rate"} * $form->{"${taccno}_base"}, 2);
  • $form->{"${taccno}_total"} =
  • $form->format_amount( \%myconfig,
  • $form->{"${taccno}_rate"} * $form->{"${taccno}_base"}, 2 );
  • $tax .= qq|
  • <tr>
  • <th align=right>$form->{"${taccno}_description"}</th>
  • <td align=right>$form->{"${taccno}_total"}</td>
  • </tr>
  • | if $form->{"${taccno}_base"};
  • }
  • $form->{invsubtotal} =
  • $form->format_amount( \%myconfig, $form->{invsubtotal}, 2, 0 );
  • $subtotal = qq|
  • <tr>
  • <th align=right>| . $locale->text('Subtotal') . qq|</th>
  • <td align=right>$form->{invsubtotal}</td>
  • </tr>
  • |;
  • }
  • $form->{oldinvtotal} = $form->{invtotal};
  • $form->{invtotal} =
  • $form->format_amount( \%myconfig, $form->{invtotal}, 2, 0 );
  • print qq|
  • <tr>
  • <td>
  • <table width=100%>
  • <tr valign=top>
  • <td>
  • <table>
  • <tr>
  • <th align=left>| . $locale->text('Notes') . qq|</th>
  • <th align=left>| . $locale->text('Internal Notes') . qq|</th>
  • </tr>
  • <tr valign=top>
  • <td>$notes</td>
  • <td>$intnotes</td>
  • </tr>
  • </table>
  • </td>
  • <td align=right>
  • <table>
  • $subtotal
  • $tax
  • <tr>
  • <th align=right>| . $locale->text('Total') . qq|</th>
  • <td align=right>$form->{invtotal}</td>
  • </tr>
  • $taxincluded
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
  • <input type=hidden name=oldtotalpaid value=$totalpaid>
  • <tr>
  • <td><hr size=3 noshade></td>
  • </tr>
  • <tr>
  • <td>
  • |;
  • &print_options;
  • print qq|
  • </td>
  • </tr>
  • </table>
  • <br>
  • |;
  • # type=submit $locale->text('Update')
  • # type=submit $locale->text('Print')
  • # type=submit $locale->text('Schedule')
  • # type=submit $locale->text('Save')
  • # type=submit $locale->text('Print and Save')
  • # type=submit $locale->text('Ship to')
  • # type=submit $locale->text('Save as new')
  • # type=submit $locale->text('Print and Save as new')
  • # type=submit $locale->text('E-mail')
  • # type=submit $locale->text('Delete')
  • # type=submit $locale->text('Sales Invoice')
  • # type=submit $locale->text('Vendor Invoice')
  • # type=submit $locale->text('Quotation')
  • # type=submit $locale->text('RFQ')
  • # type=submit $locale->text('Sales Order')
  • # type=submit $locale->text('Purchase Order')
  • if ( !$form->{readonly} ) {
  • %button = (
  • 'update' =>
  • { ndx => 1, key => 'U', value => $locale->text('Update') },
  • 'print' =>
  • { ndx => 2, key => 'P', value => $locale->text('Print') },
  • 'save' => { ndx => 3, key => 'S', value => $locale->text('Save') },
  • 'ship_to' =>
  • { ndx => 4, key => 'T', value => $locale->text('Ship to') },
  • 'e_mail' =>
  • { ndx => 5, key => 'E', value => $locale->text('E-mail') },
  • 'print_and_save' => {
  • ndx => 6,
  • key => 'R',
  • value => $locale->text('Print and Save')
  • },
  • 'save_as_new' =>
  • { ndx => 7, key => 'N', value => $locale->text('Save as new') },
  • 'print_and_save_as_new' => {
  • ndx => 8,
  • key => 'W',
  • value => $locale->text('Print and Save as new')
  • },
  • 'sales_invoice' =>
  • { ndx => 9, key => 'I', value => $locale->text('Sales Invoice') },
  • 'sales_order' =>
  • { ndx => 10, key => 'O', value => $locale->text('Sales Order') },
  • 'quotation' =>
  • { ndx => 11, key => 'Q', value => $locale->text('Quotation') },
  • 'vendor_invoice' => {
  • ndx => 12,
  • key => 'I',
  • value => $locale->text('Vendor Invoice')
  • },
  • 'purchase_order' => {
  • ndx => 13,
  • key => 'O',
  • value => $locale->text('Purchase Order')
  • },
  • 'rfq' => { ndx => 14, key => 'Q', value => $locale->text('RFQ') },
  • 'schedule' =>
  • { ndx => 15, key => 'H', value => $locale->text('Schedule') },
  • 'delete' =>
  • { ndx => 16, key => 'D', value => $locale->text('Delete') },
  • );
  • %a = ();
  • for ( "update", "ship_to", "print", "e_mail", "save" ) { $a{$_} = 1 }
  • $a{'print_and_save'} = 1 if ${LedgerSMB::Sysconfig::latex};
  • if ( $form->{id} ) {
  • $a{'delete'} = 1;
  • $a{'save_as_new'} = 1;
  • $a{'print_and_save_as_new'} = 1 if ${LedgerSMB::Sysconfig::latex};
  • if ( $form->{type} =~ /sales_/ ) {
  • if ( $myconfig{acs} !~ /AR--Sales Invoice/ ) {
  • $a{'sales_invoice'} = 1;
  • }
  • }
  • else {
  • if ( $myconfig{acs} !~ /AP--Vendor Invoice/ ) {
  • $a{'vendor_invoice'} = 1;
  • }
  • }
  • if ( $form->{type} eq 'sales_order' ) {
  • if ( $myconfig{acs} !~ /Quotations--RFQ/ ) {
  • $a{'quotation'} = 1;
  • }
  • }
  • if ( $form->{type} eq 'purchase_order' ) {
  • if ( $myconfig{acs} !~ /Quotations--RFQ/ ) {
  • $a{'rfq'} = 1;
  • }
  • }
  • if ( $form->{type} eq 'sales_quotation' ) {
  • if ( $myconfig{acs} !~ /Order Entry--Sales Order/ ) {
  • $a{'sales_order'} = 1;
  • }
  • }
  • if ( $myconfig{acs} !~ /Order Entry--Purchase Order/ ) {
  • if ( $form->{type} eq 'request_quotation' ) {
  • $a{'purchase_order'} = 1;
  • }
  • }
  • }
  • if ( $form->{type} =~ /_order/ ) {
  • $a{'schedule'} = 1;
  • }
  • }
  • for ( keys %button ) { delete $button{$_} if !$a{$_} }
  • for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
  • $form->print_button( \%button, $_ );
  • }
  • if ( $form->{lynx} ) {
  • require "bin/menu.pl";
  • &menubar;
  • }
  • $form->hide_form(qw(rowcount callback path login sessionid));
  • print qq|
  • </form>
  • </body>
  • </html>
  • |;
  • }
  • sub update {
  • if ( $form->{type} eq 'generate_purchase_order' ) {
  • for ( 1 .. $form->{rowcount} ) {
  • if ( $form->{"ndx_$_"} ) {
  • $form->{"$form->{vc}_id_$_"} = $form->{"$form->{vc}_id"};
  • $form->{"$form->{vc}_$_"} =
  • qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
  • }
  • }
  • &po_orderitems;
  • exit;
  • }
  • $form->{exchangerate} =
  • $form->parse_amount( \%myconfig, $form->{exchangerate} );
  • if ( $form->{vc} eq 'customer' ) {
  • $buysell = "buy";
  • $ARAP = "AR";
  • }
  • else {
  • $buysell = "sell";
  • $ARAP = "AP";
  • }
  • if ( $newname = &check_name( $form->{vc} ) ) {
  • &rebuild_vc( $form->{vc}, $ARAP, $form->{transdate}, 1 );
  • }
  • if ( $form->{transdate} ne $form->{oldtransdate} ) {
  • $form->{reqdate} =
  • ( $form->{terms} )
  • ? $form->current_date( \%myconfig, $form->{transdate},
  • $form->{terms} * 1 )
  • : $form->{reqdate};
  • $form->{oldtransdate} = $form->{transdate};
  • &rebuild_vc( $form->{vc}, $ARAP, $form->{transdate}, 1 ) if !$newname;
  • if ( $form->{currency} ne $form->{defaultcurrency} ) {
  • delete $form->{exchangerate};
  • $form->{exchangerate} = $exchangerate
  • if (
  • $form->{forex} = (
  • $exchangerate = $form->check_exchangerate(
  • \%myconfig, $form->{currency},
  • $form->{transdate}, $buysell
  • )
  • )
  • );
  • }
  • $form->{selectemployee} = "";
  • if ( @{ $form->{all_employee} } ) {
  • for ( @{ $form->{all_employee} } ) {
  • $form->{selectemployee} .=
  • qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  • }
  • }
  • }
  • if ( $form->{currency} ne $form->{oldcurrency} ) {
  • delete $form->{exchangerate};
  • $form->{exchangerate} = $exchangerate
  • if (
  • $form->{forex} = (
  • $exchangerate = $form->check_exchangerate(
  • \%myconfig, $form->{currency},
  • $form->{transdate}, $buysell
  • )
  • )
  • );
  • }
  • my $i = $form->{rowcount};
  • $exchangerate = ( $form->{exchangerate} ) ? $form->{exchangerate} : 1;
  • for (qw(partsgroup projectnumber)) {
  • $form->{"select$_"} = $form->unescape( $form->{"select$_"} )
  • if $form->{"select$_"};
  • }
  • if ( ( $form->{"partnumber_$i"} eq "" )
  • && ( $form->{"description_$i"} eq "" )
  • && ( $form->{"partsgroup_$i"} eq "" ) )
  • {
  • $form->{creditremaining} +=
  • ( $form->{oldinvtotal} - $form->{oldtotalpaid} );
  • &check_form;
  • }
  • else {
  • $retrieve_item = "";
  • if ( $form->{type} eq 'purchase_order'
  • || $form->{type} eq 'request_quotation' )
  • {
  • $retrieve_item = "IR::retrieve_item";
  • }
  • if ( $form->{type} eq 'sales_order'
  • || $form->{type} eq 'sales_quotation' )
  • {
  • $retrieve_item = "IS::retrieve_item";
  • }
  • &{"$retrieve_item"}( "", \%myconfig, \%$form );
  • $rows = scalar @{ $form->{item_list} };
  • if ( $form->{language_code} && $rows == 0 ) {
  • $language_code = $form->{language_code};
  • $form->{language_code} = "";
  • if ($retrieve_item) {
  • &{"$retrieve_item"}( "", \%myconfig, \%$form );
  • }
  • $form->{language_code} = $language_code;
  • $rows = scalar @{ $form->{item_list} };
  • }
  • if ($rows) {
  • if ( $rows > 1 ) {
  • &select_item;
  • exit;
  • }
  • else {
  • $form->{"qty_$i"} =
  • ( $form->{"qty_$i"} * 1 ) ? $form->{"qty_$i"} : 1;
  • $form->{"reqdate_$i"} = $form->{reqdate}
  • if $form->{type} ne 'sales_quotation';
  • $sellprice =
  • $form->parse_amount( \%myconfig, $form->{"sellprice_$i"} );
  • for (qw(partnumber description unit)) {
  • $form->{item_list}[$i]{$_} =
  • $form->quote( $form->{item_list}[$i]{$_} );
  • }
  • for ( keys %{ $form->{item_list}[0] } ) {
  • $form->{"${_}_$i"} = $form->{item_list}[0]{$_};
  • }
  • if (! defined $form->{"discount_$i"}){
  • $form->{"discount_$i"} = $form->{discount} * 100;
  • }
  • if ($sellprice) {
  • $form->{"sellprice_$i"} = $sellprice;
  • ($dec) = ( $form->{"sellprice_$i"} =~ /\.(\d+)/ );
  • $dec = length $dec;
  • $decimalplaces1 = ( $dec > 2 ) ? $dec : 2;
  • }
  • else {
  • ($dec) = ( $form->{"sellprice_$i"} =~ /\.(\d+)/ );
  • $dec = length $dec;
  • $decimalplaces1 = ( $dec > 2 ) ? $dec : 2;
  • $form->{"sellprice_$i"} /= $exchangerate;
  • }
  • ($dec) = ( $form->{"lastcost_$i"} =~ /\.(\d+)/ );
  • $dec = length $dec;
  • $decimalplaces2 = ( $dec > 2 ) ? $dec : 2;
  • for (qw(listprice lastcost)) {
  • $form->{"${_}_$i"} /= $exchangerate;
  • }
  • $amount =
  • $form->{"sellprice_$i"} * $form->{"qty_$i"} *
  • ( 1 - $form->{"discount_$i"} / 100 );
  • for ( split / /, $form->{taxaccounts} ) {
  • $form->{"${_}_base"} = 0;
  • }
  • for ( split / /, $form->{"taxaccounts_$i"} ) {
  • $form->{"${_}_base"} += $amount;
  • }
  • if ( !$form->{taxincluded} ) {
  • my @taxes = Tax::init_taxes( $form, $form->{taxaccounts} );
  • $amount +=
  • Tax::calculate_taxes( \@taxes, $form, $amount, 0 );
  • }
  • $form->{creditremaining} -= $amount;
  • for (qw(sellprice listprice)) {
  • $form->{"${_}_$i"} =
  • $form->format_amount( \%myconfig, $form->{"${_}_$i"},
  • $decimalplaces1 );
  • }
  • $form->{"lastcost_$i"} =
  • $form->format_amount( \%myconfig, $form->{"lastcost_$i"},
  • $decimalplaces2 );
  • $form->{"oldqty_$i"} = $form->{"qty_$i"};
  • for (qw(qty discount)) {
  • $form->{"{_}_$i"} =
  • $form->format_amount( \%myconfig, $form->{"${_}_$i"} );
  • }
  • }
  • &display_form;
  • }
  • else {
  • # ok, so this is a new part
  • # ask if it is a part or service item
  • if ( $form->{"partsgroup_$i"}
  • && ( $form->{"partsnumber_$i"} eq "" )
  • && ( $form->{"description_$i"} eq "" ) )
  • {
  • $form->{rowcount}--;
  • &display_form;
  • }
  • else {
  • $form->{"id_$i"} = 0;
  • $form->{"unit_$i"} = $locale->text('ea');
  • &new_item;
  • }
  • }
  • }
  • }
  • sub search {
  • $requiredby = $locale->text('Required by');
  • if ( $form->{type} eq 'purchase_order' ) {
  • $form->{title} = $locale->text('Purchase Orders');
  • $form->{vc} = 'vendor';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Employee');
  • }
  • if ( $form->{type} eq 'receive_order' ) {
  • $form->{title} = $locale->text('Receive Merchandise');
  • $form->{vc} = 'vendor';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Employee');
  • }
  • if ( $form->{type} eq 'generate_sales_order' ) {
  • $form->{title} =
  • $locale->text('Generate Sales Order from Purchase Orders');
  • $form->{vc} = 'vendor';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Employee');
  • }
  • if ( $form->{type} eq 'consolidate_sales_order' ) {
  • $form->{title} = $locale->text('Consolidate Sales Orders');
  • $form->{vc} = 'customer';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Salesperson');
  • }
  • if ( $form->{type} eq 'request_quotation' ) {
  • $form->{title} = $locale->text('Request for Quotations');
  • $form->{vc} = 'vendor';
  • $ordlabel = $locale->text('RFQ Number');
  • $ordnumber = 'quonumber';
  • $employee = $locale->text('Employee');
  • }
  • if ( $form->{type} eq 'sales_order' ) {
  • $form->{title} = $locale->text('Sales Orders');
  • $form->{vc} = 'customer';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Salesperson');
  • }
  • if ( $form->{type} eq 'ship_order' ) {
  • $form->{title} = $locale->text('Ship Merchandise');
  • $form->{vc} = 'customer';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Salesperson');
  • }
  • if ( $form->{type} eq 'sales_quotation' ) {
  • $form->{title} = $locale->text('Quotations');
  • $form->{vc} = 'customer';
  • $ordlabel = $locale->text('Quotation Number');
  • $ordnumber = 'quonumber';
  • $employee = $locale->text('Employee');
  • $requiredby = $locale->text('Valid until');
  • }
  • if ( $form->{type} eq 'generate_purchase_order' ) {
  • $form->{title} =
  • $locale->text('Generate Purchase Orders from Sales Order');
  • $form->{vc} = 'customer';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Salesperson');
  • }
  • if ( $form->{type} eq 'consolidate_purchase_order' ) {
  • $form->{title} = $locale->text('Consolidate Purchase Orders');
  • $form->{vc} = 'vendor';
  • $ordlabel = $locale->text('Order Number');
  • $ordnumber = 'ordnumber';
  • $employee = $locale->text('Employee');
  • }
  • $l_employee =
  • qq|<input name="l_employee" class=checkbox type=checkbox value=Y> $employee|;
  • $l_manager =
  • qq|<input name="l_manager" class=checkbox type=checkbox value=Y> |
  • . $locale->text('Manager');
  • if ( $form->{type} =~ /(ship|receive)_order/ ) {
  • OE->get_warehouses( \%myconfig, \%$form );
  • $l_manager = "";
  • # warehouse
  • if ( @{ $form->{all_warehouse} } ) {
  • $form->{selectwarehouse} = "<option>\n";
  • $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
  • for ( @{ $form->{all_warehouse} } ) {
  • $form->{selectwarehouse} .=
  • qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
  • }
  • $warehouse = qq|
  • <tr>
  • <th align=right>| . $locale->text('Warehouse') . qq|</th>
  • <td><select name=warehouse>$form->{selectwarehouse}</select></td>
  • <input type=hidden name=selectwarehouse value="|
  • . $form->escape( $form->{selectwarehouse}, 1 ) . qq|">
  • </tr>
  • |;
  • }
  • }
  • # setup vendor / customer selection
  • $form->all_vc( \%myconfig, $form->{vc},
  • ( $form->{vc} eq 'customer' ) ? "AR" : "AP" );
  • for ( @{ $form->{"all_$form->{vc}"} } ) {
  • $vc .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  • }
  • $selectemployee = "";
  • if ( @{ $form->{all_employee} } ) {
  • $selectemployee = "<option>\n";
  • for ( @{ $form->{all_employee} } ) {
  • $selectemployee .=
  • qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
  • }
  • $selectemployee = qq|
  • <tr>
  • <th align=right>$employee</th>
  • <td colspan=3><select name=employee>$selectemployee</select></td>
  • </tr>
  • |;
  • }
  • else {
  • $l_employee = $l_manager = "";
  • }
  • $vclabel = ucfirst $form->{vc};
  • $vclabel = $locale->text($vclabel);
  • # $locale->text('Vendor')
  • # $locale->text('Customer')
  • $vc =
  • ($vc)
  • ? qq|<select name=$form->{vc}><option>\n$vc</select>|
  • : qq|<input name=$form->{vc} size=35>|;
  • # departments
  • if ( @{ $form->{all_department} } ) {
  • $form->{selectdepartment} = "<option>\n";
  • for ( @{ $form->{all_department} } ) {
  • $form->{selectdepartment} .=
  • qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
  • }
  • }
  • $department = qq|
  • <tr>
  • <th align=right nowrap>| . $locale->text('Department') . qq|</th>
  • <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
  • </tr>
  • | if $form->{selectdepartment};
  • if ( $form->{type} =~ /(consolidate.*|generate.*|ship|receive)_order/ ) {
  • $openclosed = qq|
  • <input type=hidden name="open" value=1>
  • |;
  • }
  • else {
  • $openclosed = qq|
  • <tr>
  • <td nowrap><input name="open" class=checkbox type=checkbox value=1 checked> |
  • . $locale->text('Open')
  • . qq|</td>
  • <td nowrap><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
  • . $locale->text('Closed')
  • . qq|</td>
  • </tr>
  • |;
  • }
  • if ( @{ $form->{all_years} } ) {
  • # accounting years
  • $form->{selectaccountingyear} = "<option>\n";
  • for ( @{ $form->{all_years} } ) {
  • $form->{selectaccountingyear} .= qq|<option>$_\n|;
  • }
  • $form->{selectaccountingmonth} = "<option>\n";
  • for ( sort keys %{ $form->{all_month} } ) {
  • $form->{selectaccountingmonth} .=
  • qq|<option value=$_>|
  • . $locale->text( $form->{all_month}{$_} ) . qq|\n|;
  • }
  • $selectfrom = qq|
  • <tr>
  • <th align=right>| . $locale->text('Period') . qq|</th>
  • <td colspan=3>
  • <select name=month>$form->{selectaccountingmonth}</select>
  • <select name=year>$form->{selectaccountingyear}</select>
  • <input name=interval class=radio type=radio value=0 checked>&nbsp;|
  • . $locale->text('Current') . qq|
  • <input name=interval class=radio type=radio value=1>&nbsp;|
  • . $locale->text('Month') . qq|
  • <input name=interval class=radio type=radio value=3>&nbsp;|
  • . $locale->text('Quarter') . qq|
  • <input name=interval class=radio type=radio value=12>&nbsp;|
  • . $locale->text('Year') . qq|
  • </td>
  • </tr>
  • |;
  • }
  • if ( $form->{type} =~ /_order/ ) {
  • $ponumber = qq|
  • <tr>
  • <th align=right>| . $locale->text('PO Number') . qq|</th>
  • <td colspan=3><input name="ponumber" size=20></td>
  • </tr>
  • |;
  • $l_ponumber =
  • qq|<input name="l_ponumber" class=checkbox type=checkbox value=Y> |
  • . $locale->text('PO Number');
  • }
  • @a = ();
  • push @a,
  • qq|<input name="l_runningnumber" class=checkbox type=checkbox value=Y> |
  • . $locale->text('No.');
  • push @a, qq|<input name="l_id" class=checkbox type=checkbox value=Y> |
  • . $locale->text('ID');
  • push @a,
  • qq|<input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel|;
  • push @a,
  • qq|<input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
  • . $locale->text('Date');
  • push @a, $l_ponumber if $l_ponumber;
  • push @a,
  • qq|<input name="l_reqdate" class=checkbox type=checkbox value=Y checked> $requiredby|;
  • push @a,
  • qq|<input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel|;
  • push @a, $l_employee if $l_employee;
  • push @a, $l_manager if $l_manager;
  • push @a, qq|<input name="l_shipvia" class=checkbox type=checkbox value=Y> |
  • . $locale->text('Ship via');
  • push @a,
  • qq|<input name="l_netamount" class=checkbox type=checkbox value=Y> |
  • . $locale->text('Amount');
  • push @a, qq|<input name="l_tax" class=checkbox type=checkbox value=Y> |
  • . $locale->text('Tax');
  • push @a,
  • qq|<input name="l_amount" class=checkbox type=checkbox value=Y checked> |
  • . $locale->text('Total');
  • push @a,
  • qq|<input name="l_curr" class=checkbox type=checkbox value=Y checked> |
  • . $locale->text('Currency');
  • $form->header;
  • print qq|
  • <body>
  • <form method=post action=$form->{script}>
  • <table width=100%>
  • <tr>
  • <th class=listtop>$form->{title}</th>
  • </tr>
  • <tr height="5"></tr>
  • <tr>
  • <td>
  • <table>
  • <tr>
  • <th align=right>$vclabel</th>
  • <td colspan=3>$vc</td>
  • </tr>
  • $warehouse
  • $department
  • $selectemployee
  • <tr>
  • <th align=right>$ordlabel</th>
  • <td colspan=3><input name="$ordnumber" size=20></td>
  • </tr>
  • $ponumber
  • <tr>
  • <th align=right>| . $locale->text('Ship via') . qq|</th>
  • <td colspan=3><input name="shipvia" size=40></td>
  • </tr>
  • <tr>
  • <th align=right>| . $locale->text('Description') . qq|</th>
  • <td colspan=3><input name="description" size=40></td>
  • </tr>
  • <tr>
  • <th align=right>| . $locale->text('From') . qq|</th>
  • <td><input class="date" name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
  • <th align=right>| . $locale->text('To') . qq|</th>
  • <td><input class="date" name=transdateto size=11 title="$myconfig{dateformat}"></td>
  • </tr>
  • <input type=hidden name=sort value=transdate>
  • $selectfrom
  • <tr>
  • <th align=right>| . $locale->text('Include in Report') . qq|</th>
  • <td colspan=3>
  • <table>
  • $openclosed
  • |;
  • while (@a) {
  • for ( 1 .. 5 ) {
  • print qq|<td nowrap>| . shift @a;
  • print qq|</td>\n|;
  • }
  • print qq|</tr>\n|;
  • }
  • print qq|
  • <tr>
  • <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
  • . $locale->text('Subtotal')
  • . qq|</td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • </table>
  • </td>
  • </tr>
  • <tr><td colspan=4><hr size=3 noshade></td></tr>
  • </table>
  • <br>
  • <input type=hidden name=nextsub value=transactions>
  • |;
  • $form->hide_form(qw(path login sessionid vc type));
  • print qq|
  • <button class="submit" type="submit" name="action" value="continue">|
  • . $locale->text('Continue')
  • . qq|</button>
  • </form>
  • |;
  • if ( $form->{lynx} ) {
  • require "bin/menu.pl";
  • &menubar;
  • }
  • print qq|
  • </body>
  • </html>
  • |;
  • }
  • sub transactions {
  • # split vendor / customer
  • ( $form->{ $form->{vc} }, $form->{"$form->{vc}_id"} ) =
  • split( /--/, $form->{ $form->{vc} } );
  • OE->transactions( \%myconfig, \%$form );