[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [740] trunk
- Subject: SF.net SVN: ledger-smb: [740] trunk
- From: ..hidden..
- Date: Thu, 07 Dec 2006 11:00:24 -0800
Revision: 740
http://svn.sourceforge.net/ledger-smb/?rev=740&view=rev
Author: einhverfr
Date: 2006-12-07 11:00:23 -0800 (Thu, 07 Dec 2006)
Log Message:
-----------
A step towards fixing printing with 3-arg open statements. Printing is not verified yet.
Modified Paths:
--------------
trunk/LedgerSMB/Form.pm
trunk/bin/arapprn.pl
trunk/bin/bp.pl
trunk/bin/cp.pl
trunk/bin/io.pl
trunk/bin/jc.pl
trunk/bin/pos.pl
trunk/bin/rp.pl
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2006-12-07 18:26:43 UTC (rev 739)
+++ trunk/LedgerSMB/Form.pm 2006-12-07 19:00:23 UTC (rev 740)
@@ -598,13 +598,17 @@
$tmpfile =~ s/\./_$self->{fileid}./ if $self->{fileid};
$self->{tmpfile} = "${LedgerSMB::Sysconfig::userspath}/${fileid}_${tmpfile}";
+ my %temphash;
+
if ($self->{format} =~ /(postscript|pdf)/ || $self->{media} eq 'email') {
- my $out = $self->{OUT};
+ $temphash{out} = $self->{OUT};
$self->{OUT} = "$self->{tmpfile}";
+ $temphash{printmode} = $self->{printmode};
+ $self->{printmode} = '>';
}
if ($self->{OUT}) {
- open(OUT, '>', "$self->{OUT}") or $self->error("$self->{OUT} : $!");
+ open(OUT, $self->{printmode}, "$self->{OUT}") or $self->error("$self->{OUT} : $!");
} else {
open(OUT, ">-") or $self->error("STDOUT : $!");
@@ -918,7 +922,8 @@
} else {
- $self->{OUT} = $out;
+ $self->{OUT} = $temphash{out};
+ $self->{printmode} = $temphash{printmode};
unless (open(IN, '<', $self->{tmpfile})) {
$err = $!;
@@ -935,7 +940,7 @@
for my $i (1 .. $self->{copies}) {
if ($self->{OUT}) {
- unless (open(OUT, '>', $self->{OUT})) {
+ unless (open(OUT, $self->{printmode}, $self->{OUT})) {
$err = $!;
$self->cleanup;
$self->error("$self->{OUT} : $err");
Modified: trunk/bin/arapprn.pl
===================================================================
--- trunk/bin/arapprn.pl 2006-12-07 18:26:43 UTC (rev 739)
+++ trunk/bin/arapprn.pl 2006-12-07 19:00:23 UTC (rev 740)
@@ -1,686 +1,693 @@
-#=====================================================================
-# LedgerSMB Small Medium Business Accounting
-# http://www.ledgersmb.org/
-#
-
-# Copyright (C) 2006
-# This work contains copyrighted information from a number of sources all used
-# with permission.
-#
-# This file contains source code included with or based on SQL-Ledger which
-# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
-# under the GNU General Public License version 2 or, at your option, any later
-# version. For a full list including contact information of contributors,
-# maintainers, and copyright holders, see the CONTRIBUTORS file.
-#
-# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
-# Copyright (c) 2003
-#
-# Author: DWS Systems Inc.
-# Web: http://www.sql-ledger.org
-#
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#======================================================================
-#
-# This file has not undergone any whitespace cleanup.
-#
-# printing routines for ar, ap
-#
-
-# any custom scripts for this one
-if (-f "bin/custom/arapprn.pl") {
- eval { require "bin/custom/arapprn.pl"; };
-}
-if (-f "bin/custom/$form->{login}_arapprn.pl") {
- eval { require "bin/custom/$form->{login}_arapprn.pl"; };
-}
-
-
-1;
-# end of main
-
-
-sub print {
-
- if ($form->{media} !~ /screen/) {
- $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
- $old_form = new Form;
- for (keys %$form) { $old_form->{$_} = $form->{$_} }
- }
-
- if ($form->{formname} =~ /(check|receipt)/) {
- if ($form->{media} eq 'screen') {
- $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
- }
- }
-
- if (! $form->{invnumber}) {
- $invfld = 'sinumber';
- $invfld = 'vinumber' if $form->{ARAP} eq 'AP';
- $form->{invnumber} = $form->update_defaults(\%myconfig, $invfld);
- if ($form->{media} eq 'screen') {
- if ($form->{media} eq 'screen') {
- &update;
- exit;
- }
- }
- }
-
- if ($form->{formname} =~ /(check|receipt)/) {
- if ($form->{media} ne 'screen') {
- for (qw(action header)) { delete $form->{$_} }
- $form->{invtotal} = $form->{oldinvtotal};
-
- foreach $key (keys %$form) {
- $form->{$key} =~ s/&/%26/g;
- $form->{previousform} .= qq|$key=$form->{$key}&|;
- }
- chop $form->{previousform};
- $form->{previousform} = $form->escape($form->{previousform}, 1);
- }
-
- if ($form->{paidaccounts} > 1) {
- if ($form->{"paid_$form->{paidaccounts}"}) {
- &update;
- exit;
- } elsif ($form->{paidaccounts} > 2) {
- # select payment
- &select_payment;
- exit;
- }
- } else {
- $form->error($locale->text('Nothing to print!'));
- }
-
- }
- if ($filename = $queued{$form->{formname}}) {
- $form->{queued} =~ s/$form->{formname} $filename//;
- unlink "${LedgerSMB::Sysconfig::spool}/$filename";
- $filename =~ s/\..*$//g;
- } else {
- $filename = time;
- $filename .= $$;
- }
-
- $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
- $form->{OUT} = ">${LedgerSMB::Sysconfig::spool}/$filename" if
- $form->{media} ne 'screen';
-
- $form->{queued} .= " $form->{formname} $filename";
- $form->{queued} =~ s/^ //;
- $printform = new Form;
- for (keys %$form){
- $printform->{$_} = $form->{$_};
- }
-
-
- if ($form->{printandpost}){
- &post;
- } else {
- &{ "print_$form->{formname}" }($old_form, 1);
- }
-
-
-}
-
-
-sub print_check {
- my ($old_form, $i) = @_;
-
- $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form";
-
- if ($form->{"paid_$i"}) {
- @a = ();
-
- if (exists $form->{longformat}) {
- $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat});
- }
-
- push @a, "source_$i", "memo_$i";
- $form->format_string(@a);
- }
-
- $form->{amount} = $form->{"paid_$i"};
-
- if (($form->{formname} eq 'check' && $form->{vc} eq 'customer') ||
- ($form->{formname} eq 'receipt' && $form->{vc} eq 'vendor')) {
- $form->{amount} =~ s/-//g;
- }
-
- for (qw(datepaid source memo)) { $form->{$_} = $form->{"${_}_$i"} }
-
- &{ "$form->{vc}_details" };
- @a = qw(name address1 address2 city state zipcode country);
-
- foreach $item (qw(invnumber ordnumber)) {
- $temp{$item} = $form->{$item};
- delete $form->{$item};
- push(@{ $form->{$item} }, $temp{$item});
- }
- push(@{ $form->{invdate} }, $form->{transdate});
- push(@{ $form->{due} }, $form->format_amount(\%myconfig, $form->{oldinvtotal}, 2));
- push(@{ $form->{paid} }, $form->{"paid_$i"});
-
- use LedgerSMB::CP;
- $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode});
- $c->init;
- ($whole, $form->{decimal}) = split /\./, $form->parse_amount(\%myconfig, $form->{amount});
-
- $form->{decimal} .= "00";
- $form->{decimal} = substr($form->{decimal}, 0, 2);
- $form->{text_decimal} = $c->num2text($form->{decimal} * 1);
- $form->{text_amount} = $c->num2text($whole);
- $form->{integer_amount} = $form->format_amount($myconfig, $whole);
-
- ($form->{employee}) = split /--/, $form->{employee};
-
- $form->{notes} =~ s/^\s+//g;
- push @a, "notes";
-
- for (qw(company address tel fax businessnumber)) { $form->{$_} = $myconfig{$_} }
- $form->{address} =~ s/\\n/\n/g;
-
- push @a, qw(company address tel fax businessnumber text_amount text_decimal);
-
- $form->format_string(@a);
-
- $form->{templates} = "$myconfig{templates}";
- $form->{IN} = ($form->{formname} eq 'transaction') ? lc $form->{ARAP} . "_$form->{formname}.html" : "$form->{formname}.html";
-
- if ($form->{format} =~ /(postscript|pdf)/) {
- $form->{IN} =~ s/html$/tex/;
- }
- if ($form->{media} eq 'queue') {
-
- # save status
- $form->update_status(\%myconfig);
-
- $form->{queued} = $form->{queued};
-
- %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
- reference => $form->{"${inv}number"},
- formname => $form->{formname},
- action => 'queued',
- id => $form->{id} );
-
- $form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
- $form->{OUT} = ">${LedgerSMB::Sysconfig::spool}/$filename";
-
- $form->{queued} .= " $form->{formname} $filename";
- $form->{queued} =~ s/^ //;
- }
-
- if ($form->{media} !~ /(screen|queue)/) {
-
- %queued = split / /, $form->{queued};
-
-
- $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
-
- if ($form->{printed} !~ /$form->{formname}/) {
-
- $form->{printed} .= " $form->{formname}";
- $form->{printed} =~ s/^ //;
-
- $form->update_status(\%myconfig);
- }
-
- %audittrail = ( tablename => lc $form->{ARAP},
- reference => $form->{invnumber},
- formname => $form->{formname},
- action => 'printed',
- id => $form->{id} );
-
- %status = ();
- for (qw(printed audittrail)) { $status{$_} = $form->{$_} }
-
- $status{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
-
- }
-
- $form->{fileid} = $invnumber;
- $form->{fileid} =~ s/(\s|\W)+//g;
-
- $form->parse_template(\%myconfig);
-
- if ($form->{previousform}) {
-
- $previousform = $form->unescape($form->{previousform});
-
- for (keys %$form) { delete $form->{$_} }
-
- foreach $item (split /&/, $previousform) {
- ($key, $value) = split /=/, $item, 2;
- $value =~ s/%26/&/g;
- $form->{$key} = $value;
- }
-
- for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-
- for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) }
- for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
-
- for $i (1 .. $form->{paidaccounts}) {
- for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
- }
-
- for (qw(printed audittrail)) { $form->{$_} = $status{$_} }
-
- &{ "$display_form" };
-
- }
-
-}
-
-
-sub print_receipt {
- my ($old_form, $i) = @_;
-
- &print_check($old_form, $i);
-
-}
-
-
-sub print_transaction {
- my ($old_form) = @_;
-
- $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form";
-
-
- &{ "$form->{vc}_details" };
- @a = qw(name address1 address2 city state zipcode country);
-
-
- $form->{invtotal} = 0;
- foreach $i (1 .. $form->{rowcount} - 1) {
- ($form->{tempaccno}, $form->{tempaccount}) = split /--/, $form->{"$form->{ARAP}_amount_$i"};
- ($form->{tempprojectnumber}) = split /--/, $form->{"projectnumber_$i"};
- $form->{tempdescription} = $form->{"description_$i"};
-
- $form->format_string(qw(tempaccno tempaccount tempprojectnumber tempdescription));
-
- push(@{ $form->{accno} }, $form->{tempaccno});
- push(@{ $form->{account} }, $form->{tempaccount});
- push(@{ $form->{description} }, $form->{tempdescription});
- push(@{ $form->{projectnumber} }, $form->{tempprojectnumber});
-
- push(@{ $form->{amount} }, $form->{"amount_$i"});
-
- $form->{subtotal} += $form->parse_amount(\%myconfig, $form->{"amount_$i"});
-
- }
-
- foreach $accno (split / /, $form->{taxaccounts}) {
- if ($form->{"tax_$accno"}) {
- $form->format_string("${accno}_description");
-
- $tax += $form->parse_amount(\%myconfig, $form->{"tax_$accno"});
-
- $form->{"${accno}_tax"} = $form->{"tax_$accno"};
- push(@{ $form->{tax} }, $form->{"tax_$accno"});
-
- push(@{ $form->{taxdescription} }, $form->{"${accno}_description"});
-
- $form->{"${accno}_taxrate"} = $form->format_amount($myconfig, $form->{"${accno}_rate"} * 100);
- push(@{ $form->{taxrate} }, $form->{"${accno}_taxrate"});
-
- push(@{ $form->{taxnumber} }, $form->{"${accno}_taxnumber"});
- }
- }
-
- $tax = 0 if $form->{taxincluded};
-
- push @a, $form->{ARAP};
- $form->format_string(@a);
-
- $form->{paid} = 0;
- for $i (1 .. $form->{paidaccounts} - 1) {
-
- if ($form->{"paid_$i"}) {
- @a = ();
- $form->{paid} += $form->parse_amount(\%myconfig, $form->{"paid_$i"});
-
- if (exists $form->{longformat}) {
- $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat});
- }
-
- push @a, "$form->{ARAP}_paid_$i", "source_$i", "memo_$i";
- $form->format_string(@a);
-
- ($accno, $account) = split /--/, $form->{"$form->{ARAP}_paid_$i"};
-
- push(@{ $form->{payment} }, $form->{"paid_$i"});
- push(@{ $form->{paymentdate} }, $form->{"datepaid_$i"});
- push(@{ $form->{paymentaccount} }, $account);
- push(@{ $form->{paymentsource} }, $form->{"source_$i"});
- push(@{ $form->{paymentmemo} }, $form->{"memo_$i"});
- }
-
- }
-
- $form->{invtotal} = $form->{subtotal} + $tax;
- $form->{total} = $form->{invtotal} - $form->{paid};
-
- use LedgerSMB::CP;
- $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode});
- $c->init;
- ($whole, $form->{decimal}) = split /\./, $form->{invtotal};
-
- $form->{decimal} .= "00";
- $form->{decimal} = substr($form->{decimal}, 0, 2);
- $form->{text_decimal} = $c->num2text($form->{decimal} * 1);
- $form->{text_amount} = $c->num2text($whole);
- $form->{integer_amount} = $form->format_amount($myconfig, $whole);
-
- for (qw(invtotal subtotal paid total)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2) }
-
- ($form->{employee}) = split /--/, $form->{employee};
-
- if (exists $form->{longformat}) {
- for (qw(duedate transdate)) { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, $form->{longformat}) }
- }
-
- $form->{notes} =~ s/^\s+//g;
-
- @a = ("invnumber", "transdate", "duedate", "notes");
-
- for (qw(company address tel fax businessnumber)) { $form->{$_} = $myconfig{$_} }
- $form->{address} =~ s/\\n/\n/g;
-
- push @a, qw(company address tel fax businessnumber text_amount text_decimal);
-
- $form->format_string(@a);
-
- $form->{invdate} = $form->{transdate};
-
- $form->{templates} = "$myconfig{templates}";
- $form->{IN} = ($form->{formname} eq 'transaction') ? lc $form->{ARAP} . "_$form->{formname}.html" : "$form->{formname}.html";
-
- if ($form->{format} =~ /(postscript|pdf)/) {
- $form->{IN} =~ s/html$/tex/;
- }
- if ($form->{media} eq 'queue') {
- %queued = split / /, $form->{queued};
-
- if ($filename = $queued{$form->{formname}}) {
- $form->{queued} =~ s/$form->{formname} $filename//;
- unlink "${LedgerSMB::Sysconfig::spool}/$filename";
- $filename =~ s/\..*$//g;
- } else {
- $filename = time;
- $filename .= $$;
- }
-
- $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
- $form->{OUT} = ">${LedgerSMB::Sysconfig::spool}/$filename";
-
- $form->{queued} .= " $form->{formname} $filename";
- $form->{queued} =~ s/^ //;
-
- # save status
- $form->update_status(\%myconfig);
-
- $old_form->{queued} = $form->{queued};
-
- %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
- reference => $form->{"${inv}number"},
- formname => $form->{formname},
- action => 'queued',
- id => $form->{id} );
-
- $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
- }
-
- if ($form->{media} !~ /(queue|screen)/) {
- $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
-
- if ($form->{printed} !~ /$form->{formname}/) {
-
- $form->{printed} .= " $form->{formname}";
- $form->{printed} =~ s/^ //;
-
- $form->update_status(\%myconfig);
- }
-
- $old_form->{printed} = $form->{printed} if %$old_form;
-
- %audittrail = ( tablename => lc $form->{ARAP},
- reference => $form->{"invnumber"},
- formname => $form->{formname},
- action => 'printed',
- id => $form->{id} );
-
- $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail) if %$old_form;
-
- }
-
- $form->{fileid} = $form->{invnumber};
- $form->{fileid} =~ s/(\s|\W)+//g;
-
- $form->parse_template(\%myconfig);
-
- if (%$old_form) {
- $old_form->{invnumber} = $form->{invnumber};
- $old_form->{invtotal} = $form->{invtotal};
-
- for (keys %$form) { delete $form->{$_} }
- for (keys %$old_form) { $form->{$_} = $old_form->{$_} }
-
- if (! $form->{printandpost}) {
- for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-
- for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) }
- for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
-
- for $i (1 .. $form->{paidaccounts}) {
- for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
- }
- }
-
- &{ "$display_form" };
-
- }
-
-}
-
-
-sub vendor_details { IR->vendor_details(\%myconfig, \%$form) };
-sub customer_details { IS->customer_details(\%myconfig, \%$form) };
-
-
-sub select_payment {
-
- @column_index = ("ndx", "datepaid", "source", "memo", "paid", "$form->{ARAP}_paid");
-
- # list payments with radio button on a form
- $form->header;
-
- $title = $locale->text('Select payment');
-
- $column_data{ndx} = qq|<th width=1%> </th>|;
- $column_data{datepaid} = qq|<th>|.$locale->text('Date').qq|</th>|;
- $column_data{source} = qq|<th>|.$locale->text('Source').qq|</th>|;
- $column_data{memo} = qq|<th>|.$locale->text('Memo').qq|</th>|;
- $column_data{paid} = qq|<th>|.$locale->text('Amount').qq|</th>|;
- $column_data{"$form->{ARAP}_paid"} = qq|<th>|.$locale->text('Account').qq|</th>|;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
- <tr>
- <th class=listtop>$title</th>
- </tr>
- <tr space=5></tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>|;
-
- for (@column_index) { print "\n$column_data{$_}" }
-
- print qq|
- </tr>
-|;
-
- $checked = "checked";
- foreach $i (1 .. $form->{paidaccounts} - 1) {
-
- for (@column_index) { $column_data{$_} = qq|<td>$form->{"${_}_$i"}</td>| }
-
- $paid = $form->{"paid_$i"};
- $ok = 1;
-
- $column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
- $column_data{paid} = qq|<td align=right>$paid</td>|;
-
- $checked = "";
-
- $j++; $j %= 2;
- print qq|
- <tr class=listrow$j>|;
-
- for (@column_index) { print "\n$column_data{$_}" }
-
- print qq|
- </tr>
-|;
-
- }
-
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-|;
-
- for (qw(action nextsub)) { delete $form->{$_} }
-
- $form->hide_form;
-
- print qq|
-
-<br>
-<input type=hidden name=nextsub value=payment_selected>
-|;
-
- if ($ok) {
- print qq|
-<button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>|;
- }
-
- print qq|
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-sub payment_selected {
-
- &{ "print_$form->{formname}" }($form->{oldform}, $form->{ndx});
-
-}
-
-
-sub print_options {
-
- if ($form->{selectlanguage}) {
- $form->{"selectlanguage"} = $form->unescape($form->{"selectlanguage"});
- $form->{"selectlanguage"} =~ s/ selected//;
- $form->{"selectlanguage"} =~ s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
- $lang = qq|<select name=language_code>$form->{selectlanguage}</select>
- <input type=hidden name=selectlanguage value="|.
- $form->escape($form->{selectlanguage},1).qq|">|;
- }
-
- $form->{selectformname} = $form->unescape($form->{selectformname});
- $form->{selectformname} =~ s/ selected//;
- $form->{selectformname} =~ s/(<option value="\Q$form->{formname}\E")/$1 selected/;
-
- $type = qq|<select name=formname>$form->{selectformname}</select>
- <input type=hidden name=selectformname value="|.$form->escape($form->{selectformname},1).qq|">|;
-
- $media = qq|<select name=media>
- <option value="screen">|.$locale->text('Screen');
-
- $form->{selectformat} = qq|<option value="html">html\n|;
-
- if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) {
- for (sort keys %{LedgerSMB::Sysconfig::printer}) { $media .= qq|
- <option value="$_">$_| }
- }
-
- if (${LedgerSMB::Sysconfig::latex}) {
- $form->{selectformat} .= qq|
- <option value="postscript">|.$locale->text('Postscript').qq|
- <option value="pdf">|.$locale->text('PDF');
- $media .= qq|<option value="queue">|.$locale->text('Queue');
- }
-
- $format = qq|<select name=format>$form->{selectformat}</select>|;
- $format =~ s/(<option value="\Q$form->{format}\E")/$1 selected/;
- $format .= qq|
- <input type=hidden name=selectformat value="|.$form->escape($form->{selectformat},1).qq|">|;
- $media .= qq|</select>|;
- $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/;
-
- print qq|
- <table width=100%>
- <tr>
- <td>$type</td>
- <td>$lang</td>
- <td>$format</td>
- <td>$media</td>
- <td align=right width=90%>
- |;
-
- if ($form->{printed} =~ /$form->{formname}/) {
- print $locale->text('Printed').qq|<br>|;
- }
-
- if ($form->{recurring}) {
- print $locale->text('Scheduled');
- }
-
- print qq|
- </td>
- </tr>
- </table>
-|;
-
-}
-
-
-sub print_and_post {
-
- $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
- $form->error($locale->text('Select a Printer!')) if $form->{media} eq 'screen';
-
- $form->{printandpost} = 1;
- $form->{display_form} = "post";
- &print;
-
-}
-
-
+#=====================================================================
+# LedgerSMB Small Medium Business Accounting
+# http://www.ledgersmb.org/
+#
+
+# Copyright (C) 2006
+# This work contains copyrighted information from a number of sources all used
+# with permission.
+#
+# This file contains source code included with or based on SQL-Ledger which
+# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
+# under the GNU General Public License version 2 or, at your option, any later
+# version. For a full list including contact information of contributors,
+# maintainers, and copyright holders, see the CONTRIBUTORS file.
+#
+# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
+# Copyright (c) 2003
+#
+# Author: DWS Systems Inc.
+# Web: http://www.sql-ledger.org
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#======================================================================
+#
+# This file has not undergone any whitespace cleanup.
+#
+# printing routines for ar, ap
+#
+
+# any custom scripts for this one
+if (-f "bin/custom/arapprn.pl") {
+ eval { require "bin/custom/arapprn.pl"; };
+}
+if (-f "bin/custom/$form->{login}_arapprn.pl") {
+ eval { require "bin/custom/$form->{login}_arapprn.pl"; };
+}
+
+
+1;
+# end of main
+
+
+sub print {
+
+ if ($form->{media} !~ /screen/) {
+ $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
+ $old_form = new Form;
+ for (keys %$form) { $old_form->{$_} = $form->{$_} }
+ }
+
+ if ($form->{formname} =~ /(check|receipt)/) {
+ if ($form->{media} eq 'screen') {
+ $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
+ }
+ }
+
+ if (! $form->{invnumber}) {
+ $invfld = 'sinumber';
+ $invfld = 'vinumber' if $form->{ARAP} eq 'AP';
+ $form->{invnumber} = $form->update_defaults(\%myconfig, $invfld);
+ if ($form->{media} eq 'screen') {
+ if ($form->{media} eq 'screen') {
+ &update;
+ exit;
+ }
+ }
+ }
+
+ if ($form->{formname} =~ /(check|receipt)/) {
+ if ($form->{media} ne 'screen') {
+ for (qw(action header)) { delete $form->{$_} }
+ $form->{invtotal} = $form->{oldinvtotal};
+
+ foreach $key (keys %$form) {
+ $form->{$key} =~ s/&/%26/g;
+ $form->{previousform} .= qq|$key=$form->{$key}&|;
+ }
+ chop $form->{previousform};
+ $form->{previousform} = $form->escape($form->{previousform}, 1);
+ }
+
+ if ($form->{paidaccounts} > 1) {
+ if ($form->{"paid_$form->{paidaccounts}"}) {
+ &update;
+ exit;
+ } elsif ($form->{paidaccounts} > 2) {
+ # select payment
+ &select_payment;
+ exit;
+ }
+ } else {
+ $form->error($locale->text('Nothing to print!'));
+ }
+
+ }
+ if ($filename = $queued{$form->{formname}}) {
+ $form->{queued} =~ s/$form->{formname} $filename//;
+ unlink "${LedgerSMB::Sysconfig::spool}/$filename";
+ $filename =~ s/\..*$//g;
+ } else {
+ $filename = time;
+ $filename .= $$;
+ }
+
+ $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
+
+ if ($form->{media} ne 'screen'){
+ $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
+ $form{printmode} = '>';
+ }
+
+ $form->{queued} .= " $form->{formname} $filename";
+ $form->{queued} =~ s/^ //;
+ $printform = new Form;
+ for (keys %$form){
+ $printform->{$_} = $form->{$_};
+ }
+
+
+ if ($form->{printandpost}){
+ &post;
+ } else {
+ &{ "print_$form->{formname}" }($old_form, 1);
+ }
+
+
+}
+
+
+sub print_check {
+ my ($old_form, $i) = @_;
+
+ $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form";
+
+ if ($form->{"paid_$i"}) {
+ @a = ();
+
+ if (exists $form->{longformat}) {
+ $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat});
+ }
+
+ push @a, "source_$i", "memo_$i";
+ $form->format_string(@a);
+ }
+
+ $form->{amount} = $form->{"paid_$i"};
+
+ if (($form->{formname} eq 'check' && $form->{vc} eq 'customer') ||
+ ($form->{formname} eq 'receipt' && $form->{vc} eq 'vendor')) {
+ $form->{amount} =~ s/-//g;
+ }
+
+ for (qw(datepaid source memo)) { $form->{$_} = $form->{"${_}_$i"} }
+
+ &{ "$form->{vc}_details" };
+ @a = qw(name address1 address2 city state zipcode country);
+
+ foreach $item (qw(invnumber ordnumber)) {
+ $temp{$item} = $form->{$item};
+ delete $form->{$item};
+ push(@{ $form->{$item} }, $temp{$item});
+ }
+ push(@{ $form->{invdate} }, $form->{transdate});
+ push(@{ $form->{due} }, $form->format_amount(\%myconfig, $form->{oldinvtotal}, 2));
+ push(@{ $form->{paid} }, $form->{"paid_$i"});
+
+ use LedgerSMB::CP;
+ $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode});
+ $c->init;
+ ($whole, $form->{decimal}) = split /\./, $form->parse_amount(\%myconfig, $form->{amount});
+
+ $form->{decimal} .= "00";
+ $form->{decimal} = substr($form->{decimal}, 0, 2);
+ $form->{text_decimal} = $c->num2text($form->{decimal} * 1);
+ $form->{text_amount} = $c->num2text($whole);
+ $form->{integer_amount} = $form->format_amount($myconfig, $whole);
+
+ ($form->{employee}) = split /--/, $form->{employee};
+
+ $form->{notes} =~ s/^\s+//g;
+ push @a, "notes";
+
+ for (qw(company address tel fax businessnumber)) { $form->{$_} = $myconfig{$_} }
+ $form->{address} =~ s/\\n/\n/g;
+
+ push @a, qw(company address tel fax businessnumber text_amount text_decimal);
+
+ $form->format_string(@a);
+
+ $form->{templates} = "$myconfig{templates}";
+ $form->{IN} = ($form->{formname} eq 'transaction') ? lc $form->{ARAP} . "_$form->{formname}.html" : "$form->{formname}.html";
+
+ if ($form->{format} =~ /(postscript|pdf)/) {
+ $form->{IN} =~ s/html$/tex/;
+ }
+ if ($form->{media} eq 'queue') {
+
+ # save status
+ $form->update_status(\%myconfig);
+
+ $form->{queued} = $form->{queued};
+
+ %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
+ reference => $form->{"${inv}number"},
+ formname => $form->{formname},
+ action => 'queued',
+ id => $form->{id} );
+
+ $form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
+ $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
+ $form->{printmode} = '>';
+
+ $form->{queued} .= " $form->{formname} $filename";
+ $form->{queued} =~ s/^ //;
+ }
+
+ if ($form->{media} !~ /(screen|queue)/) {
+
+ %queued = split / /, $form->{queued};
+
+
+ $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
+ $form->{printmode} = '|-';
+
+ if ($form->{printed} !~ /$form->{formname}/) {
+
+ $form->{printed} .= " $form->{formname}";
+ $form->{printed} =~ s/^ //;
+
+ $form->update_status(\%myconfig);
+ }
+
+ %audittrail = ( tablename => lc $form->{ARAP},
+ reference => $form->{invnumber},
+ formname => $form->{formname},
+ action => 'printed',
+ id => $form->{id} );
+
+ %status = ();
+ for (qw(printed audittrail)) { $status{$_} = $form->{$_} }
+
+ $status{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
+
+ }
+
+ $form->{fileid} = $invnumber;
+ $form->{fileid} =~ s/(\s|\W)+//g;
+
+ $form->parse_template(\%myconfig);
+
+ if ($form->{previousform}) {
+
+ $previousform = $form->unescape($form->{previousform});
+
+ for (keys %$form) { delete $form->{$_} }
+
+ foreach $item (split /&/, $previousform) {
+ ($key, $value) = split /=/, $item, 2;
+ $value =~ s/%26/&/g;
+ $form->{$key} = $value;
+ }
+
+ for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
+
+ for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) }
+ for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
+
+ for $i (1 .. $form->{paidaccounts}) {
+ for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
+ }
+
+ for (qw(printed audittrail)) { $form->{$_} = $status{$_} }
+
+ &{ "$display_form" };
+
+ }
+
+}
+
+
+sub print_receipt {
+ my ($old_form, $i) = @_;
+
+ &print_check($old_form, $i);
+
+}
+
+
+sub print_transaction {
+ my ($old_form) = @_;
+
+ $display_form = ($form->{display_form}) ? $form->{display_form} : "display_form";
+
+
+ &{ "$form->{vc}_details" };
+ @a = qw(name address1 address2 city state zipcode country);
+
+
+ $form->{invtotal} = 0;
+ foreach $i (1 .. $form->{rowcount} - 1) {
+ ($form->{tempaccno}, $form->{tempaccount}) = split /--/, $form->{"$form->{ARAP}_amount_$i"};
+ ($form->{tempprojectnumber}) = split /--/, $form->{"projectnumber_$i"};
+ $form->{tempdescription} = $form->{"description_$i"};
+
+ $form->format_string(qw(tempaccno tempaccount tempprojectnumber tempdescription));
+
+ push(@{ $form->{accno} }, $form->{tempaccno});
+ push(@{ $form->{account} }, $form->{tempaccount});
+ push(@{ $form->{description} }, $form->{tempdescription});
+ push(@{ $form->{projectnumber} }, $form->{tempprojectnumber});
+
+ push(@{ $form->{amount} }, $form->{"amount_$i"});
+
+ $form->{subtotal} += $form->parse_amount(\%myconfig, $form->{"amount_$i"});
+
+ }
+
+ foreach $accno (split / /, $form->{taxaccounts}) {
+ if ($form->{"tax_$accno"}) {
+ $form->format_string("${accno}_description");
+
+ $tax += $form->parse_amount(\%myconfig, $form->{"tax_$accno"});
+
+ $form->{"${accno}_tax"} = $form->{"tax_$accno"};
+ push(@{ $form->{tax} }, $form->{"tax_$accno"});
+
+ push(@{ $form->{taxdescription} }, $form->{"${accno}_description"});
+
+ $form->{"${accno}_taxrate"} = $form->format_amount($myconfig, $form->{"${accno}_rate"} * 100);
+ push(@{ $form->{taxrate} }, $form->{"${accno}_taxrate"});
+
+ push(@{ $form->{taxnumber} }, $form->{"${accno}_taxnumber"});
+ }
+ }
+
+ $tax = 0 if $form->{taxincluded};
+
+ push @a, $form->{ARAP};
+ $form->format_string(@a);
+
+ $form->{paid} = 0;
+ for $i (1 .. $form->{paidaccounts} - 1) {
+
+ if ($form->{"paid_$i"}) {
+ @a = ();
+ $form->{paid} += $form->parse_amount(\%myconfig, $form->{"paid_$i"});
+
+ if (exists $form->{longformat}) {
+ $form->{"datepaid_$i"} = $locale->date(\%myconfig, $form->{"datepaid_$i"}, $form->{longformat});
+ }
+
+ push @a, "$form->{ARAP}_paid_$i", "source_$i", "memo_$i";
+ $form->format_string(@a);
+
+ ($accno, $account) = split /--/, $form->{"$form->{ARAP}_paid_$i"};
+
+ push(@{ $form->{payment} }, $form->{"paid_$i"});
+ push(@{ $form->{paymentdate} }, $form->{"datepaid_$i"});
+ push(@{ $form->{paymentaccount} }, $account);
+ push(@{ $form->{paymentsource} }, $form->{"source_$i"});
+ push(@{ $form->{paymentmemo} }, $form->{"memo_$i"});
+ }
+
+ }
+
+ $form->{invtotal} = $form->{subtotal} + $tax;
+ $form->{total} = $form->{invtotal} - $form->{paid};
+
+ use LedgerSMB::CP;
+ $c = CP->new(($form->{language_code}) ? $form->{language_code} : $myconfig{countrycode});
+ $c->init;
+ ($whole, $form->{decimal}) = split /\./, $form->{invtotal};
+
+ $form->{decimal} .= "00";
+ $form->{decimal} = substr($form->{decimal}, 0, 2);
+ $form->{text_decimal} = $c->num2text($form->{decimal} * 1);
+ $form->{text_amount} = $c->num2text($whole);
+ $form->{integer_amount} = $form->format_amount($myconfig, $whole);
+
+ for (qw(invtotal subtotal paid total)) { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2) }
+
+ ($form->{employee}) = split /--/, $form->{employee};
+
+ if (exists $form->{longformat}) {
+ for (qw(duedate transdate)) { $form->{$_} = $locale->date(\%myconfig, $form->{$_}, $form->{longformat}) }
+ }
+
+ $form->{notes} =~ s/^\s+//g;
+
+ @a = ("invnumber", "transdate", "duedate", "notes");
+
+ for (qw(company address tel fax businessnumber)) { $form->{$_} = $myconfig{$_} }
+ $form->{address} =~ s/\\n/\n/g;
+
+ push @a, qw(company address tel fax businessnumber text_amount text_decimal);
+
+ $form->format_string(@a);
+
+ $form->{invdate} = $form->{transdate};
+
+ $form->{templates} = "$myconfig{templates}";
+ $form->{IN} = ($form->{formname} eq 'transaction') ? lc $form->{ARAP} . "_$form->{formname}.html" : "$form->{formname}.html";
+
+ if ($form->{format} =~ /(postscript|pdf)/) {
+ $form->{IN} =~ s/html$/tex/;
+ }
+ if ($form->{media} eq 'queue') {
+ %queued = split / /, $form->{queued};
+
+ if ($filename = $queued{$form->{formname}}) {
+ $form->{queued} =~ s/$form->{formname} $filename//;
+ unlink "${LedgerSMB::Sysconfig::spool}/$filename";
+ $filename =~ s/\..*$//g;
+ } else {
+ $filename = time;
+ $filename .= $$;
+ }
+
+ $filename .= ($form->{format} eq 'postscript') ? '.ps' : '.pdf';
+ $form->{OUT} = "${LedgerSMB::Sysconfig::spool}/$filename";
+ $form->{printmode} = '>';
+
+ $form->{queued} .= " $form->{formname} $filename";
+ $form->{queued} =~ s/^ //;
+
+ # save status
+ $form->update_status(\%myconfig);
+
+ $old_form->{queued} = $form->{queued};
+
+ %audittrail = ( tablename => ($order) ? 'oe' : lc $ARAP,
+ reference => $form->{"${inv}number"},
+ formname => $form->{formname},
+ action => 'queued',
+ id => $form->{id} );
+
+ $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail);
+ }
+
+ if ($form->{media} !~ /(queue|screen)/) {
+ $form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
+ $form->{printmode} = '|-';
+
+ if ($form->{printed} !~ /$form->{formname}/) {
+
+ $form->{printed} .= " $form->{formname}";
+ $form->{printed} =~ s/^ //;
+
+ $form->update_status(\%myconfig);
+ }
+
+ $old_form->{printed} = $form->{printed} if %$old_form;
+
+ %audittrail = ( tablename => lc $form->{ARAP},
+ reference => $form->{"invnumber"},
+ formname => $form->{formname},
+ action => 'printed',
+ id => $form->{id} );
+
+ $old_form->{audittrail} .= $form->audittrail("", \%myconfig, \%audittrail) if %$old_form;
+
+ }
+
+ $form->{fileid} = $form->{invnumber};
+ $form->{fileid} =~ s/(\s|\W)+//g;
+
+ $form->parse_template(\%myconfig);
+
+ if (%$old_form) {
+ $old_form->{invnumber} = $form->{invnumber};
+ $old_form->{invtotal} = $form->{invtotal};
+
+ for (keys %$form) { delete $form->{$_} }
+ for (keys %$old_form) { $form->{$_} = $old_form->{$_} }
+
+ if (! $form->{printandpost}) {
+ for (qw(exchangerate creditlimit creditremaining)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
+
+ for (1 .. $form->{rowcount}) { $form->{"amount_$_"} = $form->parse_amount(\%myconfig, $form->{"amount_$_"}) }
+ for (split / /, $form->{taxaccounts}) { $form->{"tax_$_"} = $form->parse_amount(\%myconfig, $form->{"tax_$_"}) }
+
+ for $i (1 .. $form->{paidaccounts}) {
+ for (qw(paid exchangerate)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
+ }
+ }
+
+ &{ "$display_form" };
+
+ }
+
+}
+
+
+sub vendor_details { IR->vendor_details(\%myconfig, \%$form) };
+sub customer_details { IS->customer_details(\%myconfig, \%$form) };
+
+
+sub select_payment {
+
+ @column_index = ("ndx", "datepaid", "source", "memo", "paid", "$form->{ARAP}_paid");
+
+ # list payments with radio button on a form
+ $form->header;
+
+ $title = $locale->text('Select payment');
+
+ $column_data{ndx} = qq|<th width=1%> </th>|;
+ $column_data{datepaid} = qq|<th>|.$locale->text('Date').qq|</th>|;
+ $column_data{source} = qq|<th>|.$locale->text('Source').qq|</th>|;
+ $column_data{memo} = qq|<th>|.$locale->text('Memo').qq|</th>|;
+ $column_data{paid} = qq|<th>|.$locale->text('Amount').qq|</th>|;
+ $column_data{"$form->{ARAP}_paid"} = qq|<th>|.$locale->text('Account').qq|</th>|;
+
+ print qq|
+<body>
+
+<form method=post action=$form->{script}>
+
+<table width=100%>
+ <tr>
+ <th class=listtop>$title</th>
+ </tr>
+ <tr space=5></tr>
+ <tr>
+ <td>
+ <table width=100%>
+ <tr class=listheading>|;
+
+ for (@column_index) { print "\n$column_data{$_}" }
+
+ print qq|
+ </tr>
+|;
+
+ $checked = "checked";
+ foreach $i (1 .. $form->{paidaccounts} - 1) {
+
+ for (@column_index) { $column_data{$_} = qq|<td>$form->{"${_}_$i"}</td>| }
+
+ $paid = $form->{"paid_$i"};
+ $ok = 1;
+
+ $column_data{ndx} = qq|<td><input name=ndx class=radio type=radio value=$i $checked></td>|;
+ $column_data{paid} = qq|<td align=right>$paid</td>|;
+
+ $checked = "";
+
+ $j++; $j %= 2;
+ print qq|
+ <tr class=listrow$j>|;
+
+ for (@column_index) { print "\n$column_data{$_}" }
+
+ print qq|
+ </tr>
+|;
+
+ }
+
+ print qq|
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><hr size=3 noshade></td>
+ </tr>
+</table>
+|;
+
+ for (qw(action nextsub)) { delete $form->{$_} }
+
+ $form->hide_form;
+
+ print qq|
+
+<br>
+<input type=hidden name=nextsub value=payment_selected>
+|;
+
+ if ($ok) {
+ print qq|
+<button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>|;
+ }
+
+ print qq|
+</form>
+
+</body>
+</html>
+|;
+
+}
+
+sub payment_selected {
+
+ &{ "print_$form->{formname}" }($form->{oldform}, $form->{ndx});
+
+}
+
+
+sub print_options {
+
+ if ($form->{selectlanguage}) {
+ $form->{"selectlanguage"} = $form->unescape($form->{"selectlanguage"});
+ $form->{"selectlanguage"} =~ s/ selected//;
+ $form->{"selectlanguage"} =~ s/(<option value="\Q$form->{language_code}\E")/$1 selected/;
+ $lang = qq|<select name=language_code>$form->{selectlanguage}</select>
+ <input type=hidden name=selectlanguage value="|.
+ $form->escape($form->{selectlanguage},1).qq|">|;
+ }
+
+ $form->{selectformname} = $form->unescape($form->{selectformname});
+ $form->{selectformname} =~ s/ selected//;
+ $form->{selectformname} =~ s/(<option value="\Q$form->{formname}\E")/$1 selected/;
+
+ $type = qq|<select name=formname>$form->{selectformname}</select>
+ <input type=hidden name=selectformname value="|.$form->escape($form->{selectformname},1).qq|">|;
+
+ $media = qq|<select name=media>
+ <option value="screen">|.$locale->text('Screen');
+
+ $form->{selectformat} = qq|<option value="html">html\n|;
+
+ if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) {
+ for (sort keys %{LedgerSMB::Sysconfig::printer}) { $media .= qq|
+ <option value="$_">$_| }
+ }
+
+ if (${LedgerSMB::Sysconfig::latex}) {
+ $form->{selectformat} .= qq|
+ <option value="postscript">|.$locale->text('Postscript').qq|
+ <option value="pdf">|.$locale->text('PDF');
+ $media .= qq|<option value="queue">|.$locale->text('Queue');
+ }
+
+ $format = qq|<select name=format>$form->{selectformat}</select>|;
+ $format =~ s/(<option value="\Q$form->{format}\E")/$1 selected/;
+ $format .= qq|
+ <input type=hidden name=selectformat value="|.$form->escape($form->{selectformat},1).qq|">|;
+ $media .= qq|</select>|;
+ $media =~ s/(<option value="\Q$form->{media}\E")/$1 selected/;
+
+ print qq|
+ <table width=100%>
+ <tr>
+ <td>$type</td>
+ <td>$lang</td>
+ <td>$format</td>
+ <td>$media</td>
+ <td align=right width=90%>
+ |;
+
+ if ($form->{printed} =~ /$form->{formname}/) {
+ print $locale->text('Printed').qq|<br>|;
+ }
+
+ if ($form->{recurring}) {
+ print $locale->text('Scheduled');
+ }
+
+ print qq|
+ </td>
+ </tr>
+ </table>
+|;
+
+}
+
+
+sub print_and_post {
+
+ $form->error($locale->text('Select postscript or PDF!')) if $form->{format} !~ /(postscript|pdf)/;
+ $form->error($locale->text('Select a Printer!')) if $form->{media} eq 'screen';
+
+ $form->{printandpost} = 1;
+ $form->{display_form} = "post";
+ &print;
+
+}
+
+
Modified: trunk/bin/bp.pl
===================================================================
--- trunk/bin/bp.pl 2006-12-07 18:26:43 UTC (rev 739)
+++ trunk/bin/bp.pl 2006-12-07 19:00:23 UTC (rev 740)
@@ -1,546 +1,547 @@
-#=====================================================================
-# LedgerSMB Small Medium Business Accounting
-# http://www.ledgersmb.org/
-#
-
-# Copyright (C) 2006
-# This work contains copyrighted information from a number of sources all used
-# with permission.
-#
-# This file contains source code included with or based on SQL-Ledger which
-# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
-# under the GNU General Public License version 2 or, at your option, any later
-# version. For a full list including contact information of contributors,
-# maintainers, and copyright holders, see the CONTRIBUTORS file.
-#
-# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
-# Copyright (c) 2003
-#
-# Author: DWS Systems Inc.
-# Web: http://www.sql-ledger.org
-#
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#======================================================================
-#
-# Batch printing
-#
-#======================================================================
-
-
-use LedgerSMB::BP;
-
-1;
-# end of main
-
-
-sub search {
-
-# $locale->text('Sales Invoices')
-# $locale->text('Packing Lists')
-# $locale->text('Pick Lists')
-# $locale->text('Sales Orders')
-# $locale->text('Work Orders')
-# $locale->text('Purchase Orders')
-# $locale->text('Bin Lists')
-# $locale->text('Quotations')
-# $locale->text('RFQs')
-# $locale->text('Time Cards')
-
- # setup customer/vendor selection
- BP->get_vc(\%myconfig, \%$form);
-
- if (@{ $form->{"all_$form->{vc}"} }) {
- $name = "<option>\n";
- for (@{ $form->{"all_$form->{vc}"} }) { $name .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
- $name = qq|<select name=$form->{vc}>$name</select>|;
- } else {
- $name = qq|<input name=$form->{vc} size=35>|;
- }
-
-# $locale->text('Customer')
-# $locale->text('Vendor')
-# $locale->text('Employee')
-
- %label = ( invoice => { title => 'Sales Invoices', name => 'Customer' },
- packing_list => { title => 'Packing Lists', name => 'Customer' },
- pick_list => { title => 'Pick Lists', name => 'Customer' },
- sales_order => { title => 'Sales Orders', name => 'Customer' },
- work_order => { title => 'Work Orders', name => 'Customer' },
- purchase_order => { title => 'Purchase Orders', name => 'Vendor' },
- bin_list => { title => 'Bin Lists', name => 'Vendor' },
- sales_quotation => { title => 'Quotations', name => 'Customer' },
- request_quotation => { title => 'RFQs', name => 'Vendor' },
- timecard => { title => 'Time Cards', name => 'Employee' },
- check => {title => 'Check', name => 'Vendor'},
- );
-
- $label{invoice}{invnumber} = qq|
- <tr>
- <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
- <td colspan=3><input name=invnumber size=20></td>
- </tr>
-|;
- $label{invoice}{ordnumber} = qq|
- <tr>
- <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
- <td colspan=3><input name=ordnumber size=20></td>
- </tr>
-|;
- $label{sales_quotation}{quonumber} = qq|
- <tr>
- <th align=right nowrap>|.$locale->text('Quotation Number').qq|</th>
- <td colspan=3><input name=quonumber size=20></td>
- </tr>
-|;
-
- $label{packing_list}{invnumber} = $label{invoice}{invnumber};
- $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
- $label{pick_list}{invnumber} = $label{invoice}{invnumber};
- $label{pick_list}{ordnumber} = $label{invoice}{ordnumber};
- $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
- $label{work_order}{ordnumber} = $label{invoice}{ordnumber};
- $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
- $label{bin_list}{ordnumber} = $label{invoice}{ordnumber};
- $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
-
- # do one call to text
- $form->{title} = $locale->text('Print')." ".$locale->text($label{$form->{type}}{title});
-
- # accounting years
- 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> |.$locale->text('Current').qq|
- <input name=interval class=radio type=radio value=1> |.$locale->text('Month').qq|
- <input name=interval class=radio type=radio value=3> |.$locale->text('Quarter').qq|
- <input name=interval class=radio type=radio value=12> |.$locale->text('Year').qq|
- </td>
- </tr>
-|;
- }
-
-
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
- $form->hide_form(qw(vc type title));
-
- print qq|
-<table width=100%>
- <tr><th class=listtop>$form->{title}</th></tr>
- <tr height="5"></tr>
- <tr>
- <td>
- <table>
- <tr>
- <th align=right>|.$locale->text($label{$form->{type}}{name}).qq|</th>
- <td colspan=3>$name</td>
- </tr>
- $account
- $label{$form->{type}}{invnumber}
- $label{$form->{type}}{ordnumber}
- $label{$form->{type}}{quonumber}
- <tr>
- <th align=right nowrap>|.$locale->text('From').qq|</th>
- <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
- <th align=right>|.$locale->text('To').qq|</th>
- <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
- </tr>
- $selectfrom
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<input type=hidden name=sort value=transdate>
-<input type=hidden name=nextsub value=list_spool>
-
-<br>
-<button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
-|;
-
- $form->hide_form(qw(path login sessionid));
-
- print qq|
-
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-
-
-sub remove {
-
- $selected = 0;
-
- for $i (1 .. $form->{rowcount}) {
- if ($form->{"checked_$i"}) {
- $selected = 1;
- last;
- }
- }
-
- $form->error($locale->text('Nothing selected!')) unless $selected;
-
- $form->{title} = $locale->text('Confirm!');
-
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
- for (qw(action header)) { delete $form->{$_} }
-
- foreach $key (keys %$form) {
- print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
- }
-
- print qq|
-<h2 class=confirm>$form->{title}</h2>
-
-<h4>|.$locale->text('Are you sure you want to remove the marked entries from the queue?').qq|</h4>
-
-<button name="action" class="submit" type="submit" value="yes">|.$locale->text('Yes').qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-
-
-sub yes {
-
- $form->info($locale->text('Removing marked entries from queue ...'));
- $form->{callback} .= "&header=1" if $form->{callback};
-
- if (BP->delete_spool(\%myconfig, \%$form, ${LedgerSMB::Sysconfig::spool})) {
- $form->redirect($locale->text('Removed spoolfiles!'));
- } else {
- $form->error($locale->text('Cannot remove files!'));
- }
-
-}
-
-
-sub print {
-
- if ($form->{callback}) {
- for (1 .. $form->{rowcount}) { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
- $form->{callback} .= "&header=1";
- }
-
- for $i (1 .. $form->{rowcount}) {
- if ($form->{"checked_$i"}) {
- $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
- $form->info($locale->text('Printing')." ...");
-
- if (BP->print_spool(\%myconfig, \%$form, ${LedgerSMB::Sysconfig::spool})) {
- print $locale->text('done');
- $form->redirect($locale->text('Marked entries printed!'));
- }
- exit;
- }
- }
-
- $form->error('Nothing selected!');
-
-}
-
-
-sub list_spool {
-
- $form->{$form->{vc}} = $form->unescape($form->{$form->{vc}});
- ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
-
- BP->get_spoolfiles(\%myconfig, \%$form);
-
- $title = $form->escape($form->{title});
- $href = "$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
-
- $form->sort_order();
-
- $title = $form->escape($form->{title},1);
- $callback = "$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
-
- if ($form->{$form->{vc}}) {
- $callback .= "&$form->{vc}=".$form->escape($form->{$form->{vc}},1);
- $href .= "&$form->{vc}=".$form->escape($form->{$form->{vc}});
- $option = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
- $option .= " : $form->{$form->{vc}}";
- }
- if ($form->{account}) {
- $callback .= "&account=".$form->escape($form->{account},1);
- $href .= "&account=".$form->escape($form->{account});
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Account')." : $form->{account}";
- }
- if ($form->{invnumber}) {
- $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
- $href .= "&invnumber=".$form->escape($form->{invnumber});
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
- }
- if ($form->{ordnumber}) {
- $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
- $href .= "&ordnumber=".$form->escape($form->{ordnumber});
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Order Number')." : $form->{ordnumber}";
- }
- if ($form->{quonumber}) {
- $callback .= "&quonumber=".$form->escape($form->{quonumber},1);
- $href .= "&quonumber=".$form->escape($form->{quonumber});
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Quotation Number')." : $form->{quonumber}";
- }
-
- if ($form->{transdatefrom}) {
- $callback .= "&transdatefrom=$form->{transdatefrom}";
- $href .= "&transdatefrom=$form->{transdatefrom}";
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
- }
- if ($form->{transdateto}) {
- $callback .= "&transdateto=$form->{transdateto}";
- $href .= "&transdateto=$form->{transdateto}";
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
- }
-
- $name = ucfirst $form->{vc};
-
- @columns = qw(transdate);
- if ($form->{type} =~ /(invoice)/) {
- push @columns, "invnumber";
- }
- if ($form->{type} =~ /(packing|pick)_list/) {
- push @columns, "invnumber";
- }
- if ($form->{type} =~ /_(order|list)$/) {
- push @columns, "ordnumber";
- }
- if ($form->{type} =~ /_quotation$/) {
- push @columns, "quonumber";
- }
- if ($form->{type} eq 'timecard') {
- push @columns, "id";
- }
-
-
- push @columns, (name, spoolfile);
- @column_index = $form->sort_columns(@columns);
- unshift @column_index, "checked";
-
- $column_header{checked} = "<th class=listheading> </th>";
- $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
- $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
- $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
- $column_header{quonumber} = "<th><a class=listheading href=$href&sort=quonumber>".$locale->text('Quotation')."</a></th>";
- $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text($name)."</a></th>";
- $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
- $column_header{spoolfile} = "<th class=listheading>".$locale->text('Spoolfile')."</th>";
-
-
- $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>$option</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>
-|;
-
- for (@column_index) { print "\n$column_header{$_}" }
-
- print qq|
- </tr>
-|;
-
-
- # add sort and escape callback, this one we use for the add sub
- $form->{callback} = $callback .= "&sort=$form->{sort}";
-
- # escape callback for href
- $callback = $form->escape($callback);
-
- $i = 0;
-
- foreach $ref (@{ $form->{SPOOL} }) {
-
- $i++;
-
- $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
-
- # this is for audittrail
- $form->{module} = $ref->{module};
-
- if ($ref->{invoice}) {
- $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
- }
- $module = "$ref->{module}.pl";
-
- $column_data{transdate} = "<td>$ref->{transdate} </td>";
-
- if (${LedgerSMB::Sysconfig::spool} eq $ref->{spoolfile}) {
- $column_data{checked} = qq|<td></td>|;
- } else {
- $column_data{checked} = qq|<td><input name=checked_$i type=checkbox class=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
- }
-
- for (qw(id invnumber ordnumber quonumber)) { $column_data{$_} = qq|<td>$ref->{$_}</td>| }
-
- if ($ref->{module} eq 'oe') {
- $column_data{invnumber} = qq|<td> </td>|;
- $column_data{ordnumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{ordnumber}">|;
-
- $column_data{quonumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{quonumber}">|;
-
- } elsif ($ref->{module} eq 'jc') {
- $column_data{id} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{id}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{id}">|;
- } else {
- $column_data{invnumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{invnumber}">|;
- }
-
-
- $column_data{name} = "<td>$ref->{name}</td>";
- $column_data{spoolfile} = qq|<td><a href=${LedgerSMB::Sysconfig::spool}/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
-
-|;
-
- ${LedgerSMB::Sysconfig::spool} = $ref->{spoolfile};
-
- $j++; $j %= 2;
- print "
- <tr class=listrow$j>
-";
-
- for (@column_index) { print "\n$column_data{$_}" }
-
- print qq|
-<input type=hidden name="id_$i" value=$ref->{id}>
-<input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
-
- </tr>
-|;
-
- }
-
- print qq|
-<input type=hidden name=rowcount value=$i>
-
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<br>
-|;
-
- $form->hide_form(qw(callback title vc type sort module account path login sessionid));
-
- if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) {
- foreach $key (sort keys %{LedgerSMB::Sysconfig::printer}) {
- print qq|
-<input name=media type=radio class=radio value="$key" |;
- print qq|checked| if $key eq $myconfig{printer};
- print qq|>$key|;
- }
-
- print qq|<p>\n|;
-
-# type=submit $locale->text('Select all')
-# type=submit $locale->text('Print')
-# type=submit $locale->text('Remove')
-
- %button = ('select_all' => { ndx => 2, key => 'A', value => $locale->text('Select all') },
- 'print' => { ndx => 3, key => 'P', value => $locale->text('Print') },
- 'remove' => { ndx => 4, key => 'R', value => $locale->text('Remove') },
- );
-
- for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
-
- }
-
- if ($form->{lynx}) {
- require "bin/menu.pl";
- &menubar;
- }
-
- print qq|
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-
-sub select_all {
-
- for (1 .. $form->{rowcount}) { $form->{"checked_$_"} = 1 }
- &list_spool;
-
-}
-
-
-sub continue { &{ $form->{nextsub} } };
-
+#=====================================================================
+# LedgerSMB Small Medium Business Accounting
+# http://www.ledgersmb.org/
+#
+
+# Copyright (C) 2006
+# This work contains copyrighted information from a number of sources all used
+# with permission.
+#
+# This file contains source code included with or based on SQL-Ledger which
+# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
+# under the GNU General Public License version 2 or, at your option, any later
+# version. For a full list including contact information of contributors,
+# maintainers, and copyright holders, see the CONTRIBUTORS file.
+#
+# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
+# Copyright (c) 2003
+#
+# Author: DWS Systems Inc.
+# Web: http://www.sql-ledger.org
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#======================================================================
+#
+# Batch printing
+#
+#======================================================================
+
+
+use LedgerSMB::BP;
+
+1;
+# end of main
+
+
+sub search {
+
+# $locale->text('Sales Invoices')
+# $locale->text('Packing Lists')
+# $locale->text('Pick Lists')
+# $locale->text('Sales Orders')
+# $locale->text('Work Orders')
+# $locale->text('Purchase Orders')
+# $locale->text('Bin Lists')
+# $locale->text('Quotations')
+# $locale->text('RFQs')
+# $locale->text('Time Cards')
+
+ # setup customer/vendor selection
+ BP->get_vc(\%myconfig, \%$form);
+
+ if (@{ $form->{"all_$form->{vc}"} }) {
+ $name = "<option>\n";
+ for (@{ $form->{"all_$form->{vc}"} }) { $name .= qq|<option value="$_->{name}--$_->{id}">$_->{name}\n| }
+ $name = qq|<select name=$form->{vc}>$name</select>|;
+ } else {
+ $name = qq|<input name=$form->{vc} size=35>|;
+ }
+
+# $locale->text('Customer')
+# $locale->text('Vendor')
+# $locale->text('Employee')
+
+ %label = ( invoice => { title => 'Sales Invoices', name => 'Customer' },
+ packing_list => { title => 'Packing Lists', name => 'Customer' },
+ pick_list => { title => 'Pick Lists', name => 'Customer' },
+ sales_order => { title => 'Sales Orders', name => 'Customer' },
+ work_order => { title => 'Work Orders', name => 'Customer' },
+ purchase_order => { title => 'Purchase Orders', name => 'Vendor' },
+ bin_list => { title => 'Bin Lists', name => 'Vendor' },
+ sales_quotation => { title => 'Quotations', name => 'Customer' },
+ request_quotation => { title => 'RFQs', name => 'Vendor' },
+ timecard => { title => 'Time Cards', name => 'Employee' },
+ check => {title => 'Check', name => 'Vendor'},
+ );
+
+ $label{invoice}{invnumber} = qq|
+ <tr>
+ <th align=right nowrap>|.$locale->text('Invoice Number').qq|</th>
+ <td colspan=3><input name=invnumber size=20></td>
+ </tr>
+|;
+ $label{invoice}{ordnumber} = qq|
+ <tr>
+ <th align=right nowrap>|.$locale->text('Order Number').qq|</th>
+ <td colspan=3><input name=ordnumber size=20></td>
+ </tr>
+|;
+ $label{sales_quotation}{quonumber} = qq|
+ <tr>
+ <th align=right nowrap>|.$locale->text('Quotation Number').qq|</th>
+ <td colspan=3><input name=quonumber size=20></td>
+ </tr>
+|;
+
+ $label{packing_list}{invnumber} = $label{invoice}{invnumber};
+ $label{packing_list}{ordnumber} = $label{invoice}{ordnumber};
+ $label{pick_list}{invnumber} = $label{invoice}{invnumber};
+ $label{pick_list}{ordnumber} = $label{invoice}{ordnumber};
+ $label{sales_order}{ordnumber} = $label{invoice}{ordnumber};
+ $label{work_order}{ordnumber} = $label{invoice}{ordnumber};
+ $label{purchase_order}{ordnumber} = $label{invoice}{ordnumber};
+ $label{bin_list}{ordnumber} = $label{invoice}{ordnumber};
+ $label{request_quotation}{quonumber} = $label{sales_quotation}{quonumber};
+
+ # do one call to text
+ $form->{title} = $locale->text('Print')." ".$locale->text($label{$form->{type}}{title});
+
+ # accounting years
+ 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> |.$locale->text('Current').qq|
+ <input name=interval class=radio type=radio value=1> |.$locale->text('Month').qq|
+ <input name=interval class=radio type=radio value=3> |.$locale->text('Quarter').qq|
+ <input name=interval class=radio type=radio value=12> |.$locale->text('Year').qq|
+ </td>
+ </tr>
+|;
+ }
+
+
+ $form->header;
+
+ print qq|
+<body>
+
+<form method=post action=$form->{script}>
+|;
+
+ $form->hide_form(qw(vc type title));
+
+ print qq|
+<table width=100%>
+ <tr><th class=listtop>$form->{title}</th></tr>
+ <tr height="5"></tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align=right>|.$locale->text($label{$form->{type}}{name}).qq|</th>
+ <td colspan=3>$name</td>
+ </tr>
+ $account
+ $label{$form->{type}}{invnumber}
+ $label{$form->{type}}{ordnumber}
+ $label{$form->{type}}{quonumber}
+ <tr>
+ <th align=right nowrap>|.$locale->text('From').qq|</th>
+ <td><input name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
+ <th align=right>|.$locale->text('To').qq|</th>
+ <td><input name=transdateto size=11 title="$myconfig{dateformat}"></td>
+ </tr>
+ $selectfrom
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><hr size=3 noshade></td>
+ </tr>
+</table>
+
+<input type=hidden name=sort value=transdate>
+<input type=hidden name=nextsub value=list_spool>
+
+<br>
+<button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
+|;
+
+ $form->hide_form(qw(path login sessionid));
+
+ print qq|
+
+</form>
+
+</body>
+</html>
+|;
+
+}
+
+
+
+sub remove {
+
+ $selected = 0;
+
+ for $i (1 .. $form->{rowcount}) {
+ if ($form->{"checked_$i"}) {
+ $selected = 1;
+ last;
+ }
+ }
+
+ $form->error($locale->text('Nothing selected!')) unless $selected;
+
+ $form->{title} = $locale->text('Confirm!');
+
+ $form->header;
+
+ print qq|
+<body>
+
+<form method=post action=$form->{script}>
+|;
+
+ for (qw(action header)) { delete $form->{$_} }
+
+ foreach $key (keys %$form) {
+ print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
+ }
+
+ print qq|
+<h2 class=confirm>$form->{title}</h2>
+
+<h4>|.$locale->text('Are you sure you want to remove the marked entries from the queue?').qq|</h4>
+
+<button name="action" class="submit" type="submit" value="yes">|.$locale->text('Yes').qq|</button>
+</form>
+
+</body>
+</html>
+|;
+
+}
+
+
+
+sub yes {
+
+ $form->info($locale->text('Removing marked entries from queue ...'));
+ $form->{callback} .= "&header=1" if $form->{callback};
+
+ if (BP->delete_spool(\%myconfig, \%$form, ${LedgerSMB::Sysconfig::spool})) {
+ $form->redirect($locale->text('Removed spoolfiles!'));
+ } else {
+ $form->error($locale->text('Cannot remove files!'));
+ }
+
+}
+
+
+sub print {
+
+ if ($form->{callback}) {
+ for (1 .. $form->{rowcount}) { $form->{callback} .= "&checked_$_=1" if $form->{"checked_$_"} }
+ $form->{callback} .= "&header=1";
+ }
+
+ for $i (1 .. $form->{rowcount}) {
+ if ($form->{"checked_$i"}) {
+ $form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
+ $form->{printmode} = '|-';
+ $form->info($locale->text('Printing')." ...");
+
+ if (BP->print_spool(\%myconfig, \%$form, ${LedgerSMB::Sysconfig::spool})) {
+ print $locale->text('done');
+ $form->redirect($locale->text('Marked entries printed!'));
+ }
+ exit;
+ }
+ }
+
+ $form->error('Nothing selected!');
+
+}
+
+
+sub list_spool {
+
+ $form->{$form->{vc}} = $form->unescape($form->{$form->{vc}});
+ ($form->{$form->{vc}}, $form->{"$form->{vc}_id"}) = split(/--/, $form->{$form->{vc}});
+
+ BP->get_spoolfiles(\%myconfig, \%$form);
+
+ $title = $form->escape($form->{title});
+ $href = "$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
+
+ $form->sort_order();
+
+ $title = $form->escape($form->{title},1);
+ $callback = "$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
+
+ if ($form->{$form->{vc}}) {
+ $callback .= "&$form->{vc}=".$form->escape($form->{$form->{vc}},1);
+ $href .= "&$form->{vc}=".$form->escape($form->{$form->{vc}});
+ $option = ($form->{vc} eq 'customer') ? $locale->text('Customer') : $locale->text('Vendor');
+ $option .= " : $form->{$form->{vc}}";
+ }
+ if ($form->{account}) {
+ $callback .= "&account=".$form->escape($form->{account},1);
+ $href .= "&account=".$form->escape($form->{account});
+ $option .= "\n<br>" if ($option);
+ $option .= $locale->text('Account')." : $form->{account}";
+ }
+ if ($form->{invnumber}) {
+ $callback .= "&invnumber=".$form->escape($form->{invnumber},1);
+ $href .= "&invnumber=".$form->escape($form->{invnumber});
+ $option .= "\n<br>" if ($option);
+ $option .= $locale->text('Invoice Number')." : $form->{invnumber}";
+ }
+ if ($form->{ordnumber}) {
+ $callback .= "&ordnumber=".$form->escape($form->{ordnumber},1);
+ $href .= "&ordnumber=".$form->escape($form->{ordnumber});
+ $option .= "\n<br>" if ($option);
+ $option .= $locale->text('Order Number')." : $form->{ordnumber}";
+ }
+ if ($form->{quonumber}) {
+ $callback .= "&quonumber=".$form->escape($form->{quonumber},1);
+ $href .= "&quonumber=".$form->escape($form->{quonumber});
+ $option .= "\n<br>" if ($option);
+ $option .= $locale->text('Quotation Number')." : $form->{quonumber}";
+ }
+
+ if ($form->{transdatefrom}) {
+ $callback .= "&transdatefrom=$form->{transdatefrom}";
+ $href .= "&transdatefrom=$form->{transdatefrom}";
+ $option .= "\n<br>" if ($option);
+ $option .= $locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
+ }
+ if ($form->{transdateto}) {
+ $callback .= "&transdateto=$form->{transdateto}";
+ $href .= "&transdateto=$form->{transdateto}";
+ $option .= "\n<br>" if ($option);
+ $option .= $locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
+ }
+
+ $name = ucfirst $form->{vc};
+
+ @columns = qw(transdate);
+ if ($form->{type} =~ /(invoice)/) {
+ push @columns, "invnumber";
+ }
+ if ($form->{type} =~ /(packing|pick)_list/) {
+ push @columns, "invnumber";
+ }
+ if ($form->{type} =~ /_(order|list)$/) {
+ push @columns, "ordnumber";
+ }
+ if ($form->{type} =~ /_quotation$/) {
+ push @columns, "quonumber";
+ }
+ if ($form->{type} eq 'timecard') {
+ push @columns, "id";
+ }
+
+
+ push @columns, (name, spoolfile);
+ @column_index = $form->sort_columns(@columns);
+ unshift @column_index, "checked";
+
+ $column_header{checked} = "<th class=listheading> </th>";
+ $column_header{transdate} = "<th><a class=listheading href=$href&sort=transdate>".$locale->text('Date')."</a></th>";
+ $column_header{invnumber} = "<th><a class=listheading href=$href&sort=invnumber>".$locale->text('Invoice')."</a></th>";
+ $column_header{ordnumber} = "<th><a class=listheading href=$href&sort=ordnumber>".$locale->text('Order')."</a></th>";
+ $column_header{quonumber} = "<th><a class=listheading href=$href&sort=quonumber>".$locale->text('Quotation')."</a></th>";
+ $column_header{name} = "<th><a class=listheading href=$href&sort=name>".$locale->text($name)."</a></th>";
+ $column_header{id} = "<th><a class=listheading href=$href&sort=id>".$locale->text('ID')."</a></th>";
+ $column_header{spoolfile} = "<th class=listheading>".$locale->text('Spoolfile')."</th>";
+
+
+ $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>$option</td>
+ </tr>
+ <tr>
+ <td>
+ <table width=100%>
+ <tr class=listheading>
+|;
+
+ for (@column_index) { print "\n$column_header{$_}" }
+
+ print qq|
+ </tr>
+|;
+
+
+ # add sort and escape callback, this one we use for the add sub
+ $form->{callback} = $callback .= "&sort=$form->{sort}";
+
+ # escape callback for href
+ $callback = $form->escape($callback);
+
+ $i = 0;
+
+ foreach $ref (@{ $form->{SPOOL} }) {
+
+ $i++;
+
+ $form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
+
+ # this is for audittrail
+ $form->{module} = $ref->{module};
+
+ if ($ref->{invoice}) {
+ $ref->{module} = ($ref->{module} eq 'ar') ? "is" : "ir";
+ }
+ $module = "$ref->{module}.pl";
+
+ $column_data{transdate} = "<td>$ref->{transdate} </td>";
+
+ if (${LedgerSMB::Sysconfig::spool} eq $ref->{spoolfile}) {
+ $column_data{checked} = qq|<td></td>|;
+ } else {
+ $column_data{checked} = qq|<td><input name=checked_$i type=checkbox class=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
+ }
+
+ for (qw(id invnumber ordnumber quonumber)) { $column_data{$_} = qq|<td>$ref->{$_}</td>| }
+
+ if ($ref->{module} eq 'oe') {
+ $column_data{invnumber} = qq|<td> </td>|;
+ $column_data{ordnumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>
+ <input type=hidden name="reference_$i" value="$ref->{ordnumber}">|;
+
+ $column_data{quonumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>
+ <input type=hidden name="reference_$i" value="$ref->{quonumber}">|;
+
+ } elsif ($ref->{module} eq 'jc') {
+ $column_data{id} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{id}</a></td>
+ <input type=hidden name="reference_$i" value="$ref->{id}">|;
+ } else {
+ $column_data{invnumber} = qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>
+ <input type=hidden name="reference_$i" value="$ref->{invnumber}">|;
+ }
+
+
+ $column_data{name} = "<td>$ref->{name}</td>";
+ $column_data{spoolfile} = qq|<td><a href=${LedgerSMB::Sysconfig::spool}/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
+
+|;
+
+ ${LedgerSMB::Sysconfig::spool} = $ref->{spoolfile};
+
+ $j++; $j %= 2;
+ print "
+ <tr class=listrow$j>
+";
+
+ for (@column_index) { print "\n$column_data{$_}" }
+
+ print qq|
+<input type=hidden name="id_$i" value=$ref->{id}>
+<input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
+
+ </tr>
+|;
+
+ }
+
+ print qq|
+<input type=hidden name=rowcount value=$i>
+
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td><hr size=3 noshade></td>
+ </tr>
+</table>
+
+<br>
+|;
+
+ $form->hide_form(qw(callback title vc type sort module account path login sessionid));
+
+ if (%{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex}) {
+ foreach $key (sort keys %{LedgerSMB::Sysconfig::printer}) {
+ print qq|
+<input name=media type=radio class=radio value="$key" |;
+ print qq|checked| if $key eq $myconfig{printer};
+ print qq|>$key|;
+ }
+
+ print qq|<p>\n|;
+
+# type=submit $locale->text('Select all')
+# type=submit $locale->text('Print')
+# type=submit $locale->text('Remove')
+
+ %button = ('select_all' => { ndx => 2, key => 'A', value => $locale->text('Select all') },
+ 'print' => { ndx => 3, key => 'P', value => $locale->text('Print') },
+ 'remove' => { ndx => 4, key => 'R', value => $locale->text('Remove') },
+ );
+
+ for (sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button) { $form->print_button(\%button, $_) }
+
+ }
+
+ if ($form->{lynx}) {
+ require "bin/menu.pl";
+ &menubar;
+ }
+
+ print qq|
+</form>
+
+</body>
+</html>
+|;
+
+}
+
+
+sub select_all {
+
+ for (1 .. $form->{rowcount}) { $form->{"checked_$_"} = 1 }
+ &list_spool;
+
+}
+
+
+sub continue { &{ $form->{nextsub} } };
+
Modified: trunk/bin/cp.pl
===================================================================
--- trunk/bin/cp.pl 2006-12-07 18:26:43 UTC (rev 739)
+++ trunk/bin/cp.pl 2006-12-07 19:00:23 UTC (rev 740)
@@ -1273,7 +1273,8 @@
$form->{IN} = "$form->{formname}.tex";
if ($form->{media} ne 'screen') {
- $form->{OUT} = "| ${LedgerSMB::Sysconfig::printer}{$form->{media}}";
+ $form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
+ $form->{printmode} = '|-';
}
$form->parse_template(\%myconfig, ${LedgerSMB::Sysconfig::userspath});
Modified: trunk/bin/io.pl
===================================================================
--- trunk/bin/io.pl 2006-12-07 18:26:43 UTC (rev 739)
+++ trunk/bin/io.pl 2006-12-07 19:00:23 UTC (rev 740)
@@ -1,1703 +1,1706 @@
-######################################################################
-# LedgerSMB Small Medium Business Accounting
-# http://www.ledgersmb.org/
-#
-
-# Copyright (C) 2006
-# This work contains copyrighted information from a number of sources all used
-# with permission.
-#
-# This file contains source code included with or based on SQL-Ledger which
-# is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
-# under the GNU General Public License version 2 or, at your option, any later
-# version. For a full list including contact information of contributors,
-# maintainers, and copyright holders, see the CONTRIBUTORS file.
-#
-# Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
-# Copyright (c) 2002
-#
-# Author: DWS Systems Inc.
-# Web: http://www.sql-ledger.org
-#
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#######################################################################
-#
-# common routines used in is, ir, oe
-#
-#######################################################################
-
-use LedgerSMB::Tax;
-use LedgerSMB::Sysconfig;
-
-# any custom scripts for this one
-if (-f "bin/custom/io.pl") {
- eval { require "bin/custom/io.pl"; };
-}
-if (-f "bin/custom/$form->{login}_io.pl") {
- eval { require "bin/custom/$form->{login}_io.pl"; };
-}
-
-
-1;
-# end of main
-
-
-# this is for our long dates
-# $locale->text('January')
-# $locale->text('February')
-# $locale->text('March')
-# $locale->text('April')
-# $locale->text('May ')
-# $locale->text('June')
-# $locale->text('July')
-# $locale->text('August')
-# $locale->text('September')
-# $locale->text('October')
-# $locale->text('November')
-# $locale->text('December')
-
-# this is for our short month
-# $locale->text('Jan')
-# $locale->text('Feb')
-# $locale->text('Mar')
-# $locale->text('Apr')
-# $locale->text('May')
-# $locale->text('Jun')
-# $locale->text('Jul')
-# $locale->text('Aug')
-# $locale->text('Sep')
-# $locale->text('Oct')
-# $locale->text('Nov')
-# $locale->text('Dec')
-
-
-sub display_row {
- my $numrows = shift;
-
- @column_index = qw(runningnumber partnumber description qty);
-
- if ($form->{type} eq "sales_order") {
- push @column_index, "ship";
- $column_data{ship} = qq|<th class=listheading align=center width="auto">|.$locale->text('Ship').qq|</th>|;
- }
- if ($form->{type} eq "purchase_order") {
- push @column_index, "ship";
- $column_data{ship} = qq|<th class=listheading align=center width="auto">|.$locale->text('Recd').qq|</th>|;
- }
-
- for (qw(projectnumber partsgroup)) {
- $form->{"select$_"} = $form->unescape($form->{"select$_"}) if $form->{"select$_"};
- }
-
- if ($form->{language_code} ne $form->{oldlanguage_code}) {
- # rebuild partsgroup
- $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|;
- }
- }
- }
- $form->{oldlanguage_code} = $form->{language_code};
- }
-
-
- push @column_index, @{LedgerSMB::Sysconfig::io_lineitem_columns};
-
- my $colspan = $#column_index + 1;
-
- $form->{invsubtotal} = 0;
- for (split / /, $form->{taxaccounts}) { $form->{"${_}_base"} = 0 }
-
- $column_data{runningnumber} = qq|<th class=listheading nowrap>|.$locale->text('Item').qq|</th>|;
- $column_data{partnumber} = qq|<th class=listheading nowrap>|.$locale->text('Number').qq|</th>|;
- $column_data{description} = qq|<th class=listheading nowrap>|.$locale->text('Description').qq|</th>|;
- $column_data{qty} = qq|<th class=listheading nowrap>|.$locale->text('Qty').qq|</th>|;
- $column_data{unit} = qq|<th class=listheading nowrap>|.$locale->text('Unit').qq|</th>|;
- $column_data{sellprice} = qq|<th class=listheading nowrap>|.$locale->text('Price').qq|</th>|;
- $column_data{discount} = qq|<th class=listheading>%</th>|;
- $column_data{linetotal} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
- $column_data{bin} = qq|<th class=listheading nowrap>|.$locale->text('Bin').qq|</th>|;
- $column_data{onhand} = qq|<th class=listheading nowrap>|.$locale->text('OH').qq|</th>|;
-
- print qq|
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>|;
-
- for (@column_index) { print "\n$column_data{$_}" }
-
- print qq|
- </tr>
-|;
-
-
- $deliverydate = $locale->text('Delivery Date');
- $serialnumber = $locale->text('Serial No.');
- $projectnumber = $locale->text('Project');
- $group = $locale->text('Group');
- $sku = $locale->text('SKU');
-
- $delvar = 'deliverydate';
-
- if ($form->{type} =~ /_(order|quotation)$/) {
- $reqdate = $locale->text('Required by');
- $delvar = 'reqdate';
- }
-
- $exchangerate = $form->parse_amount(\%myconfig, $form->{exchangerate});
- $exchangerate = ($exchangerate) ? $exchangerate : 1;
-
- $spc = substr($myconfig{numberformat},-3,1);
- for $i (1 .. $numrows) {
- if ($spc eq '.') {
- ($null, $dec) = split /\./, $form->{"sellprice_$i"};
- } else {
- ($null, $dec) = split /,/, $form->{"sellprice_$i"};
- }
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
-
- # undo formatting
- for (qw(qty oldqty ship discount sellprice)) { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) }
-
- if ($form->{"qty_$i"} != $form->{"oldqty_$i"}) {
- # check pricematrix
- @a = split / /, $form->{"pricematrix_$i"};
- if (scalar @a > 2) {
- foreach $item (@a) {
- ($q, $p) = split /:/, $item;
- if (($p * 1) && ($form->{"qty_$i"} >= ($q * 1))) {
- ($dec) = ($p =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces = ($dec > 2) ? $dec : 2;
- $form->{"sellprice_$i"} = $form->round_amount($p / $exchangerate, $decimalplaces);
- }
- }
- }
- }
-
- $discount = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"}/100, $decimalplaces);
- $linetotal = $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
- $linetotal = $form->round_amount($linetotal * $form->{"qty_$i"}, 2);
-
-
- if (($rows = $form->numtextrows($form->{"description_$i"}, 46, 6)) > 1) {
- $form->{"description_$i"} = $form->quote($form->{"description_$i"});
- $column_data{description} = qq|<td><textarea name="description_$i" rows=$rows cols=46 wrap=soft>$form->{"description_$i"}</textarea></td>|;
- } else {
- $form->{"description_$i"} = $form->quote($form->{"description_$i"});
- $column_data{description} = qq|<td><input name="description_$i" size=48 value="$form->{"description_$i"}"></td>|;
- }
-
- for (qw(partnumber sku unit)) { $form->{"${_}_$i"} = $form->quote($form->{"${_}_$i"}) }
-
- $skunumber = qq|
- <p><b>$sku</b> $form->{"sku_$i"}| if ($form->{vc} eq 'vendor' && $form->{"sku_$i"});
-
-
- if ($form->{selectpartsgroup}) {
- if ($i < $numrows) {
- $partsgroup = qq|
- <b>$group</b>
- <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">|;
- ($form->{"partsgroup_$i"}) = split /--/, $form->{"partsgroup_$i"};
- $partsgroup .= $form->{"partsgroup_$i"};
- $partsgroup = "" unless $form->{"partsgroup_$i"};
- }
- }
-
- $delivery = qq|
- <td colspan=2 nowrap>
- <b>${$delvar}</b>
- <input name="${delvar}_$i" size=11 title="$myconfig{dateformat}" value="$form->{"${delvar}_$i"}"></td>
-|;
-
- $column_data{runningnumber} = qq|<td><input name="runningnumber_$i" size=3 value=$i></td>|;
- $column_data{partnumber} = qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}" accesskey="$i" title="[Alt-$i]">$skunumber</td>|;
- $column_data{qty} = qq|<td align=right><input name="qty_$i" title="$form->{"onhand_$i"}" size=5 value=|.$form->format_amount(\%myconfig, $form->{"qty_$i"}).qq|></td>|;
- $column_data{ship} = qq|<td align=right><input name="ship_$i" size=5 value=|.$form->format_amount(\%myconfig, $form->{"ship_$i"}).qq|></td>|;
- $column_data{unit} = qq|<td><input name="unit_$i" size=5 value="$form->{"unit_$i"}"></td>|;
- $column_data{sellprice} = qq|<td align=right><input name="sellprice_$i" size=9 value=|.$form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces).qq|></td>|;
- $column_data{discount} = qq|<td align=right><input name="discount_$i" size=3 value=|.$form->format_amount(\%myconfig, $form->{"discount_$i"}).qq|></td>|;
- $column_data{linetotal} = qq|<td align=right>|.$form->format_amount(\%myconfig, $linetotal, 2).qq|</td>|;
- $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
- $column_data{onhand} = qq|<td>$form->{"onhand_$i"}</td>|;
-
- print qq|
- <tr valign=top>|;
-
- for (@column_index) {
- print "\n$column_data{$_}";
- }
-
- print qq|
- </tr>
-<input type=hidden name="oldqty_$i" value="$form->{"qty_$i"}">
-|;
-
- for (qw(orderitems_id id bin weight listprice lastcost taxaccounts pricematrix sku onhand assembly inventory_accno_id income_accno_id expense_accno_id)) {
- $form->hide_form("${_}_$i");
- }
-
- $form->{selectprojectnumber} =~ s/ selected//;
- $form->{selectprojectnumber} =~ s/(<option value="\Q$form->{"projectnumber_$i"}\E")/$1 selected/;
-
- $project = qq|
- <b>$projectnumber</b>
- <select name="projectnumber_$i">$form->{selectprojectnumber}</select>
-| if $form->{selectprojectnumber};
-
-
- if (($rows = $form->numtextrows($form->{"notes_$i"}, 46, 6)) > 1) {
- $form->{"notes_$i"} = $form->quote($form->{"notes_$i"});
- $notes = qq|<td><textarea name="notes_$i" rows=$rows cols=46 wrap=soft>$form->{"notes_$i"}</textarea></td>|;
- } else {
- $form->{"notes_$i"} = $form->quote($form->{"notes_$i"});
- $notes = qq|<td><input name="notes_$i" size=48 value="$form->{"notes_$i"}"></td>|;
- }
-
- $serial = qq|
- <td colspan=6 nowrap><b>$serialnumber</b> <input name="serialnumber_$i" value="$form->{"serialnumber_$i"}"></td>| if $form->{type} !~ /_quotation/;
-
- if ($i == $numrows) {
- $partsgroup = "";
- if ($form->{selectpartsgroup}) {
- $partsgroup = qq|
- <b>$group</b>
- <select name="partsgroup_$i">$form->{selectpartsgroup}</select>
-|;
- }
-
- $serial = "";
- $project = "";
- $delivery = "";
- $notes = "";
- }
-
-
- # print second and third row
- print qq|
- <tr valign=top>
- $delivery
- $notes
- $serial
- </tr>
- <tr valign=top>
- <td colspan=$colspan>
- $project
- $partsgroup
- </td>
- </tr>
- <tr>
- <td colspan=$colspan><hr size=1 noshade></td>
- </tr>
-|;
-
- $skunumber = "";
-
- for (split / /, $form->{"taxaccounts_$i"}) {
- $form->{"${_}_base"} += $linetotal;
- }
-
- $form->{invsubtotal} += $linetotal;
- }
-
- print qq|
- </table>
- </td>
- </tr>
-|;
-
- $form->hide_form(qw(audittrail));
-
- print qq|
-
-<input type=hidden name=oldcurrency value=$form->{currency}>
-
-<input type=hidden name=selectpartsgroup value="|.$form->escape($form->{selectpartsgroup},1).qq|">
-<input type=hidden name=selectprojectnumber value="|.$form->escape($form->{selectprojectnumber},1).qq|">
-
-|;
-
-}
-
-
-sub select_item {
-
- if ($form->{vc} eq "vendor") {
- @column_index = qw(ndx partnumber sku description partsgroup onhand sellprice);
- } else {
- @column_index = qw(ndx partnumber description partsgroup onhand sellprice);
- }
-
- $column_data{ndx} = qq|<th> </th>|;
- $column_data{partnumber} = qq|<th class=listheading>|.$locale->text('Number').qq|</th>|;
- $column_data{sku} = qq|<th class=listheading>|.$locale->text('SKU').qq|</th>|;
- $column_data{description} = qq|<th class=listheading>|.$locale->text('Description').qq|</th>|;
- $column_data{partsgroup} = qq|<th class=listheading>|.$locale->text('Group').qq|</th>|;
- $column_data{sellprice} = qq|<th class=listheading>|.$locale->text('Price').qq|</th>|;
- $column_data{onhand} = qq|<th class=listheading>|.$locale->text('Qty').qq|</th>|;
-
- $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
-
- # list items with radio button on a form
- $form->header;
-
- $title = $locale->text('Select items');
-
- print qq|
-<body>
-
-<form method=post action="$form->{script}">
-
-<table width=100%>
- <tr>
- <th class=listtop>$title</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>$option</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>|;
-
- for (@column_index) { print "\n$column_data{$_}" }
-
- print qq|
- </tr>
-|;
-
- my $i = 0;
- foreach $ref (@{ $form->{item_list} }) {
- $i++;
-
- for (qw(sku partnumber description unit notes partsgroup)) {
- $ref->{$_} = $form->quote($ref->{$_});
- }
-
- $column_data{ndx} = qq|<td><input name="ndx_$i" class=checkbox type=checkbox value=$i></td>|;
-
- for (qw(partnumber sku description partsgroup)) { $column_data{$_} = qq|<td>$ref->{$_} </td>| }
-
- $column_data{sellprice} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{sellprice} / $exchangerate, 2, " ").qq|</td>|;
- $column_data{onhand} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{onhand}, '', " ").qq|</td>|;
-
- $j++; $j %= 2;
- print qq|
- <tr class=listrow$j>|;
-
- for (@column_index) {
- print "\n$column_data{$_}";
- }
-
- print qq|
- </tr>
-|;
-
- for (qw(partnumber sku description partsgroup partsgroup_id bin weight sellprice listprice lastcost onhand unit assembly taxaccounts inventory_accno_id income_accno_id expense_accno_id pricematrix id notes)) {
- print qq|<input type=hidden name="new_${_}_$i" value="$ref->{$_}">\n|;
- }
- }
-
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<input name=lastndx type=hidden value=$i>
-
-|;
-
- # delete variables
- for (qw(nextsub item_list)) { delete $form->{$_} }
-
- $form->{action} = "item_selected";
-
- $form->hide_form;
-
- print qq|
-<input type="hidden" name="nextsub" value="item_selected">
-
-<br>
-<button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-
-
-sub item_selected {
-
- $i = $form->{rowcount} - 1;
- $i = $form->{assembly_rows} - 1 if ($form->{item} eq 'assembly');
- $qty = ($form->{"qty_$form->{rowcount}"}) ? $form->{"qty_$form->{rowcount}"} : 1;
-
- for $j (1 .. $form->{lastndx}) {
-
- if ($form->{"ndx_$j"}) {
-
- $i++;
-
- $form->{"qty_$i"} = $qty;
- $form->{"discount_$i"} = $form->{discount} * 100;
- $form->{"reqdate_$i"} = $form->{reqdate} if $form->{type} !~ /_quotation/;
-
- for (qw(id partnumber sku description sellprice listprice lastcost bin unit weight assembly taxaccounts pricematrix onhand notes inventory_accno_id income_accno_id expense_accno_id)) {
- $form->{"${_}_$i"} = $form->{"new_${_}_$j"};
- }
-
- $form->{"partsgroup_$i"} = qq|$form->{"new_partsgroup_$j"}--$form->{"new_partsgroup_id_$j"}|;
-
- ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces1 = ($dec > 2) ? $dec : 2;
-
- ($dec) = ($form->{"lastcost_$i"} =~ /\.(\d+)/);
- $dec = length $dec;
- $decimalplaces2 = ($dec > 2) ? $dec : 2;
-
- # if there is an exchange rate adjust sellprice
- if (($form->{exchangerate} * 1)) {
- for (qw(sellprice listprice lastcost)) { $form->{"${_}_$i"} /= $form->{exchangerate} }
- # don't format list and cost
- $form->{"sellprice_$i"} = $form->round_amount($form->{"sellprice_$i"}, $decimalplaces1);
- }
-
- # this is for the assembly
- if ($form->{item} eq 'assembly') {
- $form->{"adj_$i"} = 1;
-
- for (qw(sellprice listprice weight)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-
- $form->{sellprice} += ($form->{"sellprice_$i"} * $form->{"qty_$i"});
- $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"});
- }
-
- $amount = $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * $form->{"qty_$i"};
- for (split / /, $form->{"taxaccounts_$i"}) { $form->{"${_}_base"} += $amount }
- if (!$form->{taxincluded}) {
- my @taxlist= Tax::init_taxes($form, $form->{"taxaccounts_$i"});
- $amount += Tax::calculate_taxes(..hidden.., $form, $amount, 0);
- }
-
- $form->{creditremaining} -= $amount;
-
- $form->{"runningnumber_$i"} = $i;
-
- # format amounts
- if ($form->{item} ne 'assembly') {
- 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->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"discount_$i"});
-
- }
- }
-
- $form->{rowcount} = $i;
- $form->{assembly_rows} = $i if ($form->{item} eq 'assembly');
-
- $form->{focus} = "description_$i";
-
- # delete all the new_ variables
- for $i (1 .. $form->{lastndx}) {
- for (qw(id partnumber sku description sellprice listprice lastcost bin unit weight assembly taxaccounts pricematrix onhand notes inventory_accno_id income_accno_id expense_accno_id)) {
- delete $form->{"new_${_}_$i"};
- }
- }
-
- for (qw(ndx lastndx nextsub)) { delete $form->{$_} }
-
- &display_form;
-
-}
-
-
-sub new_item {
-
- if ($form->{language_code} && $form->{"description_$form->{rowcount}"}) {
- $form->error($locale->text('Translation not on file!'));
- }
-
- # change callback
- $form->{old_callback} = $form->escape($form->{callback},1);
- $form->{callback} = $form->escape("$form->{script}?action=display_form",1);
-
- # delete action
- delete $form->{action};
-
- # save all other form variables in a previousform variable
- if (!$form->{previousform}) {
- foreach $key (keys %$form) {
- # escape ampersands
- $form->{$key} =~ s/&/%26/g;
- $form->{previousform} .= qq|$key=$form->{$key}&|;
- }
- chop $form->{previousform};
- $form->{previousform} = $form->escape($form->{previousform}, 1);
- }
-
- $i = $form->{rowcount};
- for (qw(partnumber description)) { $form->{"${_}_$i"} = $form->quote($form->{"${_}_$i"}) }
-
- $form->header;
-
- print qq|
-<body>
-
-<h4 class=error>|.$locale->text('Item not on file!').qq|</h4>|;
-
- if ($myconfig{acs} !~ /(Goods \& Services--Add Part|Goods \& Services--Add Service)/) {
-
- print qq|
-<h4>|.$locale->text('What type of item is this?').qq|</h4>
-
-<form method=post action=ic.pl>
-
-<p>
-
- <input class=radio type=radio name=item value=part checked> |.$locale->text('Part')
-.qq|<br>
- <input class=radio type=radio name=item value=service> |.$locale->text('Service')
-
-.qq|
-<input type=hidden name=partnumber value="$form->{"partnumber_$i"}">
-<input type=hidden name=description value="$form->{"description_$i"}">
-<input type=hidden name=nextsub value=add>
-<input type=hidden name=action value=add>
-|;
-
- $form->hide_form(qw(previousform rowcount path login sessionid));
-
- print qq|
-<p>
-<button class="submit" type="submit" name="action" value="continue">|.$locale->text('Continue').qq|</button>
-</form>
-|;
- }
-
- print qq|
-</body>
-</html>
-|;
-
-}
-
-
-
-sub display_form {
-
- # if we have a display_form
- if ($form->{display_form}) {
- &{ "$form->{display_form}" };
- exit;
- }
-
- &form_header;
-
- $numrows = ++$form->{rowcount};
- $subroutine = "display_row";
-
- if ($form->{item} eq 'part') {
- # create makemodel rows
- &makemodel_row(++$form->{makemodel_rows});
-
- &vendor_row(++$form->{vendor_rows});
-
- $numrows = ++$form->{customer_rows};
- $subroutine = "customer_row";
- }
- if ($form->{item} eq 'assembly') {
- # create makemodel rows
- &makemodel_row(++$form->{makemodel_rows});
-
- $numrows = ++$form->{customer_rows};
- $subroutine = "customer_row";
- }
- if ($form->{item} eq 'service') {
- &vendor_row(++$form->{vendor_rows});
-
- $numrows = ++$form->{customer_rows};
- $subroutine = "customer_row";
- }
- if ($form->{item} eq 'labor') {
- $numrows = 0;
- }
-
- # create rows
- &{ $subroutine }($numrows) if $numrows;
-
- &form_footer;
-
-}
-
-
-
-sub check_form {
-
- my @a = ();
- my $count = 0;
- my $i;
- my $j;
- my @flds = qw(id runningnumber partnumber description partsgroup qty ship unit sellprice discount oldqty orderitems_id bin weight listprice lastcost taxaccounts pricematrix sku onhand assembly inventory_accno_id income_accno_id expense_accno_id notes reqdate deliverydate serialnumber projectnumber);
-
- # remove any makes or model rows
- if ($form->{item} eq 'part') {
- for (qw(listprice sellprice lastcost avgcost weight rop markup)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-
- &calc_markup;
-
- @flds = qw(make model);
- $count = 0;
- @a = ();
- for $i (1 .. $form->{makemodel_rows}) {
- if (($form->{"make_$i"} ne "") || ($form->{"model_$i"} ne "")) {
- push @a, {};
- $j = $#a;
-
- for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
- $count++;
- }
- }
-
- $form->redo_rows(..hidden.., ..hidden.., $count, $form->{makemodel_rows});
- $form->{makemodel_rows} = $count;
-
- &check_vendor;
- &check_customer;
-
- }
-
- if ($form->{item} eq 'service') {
-
- for (qw(sellprice listprice lastcost avgcost markup)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-
- &calc_markup;
- &check_vendor;
- &check_customer;
-
- }
-
- if ($form->{item} eq 'assembly') {
-
- if (!$form->{project_id}) {
- $form->{sellprice} = 0;
- $form->{listprice} = 0;
- $form->{lastcost} = 0;
- $form->{weight} = 0;
- }
-
- for (qw(rop stock markup)) { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
-
- @flds = qw(id qty unit bom adj partnumber description sellprice listprice lastcost weight assembly runningnumber partsgroup);
- $count = 0;
- @a = ();
-
- for $i (1 .. ($form->{assembly_rows} - 1)) {
- if ($form->{"qty_$i"}) {
- push @a, {};
- my $j = $#a;
-
- $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
-
- for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
-
- if (! $form->{project_id}) {
- for (qw(sellprice listprice weight lastcost)) { $form->{$_} += ($form->{"${_}_$i"} * $form->{"qty_$i"}) }
- }
-
- $count++;
- }
- }
-
- if ($form->{markup} && $form->{markup} != $form->{oldmarkup}) {
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.