[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[2288] trunk



Revision: 2288
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2288&view=rev
Author:   einhverfr
Date:     2008-08-20 22:59:39 +0000 (Wed, 20 Aug 2008)

Log Message:
-----------
Removing the last references to CT.pm and ct.pl, removing these files.

Modified Paths:
--------------
    trunk/LedgerSMB/AA.pm
    trunk/bin/aa.pl

Removed Paths:
-------------
    trunk/LedgerSMB/CT.pm
    trunk/bin/ct.pl

Modified: trunk/LedgerSMB/AA.pm
===================================================================
--- trunk/LedgerSMB/AA.pm	2008-08-20 21:06:06 UTC (rev 2287)
+++ trunk/LedgerSMB/AA.pm	2008-08-20 22:59:39 UTC (rev 2288)
@@ -827,7 +827,7 @@
 		          a.invoice, a.datepaid, a.terms, a.notes,
 		          a.shipvia, a.shippingpoint, ee.name AS employee, 
 		          vce.name, vc.meta_number,
-		          a.entity_id, a.till, me.name AS manager, a.curr,
+		          vc.entity_id, a.till, me.name AS manager, a.curr,
 		          ex.$buysell AS exchangerate, 
 		          d.description AS department, 
 		          a.ponumber $acc_trans_flds

Deleted: trunk/LedgerSMB/CT.pm
===================================================================
--- trunk/LedgerSMB/CT.pm	2008-08-20 21:06:06 UTC (rev 2287)
+++ trunk/LedgerSMB/CT.pm	2008-08-20 22:59:39 UTC (rev 2288)
@@ -1,1084 +0,0 @@
-#=====================================================================
-# LedgerSMB
-# Small Medium Business Accounting software
-# 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) 2000
-#
-#  Author: DWS Systems Inc.
-#     Web: http://www.sql-ledger.org
-#
-#  Contributors:
-#
-#
-#======================================================================
-#
-# This file has undergone whitespace cleanup.
-#
-#======================================================================
-#
-# backend code for customers and vendors
-#
-#======================================================================
-
-package CT;
-
-sub create_links {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-    my $query;
-    my $sth;
-    my $ref;
-    my $arap = ( $form->{db} eq 'customer' ) ? "ar" : "ap";
-    my $ARAP = uc $arap;
-
-    if ( $form->{id} ) {
-        $query = qq|
-			    SELECT ct.*, b.description AS business, s.*,
-			           e.name AS employee, 
-			           g.pricegroup AS pricegroup,
-			           l.description AS language, ct.curr
-			      FROM $form->{db} ct
-			 LEFT JOIN business b ON (ct.business_id = b.id)
-			 LEFT JOIN shipto s ON (ct.id = s.trans_id)
-			 LEFT JOIN employee e ON (ct.employee_id = e.id)
-			 LEFT JOIN pricegroup g ON (g.id = ct.pricegroup_id)
-			 LEFT JOIN language l ON (l.code = ct.language_code)
-			     WHERE ct.id = ?|;
-
-        $sth = $dbh->prepare($query);
-        $sth->execute( $form->{id} ) || $form->dberror($query);
-
-        $ref = $sth->fetchrow_hashref(NAME_lc);
-        for ( keys %$ref ) { $form->{$_} = $ref->{$_} }
-        $sth->finish;
-
-        # check if it is orphaned
-        $query = qq|
-			SELECT a.id
-			  FROM $arap a
-			  JOIN $form->{db} ct ON (a.$form->{db}_id = ct.id)
-			 WHERE ct.id = ?
-
-			 UNION
-
-			SELECT a.id
-			  FROM oe a
-			  JOIN $form->{db} ct ON (a.$form->{db}_id = ct.id)
-			 WHERE ct.id = ?|;
-
-        $sth = $dbh->prepare($query);
-        $sth->execute( $form->{id}, $form->{id} )
-          || $form->dberror($query);
-
-        unless ( $sth->fetchrow_array ) {
-            $form->{status} = "orphaned";
-        }
-
-        $sth->finish;
-
-        # get taxes for customer/vendor
-        $query = qq|
-			SELECT c.accno
-			  FROM chart c
-			  JOIN $form->{db}tax t ON (t.chart_id = c.id)
-			 WHERE t.$form->{db}_id = ?|;
-
-        $sth = $dbh->prepare($query);
-        $sth->execute( $form->{id} ) || $form->dberror($query);
-
-        while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-            $form->{tax}{ $ref->{accno} }{taxable} = 1;
-        }
-
-        $sth->finish;
-
-    }
-    else {
-
-        ( $form->{employee}, $form->{employee_id} ) = $form->get_employee($dbh);
-
-        $query = qq|SELECT current_date|;
-        ( $form->{startdate} ) = $dbh->selectrow_array($query);
-
-    }
-
-    # get tax labels
-    $query = qq|
-		   SELECT DISTINCT c.accno, c.description
-		     FROM chart c
-		     JOIN tax t ON (t.chart_id = c.id)
-		    WHERE c.link LIKE ?
-		 ORDER BY c.accno|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute("%${ARAP}_tax%") || $form->dberror($query);
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        $form->{taxaccounts} .= "$ref->{accno} ";
-        $form->{tax}{ $ref->{accno} }{description} = $ref->{description};
-    }
-
-    $sth->finish;
-    chop $form->{taxaccounts};
-
-# get business types ## needs fixing, this is bad (SELECT * ...) with order by 2. Yuck
-    $query = qq|
-		   SELECT *
-		     FROM business
-		 ORDER BY 2|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{all_business} }, $ref;
-    }
-
-    $sth->finish;
-
-    # employees/salespersons
-    $form->all_employees( $myconfig, $dbh, undef,
-        ( $form->{vc} eq 'customer' )
-        ? 1
-        : 0 );
-
-# get language ## needs fixing, this is bad (SELECT * ...) with order by 2. Yuck
-    $query = qq|
-		  SELECT *
-		    FROM language
-		ORDER BY 2|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{all_language} }, $ref;
-    }
-
-    $sth->finish;
-
-# get pricegroups ## needs fixing, this is bad (SELECT * ...) with order by 2. Yuck
-    $query = qq|
-		  SELECT *
-		    FROM pricegroup
-		ORDER BY 2|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{all_pricegroup} }, $ref;
-    }
-
-    $sth->finish;
-
-    # get currencies
-    $query = qq|
-		SELECT value AS currencies
-		  FROM defaults
-		  WHERE setting_key = 'curr'|;
-
-    ( $form->{currencies} ) = $dbh->selectrow_array($query);
-
-    $dbh->commit;
-
-}
-
-sub _save_vc {
-    ($form) = @_;
-    my $dbh = $form->{dbh};
-    my $updated = 0;
-    if ($form->{vc} eq 'customer'){
-       $form->{vc}  = 'customer';
-       $form->{entity_class} = 2;
-    } else {
-       $form->{vc} = 'vendor';
-       $form->{entity_class} = 1;
-    }
-    
-    # this should really all be replaced by an upsert.
-    if ( $form->{id} ) {
-        # This module is depricated, so we are just going to throw an error here
-        $form->error("Updating $form->{vc} not supported.  ".
-		"Please wait for us to move to the new codebase.");
-
-    }
-    if (!$updated){
-            # Creating Entity
-            ($form->{entity_id}) = $dbh->selectrow_array("SELECT nextval('entity_id_seq')");
-            $query = qq|INSERT INTO entity (id, name, entity_class) VALUES (?, ?,?)|;
-            $sth = $dbh->prepare($query);
-            $sth->execute($form->{entity_id}, $form->{name}, $form->{entity_class});
-            $sth->finish;
-		
-            # Creating LOCATION
-            ($form->{location_id}) = 
-		$dbh->selectrow_array("SELECT nextval('location_id_seq')");
-            $query = qq|
-		INSERT INTO location
-			(id, line_one, line_two, city_province, mail_code, 
-			country_id, location_class, created)
-		VALUES
-			(?, ?, ?, ?, ?, 
-				(SELECT id FROM country
-				WHERE short_name = ? OR name = ?),
-			 1, current_date)
-            |; # location class 1 is Billing. This is a sensible default.
-            $sth = $dbh->prepare($query);
-            $sth->execute($form->{location_id}, $form->{address1}, $form->{address2}, 
-                  "$form->{city}, $form->{state}", $form->{zipcode},
-                  $form->{country}, $form->{country}
-            ) || $form->dberror($query);
-            
-            
-            #Creating company
-            # Removed entity_class_id,
-            # removed primary_location_id,
-            # added sic_code  ~Aurynn
-            $query = qq|
-		INSERT INTO company
-			(entity_id, legal_name, tax_id, sic_code)
-		VALUES
-			(?, ?, ?, ?)
-            |;
-            $sth = $dbh->prepare($query) || $form->dberror($query);
-            $sth->execute($form->{entity_id}, # $form->{entity_class}, # removed entity_class_id ~Aurynn
-                  $form->{name}, 
-                  # $form->{location_id}, # removed by ~aurynn
-                  $form->{taxnumber},
-                  $form->{sic_code});
-            # Creating entity_metadata record, replacing customer and vendor.
-            $query = qq|
-    		INSERT INTO entity_credit_account
-    			(entity_id, entity_class, discount, taxincluded, creditlimit, 
-    			    terms, meta_number, cc, bcc, business_id,
-    				language_code, pricegroup_id, curr, startdate,
-    				enddate)
-
-    		VALUES (?, ?, ?, ?, ?,
-    			?, ?, ?, ?,
-    			?, ?, ?, ?,
-    			?, ?)|;
-            
-            $sth = $dbh->prepare($query);
-            $sth->execute(
-                 $form->{entity_id}, $form->{entity_class}, $form->{discount}, 
-                 $form->{taxincluded}, $form->{creditlimit}, 
-                 $form->{terms}, $form->{"$form->{db}number"}, $form->{cc},
-                 $form->{bcc}, $form->{business_id},
-                 $form->{language_code}, $form->{pricegroup_id}, $form->{curr},
-                 $form->{startdate} || undef, $form->{enddate} || undef, 
-            ) || $form->dberror($query);
-            
-            $query = qq|
-                INSERT INTO entity_bank_account (entity_id, bic, iban) 
-                VALUES (?,?,?)
-            |;
-            $sth = $dbh->prepare($query);
-            $sth->execute($form->{entity_id}, $form->{bic}, $form->{iban}) || 
-                $form->dberror($query);
-            
-    }
-}
-
-sub save_customer {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to databaseÂ
-    my $dbh = $form->{dbh};
-    my $query;
-    my $sth;
-    my $null;
-    $form->{vc} = 'customer';
-    # remove double spaces
-    $form->{name} =~ s/  / /g;
-
-    # remove double minus and minus at the end
-    $form->{name} =~ s/--+/-/g;
-    $form->{name} =~ s/-+$//;
-
-    # assign value discount, terms, creditlimit
-    $form->{discount} = $form->parse_amount( $myconfig, $form->{discount} );
-    $form->{discount} /= 100;
-    $form->{terms}       *= 1;
-    $form->{taxincluded} *= 1;
-    $form->{creditlimit} =
-      $form->parse_amount( $myconfig, $form->{creditlimit} );
-    if ( !$form->{creditlimit} ) {
-        $form->{creditlimit} = 0;
-    }
-    &_save_vc($form);
-    # save taxes
-    foreach $item ( split / /, $form->{taxaccounts} ) {
-
-        if ( $form->{"tax_$item"} ) {
-            $query = qq|
-				INSERT INTO customertax (customer_id, chart_id)
-				     VALUES (currval('entity_credit_account_id_seq'), 
-				                 (SELECT id
-				                   FROM chart
-				                  WHERE accno = ?))|;
-
-            $sth = $dbh->prepare($query);
-            $sth->execute( $item )
-              || $form->dberror($query);
-        }
-    }
-
-    # add shipto
-    $form->add_shipto( $dbh, $form->{id} );
-
-    $dbh->commit;
-}
-
-sub save_vendor {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $query;
-    my $sth;
-    my $null;
-
-    # remove double spaces
-    $form->{name} =~ s/  / /g;
-
-    # remove double minus and minus at the end
-    $form->{name} =~ s/--+/-/g;
-    $form->{name} =~ s/-+$//;
-
-    $form->{discount} = $form->parse_amount( $myconfig, $form->{discount} );
-    $form->{discount} /= 100;
-    $form->{terms}       *= 1;
-    $form->{taxincluded} *= 1;
-    $form->{creditlimit} =
-      $form->parse_amount( $myconfig, $form->{creditlimit} );
-    &_save_vc($form);
-
-    # save taxes
-    foreach $item ( split / /, $form->{taxaccounts} ) {
-        if ( $form->{"tax_$item"} ) {
-            $query = qq|
-				INSERT INTO vendortax (vendor_id, chart_id)
-				     VALUES (?, (SELECT id
-				                   FROM chart
-				                  WHERE accno = ?))|;
-
-            $sth = $dbh->prepare($query);
-            $sth->execute( $form->{id}, $item )
-              || $form->dberror($query);
-        }
-    }
-
-    # add shipto
-    $form->add_shipto( $dbh, $form->{id} );
-
-    $dbh->commit;
-
-}
-
-sub delete {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    # delete customer/vendor
-    my $query = qq|DELETE FROM $form->{db}
-					WHERE id = ?|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    $dbh->commit;
-
-}
-
-sub search {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $where = "1 = 1";
-    $form->{sort} = ( $form->{sort} ) ? $form->{sort} : "name";
-    my @a         = qw(name);
-    my $sortorder = $form->sort_order( ..hidden.. );
-
-    my $var;
-    my $item;
-
-    @a = ("$form->{db}number");
-    push @a, qw(name contact city state zipcode country notes phone email);
-
-    if ( $form->{employee} ) {
-        $var = $dbh->quote($form->like(lc $form->{employee}));
-        $where .= " AND lower(e.name) LIKE $var";
-    }
-
-    foreach $item (@a) {
-
-        if ( $form->{$item} ne "" ) {
-            $var = $dbh->quote($form->like( lc $form->{$item}) );
-            $where .= " AND lower(ct.$item) LIKE $var";
-        }
-    }
-
-    if ( $form->{address} ne "" ) {
-        $var = $dbh->quote( $form->like( lc $form->{address} ) );
-        $where .=
-" AND (lower(ct.address1) ILIKE $var)";
-    }
-
-    if ( $form->{startdatefrom} ) {
-        $where .=
-          " AND ct.startdate >= " . $dbh->quote( $form->{startdatefrom} );
-    }
-
-    if ( $form->{startdateto} ) {
-        $where .= " AND ct.startdate <= " . $dbh->quote( $form->{startdateto} );
-    }
-
-    if ( $form->{status} eq 'active' ) {
-        $where .= " AND ct.enddate IS NULL";
-    }
-
-    if ( $form->{status} eq 'inactive' ) {
-        $where .= " AND ct.enddate <= current_date";
-    }
-
-    if ( $form->{status} eq 'orphaned' ) {
-        $where .= qq| 
-			AND ct.id NOT IN (SELECT o.$form->{db}_id
-			                    FROM oe o, $form->{db} vc
-			                   WHERE vc.id = o.$form->{db}_id)|;
-
-        if ( $form->{db} =~ /(^customer$|^vendor$)/ ) {
-            $where .= qq| AND ct.id NOT IN (SELECT a.entity_id
-											  FROM ar a, customer vc
-											 WHERE vc.entity_id = a.entity_id)|;
-        }
-
-
-        $form->{l_invnumber} = $form->{l_ordnumber} = $form->{l_quonumber} = "";
-    }
-
-    my $query = qq|
-		   SELECT ct.*, b.description AS business,
-		          e.name AS employee, g.pricegroup, 
-		          l.description AS language, m.name AS manager
-		     FROM $form->{db} ct
-		LEFT JOIN business b ON (ct.business_id = b.id)
-		LEFT JOIN employee e ON (ct.employee_id = e.id)
-		LEFT JOIN employee m ON (m.id = e.managerid)
-		LEFT JOIN pricegroup g ON (ct.pricegroup_id = g.id)
-		LEFT JOIN language l ON (l.code = ct.language_code)
-		    WHERE $where|;
-
-    # redo for invoices, orders and quotations
-    if (   $form->{l_transnumber}
-        || $form->{l_invnumber}
-        || $form->{l_ordnumber}
-        || $form->{l_quonumber} )
-    {
-
-        my ( $ar, $union, $module );
-        $query = "";
-        my $transwhere;
-        my $openarap = "";
-        my $openoe   = "";
-
-        if ( $form->{open} || $form->{closed} ) {
-            unless ( $form->{open} && $form->{closed} ) {
-                $openarap = " AND a.amount != a.paid"
-                  if $form->{open};
-                $openarap = " AND a.amount = a.paid"
-                  if $form->{closed};
-                $openoe = " AND o.closed = '0'"
-                  if $form->{open};
-                $openoe = " AND o.closed = '1'"
-                  if $form->{closed};
-            }
-        }
-
-        if ( $form->{l_transnumber} ) {
-
-            $ar = ( $form->{db} eq 'customer' ) ? 'ar' : 'ap';
-            $module = $ar;
-
-            $transwhere = "";
-            $transwhere .=
-              " AND a.transdate >= " . $dbh->quote( $form->{transdatefrom} )
-              if $form->{transdatefrom};
-            $transwhere .=
-              " AND a.transdate <= " . $dbh->quote( $form->{transdateto} )
-              if $form->{transdateto};
-
-            $query = qq|
-				    SELECT ct.*, b.description AS business,
-				           a.invnumber, a.ordnumber, 
-				           a.quonumber, 
-				           a.id AS invid, '$ar' AS module, 
-				           'invoice' AS formtype, 
-				           (a.amount = a.paid) AS closed, 
-				           a.amount,
-				           a.netamount, e.name AS employee, 
-				           m.name AS manager
-				      FROM $form->{db} ct
-				      JOIN $ar a ON (a.$form->{db}_id = ct.id)
-				 LEFT JOIN business b ON (ct.business_id = b.id)
-				 LEFT JOIN employee e ON (a.employee_id = e.id)
-				 LEFT JOIN employee m ON (m.id = e.managerid)
-				     WHERE $where
-				           AND a.invoice = '0'
-				           $transwhere
-				           $openarap |;
-
-            $union = qq| UNION |;
-
-        }
-
-        if ( $form->{l_invnumber} ) {
-            $ar     = ( $form->{db} eq 'customer' ) ? 'ar' : 'ap';
-            $module = ( $ar         eq 'ar' )       ? 'is' : 'ir';
-
-            $transwhere = "";
-            $transwhere .=
-              " AND a.transdate >= " . $dbh->quote( $form->{transdatefrom} )
-              if $form->{transdatefrom};
-            $transwhere .=
-              " AND a.transdate <= " . $dbh->quote( $form->{transdateto} )
-              if $form->{transdateto};
-
-            $query .= qq|
-				$union
-				   SELECT ct.*, b.description AS business,
-				          a.invnumber, a.ordnumber, a.quonumber,
-				          a.id AS invid,
-				          '$module' AS module, 
-				          'invoice' AS formtype,
-				          (a.amount = a.paid) AS closed, 
-				          a.amount, a.netamount,
-				          e.name AS employee, m.name AS manager
-				     FROM $form->{db} ct
-				     JOIN $ar a ON (a.$form->{db}_id = ct.id)
-				LEFT JOIN business b ON (ct.business_id = b.id)
-				LEFT JOIN employee e ON (a.employee_id = e.id)
-				LEFT JOIN employee m ON (m.id = e.managerid)
-				    WHERE $where
-				          AND a.invoice = '1'
-				          $transwhere
-				          $openarap |;
-
-            $union = qq| UNION|;
-
-        }
-
-        if ( $form->{l_ordnumber} ) {
-
-            $transwhere = "";
-            $transwhere .=
-              " AND o.transdate >= " . $dbh->quote( $form->{transdatefrom} )
-              if $form->{transdatefrom};
-            $transwhere .=
-              " AND o.transdate <= " . $dbh->quote( $form->{transdateto} )
-              if $form->{transdateto};
-
-            $query .= qq|
-				$union
-				   SELECT ct.*, b.description AS business,
-				          ' ' AS invnumber, o.ordnumber, 
-				          o.quonumber, o.id AS invid,
-				          'oe' AS module, 'order' AS formtype,
-				          o.closed, o.amount, o.netamount,
-				          e.name AS employee, m.name AS manager
-				     FROM $form->{db} ct
-				     JOIN oe o ON (o.$form->{db}_id = ct.id)
-				LEFT JOIN business b ON (ct.business_id = b.id)
-				LEFT JOIN employee e ON (o.employee_id = e.id)
-				LEFT JOIN employee m ON (m.id = e.managerid)
-				    WHERE $where
-				      AND o.quotation = '0'
-				          $transwhere
-				          $openoe |;
-
-            $union = qq| UNION|;
-
-        }
-
-        if ( $form->{l_quonumber} ) {
-
-            $transwhere = "";
-            $transwhere .=
-              " AND o.transdate >= " . $dbh->quote( $form->{transdatefrom} )
-              if $form->{transdatefrom};
-            $transwhere .=
-              " AND o.transdate <= " . $dbh->quote( $form->{transdateto} )
-              if $form->{transdateto};
-
-            $query .= qq|
-				$union
-				   SELECT ct.*, b.description AS business,
-				          ' ' AS invnumber, o.ordnumber, 
-				          o.quonumber, o.id AS invid,
-				          'oe' AS module, 
-				          'quotation' AS formtype,
-				          o.closed, o.amount, o.netamount,
-				          e.name AS employee, m.name AS manager
-				     FROM $form->{db} ct
-				     JOIN oe o ON (o.$form->{db}_id = ct.id)
-				LEFT JOIN business b ON (ct.business_id = b.id)
-				LEFT JOIN employee e ON (o.employee_id = e.id)
-				LEFT JOIN employee m ON (m.id = e.managerid)
-				    WHERE $where
-				          AND o.quotation = '1'
-				          $transwhere
-				          $openoe |;
-
-        }
-
-        $sortorder .= ", invid";
-    }
-
-    $query .= qq| ORDER BY $sortorder|;
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    # accounts
-    $query = qq|
-		SELECT c.accno
-		  FROM chart c
-		  JOIN $form->{db}tax t ON (t.chart_id = c.id)
-		 WHERE t.$form->{db}_id = ?|;
-
-    my $tth = $dbh->prepare($query);
-
-    while ( my $ref = $sth->fetchrow_hashref('NAME_lc') ) {
-        $form->db_parse_numeric(sth => $sth, hashref => $ref);
-        $tth->execute( $ref->{id} );
-
-        while ( ($item) = $tth->fetchrow_array ) {
-            $ref->{taxaccount} .= "$item ";
-        }
-
-        $tth->finish;
-        chop $ref->{taxaccount};
-
-        $ref->{address} = "";
-
-        for (qw(address1 address2 city state zipcode country)) {
-            $ref->{address} .= "$ref->{$_} ";
-        }
-        push @{ $form->{CT} }, $ref;
-    }
-
-    $sth->finish;
-    $dbh->commit;
-
-}
-
-sub get_history {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $query;
-    my $where = "1 = 1";
-    $form->{sort} = "partnumber" unless $form->{sort};
-    my $sortorder = $form->{sort};
-    my %ordinal   = ();
-    my $var;
-    my $table;
-
-    # setup ASC or DESC
-    $form->sort_order();
-
-    if ( $form->{"$form->{db}number"} ne "" ) {
-        $var = $dbh->quote( $form->like( lc $form->{"$form->{db}number"} ) );
-        $where .= " AND lower(ct.$form->{db}number) LIKE $var";
-    }
-
-    if ( $form->{address} ne "" ) {
-        $var = $dbh->quote( $form->like( lc $form->{address} ) );
-        $where .= " AND lower(ct.address1) ILIKE $var";
-    }
-
-    for (qw(name contact email phone notes city state zipcode country)) {
-
-        if ( $form->{$_} ne "" ) {
-            $var = $dbh->quote( $form->like( lc $form->{$_} ) );
-            $where .= " AND lower(ct.$_) LIKE $var";
-        }
-    }
-
-    if ( $form->{employee} ne "" ) {
-        $var = $dbh->quote($form->like(lc $form->{employee}));
-        $where .= " AND lower(e.name) LIKE $var";
-    }
-
-    $transwhere .=
-      " AND a.transdate >= " . $dbh->quote( $form->{transdatefrom} )
-      if $form->{transdatefrom};
-    $transwhere .= " AND a.transdate <= " . $dbh->quote( $form->{transdateto} )
-      if $form->{transdateto};
-
-    if ( $form->{open} || $form->{closed} ) {
-
-        unless ( $form->{open} && $form->{closed} ) {
-
-            if ( $form->{type} eq 'invoice' ) {
-                $where .= " AND a.amount != a.paid"
-                  if $form->{open};
-                $where .= " AND a.amount = a.paid"
-                  if $form->{closed};
-            }
-            else {
-                $where .= " AND a.closed = '0'"
-                  if $form->{open};
-                $where .= " AND a.closed = '1'"
-                  if $form->{closed};
-            }
-        }
-    }
-
-    my $invnumber = 'invnumber';
-    my $deldate   = 'deliverydate';
-    my $buysell;
-    my $sellprice = "sellprice";
-
-    if ( $form->{db} eq 'customer' ) {
-        $buysell = "buy";
-
-        if ( $form->{type} eq 'invoice' ) {
-            $where .= qq|
-				AND a.invoice = '1' AND i.assemblyitem = '0'|;
-            $table     = 'ar';
-            $sellprice = "fxsellprice";
-        }
-        else {
-            $table = 'oe';
-
-            if ( $form->{type} eq 'order' ) {
-                $invnumber = 'ordnumber';
-                $where .= qq| AND a.quotation = '0'|;
-            }
-            else {
-                $invnumber = 'quonumber';
-                $where .= qq| AND a.quotation = '1'|;
-            }
-
-            $deldate = 'reqdate';
-        }
-    }
-
-    if ( $form->{db} eq 'vendor' ) {
-
-        $buysell = "sell";
-
-        if ( $form->{type} eq 'invoice' ) {
-
-            $where .= qq| AND a.invoice = '1' AND i.assemblyitem = '0'|;
-            $table     = 'ap';
-            $sellprice = "fxsellprice";
-
-        }
-        else {
-
-            $table = 'oe';
-
-            if ( $form->{type} eq 'order' ) {
-                $invnumber = 'ordnumber';
-                $where .= qq| AND a.quotation = '0'|;
-            }
-            else {
-                $invnumber = 'quonumber';
-                $where .= qq| AND a.quotation = '1'|;
-            }
-
-            $deldate = 'reqdate';
-        }
-    }
-
-    my $invjoin = qq| JOIN invoice i ON (i.trans_id = a.id)|;
-
-    if ( $form->{type} eq 'order' ) {
-        $invjoin = qq| JOIN orderitems i ON (i.trans_id = a.id)|;
-    }
-
-    if ( $form->{type} eq 'quotation' ) {
-        $invjoin = qq| JOIN orderitems i ON (i.trans_id = a.id)|;
-        $where .= qq| AND a.quotation = '1'|;
-    }
-
-    %ordinal = (
-        partnumber    => 9,
-        description   => 12,
-        "$deldate"    => 16,
-        serialnumber  => 17,
-        projectnumber => 18
-    );
-
-    $sortorder =
-      "2 $form->{direction}, 1, 11, $ordinal{$sortorder} $form->{direction}";
-
-    $query = qq|
-		  SELECT ct.id AS ctid, ct.name, ct.address1,
-		         ct.address2, ct.city, ct.state,
-		         p.id AS pid, p.partnumber, a.id AS invid,
-		         a.$invnumber, a.curr, i.description,
-		         i.qty, i.$sellprice AS sellprice, i.discount,
-		         i.$deldate, i.serialnumber, pr.projectnumber,
-		         e.name AS employee, ct.zipcode, ct.country, i.unit,
-		         (SELECT $buysell 
-			    FROM exchangerate ex
-			   WHERE a.curr = ex.curr
-		                 AND a.transdate = ex.transdate) AS exchangerate
-		     FROM $form->{db} ct
-		     JOIN $table a ON (a.$form->{db}_id = ct.id)
-		          $invjoin
-		     JOIN parts p ON (p.id = i.parts_id)
-		LEFT JOIN project pr ON (pr.id = i.project_id)
-		LEFT JOIN employee e ON (e.id = a.employee_id)
-				 WHERE $where
-			  ORDER BY $sortorder|;
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-
-    while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        $ref->{address} = "";
-        $ref->{exchangerate} ||= 1;
-        for (qw(address1 address2 city state zipcode country)) {
-            $ref->{address} .= "$ref->{$_} ";
-        }
-        $ref->{id} = $ref->{ctid};
-        push @{ $form->{CT} }, $ref;
-    }
-
-    $sth->finish;
-    $dbh->commit;
-
-}
-
-sub pricelist {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $query;
-
-    if ( $form->{db} eq 'customer' ) {
-        $query = qq|SELECT p.id, p.partnumber, p.description,
-						   p.sellprice, pg.partsgroup, p.partsgroup_id,
-						   m.pricebreak, m.sellprice,
-						   m.validfrom, m.validto, m.curr
-					  FROM partscustomer m
-					  JOIN parts p ON (p.id = m.parts_id)
-				 LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
-					 WHERE m.customer_id = ?
-				  ORDER BY partnumber|;
-    }
-
-    if ( $form->{db} eq 'vendor' ) {
-        $query = qq|SELECT p.id, p.partnumber AS sku, p.description,
-						   pg.partsgroup, p.partsgroup_id,
-						   m.partnumber, m.leadtime, m.lastcost, m.curr
-					  FROM partsvendor m
-					  JOIN parts p ON (p.id = m.parts_id)
-				 LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
-					 WHERE m.vendor_id = ?
-				  ORDER BY p.partnumber|;
-    }
-
-    my $sth;
-    my $ref;
-
-    if ( $form->{id} ) {
-
-        $sth = $dbh->prepare($query);
-        $sth->execute( $form->{id} ) || $form->dberror($query);
-
-        while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-            push @{ $form->{all_partspricelist} }, $ref;
-        }
-
-        $sth->finish;
-    }
-
-    $query = qq|SELECT value FROM defaults where setting_key = 'curr'|;
-    ( $form->{currencies} ) = $dbh->selectrow_array($query);
-
-    $query = qq|SELECT id, partsgroup 
-				  FROM partsgroup
-			  ORDER BY partsgroup|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute || $self->dberror($query);
-
-    $form->{all_partsgroup} = ();
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{all_partsgroup} }, $ref;
-    }
-
-    $sth->finish;
-
-    $dbh->commit;
-
-}
-
-sub save_pricelist {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    my $dbh = $form->{dbh};
-
-    my $query = qq|
-		DELETE FROM parts$form->{db}
-		 WHERE $form->{db}_id = ?|;
-
-    $sth = $dbh->prepare($query);
-    $sth->execute( $form->{id} ) || $form->dberror($query);
-
-    foreach $i ( 1 .. $form->{rowcount} ) {
-
-        if ( $form->{"id_$i"} ) {
-
-            if ( $form->{db} eq 'customer' ) {
-
-                for (qw(pricebreak sellprice)) {
-                    $form->{"${_}_$i"} =
-                      $form->parse_amount( $myconfig, $form->{"${_}_$i"} );
-                }
-
-                $query = qq|
-					INSERT INTO parts$form->{db} 
-					            (parts_id, customer_id,
-					            pricebreak, sellprice, 
-					            validfrom, validto, curr)
-					     VALUES (?, ?, ?, ?, ?, ?, ?)|;
-                @queryargs = (
-                    $form->{"id_$i"},         $form->{id},
-                    $form->{"pricebreak_$i"}, $form->{"sellprice_$i"},
-                    $form->{"validfrom_$i"},  $form->{"validto_$i"},
-                    $form->{"curr_$i"}
-                );
-            }
-            else {
-
-                for (qw(leadtime lastcost)) {
-                    $form->{"${_}_$i"} =
-                      $form->parse_amount( $myconfig, $form->{"${_}_$i"} );
-                }
-
-                $query = qq|
-					INSERT INTO parts$form->{db} 
-					            (parts_id, vendor_id,
-					            partnumber, lastcost, 
-					            leadtime, curr)
-					     VALUES (?, ?, ?, ?, ?, ?)|;
-                @queryargs = (
-                    $form->{"id_$i"},         $form->{id},
-                    $form->{"partnumber_$i"}, $form->{"lastcost_$i"},
-                    $form->{"leadtime_$i"},   $form->{"curr_$i"}
-                );
-
-            }
-            $sth = $dbh->prepare($query);
-            $sth->execute(@queryargs) || $form->dberror($query);
-        }
-
-    }
-
-    $_ = $dbh->commit;
-
-}
-
-sub retrieve_item {
-
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $i = $form->{rowcount};
-    my $var;
-    my $null;
-
-    my $where = "WHERE p.obsolete = '0'";
-
-    if ( $form->{db} eq 'vendor' ) {
-
-        # parts, services, labor
-        $where .= " AND p.assembly = '0'";
-    }
-
-    if ( $form->{db} eq 'customer' ) {
-
-        # parts, assemblies, services
-        $where .= " AND p.income_accno_id > 0";
-    }
-
-    if ( $form->{"partnumber_$i"} ne "" ) {
-        $var = $dbh->quote( $form->like( lc $form->{"partnumber_$i"} ) );
-        $where .= " AND lower(p.partnumber) LIKE $var";
-    }
-
-    if ( $form->{"description_$i"} ne "" ) {
-        $var = $dbh->quote( $form->like( lc $form->{"description_$i"} ) );
-        $where .= " AND lower(p.description) LIKE $var";
-    }
-
-    if ( $form->{"partsgroup_$i"} ne "" ) {
-        ( $null, $var ) = split /--/, $form->{"partsgroup_$i"};
-        $var = $dbh->quote($var);
-        $where .= qq| AND p.partsgroup_id = $var|;
-    }
-
-    my $query = qq|
-		   SELECT p.id, p.partnumber, p.description, p.sellprice,
-		          p.lastcost, p.unit, pg.partsgroup, p.partsgroup_id
-		     FROM parts p
-		LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id)
-		          $where
-		 ORDER BY partnumber|;
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute || $form->dberror($query);
-    my $ref;
-    $form->{item_list} = ();
-
-    while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-        push @{ $form->{item_list} }, $ref;
-    }
-
-    $sth->finish;
-    $dbh->commit;
-}
-
-1;
-

