summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-08-20 22:59:39 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-08-20 22:59:39 +0000
commite22738400723dcedbca631d5789d171e078876b2 (patch)
tree3b1b191bd53c874ace71df8af035e73d96d6edf8 /bin
parent49c0b62ecacd828569849c4a05607f4161f0cbac (diff)
Removing the last references to CT.pm and ct.pl, removing these files.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2288 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'bin')
-rw-r--r--bin/aa.pl11
-rw-r--r--bin/ct.pl2219
2 files changed, 9 insertions, 2221 deletions
diff --git a/bin/aa.pl b/bin/aa.pl
index 5709875f..75573ab6 100644
--- a/bin/aa.pl
+++ b/bin/aa.pl
@@ -1561,6 +1561,13 @@ sub transactions {
( $form->{ $form->{vc} }, $form->{"$form->{vc}_id"} ) =
split( /--/, $form->{ $form->{vc} } );
}
+ if ($form->{vc} eq 'customer'){
+ $form->{entity_class} = 2;
+ } elsif ($form->{vc} eq 'vendor'){
+ $form->{entity_class} = 1;
+ } else {
+ $form->{entity_class} = "0";
+ }
@column_index;
AA->transactions( \%myconfig, \%$form );
@@ -1969,10 +1976,10 @@ sub transactions {
for (qw(id curr)) { $column_data{$_} = "<td>$ref->{$_}</td>" }
$column_data{accno} =
-qq|<td><a href=ca.pl?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&action=list_transactions&accounttype=standard&accno=$ref->{accno}&fromdate=$form->{transdatefrom}&todate=$form->{transdateto}&sort=transdate&l_subtotal=$form->{l_subtotal}&prevreport=$callback>$ref->{accno}</a></td>|;
+qq|<td><a href=ca.pl?path=$form->{path}&action=list_transactions&accounttype=standard&accno=$ref->{accno}&fromdate=$form->{transdatefrom}&todate=$form->{transdateto}&sort=transdate&l_subtotal=$form->{l_subtotal}&prevreport=$callback>$ref->{accno}</a></td>|;
$column_data{name} =
-qq|<td>$ref->{meta_number}</td><td><a href=ct.pl?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&action=edit&id=$ref->{"$form->{vc}_id"}&db=$form->{vc}&callback=$callback>$ref->{name}</a></td>|;
+qq|<td>$ref->{meta_number}</td><td><a href=$form->{vc}.pl?path=$form->{path}&action=edit&entity_id=$ref->{entity_id}&meta_number=$ref->{meta_number}&db=$form->{vc}&callback=$callback>$ref->{name}</a></td>|;
if ( $ref->{id} != $sameid ) {
$j++;
diff --git a/bin/ct.pl b/bin/ct.pl
deleted file mode 100644
index 3b664096..00000000
--- a/bin/ct.pl
+++ /dev/null
@@ -1,2219 +0,0 @@
-#=====================================================================
-# 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) 2001
-#
-# Author: DWS Systems Inc.
-# Web: http://www.sql-ledger.org
-#
-# Contributors: Reed White <alta@alta-research.com>
-#
-#
-#
-# 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.
-#======================================================================
-#
-# customer/vendor module
-#
-#======================================================================
-
-use LedgerSMB::CT;
-use LedgerSMB::Template;
-
-1;
-
-# end of main
-
-sub add {
-
- $form->{title} = "Add";
-
- # $locale->text('Add Customer')
- # $locale->text('Add Vendor')
-
- $form->{callback} =
-"$form->{script}?action=add&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
- unless $form->{callback};
-
- CT->create_links( \%myconfig, \%$form );
-
- &form_header;
- &form_footer;
-
-}
-
-sub history {
-
- # $locale->text('Customer History')
- # $locale->text('Vendor History')
-
- my %hiddens;
- my @buttons;
- $history = 1;
- $label = ucfirst $form->{db};
- $label .= " History";
-
- if ( $form->{db} eq 'customer' ) {
- $form->{invlabel} = $locale->text('Sales Invoices');
- $form->{ordlabel} = $locale->text('Sales Orders');
- $form->{quolabel} = $locale->text('Quotations');
- } else {
- $form->{invlabel} = $locale->text('Vendor Invoices');
- $form->{ordlabel} = $locale->text('Purchase Orders');
- $form->{quolabel} = $locale->text('Request for Quotations');
- }
-
- $form->{title} = $locale->text($label);
-
- $form->{nextsub} = "list_history";
-
- &search_name(\%hiddens, \@buttons);
-
-##SC: Temporary removal
-## if ( $form->{lynx} ) {
-## require "bin/menu.pl";
-## &menubar;
-## }
-
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'ct-search',
- );
- $template->render({
- form => $form,
- user => \%myconfig,
- hiddens => \%hiddens,
- buttons => \@buttons,
- });
-}
-
-sub transactions {
- if ( $form->{db} eq 'customer' ) {
- $form->{translabel} = $locale->text('AR Transactions');
- $form->{invlabel} = $locale->text('Sales Invoices');
- $form->{ordlabel} = $locale->text('Sales Orders');
- $form->{quolabel} = $locale->text('Quotations');
- } else {
- $form->{translabel} = $locale->text('AP Transactions');
- $form->{invlabel} = $locale->text('Vendor Invoices');
- $form->{ordlabel} = $locale->text('Purchase Orders');
- $form->{quolabel} = $locale->text('Request for Quotations');
- }
-}
-
-sub include_in_report {
-
- $label = ucfirst $form->{db};
-
- my @fields = ();
-
- push @fields, {
- name => 'l_ndx',
- label => $locale->text('No.'),
- };
- push @fields, {
- name => 'l_id',
- label => $locale->text('ID'),
- };
- push @fields, {
- name => "l_$form->{db}number",
- label => $locale->text($label . ' Number'),
- };
- push @fields, {
- name => 'l_name',
- label => $locale->text('Company Name'),
- $form->{l_name} => $form->{l_name},
- };
- push @fields, {
- name => 'l_contact',
- label => $locale->text('Contact'),
- $form->{l_contact} => $form->{l_contact},
- };
- push @fields, {
- name => 'l_email',
- label => $locale->text('E-mail'),
- $form->{l_email} => $form->{l_email},
- };
- push @fields, {
- name => 'l_address',
- label => $locale->text('Address'),
- };
- push @fields, {
- name => 'l_city',
- label => $locale->text('City'),
- };
- push @fields, {
- name => 'l_state',
- label => $locale->text('State/Province'),
- };
- push @fields, {
- name => 'l_zipcode',
- label => $locale->text('Zip/Postal Code'),
- };
- push @fields, {
- name => 'l_country',
- label => $locale->text('Country'),
- };
- push @fields, {
- name => 'l_phone',
- label => $locale->text('Phone'),
- $form->{l_phone} => $form->{l_phone},
- };
- push @fields, {
- name => 'l_fax',
- label => $locale->text('Fax'),
- };
- push @fields, {
- name => 'l_cc',
- label => $locale->text('Cc'),
- };
-
- if ( $myconfig{role} =~ /(admin|manager)/ ) {
- push @fields, {
- name => 'l_bcc',
- label => $locale->text('Bcc'),
- };
- }
-
- push @fields, {
- name => 'l_notes',
- label => $locale->text('Notes'),
- };
- push @fields, {
- name => 'l_discount',
- label => $locale->text('Discount'),
- };
- push @fields, {
- name => 'l_taxaccount',
- label => $locale->text('Tax Account'),
- };
- push @fields, {
- name => 'l_taxnumber',
- label => $locale->text('Tax Number'),
- };
-
- if ( $form->{db} eq 'customer' ) {
- push @fields, {
- name => 'l_employee',
- label => $locale->text('Salesperson'),
- };
- push @fields, {
- name => 'l_manager',
- label => $locale->text('Manager'),
- };
- push @fields, {
- name => 'l_pricegroup',
- label => $locale->text('Pricegroup'),
- };
-
- } else {
- push @fields, {
- name => 'l_employee',
- label => $locale->text('Employee'),
- };
- push @fields, {
- name => 'l_manager',
- label => $locale->text('Manager'),
- };
- push @fields, {
- name => 'l_gifi_accno',
- label => $locale->text('GIFI'),
- };
- }
-
- push @fields, {
- name => 'l_sic_code',
- label => $locale->text('SIC'),
- };
- push @fields, {
- name => 'l_iban',
- label => $locale->text('IBAN'),
- };
- push @fields, {
- name => 'l_bic',
- label => $locale->text('BIC'),
- };
- push @fields, {
- name => 'l_business',
- label => $locale->text('Type of Business'),
- };
- push @fields, {
- name => 'l_terms',
- label => $locale->text('Terms'),
- };
- push @fields, {
- name => 'l_langauge',
- label => $locale->text('Language'),
- };
- push @fields, {
- name => 'l_startdate',
- label => $locale->text('Startdate'),
- };
- push @fields, {
- name => 'l_enddate',
- label => $locale->text('Enddate'),
- };
-
- $form->{includes} = [];
- my $i = 0;
- while (@fields) {
- push @{$form->{includes}}, [];
- for ( 1 .. 5 ) {
- push @{$form->{includes}[$i]}, shift(@fields);
- if ($form->{includes}[$i][$_ - 1]) {
- $form->{includes}[$i][$_ - 1]{type} = 'checkbox';
- $form->{includes}[$i][$_ - 1]{value} = 'Y';
- }
- }
- $i++;
- }
-}
-
-sub search {
-
- # $locale->text('Customers')
- # $locale->text('Vendors')
-
- my %hiddens;
- my @buttons;
- $form->{title} = $locale->text('Search') unless $form->{title};
-
- for (qw(name contact phone email)) { $form->{"l_$_"} = 'checked' }
-
- $form->{nextsub} = "list_names";
-
- &transactions;
- &include_in_report;
- &search_name(\%hiddens, \@buttons);
-
-##SC: Temporary removal
-## if ( $form->{lynx} ) {
-## require "bin/menu.pl";
-## &menubar;
-## }
-
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'ct-search',
- );
- $template->render({
- form => $form,
- user => \%myconfig,
- hiddens => \%hiddens,
- buttons => \@buttons,
- });
-}
-
-sub search_name {
-
- my $hiddens = shift;
- my $buttons = shift;
-
- my $label = ucfirst $form->{db};
- $form->{label} = $label;
- $hiddens->{$_} = $form->{$_} foreach qw(db nextsub path login sessionid);
- push @{$buttons}, {
- name => 'action',
- value => 'continue',
- text => $locale->text('Continue'),
- };
-}
-
-sub list_names {
-
- my %hiddens;
- my @buttons;
- my @options;
-
- CT->search( \%myconfig, \%$form );
-
- my $href =
-"$form->{script}?action=list_names&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&l_subtotal=$form->{l_subtotal}";
-
- $form->sort_order();
-
- my $callback =
-"$form->{script}?action=list_names&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&l_subtotal=$form->{l_subtotal}";
-
- my @columns = $form->sort_columns( id, name, "$form->{db}number", address,
- city, state, zipcode, country,
- contact, phone, fax, email,
- cc, bcc, employee, manager,
- notes, discount, terms, taxaccount,
- taxnumber, gifi_accno, sic_code, business,
- pricegroup, language, iban, bic,
- startdate, enddate, invnumber, invamount,
- invtax, invtotal, ordnumber, ordamount,
- ordtax, ordtotal, quonumber, quoamount,
- quotax, quototal
- );
- unshift @columns, "ndx";
-
- $form->{l_invnumber} = "Y" if $form->{l_transnumber};
- foreach my $item (qw(inv ord quo)) {
- if ( $form->{"l_${item}number"} ) {
- for (qw(amount tax total)) {
- $form->{"l_$item$_"} = $form->{"l_$_"};
- }
- $removeemployee = 1;
- $openclosed = 1;
- }
- }
- $form->{open} = $form->{closed} = "" if !$openclosed;
-
- my @column_index;
- foreach my $item (@columns) {
- if ( $form->{"l_$item"} eq "Y" ) {
- push @column_index, $item;
-
- # add column to href and callback
- $callback .= "&l_$item=Y";
- $href .= "&l_$item=Y";
- }
- }
-
- foreach my $item (qw(amount tax total transnumber)) {
- if ( $form->{"l_$item"} eq "Y" ) {
- $callback .= "&l_$item=Y";
- $href .= "&l_$item=Y";
- }
- }
-
- if ( $form->{status} eq 'all' ) {
- push @options, $locale->text('All');
- } elsif ( $form->{status} eq 'orphaned' ) {
- push @options, $locale->text('Orphaned');
- } elsif ( $form->{status} eq 'active' ) {
- push @options, $locale->text('Active');
- } elsif ( $form->{status} eq 'inactive' ) {
- push @options, $locale->text('Inactive');
- }
-
- if ( $form->{name} ) {
- $callback .= "&name=" . $form->escape( $form->{name}, 1 );
- $href .= "&name=" . $form->escape( $form->{name} );
- push @options, $locale->text('Name: [_1]', $form->{name});
- }
- if ( $form->{address} ) {
- $callback .= "&address=" . $form->escape( $form->{address}, 1 );
- $href .= "&address=" . $form->escape( $form->{address} );
- push @options, $locale->text('Address: [_1]', $form->{address});
- }
- if ( $form->{city} ) {
- $callback .= "&city=" . $form->escape( $form->{city}, 1 );
- $href .= "&city=" . $form->escape( $form->{city} );
- push @options, $locale->text('City: [_1]', $form->{city});
- }
- if ( $form->{state} ) {
- $callback .= "&state=" . $form->escape( $form->{state}, 1 );
- $href .= "&state=" . $form->escape( $form->{state} );
- push @options, $locale->text('State: [_1]', $form->{state});
- }
- if ( $form->{zipcode} ) {
- $callback .= "&zipcode=" . $form->escape( $form->{zipcode}, 1 );
- $href .= "&zipcode=" . $form->escape( $form->{zipcode} );
- push @options, $locale->text('Zip/Postal Code: [_1]', $form->{zipcode});
- }
- if ( $form->{country} ) {
- $callback .= "&country=" . $form->escape( $form->{country}, 1 );
- $href .= "&country=" . $form->escape( $form->{country} );
- push @options, $locale->text('Country: [_1]', $form->{country});
- }
- if ( $form->{contact} ) {
- $callback .= "&contact=" . $form->escape( $form->{contact}, 1 );
- $href .= "&contact=" . $form->escape( $form->{contact} );
- push @options, $locale->text('Contact: [_1]', $form->{contact});
- }
- if ( $form->{employee} ) {
- $callback .= "&employee=" . $form->escape( $form->{employee}, 1 );
- $href .= "&employee=" . $form->escape( $form->{employee} );
- if ( $form->{db} eq 'customer' ) {
- push @options, $locale->text('Salesperson: [_1]', $form->{employee});
- } elsif ( $form->{db} eq 'vendor' ) {
- push @options, $locale->text('Employee: [_1]', $form->{employee});
- }
- }
-
- my $fromdate = "";
- my $todate = "";
- if ( $form->{startdatefrom} ) {
- $callback .= "&startdatefrom=$form->{startdatefrom}";
- $href .= "&startdatefrom=$form->{startdatefrom}";
- $fromdate = $locale->date( \%myconfig, $form->{startdatefrom}, 1 );
- }
- if ( $form->{startdateto} ) {
- $callback .= "&startdateto=$form->{startdateto}";
- $href .= "&startdateto=$form->{startdateto}";
- $todate = $locale->date( \%myconfig, $form->{startdateto}, 1 );
- }
- if ( $fromdate || $todate ) {
- push @options,
- $locale->text('Startdate [_1] - [_2]', $fromdate, $todate);
- }
-
- if ( $form->{notes} ) {
- $callback .= "&notes=" . $form->escape( $form->{notes}, 1 );
- $href .= "&notes=" . $form->escape( $form->{notes} );
- push @options, $locale->text('Notes: [_1]', $form->{notes});
- }
- if ( $form->{"$form->{db}number"} ) {
- $callback .=
- qq|&$form->{db}number=|
- . $form->escape( $form->{"$form->{db}number"}, 1 );
- $href .=
- "&$form->{db}number=" . $form->escape( $form->{"$form->{db}number"} );
- push @options,
- $locale->text('Number: [_1]', $form->{"$form->{db}number"});
- }
- if ( $form->{phone} ) {
- $callback .= "&phone=" . $form->escape( $form->{phone}, 1 );
- $href .= "&phone=" . $form->escape( $form->{phone} );
- push @options, $locale->text('Phone: [_1]', $form->{phone});
- }
- if ( $form->{email} ) {
- $callback .= "&email=" . $form->escape( $form->{email}, 1 );
- $href .= "&email=" . $form->escape( $form->{email} );
- push @options, $locale->text('E-mail: [_1]', $form->{email});
- }
- if ( $form->{transdatefrom} ) {
- $callback .= "&transdatefrom=$form->{transdatefrom}";
- $href .= "&transdatefrom=$form->{transdatefrom}";
- push @options, $locale->text('From [_1]',
- $locale->date( \%myconfig, $form->{transdatefrom}, 1 ));
- }
- if ( $form->{transdateto} ) {
- $callback .= "&transdateto=$form->{transdateto}";
- $href .= "&transdateto=$form->{transdateto}";
- if ( $form->{transdatefrom} ) {
- pop @options;
- push @options, $locale->text('From [_1] To [_2]',
- $locale->date( \%myconfig, $form->{transdatefrom}, 1 ),
- $locale->date( \%myconfig, $form->{transdateto}, 1 ));
- } else {
- push @options, $locale->text('To [_1]',
- $locale->date( \%myconfig, $form->{transdateto}, 1 ));
- }
- }
- if ( $form->{open} ) {
- $callback .= "&open=$form->{open}";
- $href .= "&open=$form->{open}";
- push @options, $locale->text('Open');
- }
- if ( $form->{closed} ) {
- $callback .= "&closed=$form->{closed}";
- $href .= "&closed=$form->{closed}";
- push @options, $locale->text('Closed');
- }
-
- $form->{callback} = "$callback&sort=$form->{sort}";
- $callback = $form->escape( $form->{callback} );
-
- my %column_header;
- $column_header{ndx} = ' ';
- $column_header{id} = $locale->text('ID');
- $column_header{"$form->{db}number"} = {
- href => "$href&sort=$form->{db}number",
- text => $locale->text('Number')
- };
- $column_header{name} = {
- href => "$href&sort=name",
- text => $locale->text('Name')
- };
- $column_header{address} = $locale->text('Address');
- $column_header{city} = {
- href => "$href&sort=city",
- text => $locale->text('City')
- };
- $column_header{state} = {
- href => "$href&sort=state",
- text => $locale->text('State/Province')
- };
- $column_header{zipcode} = {
- href => "$href&sort=zipcode",
- text => $locale->text('Zip/Postal Code')
- };
- $column_header{country} = {
- href => "$href&sort=country",
- text => $locale->text('Country')
- };
- $column_header{contact} = {
- href => "$href&sort=contact",
- text => $locale->text('Contact'),
- };
- $column_header{phone} = {
- href => "$href&sort=phone",
- text => $locale->text('Phone')
- };
- $column_header{fax} = {
- href => "$href&sort=fax",
- text => $locale->text('Fax')
- };
- $column_header{email} = {
- href => "$href&sort=email",
- text => $locale->text('E-mail')
- };
- $column_header{cc} = {
- href => "$href&sort=cc",
- text => $locale->text('Cc')
- };
- $column_header{bcc} = {
- href => "$href&sort=cc",
- text => $locale->text('Bcc')
- };
- $column_header{notes} = {
- href => "$href&sort=notes",
- text => $locale->text('Notes')
- };
- $column_header{discount} = '%';
- $column_header{terms} = $locale->text('Terms');
-
- $column_header{taxnumber} = {
- href => "$href&sort=taxnumber",
- text => $locale->text('Tax Number')
- };
- $column_header{taxaccount} = $locale->text('Tax Account');
- $column_header{gifi_accno} = {
- href => "$href&sort=gifi_accno",
- text => $locale->text('GIFI')
- };
- $column_header{sic_code} = {
- href => "$href&sort=sic_code",
- text => $locale->text('SIC')
- };
- $column_header{business} = {
- href => "$href&sort=business",
- text => $locale->text('Type of Business')
- };
- $column_header{iban} = $locale->text('IBAN');
- $column_header{bic} = $locale->text('BIC');
- $column_header{startdate} = {
- href => "$href&sort=startdate",
- text => $locale->text('Startdate')
- };
- $column_header{enddate} = {
- href => "$href&sort=enddate",
- text => $locale->text('Enddate')
- };
-
- $column_header{invnumber} = {
- href => "$href&sort=invnumber",
- text => $locale->text('Invoice')
- };
- $column_header{ordnumber} = {
- href => "$href&sort=ordnumber",
- text => $locale->text('Order')
- };
- $column_header{quonumber} = {
- href => "$href&sort=quonumber",
- text => $locale->text('Quotation')
- };
-
- if ( $form->{db} eq 'customer' ) {
- $column_header{employee} = {
- href => "$href&sort=employee",
- text => $locale->text('Salesperson')
- };
- } else {
- $column_header{employee} = {
- href => "$href&sort=employee",
- text => $locale->text('Employee')
- };
- }
- $column_header{manager} = {
- href => "$href&sort=manager",
- text => $locale->text('Manager')
- };
-
- $column_header{pricegroup} = {
- href => "$href&sort=pricegroup",
- text => $locale->text('Pricegroup')
- };
- $column_header{language} = {
- href => "$href&sort=language",
- text => $locale->text('Language')
- };
-
- $amount = $locale->text('Amount');
- $tax = $locale->text('Tax');
- $total = $locale->text('Total');
-
- $column_header{invamount} = $amount;
- $column_header{ordamount} = $amount;
- $column_header{quoamount} = $amount;
-
- $column_header{invtax} = $tax;
- $column_header{ordtax} = $tax;
- $column_header{quotax} = $tax;
-
- $column_header{invtotal} = $total;
- $column_header{ordtotal} = $total;
- $column_header{quototal} = $total;
-
- if ( $form->{status} ) {
- $label = ucfirst $form->{db} . "s";
- $form->{title} = $locale->text($label);
- } else {
- $label = ucfirst $form->{db};
- $form->{title} = $locale->text( $label . " Transactions" );
- }
-
- my $ordertype =
- ( $form->{db} eq 'customer' ) ? 'sales_order' : 'purchase_order';
- my $quotationtype =
- ( $form->{db} eq 'customer' ) ? 'sales_quotation' : 'request_quotation';
- $subtotal = 0;
-
- my $i = 0;
- my @rows;
- foreach my $ref ( @{ $form->{CT} } ) {
-
- if ( $ref->{ $form->{sort} } ne $sameitem && $form->{l_subtotal} ) {
- # append subtotal
- if ($subtotal) {
- push @rows, &list_subtotal;
- }
- }
-
- my %column_data;
- if ( $ref->{id} eq $sameid ) {
- for (@column_index) { $column_data{$_} = ' ' }
- } else {
-
- $i++;
-
- $ref->{notes} =~ s/\r?\n/<br>/g;
- for (@column_index) {
- $column_data{$_} = $ref->{$_};
- }
- $column_data{ndx} = $i;
-
- if ( $ref->{ $form->{sort} } eq $sameitem ) {
- $column_data{ $form->{sort} } = ' ';
- }
-
- $column_data{address} =
- "$ref->{address1} $ref->{address2}";
- $column_data{name} = {
- text => $ref->{name},
- href => "$form->{script}?action=edit&id=$ref->{id}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&status=$form->{status}&callback=$callback",
- };
-
- $email = "";
- if ( $form->{sort} =~ /(email|cc)/ ) {
- if ( $ref->{ $form->{sort} } ne $sameitem ) {
- $email = 1;
- }
- } else {
- $email = 1;
- }
-
- if ($email) {
- foreach $item (qw(email cc bcc)) {
- if ( $ref->{$item} ) {
- $email = $ref->{$item};
- $column_data{$item} = {
- href => "mailto:$ref->{$item}",
- text => $email,
- };
- }
- }
- }
- }
-
- if ( $ref->{formtype} eq 'invoice' ) {
- $column_data{invnumber} = {
- href => "$ref->{module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- text => $ref->{invnumber},
- };
-
- $column_data{invamount} =
- $form->format_amount( \%myconfig, $ref->{netamount}, 2, ' ' );
- $column_data{invtax} = $form->format_amount( \%myconfig,
- $ref->{amount} - $ref->{netamount}, 2, ' ' );
- $column_data{invtotal} =
- $form->format_amount( \%myconfig, $ref->{amount}, 2, ' ' );
-
- $invamountsubtotal += $ref->{netamount};
- $invtaxsubtotal += ( $ref->{amount} - $ref->{netamount} );
- $invtotalsubtotal += $ref->{amount};
- $subtotal = 1;
- } elsif ( $ref->{formtype} eq 'order' ) {
- $column_data{ordnumber} = {
- href => "$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- text => $ref->{ordnumber},
- };
-
- $column_data{ordamount} =
- $form->format_amount( \%myconfig, $ref->{netamount}, 2, ' ' );
- $column_data{ordtax} = $form->format_amount( \%myconfig,
- $ref->{amount} - $ref->{netamount}, 2, ' ' );
- $column_data{ordtotal} =
- $form->format_amount( \%myconfig, $ref->{amount}, 2, ' ' );
-
- $ordamountsubtotal += $ref->{netamount};
- $ordtaxsubtotal += ( $ref->{amount} - $ref->{netamount} );
- $ordtotalsubtotal += $ref->{amount};
- $subtotal = 1;
- } elsif ( $ref->{formtype} eq 'quotation' ) {
- $column_data{quonumber} = {
- href => "$ref->{module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- text => $ref->{quonumber},
- };
-
- $column_data{quoamount} =
- $form->format_amount( \%myconfig, $ref->{netamount}, 2, ' ' );
- $column_data{quotax} = $form->format_amount( \%myconfig,
- $ref->{amount} - $ref->{netamount}, 2, ' ' );
- $column_data{quototal} =
- $form->format_amount( \%myconfig, $ref->{amount}, 2, ' ' );
-
- $quoamountsubtotal += $ref->{netamount};
- $quotaxsubtotal += ( $ref->{amount} - $ref->{netamount} );
- $quototalsubtotal += $ref->{amount};
- $subtotal = 1;
- }
-
- if ( $sameid ne "$ref->{id}" ) {
- if ( $form->{l_discount} ) {
- $column_data{discount} =
- $form->format_amount( \%myconfig, $ref->{discount} * 100,
- "", ' ' );
- }
- if ( $form->{l_terms} ) {
- $column_data{terms} =
- $form->format_amount( \%myconfig, $ref->{terms}, "", ' ' );
- }
- }
-
- $j++;
- $j %= 2;
- $column_data{i} = $j;
-
- $sameitem = $ref->{$form->{sort}};
- $sameid = $ref->{id};
-
- push @rows, \%column_data;
- }
-
- if ( $form->{l_subtotal} && $subtotal ) {
- push @rows, &list_subtotal;
- }
-
- $i = 1;
- if ( $myconfig{acs} !~ /AR--AR/ ) {
- if ( $form->{db} eq 'customer' ) {
- $button{'AR--Customers--Add Customer'}{code} = {
- name => 'action',
- value => 'add_customer',
- text => $locale->text('Add Customer'),
- };
- $button{'AR--Customers--Add Customer'}{order} = $i++;
- }
- }
- if ( $myconfig{acs} !~ /AP--AP/ ) {
- if ( $form->{db} eq 'vendor' ) {
- $button{'AP--Vendors--Add Vendor'}{code} = {
- name => 'action',
- value => 'add_vendor',
- text => $locale->text('Add Vendor'),
- };
- $button{'AP--Vendors--Add Vendor'}{order} = $i++;
- }
- }
-
- foreach $item ( split /;/, $myconfig{acs} ) {
- delete $button{$item};
- }
-
- $hiddens{$_} = $form->{$_} foreach qw(callback db path login sessionid);
-
- if ( $form->{status} ) {
- foreach $item ( sort { $a->{order} <=> $b->{order} } %button ) {
- push @buttons, $item->{code};
- }
- }
-
-##SC: Temporary removal
-## if ( $form->{lynx} ) {
-## require "bin/menu.pl";
-## &menubar;
-## }
-
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'form-dynatable',
- );
- $template->render({
- form => $form,
- user => \%myconfig,
- hiddens => \%hiddens,
- buttons => \@buttons,
- options => \@options,
- rows => \@rows,
- columns => \@column_index,
- heading => \%column_header,
- });
-}
-
-sub list_subtotal {
-
- my %column_data;
- $column_data{invamount} =
- $form->format_amount( \%myconfig, $invamountsubtotal, 2, ' ' );
- $column_data{invtax} =
- $form->format_amount( \%myconfig, $invtaxsubtotal, 2, ' ' );
- $column_data{invtotal} =
- $form->format_amount( \%myconfig, $invtotalsubtotal, 2, ' ' );
-
- $invamountsubtotal = 0;
- $invtaxsubtotal = 0;
- $invtotalsubtotal = 0;
-
- $column_data{ordamount} =
- $form->format_amount( \%myconfig, $ordamountsubtotal, 2, ' ' );
- $column_data{ordtax} =
- $form->format_amount( \%myconfig, $ordtaxsubtotal, 2, ' ' );
- $column_data{ordtotal} =
- $form->format_amount( \%myconfig, $ordtotalsubtotal, 2, ' ' );
-
- $ordamountsubtotal = 0;
- $ordtaxsubtotal = 0;
- $ordtotalsubtotal = 0;
-
- $column_data{quoamount} =
- $form->format_amount( \%myconfig, $quoamountsubtotal, 2, ' ' );
- $column_data{quotax} =
- $form->format_amount( \%myconfig, $quotaxsubtotal, 2, ' ' );
- $column_data{quototal} =
- $form->format_amount( \%myconfig, $quototalsubtotal, 2, ' ' );
-
- $quoamountsubtotal = 0;
- $quotaxsubtotal = 0;
- $quototalsubtotal = 0;
-
- $column_data{class} = 'subtotal';
- \%column_data;
-}
-
-sub list_history {
-
- CT->get_history( \%myconfig, \%$form );
- my %hiddens;
- my @buttons;
-
- my $href =
-"$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}";
-
- $form->sort_order();
-
- my $callback =
-"$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}";
-
- $form->{l_fxsellprice} = $form->{l_curr};
- my @columns = $form->sort_columns( partnumber, description, qty, unit,
- sellprice, fxsellprice, curr, discount,
- deliverydate, projectnumber, serialnumber
- );
-
- if ( $form->{history} eq 'summary' ) {
- @columns =
- $form->sort_columns( partnumber, description, qty, unit, sellprice,
- curr );
- }
-
- my @column_index;
- foreach $item (@columns) {
- if ( $form->{"l_$item"} eq "Y" ) {
- push @column_index, $item;
-
- # add column to href and callback
- $callback .= "&l_$item=Y";
- $href .= "&l_$item=Y";
- }
- }
-
- my @options;
- if ( $form->{history} eq 'detail' ) {
- push @options, $locale->text('Detail');
- } elsif ( $form->{history} eq 'summary' ) {
- push @options, $locale->text('Summary');
- }
- if ( $form->{name} ) {
- $callback .= "&name=" . $form->escape( $form->{name}, 1 );
- $href .= "&name=" . $form->escape( $form->{name} );
- push @options, $locale->text('Name: [_1]', $form->{name});
- }
- if ( $form->{contact} ) {
- $callback .= "&contact=" . $form->escape( $form->{contact}, 1 );
- $href .= "&contact=" . $form->escape( $form->{contact} );
- push @options, $locale->text('Contact: [_1]', $form->{contact});
- }
- if ( $form->{"$form->{db}number"} ) {
- $callback .=
- qq|&$form->{db}number=|
- . $form->escape( $form->{"$form->{db}number"}, 1 );
- $href .=
- "&$form->{db}number=" . $form->escape( $form->{"$form->{db}number"} );
- push @options, $locale->text('Number: [_1]',
- $form->{"$form->{db}number"});
- }
- if ( $form->{email} ) {
- $callback .= "&email=" . $form->escape( $form->{email}, 1 );
- $href .= "&email=" . $form->escape( $form->{email} );
- push @options, $locale->text('E-mail: [_1]', $form->{email});
- }
- if ( $form->{transdatefrom} ) {
- $callback .= "&transdatefrom=$form->{transdatefrom}";
- $href .= "&transdatefrom=$form->{transdatefrom}";
- push @options, $locale->text('From [_1]',
- $locale->date( \%myconfig, $form->{transdatefrom}, 1 ));
- }
- if ( $form->{transdateto} ) {
- $callback .= "&transdateto=$form->{transdateto}";
- $href .= "&transdateto=$form->{transdateto}";
- if ( $form->{transdatefrom} ) {
- pop @options;
- push @options, $locale->text('From [_1] To [_2]',
- $locale->date( \%myconfig, $form->{transdatefrom}, 1 ),
- $locale->date( \%myconfig, $form->{transdateto}, 1 ));
- } else {
- push @options, $locale->text('To [_1]',
- $locale->date( \%myconfig, $form->{transdateto}, 1 ));
- }
- }
- if ( $form->{open} ) {
- $callback .= "&open=$form->{open}";
- $href .= "&open=$form->{open}";
- push @options, $locale->text('Open');
- }
- if ( $form->{closed} ) {
- $callback .= "&closed=$form->{closed}";
- $href .= "&closed=$form->{closed}";
- push @options, $locale->text('Closed');
- }
-
- $form->{callback} = "$callback&sort=$form->{sort}";
- $callback = $form->escape( $form->{callback} );
-
- my %column_header;
- $column_header{partnumber} = {
- href => "$href&sort=partnumber",
- text => $locale->text('Part Number')
- };
- $column_header{description} = {
- href => "$href&sort=description",
- text => $locale->text('Description')
- };
-
- if ( $form->{history} eq 'summary' ) {
- $column_header{sellprice} = $locale->text('Total');
- } else {
- $column_header{sellprice} = $locale->text('Sell Price');
- }
- $column_header{fxsellprice} = ' ';
-
- $column_header{curr} = $locale->text('Curr');
- $column_header{discount} = $locale->text('Discount');
- $column_header{qty} = $locale->text('Qty');
- $column_header{unit} = $locale->text('Unit');
- $column_header{deliverydate} = {
- href => "$href&sort=deliverydate",
- text => $locale->text('Delivery Date')
- };
- $column_header{projectnumber} = {
- href => "$href&sort=projectnumber",
- text => $locale->text('Project Number')
- };
- $column_header{serialnumber} = {
- href => "$href&sort=serialnumber",
- text => $locale->text('Serial Number')
- };
-
- # $locale->text('Customer History')
- # $locale->text('Vendor History')
-
- $label = ucfirst $form->{db};
- $form->{title} = $locale->text( $label . " History" );
-
- $module = 'oe';
- if ( $form->{db} eq 'customer' ) {
- $invlabel = $locale->text('Sales Invoice');
- $ordlabel = $locale->text('Sales Order');
- $quolabel = $locale->text('Quotation');
-
- $ordertype = 'sales_order';
- $quotationtype = 'sales_quotation';
- if ( $form->{type} eq 'invoice' ) {
- $module = 'is';
- }
- } else {
- $invlabel = $locale->text('Vendor Invoice');
- $ordlabel = $locale->text('Purchase Order');
- $quolabel = $locale->text('RFQ');
-
- $ordertype = 'purchase_order';
- $quotationtype = 'request_quotation';
- if ( $form->{type} eq 'invoice' ) {
- $module = 'ir';
- }
- }
-
- $ml = ( $form->{db} eq 'vendor' ) ? -1 : 1;
-
- my @rows;
- foreach my $ref ( @{ $form->{CT} } ) {
-
- if ( $ref->{id} ne $sameid ) {
- # print the header
- push @rows, {
- class => 'divider',
- text => "$ref->{name} $ref->{address}"
- href => "$form->{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- };
- }
-
- if ( $form->{type} ne 'invoice' ) {
- $ref->{fxsellprice} = $ref->{sellprice};
- $ref->{sellprice} *= $ref->{exchangerate};
- }
-
- if ( $form->{history} eq 'detail' and $ref->{invid} ne $sameinvid ) {
-
- # print inv, ord, quo number
- $i++;
- $i %= 2;
-
- if ( $form->{type} eq 'invoice' ) {
- push @rows, {
- class => 'divider',
- href => "${module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- text => "$invlabel $ref->{invnumber} / $ref->{employee}";
- };
- } elsif ( $form->{type} eq 'order' ) {
- push @rows, {
- class => 'divider',
- href => "${module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- text => "$ordlabel $ref->{ordnumber} / $ref->{employee}"
- };
- } elsif ( $form->{type} eq 'quotation' ) {
- push @rows, {
- class => 'divider',
- href => "${module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback",
- text => "$quolabel $ref->{quonumber} / $ref->{employee}"
- };
- }
- }
-
- my %column_data;
- for (@column_index) { $column_data{$_} = $ref->{$_} }
-
- if ( $form->{l_curr} ) {
- $column_data{fxsellprice} =
- $form->format_amount( \%myconfig, $ref->{fxsellprice}, 2 );
- }
- $column_data{sellprice} =
- $form->format_amount( \%myconfig, $ref->{sellprice}, 2 );
- $column_data{qty} =
- $form->format_amount( \%myconfig, $ref->{qty} * $ml );
- $column_data{discount} =
- $form->format_amount( \%myconfig, $ref->{discount} * 100, "", ' ' );
- $column_data{partnumber} = {
- href => "ic.pl?action=edit&id=$ref->{pid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"
- text => $ref->{partnumber}
- };
-
- $i++;
- $i %= 2;
- $column_data{i} = $i;
-
- push @rows, \%column_data;
-
- $sameid = $ref->{id};
- $sameinvid = $ref->{invid};
-
- }
-
-##SC: Temporary removal
-## if ( $form->{lynx} ) {
-## require "bin/menu.pl";
-## &menubar;
-## }
-
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'form-dynatable',
- );
- $template->render({
- form => $form,
- options => \@options,
- rows => \@rows,
- columns => \@column_index,
- heading => \%column_header,
- });
-}
-
-sub edit {
-
- # $locale->text('Edit Customer')
- # $locale->text('Edit Vendor')
-
- CT->create_links( \%myconfig, \%$form );
-
- for ( keys %$form ) { $form->{$_} = $form->quote( $form->{$_} ) }
-
- $form->{title} = "Edit";
-
- # format discount
- $form->{discount} *= 100;
-
- &form_header;
- &form_footer;
-
-}
-
-sub form_header {
-
- $form->{taxincluded} = ( $form->{taxincluded} ) ? "checked" : "";
- $form->{creditlimit} =
- $form->format_amount( \%myconfig, $form->{creditlimit}, 0 );
- $form->{discount} =
- $form->format_amount( \%myconfig, $form->{discount}, "" );
- $form->{terms} = $form->format_amount( \%myconfig, $form->{terms}, "" );
-
- if ( $form->{currencies} ) {
- # currencies
- $form->{selectcurrency} = {
- name => 'curr',
- options => [],
- default_values => $form->{curr},
- };
- push @{$form->{selectcurrency}{options}}, {
- text => $_,
- value => $_,
- } foreach split /:/, $form->{currencies};
- }
-
- $form->{taxable} = [];
- foreach my $item ( split / /, $form->{taxaccounts} ) {
- my $temp_tax = {
- name => "tax_$item",
- value => 1,
- type => 'checkbox',
- label => $form->{tax}{$item}{description}
- };
- $temp_tax->{checked} = 'checked' if $form->{tax}{$item}{taxable};
- push @{$form->{taxable}}, $temp_tax;
- }
-
- if (ref $form->{all_business} eq 'ARRAY') {
- $form->{selectbusiness} = {
- name => 'business',
- options => [{text => '', value => ''}],
- };
- push @{$form->{selectbusiness}{options}}, {
- text => $_->{description},
- value => "$_->{description}--$_->{id}",
- } foreach @{$form->{all_business}};
- $form->{selectbusiness}{default_values} =
- "$form->{business}--$form->{business_id}";
- }
-
- if (ref $form->{all_pricegroup} eq 'ARRAY' && $form->{db} eq 'customer') {
- $form->{selectpricegroup} = {
- name => 'pricegroup',
- options => [{text => '', value => ''}],
- };
- push @{$form->{selectpricegroup}{options}}, {
- name => $_->{pricegroup},
- value => "$_->{pricegroup}--$_->{id}",
- } foreach @{$form->{all_pricegroup}};
- $form->{selectpricegroup}{default_values} =
- "$form->{pricegroup}--$form->{pricegroup_id}";
- }
-
- if ( @{ $form->{all_language} } ) {
- $form->{selectlanguage} = {
- name => 'language',
- options => [{text => '', value => ''}],
- };
- push @{$form->{selectlanguage}{options}}, {
- text => $_->{description},
- value => "$_->{description}--$_->{code}",
- } foreach @{$form->{all_language}};
- $form->{selectlangauge}{default_values} =
- "$form->{language}--$form->{language_code}";
- }
-
- $form->{selectemployee} = {
- name => 'employee',
- options => [{text => '', value => ''}],
- default_values => "$form->{employee}--$form->{employee_id}",
- };
- push @{$form->{selectemployee}{options}}, {
- text => $_->{name},
- value => "$_->{name}--$_->{id}",
- } foreach @{$form->{all_employee}};
-
- if (ref $form->{all_employee} eq 'ARRAY') {
- if ( $myconfig{role} eq 'user' && $form->{id} ) {
- $hiddens{employee} = "$form->{employee}--$form->{employee_id}";
- }
- }
-
- # $locale->text('Customer Number')
- # $locale->text('Vendor Number')
-
- $label = ucfirst $form->{db};
- $form->{label} = $label;
- $form->{title} = $locale->text("$form->{title} $label");
-}
-
-sub form_footer {
-
- # type=submit $locale->text('Save')
- # type=submit $locale->text('Save as new')
- # type=submit $locale->text('AR Transaction')
- # type=submit $locale->text('Sales Invoice')
- # type=submit $locale->text('Sales Order')
- # type=submit $locale->text('Quotation')
- # type=submit $locale->text('AP Transaction')
- # type=submit $locale->text('Vendor Invoice')
- # type=submit $locale->text('Purchase Order')
- # type=submit $locale->text('RFQ')
- # type=submit $locale->text('Pricelist')
- # type=submit $locale->text('Delete')
- # type=submit $locale->text('POS')
-
- my %hiddens;
- my @buttons;
-
- %button = (
- 'save' => { ndx => 1, key => 'S', value => $locale->text('Save') },
- 'save_as_new' =>
- { ndx => 2, key => 'N', value => $locale->text('Save as new') },
- 'ar_transaction' =>
- { ndx => 7, key => 'A', value => $locale->text('AR Transaction') },
- 'ap_transaction' =>
- { ndx => 8, key => 'A', value => $locale->text('AP Transaction') },
- 'sales_invoice' =>
- { ndx => 9, key => 'I', value => $locale->text('Sales Invoice') },
- 'pos' => { ndx => 10, key => 'C', value => $locale->text('POS') },
- 'sales_order' =>
- { ndx => 11, key => 'O', value => $locale->text('Sales Order') },
- 'quotation' =>
- { ndx => 12, key => 'Q', value => $locale->text('Quotation') },
- 'vendor_invoice' =>
- { ndx => 13, key => 'I', value => $locale->text('Vendor Invoice') },
- 'purchase_order' =>
- { ndx => 14, key => 'O', value => $locale->text('Purchase Order') },
- 'rfq' => { ndx => 15, key => 'Q', value => $locale->text('RFQ') },
- 'pricelist' =>
- { ndx => 16, key => 'P', value => $locale->text('Pricelist') },
- 'delete' => { ndx => 17, key => 'D', value => $locale->text('Delete') },
- );
-
- my %blist = ();
-
- if ( $form->{db} eq 'customer' ) {
- if ( $myconfig{acs} !~ /AR--Customers--Add Customer/ ) {
- $blist{'save'} = 1;
-
- if ( $form->{id} ) {
- $blist{'save_as_new'} = 1;
- if ( $form->{status} eq 'orphaned' ) {
- $blist{'delete'} = 1;
- }
- }
- }
-
- if ( $myconfig{acs} !~ /AR--AR/ ) {
- if ( $myconfig{acs} !~ /AR--Add Transaction/ ) {
- $blist{'ar_transaction'} = 1;
- }
- if ( $myconfig{acs} !~ /AR--Sales Invoice/ ) {
- $blist{'sales_invoice'} = 1;
- }
- }
- if ( $myconfig{acs} !~ /POS--POS/ ) {
- if ( $myconfig{acs} !~ /POS--Sale/ ) {
- $blist{'pos'} = 1;
- }
- }
- if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
- if ( $myconfig{acs} !~ /Order Entry--Sales Order/ ) {
- $blist{'sales_order'} = 1;
- }
- }
- if ( $myconfig{acs} !~ /Quotations--Quotations/ ) {
- if ( $myconfig{acs} !~ /Quotations--Quotation/ ) {
- $blist{'quotation'} = 1;
- }
- }
- }
-
- if ( $form->{db} eq 'vendor' ) {
- if ( $myconfig{acs} !~ /AP--Vendors--Add Vendor/ ) {
- $blist{'save'} = 1;
-
- if ( $form->{id} ) {
- $blist{'save_as_new'} = 1;
- if ( $form->{status} eq 'orphaned' ) {
- $blist{'delete'} = 1;
- }
- }
- }
-
- if ( $myconfig{acs} !~ /AP--AP/ ) {
- if ( $myconfig{acs} !~ /AP--Add Transaction/ ) {
- $blist{'ap_transaction'} = 1;
- }
- if ( $myconfig{acs} !~ /AP--Vendor Invoice/ ) {
- $blist{'vendor_invoice'} = 1;
- }
- }
- if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
- if ( $myconfig{acs} !~ /Order Entry--Purchase Order/ ) {
- $blist{'purchase_order'} = 1;
- }
- }
- if ( $myconfig{acs} !~ /Quotations--Quotations/ ) {
- if ( $myconfig{acs} !~ /Quotations--RFQ/ ) {
- $blist{'rfq'} = 1;
- }
- }
- }
-
- if ( $myconfig{acs} !~ /Goods & Services--Goods & Services/ ) {
- $myconfig{acs} =~
- s/(Goods & Services--)Add (Service|Assembly).*;/$1--Add Part/g;
- if ( $myconfig{acs} !~ /Goods & Services--Add Part/ ) {
- $blist{'pricelist'} = 1;
- }
- }
-
- $hiddens{$_} = $form->{$_} foreach
- qw(id taxaccounts path login sessionid callback db);
-
- for ( keys %button ) { delete $button{$_} if !$blist{$_} }
- for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
- push @buttons, {
- name => 'action',
- value => $_,
- accesskey => $button{$_}{key},
- title => "$button{$name}{value} [Alt-$button{$_}{key}]",
- text => $button{$_}{value},
- };
- }
-
-##SC: Temporary removal
-## if ( $form->{lynx} ) {
-## require "bin/menu.pl";
-## &menubar;
-## }
-
- $form->{dbnumber} = "$form->{db}number";
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'ct-form',
- );
- $template->render({
- form => $form,
- user => \%myconfig,
- hiddens => \%hiddens,
- buttons => \@buttons,
- options => \@options,
- });
-}
-
-sub pricelist {
-
- $form->isblank( "name", $locale->text('Name missing!') );
-
- $form->{display_form} ||= "display_pricelist";
-
- CT->pricelist( \%myconfig, \%$form );
-
- foreach $ref ( @{ $form->{"all_partspricelist"} } ) {
- $i++;
- for ( keys %$ref ) { $form->{"${_}_$i"} = $ref->{$_} }
- }
- $form->{rowcount} = $i;
-
- # currencies
- @curr = split /:/, $form->{currencies};
- $form->{selectcurrency} = [];
- for (@curr) {push @{$form->{selectcurrency}}, {text => $_, value => $_}}
-
- if (ref $form->{all_partsgroup} eq 'ARRAY') {
- $form->{selectpartsgroup} = "";
- foreach $ref ( @{ $form->{all_partsgroup} } ) {
- $form->{selectpartsgroup} .= qq|$ref->{partsgroup}--$ref->{id}\n|;
- }
- }
-
- for (qw(currencies all_partsgroup all_partspricelist)) {
- delete $form->{$_};
- }
-
- foreach $i ( 1 .. $form->{rowcount} ) {
-
- if ( $form->{db} eq 'customer' ) {
-
- $form->{"pricebreak_$i"} =
- $form->format_amount( \%myconfig, $form->{"pricebreak_$i"} );
-
- $form->{"sellprice_$i"} =
- $form->format_amount( \%myconfig, $form->{"sellprice_$i"}, 2 );
-
- }
-
- if ( $form->{db} eq 'vendor' ) {
-
- $form->{"leadtime_$i"} =
- $form->format_amount( \%myconfig, $form->{"leadtime_$i"} );
-
- $form->{"lastcost_$i"} =
- $form->format_amount( \%myconfig, $form->{"lastcost_$i"}, 2 );
-
- }
- }
-
- $form->{rowcount}++;
- &{"$form->{db}_pricelist"};
-
-}
-
-sub customer_pricelist {
-
- my @flds =
- qw(runningnumber id partnumber description sellprice unit partsgroup pricebreak curr validfrom validto);
-
- $form->{rowcount}--;
-
- # remove empty rows
- if ( $form->{rowcount} ) {
-
- foreach $i ( 1 .. $form->{rowcount} ) {
-
- for (qw(pricebreak sellprice)) {
- $form->{"${_}_$i"} =
- $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
- }
-
- ( $a, $b ) = split /\./, $form->{"pricebreak_$i"};
- $a = length $a;
- $b = length $b;
- $whole = ( $whole > $a ) ? $whole : $a;
- $dec = ( $dec > $b ) ? $dec : $b;
- }
- $pad1 = '0' x $whole;
- $pad2 = '0' x $dec;
-
- foreach $i ( 1 .. $form->{rowcount} ) {
- ( $a, $b ) = split /\./, $form->{"pricebreak_$i"};
-
- $a = substr( "$pad1$a", -$whole );
- $b = substr( "$b$pad2", 0, $dec );
- $ndx{qq|$form->{"partnumber_$i"}_$form->{"id_$i"}_$a$b|} = $i;
- }
-
- $i = 1;
- for ( sort keys %ndx ) { $form->{"runningnumber_$ndx{$_}"} = $i++ }
-
- foreach $i ( 1 .. $form->{rowcount} ) {
- if ( $form->{"partnumber_$i"} && $form->{"sellprice_$i"} ) {
- if ( $form->{"id_$i"} eq $sameid ) {
- $j = $i + 1;
- next
- if ( $form->{"id_$j"} eq $sameid
- && !$form->{"pricebreak_$i"} );
- }
-
- push @a, {};
- $j = $#a;
-
- for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
- $count++;
- }
- $sameid = $form->{"id_$i"};
- }
-
- $form->redo_rows( \@flds, \@a, $count, $form->{rowcount} );
- $form->{rowcount} = $count;
-
- }
-
- $form->{rowcount}++;
-
- if ( $form->{display_form} ) {
- &{"$form->{display_form}"};
- }
-
-}
-
-sub vendor_pricelist {
-
- my @flds =
- qw(runningnumber id sku partnumber description lastcost unit partsgroup curr leadtime);
-
- $form->{rowcount}--;
-
- # remove empty rows
- if ( $form->{rowcount} ) {
-
- foreach $i ( 1 .. $form->{rowcount} ) {
-
- for (qw(leadtime lastcost)) {
- $form->{"${_}_$i"} =
- $form->parse_amount( \%myconfig, $form->{"${_}_$i"} );
- }
- $var =
- ( $form->{"partnumber_$i"} )
- ? $form->{"sku_$i"}
- : qq|_$form->{"sku_$i"}|;
- $ndx{$var} = $i;
-
- }
-
- $i = 1;
- for ( sort keys %ndx ) { $form->{"runningnumber_$ndx{$_}"} = $i++ }
-
- foreach $i ( 1 .. $form->{rowcount} ) {
- if ( $form->{"sku_$i"} ) {
- push @a, {};
- $j = $#a;
-
- for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
- $count++;
- }
- }
-
- $form->redo_rows( \@flds, \@a, $count, $form->{rowcount} );
- $form->{rowcount} = $count;
-
- }
-
- $form->{rowcount}++;
-
- if ( $form->{display_form} ) {
- &{"$form->{display_form}"};
- }
-
-}
-
-sub display_pricelist {
-
- my %hiddens;
- my $buttons = &pricelist_footer;
- delete $form->{action};
- $hiddens{$_} = $form->{$_} foreach sort keys %$form;
- &pricelist_header(\%hiddens, $buttons);
-}
-
-sub pricelist_header {
- my $hiddens = shift;
- my $buttons = shift;
-
- $form->{title} = $form->{name};
-
- my @column_index;
- my %column_header;
-
- if ( $form->{db} eq 'customer' ) {
- @column_index = qw(partnumber description);
- push @column_index, "partsgroup" if $form->{selectpartsgroup};
- push @column_index, qw(pricebreak sellprice curr validfrom validto);
-
- $column_header{pricebreak} = $locale->text('Break');
- $column_header{sellprice} = $locale->text('Sell Price');
- $column_header{validfrom} = $locale->text('From');
- $column_header{validto} = $locale->text('To');
- }
-
- if ( $form->{db} eq 'vendor' ) {
- @column_index = qw(sku partnumber description);
- push @column_index, "partsgroup" if $form->{selectpartsgroup};
- push @column_index, qw(lastcost curr leadtime);
-
- $column_header{sku} = $locale->text('SKU');
- $column_header{leadtime} = $locale->text('Leadtime');
- $column_header{lastcost} = $locale->text('Cost');
- }
-
- $column_header{partnumber} = $locale->text('Number');
- $column_header{description} = $locale->text('Description'); #80% width
- $column_header{partsgroup} = $locale->text('Group');
- $column_header{curr} = $locale->text('Curr');
-
- $sameid = "";
- my @rows;
- foreach my $i ( 1 .. $form->{rowcount} ) {
- my %column_data;
-
- if ( $form->{selectpartsgroup} ) {
- if ( $i < $form->{rowcount} ) {
- ($partsgroup) = split /--/, $form->{"partsgroup_$i"};
- $hiddens->{"partsgroup_$i"} = $form->{"partsgroup_$i"};
- $column_data{partsgroup} = $partsgroup;
- }
- }
-
- if ( $i < $form->{rowcount} ) {
- if ( $form->{"id_$i"} eq $sameid ) {
- for (qw(partnumber description partsgroup)) {
- $hiddens->{"${_}_$i"} = $form->{"${_}_$i"};
- $column_data{$_} = ' ';
- }
- } else {
- $column_data{sku} = {input => {
- name => "sku_$i",
- value => $form->{"sku_$i"}
- }};
- $column_data{partnumber} = {input => {
- name => "partnumber_$i",
- value => $form->{"partnumber_$i"}
- }};
- $column_data{description} =$form->{"description_$i"};
- $hiddens->{"description_$i"} = $form->{"description_$i"};
- }
- $hiddens->{"id_$i"} = $form->{"id_$i"};
- } else {
- if ( $form->{db} eq 'customer' ) {
- $column_data{partnumber} = {input => {
- name => "partnumber_$i",
- value => $form->{"partnumber_$i"}
- }};
- } else {
- $column_data{partnumber} = ' ';
- }
-
- $hiddens->{"id_$i"} = $form->{"id_$i"};
-
- $column_data{sku} = {input => {
- name => "sku_$i",
- value => $form->{"sku_$i"}
- }};
- $column_data{partnumber} = {input => {
- name => "partnumber_$i",
- value => $form->{"partnumber_$i"}
- }};
-
- if ( $form->{selectpartsgroup} ) {
- @selectpartsgroup = ({text => '', value => ''});
- foreach $line ( split /\n/, $form->{selectpartsgroup} ) {
- push @selectpartsgroup, {
- text => (split /--/, $line)[0],
- value => $line,
- };
- }
- $column_data{partsgroup} = {'select' => {
- name => "partnumber_$i",
- options => \@selectpartsgroup,
- }};
- }
- }
-
- if ( $form->{db} eq 'customer' ) {
-
- $column_data{pricebreak} = {input => {
- name => "pricebreak_$i",
- size => 5,
- value => $form->format_amount(\%myconfig, $form->{"pricebreak_$i"})
- }};
- $column_data{sellprice} = {input => {
- name => "sellprice_$i",
- size => 10,
- value => $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, 2)
- }};
- $column_data{validfrom} = {input => {
- name => "validfrom_$i",
- size => 11,
- value => $form->{"validfrom_$i"},
- }};
- $column_data{validto} = {input => {
- name => "validto_$i",
- size => 11,
- value => $form->{"validto_$i"},
- }};
- }
-
- if ( $form->{db} eq 'vendor' ) {
- $column_data{leadtime} = {input => {
- name => "leadtime_$i",
- size => 5,
- value => $form->format_amount(\%myconfig, $form->{"leadtime_$i"})
- }};
- $column_data{lastcost} = {input => {
- name => "lastcost_$i",
- size => 10,
- value => $form->format_amount( \%myconfig, $form->{"lastcost_$i"}, 2 )
- }};
- }
-
- $column_data{curr} = {'select' => {
- name => "curr_$i",
- options => $form->{selectcurrency},
- default_values => $form->{"curr_$i"},
- }};
- $sameid = $form->{"id_$i"};
-
- push @rows, \%column_data;
- }
-
- # delete variables
- foreach $i ( 1 .. $form->{rowcount} ) {
- for ( @column_index, "id" ) { delete $form->{"${_}_$i"} }
- }
- for (qw(title titlebar script none)) { delete $form->{$_} }
-
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'form-dynatable',
- );
- $template->render({
- form => $form,
- user => \%myconfig,
- hiddens => $hiddens,
- buttons => $buttons,
- options => \@options,
- rows => \@rows,
- columns => \@column_index,
- heading => \%column_header,
- });
-}
-
-sub pricelist_footer {
-
- # type=submit $locale->text('Update')
- # type=submit $locale->text('Save Pricelist')
-
- %button = (
- 'update' => { ndx => 1, key => 'U', value => $locale->text('Update') },
- 'save_pricelist' =>
- { ndx => 3, key => 'S', value => $locale->text('Save Pricelist') },
- );
-
- my @buttons;
- for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
- push @buttons, {
- name => 'action',
- value => $_,
- accesskey => $button{$_}{key},
- title => "$button{$name}{value} [Alt-$button{$_}{key}]",
- text => $button{$_}{value},
- };
- }
-
- \@buttons;
-}
-
-sub update {
-
- $i = $form->{rowcount};
- $additem = 0;
-
- if ( $form->{db} eq 'customer' ) {
- $additem = 1
- if !(( $form->{"partnumber_$i"} eq "" )
- && ( $form->{"description_$i"} eq "" )
- && ( $form->{"partsgroup_$i"} eq "" ) );
- }
- if ( $form->{db} eq 'vendor' ) {
- if (
- !(
- ( $form->{"sku_$i"} eq "" )
- && ( $form->{"description_$i"} eq "" )
- && ( $form->{"partsgroup_$i"} eq "" )
- )
- )
- {
- $additem = 1;
- $form->{"partnumber_$i"} = $form->{"sku_$i"};
- }
- }
-
- if ($additem) {
-
- CT->retrieve_item( \%myconfig, \%$form );
-
- $rows = scalar @{ $form->{item_list} };
-
- if ( $rows > 0 ) {
-
- if ( $rows > 1 ) {
-
- &select_item;
- exit;
-
- } else {
-
- $sellprice = $form->{"sellprice_$i"};
- $pricebreak = $form->{"pricebreak_$i"};
- $lastcost = $form->{"lastcost_$i"};
-
- for (qw(partnumber description)) {
- $form->{item_list}[0]{$_} =
- $form->quote( $form->{item_list}[0]{$_} );
- }
- for ( keys %{ $form->{item_list}[0] } ) {
- $form->{"${_}_$i"} = $form->{item_list}[0]{$_};
- }
-
- if ( $form->{db} eq 'customer' ) {
-
- if ($sellprice) {
- $form->{"sellprice_$i"} = $sellprice;
- }
-
- $form->{"sellprice_$i"} =
- $form->format_amount( \%myconfig, $form->{"sellprice_$i"},
- 2 );
-
- $form->{"pricebreak_$i"} = $pricebreak;
-
- } else {
-
- foreach $j ( 1 .. $form->{rowcount} - 1 ) {
- if ( $form->{"sku_$j"} eq $form->{"partnumber_$i"} ) {
- $form->error(
- $locale->text('Item already on pricelist!') );
- }
- }
-
- if ($lastcost) {
- $form->{"lastcost_$i"} = $lastcost;
- }
-
- $form->{"lastcost_$i"} =
- $form->format_amount( \%myconfig, $form->{"lastcost_$i"},
- 2 );
-
- $form->{"sku_$i"} = $form->{"partnumber_$i"};
-
- # delete $form->{"partnumber_$i"};
-
- }
-
- $form->{rowcount}++;
-
- }
-
- } else {
- $form->error( $locale->text('Item not on file!') );
- }
- }
-
- &{"$form->{db}_pricelist"};
-
-}
-
-sub select_item {
- my %hiddens;
-
- my @column_index =
- qw(ndx partnumber description partsgroup unit sellprice lastcost);
-
- my %column_data;
- $column_data{ndx} = ' ';
- $column_data{partnumber} = locale->text('Number');
- $column_data{description} = $locale->text('Description');
- $column_data{partsgroup} = $locale->text('Group');
- $column_data{unit} = $locale->text('Unit');
- $column_data{sellprice} = $locale->text('Sell Price');
- $column_data{lastcost} = $locale->text('Cost');
-
- $form->{title} = $locale->text('Select items');
-
- my $i = 0;
- my @rows;
- foreach $ref ( @{ $form->{item_list} } ) {
- $i++;
- my %column_data;
-
- for (qw(partnumber description unit)) {
- $ref->{$_} = $form->quote( $ref->{$_} );
- }
-
- $column_data{ndx} = {input => {
- name => "ndx_$i",
- type => 'checkbox',
- value => $i,
- }};
-
- $column_data{$_} = $ref->{$_} foreach
- qw(partnumber description partsgroup unit);
- $column_data{sellprice} =
- $form->format_amount( \%myconfig, $ref->{sellprice}, 2, ' ' );
- $column_data{lastcost} =
- $form->format_amount( \%myconfig, $ref->{lastcost}, 2, ' ' );
-
- $j++;
- $j %= 2;
- $column_data{i} = $j;
-
- push @rows, \%column_data;
-
- $hiddens{"new_${_}_$i"} = $ref->{$_} foreach
- qw(partnumber description partsgroup partsgroup_id sellprice lastcost unit id);
- }
-
- # delete action variable
- for (qw(nextsub item_list)) { delete $form->{$_} }
- $form->{action} = "item_selected";
-
- $hiddens{$_} = $form->{$_} foreach sort keys %$form;
- $hiddens{nextsub} = 'item_selected';
- $hiddens{lastndx} = $i;
-
- my @buttons = ({
- name => 'action',
- value => 'item_selected',
- text => $locale->text('Continue'),
- });
- my $template = LedgerSMB::Template->new_UI(
- user => \%myconfig,
- locale => $locale,
- template => 'form-dynatable',
- );
- $template->render({
- form => $form,
- user => \%myconfig,
- hiddens => \%hiddens,
- buttons => \@buttons,
- options => \@options,
- rows => \@rows,
- columns => \@column_index,
- heading => \%column_header,
- });
-}
-
-sub item_selected {
-
- # add rows
- $i = $form->{rowcount};
-
- %id = ();
- for $i ( 1 .. $form->{rowcount} - 1 ) {
- $id{ $form->{"id_$i"} } = 1;
- }
-
- for $j ( 1 .. $form->{lastndx} ) {
-
- if ( $form->{"ndx_$j"} ) {
-
- if ( $id{ $form->{"new_id_$j"} } ) {
- next if $form->{db} eq 'vendor';
- }
-
- for (qw(id partnumber description unit sellprice lastcost)) {
- $form->{"${_}_$i"} = $form->{"new_${_}_$j"};
- }
-
- $form->{"partsgroup_$i"} =
- qq|$form->{"new_partsgroup_$j"}--$form->{"new_partsgroup_id_$j"}|;
- $form->{"sku_$i"} = $form->{"new_partnumber_$j"};
-
- $i++;
-
- }
- }
-
- $form->{rowcount} = $i;
-
- # delete all the new_ variables
- for $i ( 1 .. $form->{lastndx} ) {
- for (
- qw(id partnumber description unit sellprice lastcost partsgroup partsgroup_id)
- )
- {
- delete $form->{"new_${_}_$i"};
- }
- delete $form->{"ndx_$i"};
- }
-
- for (qw(ndx lastndx nextsub)) { delete $form->{$_} }
-
- &{"$form->{db}_pricelist"};
-
-}
-
-sub save_pricelist {
-
- &{"CT::save_$form->{db}"}( "", \%myconfig, \%$form );
-
- $callback = $form->{callback};
- $form->{callback} = "$form->{script}?action=edit";
- for (qw(db id login path sessionid)) {
- $form->{callback} .= "&$_=$form->{$_}";
- }
- $form->{callback} .= "&callback=" . $form->escape( $callback, 1 );
-
- if ( CT->save_pricelist( \%myconfig, \%$form ) ) {
- $form->redirect;
- }
- else {
- $form->error( $locale->text('Could not save pricelist!') );
- }
-
-}
-
-sub add_transaction {
-
- $form->isblank( "name", $locale->text("Name missing!") );
-
- &{"CT::save_$form->{db}"}( "", \%myconfig, \%$form );
-
- $form->{callback} = $form->escape( $form->{callback}, 1 );
- $name = $form->escape( $form->{name}, 1 );
-
- $form->{callback} =
-"$form->{script}?login=$form->{login}&path=$form->{path}&sessionid=$form->{sessionid}&action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&callback=$form->{callback}";
-
- $form->redirect;
-
-}
-
-sub ap_transaction {
-
- $form->{script} = "ap.pl";
- $form->{type} = "ap_transaction";
- &add_transaction;
-
-}
-
-sub ar_transaction {
-
- $form->{script} = "ar.pl";
- $form->{type} = "ar_transaction";
- &add_transaction;
-
-}
-
-sub sales_invoice {
-
- $form->{script} = "is.pl";
- $form->{type} = "invoice";
- &add_transaction;
-
-}
-
-sub pos {
-
- $form->{script} = "ps.pl";
- $form->{type} = "pos_invoice";
- &add_transaction;
-
-}
-
-sub vendor_invoice {
-
- $form->{script} = "ir.pl";
- $form->{type} = "invoice";
- &add_transaction;
-
-}
-
-sub rfq {
-
- $form->{script} = "oe.pl";
- $form->{type} = "request_quotation";
- &add_transaction;
-
-}
-
-sub quotation {
-
- $form->{script} = "oe.pl";
- $form->{type} = "sales_quotation";
- &add_transaction;
-
-}
-
-sub sales_order {
-
- $form->{script} = "oe.pl";
- $form->{type} = "sales_order";
- &add_transaction;
-
-}
-
-sub purchase_order {
-
- $form->{script} = "oe.pl";
- $form->{type} = "purchase_order";
- &add_transaction;
-
-}
-
-sub save_as_new {
-
- delete $form->{id};
- &save;
-
-}
-
-sub save {
-
- # $locale->text('Customer saved!')
- # $locale->text('Vendor saved!')
-
- $msg = ucfirst $form->{db};
- $msg .= " saved!";
-
- $form->isblank( "name", $locale->text("Name missing!") );
- &{"CT::save_$form->{db}"}( "", \%myconfig, \%$form );
-
- $form->redirect( $locale->text($msg) );
-
-}
-
-sub delete {
-
- # $locale->text('Customer deleted!')
- # $locale->text('Cannot delete customer!')
- # $locale->text('Vendor deleted!')
- # $locale->text('Cannot delete vendor!')
-
- CT->delete( \%myconfig, \%$form );
-
- $msg = ucfirst $form->{db};
- $msg .= " deleted!";
- $form->redirect( $locale->text($msg) );
-
-}
-
-sub continue { &{ $form->{nextsub} } }
-
-sub add_customer { &add }
-sub add_vendor { &add }
-