Modified: trunk/bin/aa.pl
===================================================================
--- trunk/bin/aa.pl	2008-08-20 21:06:06 UTC (rev 2287)
+++ trunk/bin/aa.pl	2008-08-20 22:59:39 UTC (rev 2288)
@@ -1561,6 +1561,13 @@
         ( $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 @@
         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++;

Deleted: trunk/bin/ct.pl
===================================================================
--- trunk/bin/ct.pl	2008-08-20 21:06:06 UTC (rev 2287)
+++ trunk/bin/ct.pl	2008-08-20 22:59:39 UTC (rev 2288)
@@ -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 <..hidden..>
-#
-#
-#
-# 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, ..hidden..);
-
-##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 => ..hidden..,
-    });
-}
-
-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, ..hidden..);
-
-##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 => ..hidden..,
-    });
-}
-
-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 => ..hidden..,
-        options => ..hidden..,
-        rows => ..hidden..,
-        columns => ..hidden..,
-        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 => ..hidden..,
-        rows => ..hidden..,
-        columns => ..hidden..,
-        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 => ..hidden..,
-        options => ..hidden..,
-    });
-}
-
-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( ..hidden.., ..hidden.., $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( ..hidden.., ..hidden.., $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 => ..hidden..,
-                    }};
-            }
-        }
-
-        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 => ..hidden..,
-        rows => ..hidden..,
-        columns => ..hidden..,
-        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},
-            }; 
-    }
-
-    ..hidden..;
-}
-
-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 => ..hidden..,
-        options => ..hidden..,
-        rows => ..hidden..,
-        columns => ..hidden..,
-        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"};
-
-}
-

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.