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

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



Revision: 5382
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5382&view=rev
Author:   einhverfr
Date:     2012-12-19 07:33:27 +0000 (Wed, 19 Dec 2012)
Log Message:
-----------
Moved order/quotation search to new reporting framework.

Modified Paths:
--------------
    trunk/LedgerSMB/OE.pm
    trunk/bin/oe.pl
    trunk/sql/Pg-database.sql
    trunk/sql/modules/menu_rebuild.sql

Added Paths:
-----------
    trunk/LedgerSMB/Report/Orders.pm
    trunk/LedgerSMB/Scripts/order.pm
    trunk/UI/Reports/filters/orders.html
    trunk/order.pl
    trunk/sql/modules/OrderEntry.sql

Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm	2012-12-18 09:15:29 UTC (rev 5381)
+++ trunk/LedgerSMB/OE.pm	2012-12-19 07:33:27 UTC (rev 5382)
@@ -84,228 +84,6 @@
     $sth->finish;
 }
 
-sub transactions {
-    my ( $self, $myconfig, $form ) = @_;
-
-    # connect to database
-    my $dbh = $form->{dbh};
-
-    my $query;
-    my $null;
-    my $var;
-    my $ordnumber = 'ordnumber';
-    my $quotation = '0';
-    my $department;
-
-    my $rate = ( $form->{vc} eq 'customer' ) ? 'buy' : 'sell';
-
-    ( $form->{transdatefrom}, $form->{transdateto} ) =
-      $form->from_to( $form->{year}, $form->{month}, $form->{interval} )
-      if $form->{year} && $form->{month};
-
-    if ( $form->{type} =~ /_quotation$/ ) {
-        $quotation = '1';
-        $ordnumber = 'quonumber';
-    }
-
-    my $number  = $form->like( lc $form->{$ordnumber} );
-    my $name    = $form->like( lc $form->{ $form->{vc} } );
-    my @dptargs = ();
-
-    for (qw(department employee)) {
-        if ( $form->{$_} ) {
-            ( $null, $var ) = split /--/, $form->{$_};
-            $department .= " AND o.${_}_id = ?";
-            push @dptargs, $var;
-        }
-    }
-
-    if ( $form->{vc} ne 'customer' ) {    # Sanitize $form->{vc}
-        $form->{vc} = 'vendor';
-    }
-    $query = qq|
-		SELECT o.id, o.ordnumber, o.transdate, o.reqdate,
-			o.amount, c.legal_name AS name, o.netamount, o.entity_credit_account AS $form->{vc}_id,
-			ex.$rate AS exchangerate, o.closed, o.quonumber, 
-			o.shippingpoint, o.shipvia,
-			pe.first_name \|\| ' ' \|\| pe.last_name AS employee, 
-			pm.first_name \|\| ' ' \|\| pm.last_name AS manager, 
-			o.curr, o.ponumber, ct.meta_number, c.entity_id
-		FROM oe o
-		JOIN entity_credit_account ct ON (o.entity_credit_account = ct.id)
-		JOIN company c ON (c.entity_id = ct.entity_id)
-		LEFT JOIN person pe ON (o.person_id = pe.id)
-		LEFT JOIN entity_employee e ON (pe.entity_id = e.entity_id)
-		LEFT JOIN person pm ON (e.manager_id = pm.id)
-		LEFT JOIN entity_employee m ON (pm.entity_id = m.entity_id)
-		LEFT JOIN exchangerate ex 
-			ON (ex.curr = o.curr AND ex.transdate = o.transdate)
-		WHERE o.quotation = ?
-                      AND o.oe_class_id = ?
-		$department|;
-
-    my @queryargs = @dptargs;
-    unshift @queryargs, $form->{oe_class_id};
-    unshift @queryargs, $quotation;
-
-    my %ordinal = (
-        id        => 1,
-        ordnumber => 2,
-        transdate => 3,
-        reqdate   => 4,
-        name      => 6,
-        quonumber => 11,
-        shipvia   => 13,
-        employee  => 14,
-        manager   => 15,
-        curr      => 16,
-        ponumber  => 17
-    );
-
-    my @a = ( 'transdate', $ordnumber, 'name' );
-    push @a, "employee" if $form->{l_employee};
-    if ( $form->{type} !~ /(ship|receive)_order/ ) {
-        push @a, "manager" if $form->{l_manager};
-    }
-    my $sortorder = $form->sort_order( ..hidden.., \%ordinal );
-
-    # build query if type eq (ship|receive)_order
-    if ( $form->{type} =~ /(ship|receive)_order/ ) {
-
-        my ( $warehouse, $warehouse_id ) = split /--/, $form->{warehouse};
-
-        #HV alias company.ct changed to company.c
-        $query = qq|
-			SELECT DISTINCT o.id, o.ordnumber, o.transdate,
-				o.reqdate, o.amount, c.legal_name as name, 
-                                eca.meta_number, o.netamount, eca.entity_id,
-                                o.entity_credit_account as $form->{vc}_id, 
-                                ex.$rate AS exchangerate,
-		 		o.closed, o.quonumber, o.shippingpoint, 
-				o.shipvia, ee.name AS employee, o.curr, 
-				o.ponumber
-			FROM oe o
-			JOIN entity_credit_account eca  
-                             ON (o.entity_credit_account = eca.id)
-                        JOIN company c ON eca.entity_id = c.entity_id
-			JOIN orderitems oi ON (oi.trans_id = o.id)
-			JOIN parts p ON (p.id = oi.parts_id)|;
-
-        if ( $warehouse_id && $form->{type} eq 'ship_order' ) {
-            $query .= qq|
-				JOIN inventory i ON (oi.parts_id = i.parts_id)
-				|;
-        }
-
-        $query .= qq|
-                        LEFT JOIN person per ON per.id = o.person_id
-			LEFT JOIN entity_employee e ON (per.entity_id = e.entity_id)
-			LEFT JOIN entity ee ON (e.entity_id = ee.id)
-			LEFT JOIN exchangerate ex 
-				ON (ex.curr = o.curr 
-					AND ex.transdate = o.transdate)
-			WHERE o.quotation = '0'
-			AND (p.inventory_accno_id > 0 OR p.assembly = '1')
-			AND oi.qty != oi.ship
-                        AND o.oe_class_id = ?
-			$department|;
-        @queryargs = ( $form->{oe_class_id} );
-
-        if ( $warehouse_id && $form->{type} eq 'ship_order' ) {
-            $query .= qq| 
-				AND i.warehouse_id = ?
-				AND ( 
-					SELECT SUM(i.qty)
-					FROM inventory i
-					WHERE oi.parts_id = i.parts_id
-					AND i.warehouse_id = ? 
-				) > 0|;
-            push( @queryargs, $warehouse_id, $warehouse_id );
-        }
-
-    }
-
-    if ( $form->{"$form->{vc}_id"} ) {
-        $query .= qq| AND o.$form->{vc}_id = $form->{"$form->{vc}_id"}|;
-    }
-    elsif ( $form->{ $form->{vc} } ne "" ) {
-        $query .= " AND lower(c.legal_name) LIKE ?";
-        push @queryargs, $name;
-    }
-
-    if ( $form->{$ordnumber} ne "" ) {
-	$ordnumber = ($ordnumber eq 'ordnumber') ? 'ordnumber' : 'quonumber';
-        $query .= " AND lower($ordnumber) LIKE ?";
-        push @queryargs, $number;
-        $form->{open}   = 1;
-        $form->{closed} = 1;
-    }
-    if ( $form->{ponumber} ne "" ) {
-        $query .= " AND lower(ponumber) LIKE '%' || lower(?) || '%'";
-        push @queryargs, $form->{ponumber};
-    }
-
-    if ( !$form->{open} && !$form->{closed} ) {
-        $query .= " AND o.id = 0";
-    }
-    elsif ( !( $form->{open} && $form->{closed} ) ) {
-        $query .=
-          ( $form->{open} ) ? " AND o.closed = '0'" : " AND o.closed = '1'";
-    }
-
-    if ( $form->{shipvia} ne "" ) {
-        $var = $form->like( lc $form->{shipvia} );
-        $query .= " AND lower(o.shipvia) LIKE ?";
-        push @queryargs, $var;
-    }
-
-    if ( $form->{description} ne "" ) {
-        $var = $dbh->quote($form->like( lc $form->{description} ));
-        $query .= " AND o.id IN (SELECT DISTINCT trans_id
-                             FROM orderitems
-			     WHERE lower(description) LIKE $var)";
-    }
-
-    if ( $form->{transdatefrom} ) {
-        $query .= " AND o.transdate >= ?";
-        push @queryargs, $form->{transdatefrom};
-    }
-    if ( $form->{transdateto} ) {
-        $query .= " AND o.transdate <= ?";
-        push @queryargs, $form->{transdateto};
-    }
-
-    $query .= " ORDER by $sortorder";
-
-    my $sth = $dbh->prepare($query);
-    $sth->execute(@queryargs) || $form->dberror($query);
-
-    my %oid = ();
-    while ( my $ref = $sth->fetchrow_hashref(NAME_lc) ) {
-	$form->db_parse_numeric(sth=>$sth, hashref=>$ref);
-        $ref->{exchangerate} = 1 unless $ref->{exchangerate};
-        if ( $ref->{id} != $oid{id}{ $ref->{id} } ) {
-            push @{ $form->{OE} }, $ref;
-            $oid{vc}{ $ref->{curr} }{ $ref->{"$form->{vc}_id"} }++;
-        }
-        $oid{id}{ $ref->{id} } = $ref->{id};
-    }
-    $sth->finish;
-
-    $dbh->commit;
-
-    if ( $form->{type} =~ /^consolidate_/ ) {
-        @a = ();
-        foreach $ref ( @{ $form->{OE} } ) {
-            push @a, $ref
-              if $oid{vc}{ $ref->{curr} }{ $ref->{"$form->{vc}_id"} } > 1;
-        }
-
-        @{ $form->{OE} } = @a;
-    }
-
-}
-
 sub save {
     my ( $self, $myconfig, $form ) = @_;
   

Added: trunk/LedgerSMB/Report/Orders.pm
===================================================================
--- trunk/LedgerSMB/Report/Orders.pm	                        (rev 0)
+++ trunk/LedgerSMB/Report/Orders.pm	2012-12-19 07:33:27 UTC (rev 5382)
@@ -0,0 +1,328 @@
+=head1 NAME
+
+LedgerSMB::Report::Orders - Search for Orders and Quotations in LedgerSMB
+
+=head1 SYNPOSIS
+
+ my $report = LedgerSMB::Report::Orders->new(%$request);
+ $report->render($request);
+
+=cut
+
+package LedgerSMB::Report::Orders;
+use Moose;
+extends 'LedgerSMB::Report';
+with 'LedgerSMB::Report::Dates';
+use LedgerSMB::MooseTypes;
+
+=head1 DESCRIPTION
+
+This module produces a search report for LedgerSMB.  This differs very slightly
+from some other reports in that the buttons are typically assigned by controller
+scripts as this report serves number of different roles.
+
+=head1 CRITERIA PROPERTIES
+
+=over
+
+=item oe_class_id int
+
+This is the ID of the order entry class.  Valid values are:
+ 
+  id |    oe_class    
+ ----+----------------
+   1 | Sales Order
+   2 | Purchase Order
+   3 | Quotation
+   4 | RFQ
+
+=cut
+
+has oe_class_id => (is => 'ro', isa => 'Int', required => 1);
+
+=item open bool
+
+If set, show open orders in the report
+
+=cut
+
+has open => (is => 'ro', isa => 'Bool', required => 0);
+
+=item closed bool
+
+If set show closed orders in report.  Note that if both open and closed are
+unset, the report will not return any results.
+
+=cut
+
+has closed  => (is => 'ro', isa => 'Bool', required => 0);
+
+=item shippable bool
+
+If set only show orders which can be shipped or received
+
+=cut
+
+has shippable => (is => 'ro', isa => 'Bool', required => 0);
+
+=item meta_number string
+
+This is a prefix search for the customer or vendor number.
+
+=cut
+
+has meta_number => (is => 'ro', isa => 'Str', required => '0');
+
+=item legal_name string
+
+This is a full text search for customer or vendor entity name
+
+=cut
+
+has legal_name => (is => 'ro', isa => 'Str', required => '0');
+
+=item ponumber string
+
+Prefix search on the ponumber field
+
+=cut
+
+has ponumber => (is => 'ro', isa => 'Str', required => '0');
+
+=item ordnumber string
+
+Prefix search on order number field
+
+=cut
+
+has ordnumber => (is => 'ro', isa => 'Str', required => '0');
+
+=item shipvia string
+
+Full text on ship via field
+
+=cut
+
+has shipvia => (is => 'ro', isa => 'Str', required => '0');
+
+=item description text
+
+Full text search on line item description
+
+=cut
+
+has description => (is => 'ro', isa => 'Str', required => '0');
+
+=item href_action string
+
+Sets the href action for the ordnumber field
+
+=cut
+
+has href_action => (is => 'ro', isa => 'Str', required => '0');
+
+=item selectable bool 
+
+If set true, then the display will include a checkbox for each order and a 
+hidden id field.
+
+=cut
+
+has selectable => (is => 'ro', isa => 'Bool', required => 0);
+
+=back
+
+=head1 INTERNALS
+
+=head2 columns
+
+=over
+
+=item id
+
+=item ordnumber
+
+=item transdate
+
+=item reqdate
+
+=item amount
+
+=item legal_name
+
+=item closed
+
+=item quonumber
+
+=item shippingpoint
+
+=item exchangerate
+
+=item shipvia
+
+=item employee
+
+=item manager
+
+=item curr
+
+=item ponumber
+
+=item meta_number
+
+=item entity_id
+
+=back
+
+If $self->selectable is set, we also prepend a selected field to the front, and an id hidden field.
+
+=cut
+
+sub columns {
+    my ($self) = @_;
+    my $ORDNUMBER;
+    my $METANUMBER;
+    if (1 == $self->oe_class_id){ 
+       $ORDNUMBER = LedgerSMB::Report::text('Sales Orders');
+       $METANUMBER = LedgerSMB::Report::text('Customer');
+    } elsif (2 == $self->oe_class_id){
+       $ORDNUMBER = LedgerSMB::Report::text('Purchase Orders');
+       $METANUMBER = LedgerSMB::Report::text('Vendor');
+    } elsif (3 == $self->oe_class_id){
+       $ORDNUMBER = LedgerSMB::Report::text('Quotations');
+       $METANUMBER = LedgerSMB::Report::text('Customer');
+    } elsif (4 == $self->oe_class_id){
+       $ORDNUMBER = LedgerSMB::Report::text('RFQs');
+       $METANUMBER = LedgerSMB::Report::text('Vendor');
+    } else {
+        die 'Unsupported OE Class Type';
+    }
+    my $HREF_ACTION = 'edit';
+    $HREF_ACTION = $self->href_action if $self->href_action;
+    my $cols = [
+       {col_id => 'id',
+          name => LedgerSMB::Report::text('ID'),
+          type => 'text', },
+
+       {col_id => 'transdate',
+          name => LedgerSMB::Report::text('Date'),
+          type => 'text', },
+
+       {col_id => 'ordnumber',
+          name => $ORDNUMBER,
+          type => 'href',
+     href_base => "oe.pl?action=$HREF_ACTION&id=", },
+
+       {col_id => 'reqdate',
+          name => LedgerSMB::Report::text('Required Date'),
+          type => 'text', },
+
+       {col_id => 'meta_number',
+          name => $METANUMBER,
+          type => 'text', } ,
+
+       {col_id => 'legal_name',
+          name => LedgerSMB::Report::text('Name'),
+          type => 'text', },
+
+       {col_id => 'amount',
+          name => LedgerSMB::Report::text('Amount'),
+          type => 'text', },
+
+       {col_id => 'curr',
+          name => LedgerSMB::Report::text('Currency'),
+          type => 'text', },
+
+       {col_id => 'Closed',
+          name => LedgerSMB::Report::text('Closed'),
+          type => 'text', },
+
+       {col_id => 'ponumber',
+          name => LedgerSMB::Report::text('PO Number'),
+          type => 'text', },
+
+       {col_id => 'quonumber',
+          name => LedgerSMB::Report::text('Quotation'),
+          type => 'text', },
+
+       {col_id => 'shippingpoint',
+          name => LedgerSMB::Report::text('Shipping Point'),
+          type => 'text', },
+
+       {col_id => 'shipvia',
+          name => LedgerSMB::Report::text('Ship Via'),
+          type => 'text', },
+
+       {col_id => 'employee',
+          name => LedgerSMB::Report::text('Employee'),
+          type => 'text', },
+
+       {col_id => 'manager',
+          name => LedgerSMB::Report::text('Manager'),
+          type => 'text', },
+    ];
+    if ($self->selectable){
+        unshift @$cols, 
+       {col_id => 'id',
+          type => 'hidden', },
+       {col_id => 'selected',
+          type => 'checkbox',
+          name => LedgerSMB::Report::text('Selected')};
+    }
+    return $cols;
+}
+
+=head2 header_lines
+
+=cut 
+
+sub header_lines {
+    return [];
+}
+
+=head2 name 
+
+=cut
+
+sub name {
+    my ($self) = @_;
+    if (1 == $self->oe_class_id){ 
+       return LedgerSMB::Report::text('Sales Orders');
+    } elsif (2 == $self->oe_class_id){
+       return LedgerSMB::Report::text('Purchase Orders');
+    } elsif (3 == $self->oe_class_id){
+       return LedgerSMB::Report::text('Quotations');
+    } elsif (4 == $self->oe_class_id){
+       return LedgerSMB::Report::text('RFQs');
+    } else {
+        die 'Unsupported OE Class Type';
+    }
+};
+
+=head1 METHODS
+
+=head2 run_report
+
+This sets the $report->rows attribute but does not set buttons.  The calling 
+script should do that separately.
+
+=cut
+
+sub run_report {
+    my ($self) = @_;
+    my @rows = $self->exec_method({funcname => 'order__search'});
+    for my $r(@rows){
+       $r->{row_id} = $r->{id};
+    }
+    $self->rows(..hidden..);
+}
+
+=head1 COPYRIGHT
+
+COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
+terms of the LedgerSMB General Public License version 2 or at your option any
+later version.  Please see enclosed LICENSE file for details.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;

Added: trunk/LedgerSMB/Scripts/order.pm
===================================================================
--- trunk/LedgerSMB/Scripts/order.pm	                        (rev 0)
+++ trunk/LedgerSMB/Scripts/order.pm	2012-12-19 07:33:27 UTC (rev 5382)
@@ -0,0 +1,105 @@
+=head1 NAME
+
+LedgerSMB::Scripts::order - Order search functions for LedgerSMB
+
+=head1 SYNPOSIS
+
+  LedgerSMB::Scripts::order->get_criteria($request);
+
+=head1 DESCRIPTION
+
+This module contains the routines needed to search for orders, whether for 
+shipping or receiving, merging several orders into one, or the like.
+
+=cut
+
+package LedgerSMB::Scripts::order;
+use LedgerSMB::App_State;
+use LedgerSMB::Scripts::reports;
+use LedgerSMB::Report::Orders;
+
+=head1 ROUTINES
+
+=over
+
+=item get_criteria
+
+Expects "search_type" and "oe_class_id" to be set.  Any other properties of 
+LedgerSMB::Report::Orders can be set here and will act as defaults.
+
+Search type can be one of
+
+=over
+
+=item search (valid for all types)
+
+=item combine (valid for sales/purchase orders only at this time)
+
+=item generate (valid for sales/purchase orders only)
+
+=back
+
+=cut
+
+sub get_criteria {
+    my ($request) = @_;
+    my $locale = $LedgerSMB::App_State::Locale;
+    $request->{entity_class} = $request->{oe_class_id} % 2 + 1;
+    $request->{report_name} = 'orders';
+    if ($request->{oe_class_id} == 1){
+        if ($request->{search_type} eq 'search'){
+            $request->{title} = $locale->text('Search Sales Orders');
+        } elsif ($request->{search_type} eq 'generate'){
+            $request->{title} = 
+                   $locale->text('Generate Sales Orders from Purchase Orders');
+        } elsif ($request->{search_type} eq 'combine'){
+            $request->{title} = $locale->text('Combine Sales Orders');
+        } elsif ($request->{search_type} eq 'ship'){
+            $request->{title} = $locale->text('Ship');
+        }
+    } elsif ($request->{oe_class_id} == 2){
+        if ($request->{search_type} eq 'search'){
+            $request->{title} = $locale->text('Search Purchase Orders');
+        } elsif ($request->{search_type} eq 'generate'){
+            $request->{title} = 
+                   $locale->text('Generate Purchase Orders from Sales Orders');
+        } elsif ($request->{search_type} eq 'ship'){
+            $request->{title} = $locale->text('Receive');
+        }
+    } elsif ($request->{oe_class_id} == 3){
+        if ($request->{search_type} eq 'search'){
+            $request->{title} = $locale->text('Search Quotations');
+        } 
+    } elsif ($request->{oe_class_id} == 4){
+        if ($request->{search_type} eq 'search'){
+            $request->{title} = $locale->text('Search Requests for Quotation');
+        } 
+    }
+    LedgerSMB::Scripts::reports::start_report($request);
+}
+
+=item search
+
+=cut
+
+sub search {
+    my $request = shift @_;
+    if ($request->{search_type} eq 'combine' 
+         or $request->{search_type} eq 'generate'){
+       $request->{selectable} = 1;
+    }
+    my $report = LedgerSMB::Report::Orders->new(%$request);
+    $report->render(%request);
+}
+
+=back
+
+=head1 COPYRIGHT
+
+COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be re-used under the
+terms of the LedgerSMB General Public License version 2 or at your option any
+later version.  Please see enclosed LICENSE file for details.
+
+=cut
+
+1;

Added: trunk/UI/Reports/filters/orders.html
===================================================================
--- trunk/UI/Reports/filters/orders.html	                        (rev 0)
+++ trunk/UI/Reports/filters/orders.html	2012-12-19 07:33:27 UTC (rev 5382)
@@ -0,0 +1,217 @@
+<?lsmb INCLUDE 'ui-header.html';
+       PROCESS 'report_base.html';
+       PROCESS 'elements.html'; 
+       IF entity_class == 1;
+           CV = text('Vendor');
+           ECA = text('Vendor Name'); #'
+       ELSE;
+           CV = text('Customer');
+           ECA = text('Customer Name'); #'
+       END;
+?>
+
+<body>
+<div class="listtop"><?lsmb title ?></div>
+<form action="order.pl" method="get">
+<table class="form">
+  <tr>
+    <th><?lsmb ECA ?></th>
+    <td colspan="2"><?lsmb PROCESS input element_data = {
+        name = 'entity_name'
+        type = 'text'
+       class = "name"
+       value = entity_name
+        size = 32
+    } ?></td>
+  </tr>
+  <tr>
+    <th><?lsmb text('Account') ?></th>
+    <td><?lsmb  PROCESS input element_data = {
+        name = 'meta_number'
+        size = 16
+       class = 'control-code'
+        type = 'text'
+       value = meta_number
+    } ?></td>
+  </tr>
+  <tr>
+    <th><?lsmb text('Order Number') ?></th>
+    <td><?lsmb  PROCESS input element_data = {
+        name = 'ordnumber'
+        size = 16
+       class = 'control-code'
+        type = 'text'
+       value = ordnumber
+    } ?></td>
+  </tr>
+  <tr>
+    <th><?lsmb text('PO Number') ?></th>
+    <td><?lsmb  PROCESS input element_data = {
+        name = 'ponumber'
+        size = 16
+       class = 'control-code'
+        type = 'text'
+       value = ponumber
+    } ?></td>
+  </tr>
+  <tr>
+    <th><?lsmb text('Ship Via') ?></th>
+    <td colspan="2"><?lsmb  PROCESS input element_data = {
+        name = 'shipvia'
+        size = 32
+       class = 'info'
+        type = 'text'
+       value = shipvia
+    } ?></td>
+  </tr>
+  <tr>
+    <th><?lsmb text('Description') ?></th>
+    <td colspan="2"><?lsmb  PROCESS input element_data = {
+        name = 'description'
+        size = 32
+       class = 'description'
+        type = 'text'
+       value = description
+    } ?></td>
+  </tr>
+  <?lsmb PROCESS date_row; label_pos = 1 ?>
+  <tr>
+  <th colspan="5" class="centered"><?lsmb text('Include in Report') ?></th>
+  </tr>
+  <tr>
+  <td>&nbsp;</td>
+  <td colspan="4"><table>
+      <?lsmb IF !open ?>
+      <tr>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'open'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = text('Open')
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'closed'
+             type = 'checkbox'
+            value = '1'
+            label = text('Closed')
+         } ?></td>
+      </tr>
+      <?lsmb END ?>
+      <tr>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_running_number'
+             type = 'checkbox'
+            value = '1'
+            label = text('No.')
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_id'
+             type = 'checkbox'
+            value = '1'
+            label = text('ID')
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_ordnumber'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = text('Order Number') #'
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_transdate'
+             type = 'checkbox'
+            value = '1'
+            label = text('Date')
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_ponumber'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = text('PO Number') #'
+         } ?></td>
+      </tr>
+      <tr>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_reqdate'
+          checked = 'CHECKED' 
+             type = 'checkbox'
+            value = '1'
+            label = text('Required By') #'
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_id'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = CV
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_meta_number'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = text('Account')
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_shipvia'
+             type = 'checkbox'
+            value = '1'
+            label = text('Ship Via') #'
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_amount'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = text('Amount') 
+         } ?></td>
+      </tr>
+      <tr>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_tax'
+             type = 'checkbox'
+            value = '1'
+            label = text('Tax')
+         } ?></td>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'col_curr'
+             type = 'checkbox'
+          checked = 'CHECKED' 
+            value = '1'
+            label = text('Currency')
+         } ?></td>
+      </tr>
+      <tr>
+         <td><?lsmb PROCESS input element_data = {
+             name = 'subtotal'
+             type = 'checkbox'
+            value = '1'
+            label = text('Subtotal')
+         } ?></td>
+      </tr>
+      </table></td>
+</table>
+<hr />
+<?lsmb PROCESS button element_data = {
+    text = text('Continue')
+    name = 'action'
+   value = 'search'
+   class = 'submit'
+    type = 'submit'
+};
+PROCESS input element_data = {
+    type = 'hidden'
+    name = 'search_type'
+   value = search_type
+};
+PROCESS input element_data = {
+    type = 'hidden'
+    name = 'oe_class_id'
+   value = oe_class_id
+} ?>
+
+</form>
+</body>
+</html>

Modified: trunk/bin/oe.pl
===================================================================
--- trunk/bin/oe.pl	2012-12-18 09:15:29 UTC (rev 5381)
+++ trunk/bin/oe.pl	2012-12-19 07:33:27 UTC (rev 5382)
@@ -1214,1015 +1214,6 @@
 
 }
 
-sub search {
-
-    $requiredby = $locale->text('Required by');
-
-    if ( $form->{type} eq 'purchase_order' ) {
-        $form->{title}       = $locale->text('Purchase Orders');
-        $form->{vc}          = 'vendor';
-        $ordlabel            = $locale->text('Order Number');
-        $ordnumber           = 'ordnumber';
-        $employee            = $locale->text('Employee');
-        $form->{oe_class_id} = 2;
-    }
-
-    if ( $form->{type} eq 'receive_order' ) {
-        $form->{title} = $locale->text('Receive Merchandise');
-        $form->{vc}    = 'vendor';
-        $ordlabel      = $locale->text('Order Number');
-        $ordnumber     = 'ordnumber';
-        $employee      = $locale->text('Employee');
-        $form->{oe_class_id} = 2;
-    }
-
-    if ( $form->{type} eq 'generate_sales_order' ) {
-        $form->{title}       =
-          $locale->text('Generate Sales Order from Purchase Orders');
-        $form->{vc}          = 'vendor';
-        $ordlabel            = $locale->text('Order Number');
-        $ordnumber           = 'ordnumber';
-        $employee            = $locale->text('Employee');
-        $form->{oe_class_id} = 2;
-    }
-
-    if ( $form->{type} eq 'consolidate_sales_order' ) {
-        $form->{title}       = $locale->text('Consolidate Sales Orders');
-        $form->{vc}          = 'customer';
-        $ordlabel            = $locale->text('Order Number');
-        $ordnumber           = 'ordnumber';
-        $employee            = $locale->text('Salesperson');
-        $form->{oe_class_id} = 1;
-    }
-
-    if ( $form->{type} eq 'request_quotation' ) {
-        $form->{title}       = $locale->text('Request for Quotations');
-        $form->{vc}          = 'vendor';
-        $ordlabel            = $locale->text('RFQ Number');
-        $ordnumber           = 'quonumber';
-        $employee            = $locale->text('Employee');
-        $form->{oe_class_id} = 4;
-    }
-
-    if ( $form->{type} eq 'sales_order' ) {
-        $form->{title}       = $locale->text('Sales Orders');
-        $form->{vc}          = 'customer';
-        $ordlabel            = $locale->text('Order Number');
-        $ordnumber           = 'ordnumber';
-        $employee            = $locale->text('Salesperson');
-        $form->{oe_class_id} = 1;
-    }
-
-    if ( $form->{type} eq 'ship_order' ) {
-        $form->{title} = $locale->text('Ship Merchandise');
-        $form->{vc}    = 'customer';
-        $ordlabel      = $locale->text('Order Number');
-        $ordnumber     = 'ordnumber';
-        $employee      = $locale->text('Salesperson');
-        $form->{oe_class_id} = 1;
-    }
-
-    if ( $form->{type} eq 'sales_quotation' ) {
-        $form->{title}       = $locale->text('Quotations');
-        $form->{vc}          = 'customer';
-        $ordlabel            = $locale->text('Quotation Number');
-        $ordnumber           = 'quonumber';
-        $employee            = $locale->text('Employee');
-        $requiredby          = $locale->text('Valid until');
-        $form->{oe_class_id} = 3;
-    }
-
-    if ( $form->{type} eq 'generate_purchase_order' ) {
-        $form->{title}       =
-          $locale->text('Generate Purchase Orders from Sales Order');
-        $form->{vc}          = 'customer';
-        $ordlabel            = $locale->text('Order Number');
-        $ordnumber           = 'ordnumber';
-        $employee            = $locale->text('Salesperson');
-        $form->{oe_class_id} = 1;
-    }
-
-    if ( $form->{type} eq 'consolidate_purchase_order' ) {
-        $form->{title}       = $locale->text('Consolidate Purchase Orders');
-        $form->{vc}          = 'vendor';
-        $ordlabel            = $locale->text('Order Number');
-        $ordnumber           = 'ordnumber';
-        $employee            = $locale->text('Employee');
-        $form->{oe_class_id} = 2;
-    }
-
-    $l_employee =
-qq|<input name="l_employee" class=checkbox type=checkbox value=Y> $employee|;
-    $l_manager =
-      qq|<input name="l_manager" class=checkbox type=checkbox value=Y> |
-      . $locale->text('Manager');
-
-    if ( $form->{type} =~ /(ship|receive)_order/ ) {
-        OE->get_warehouses( \%myconfig, \%$form );
-
-        $l_manager = "";
-
-        # warehouse
-        if ( @{ $form->{all_warehouse} } ) {
-            $form->{selectwarehouse} = "<option>\n";
-            $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
-
-            for ( @{ $form->{all_warehouse} } ) {
-                $form->{selectwarehouse} .=
-qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
-            }
-
-            $warehouse = qq|
-	      <tr>
-		<th align=right>| . $locale->text('Warehouse') . qq|</th>
-		<td><select name=warehouse>$form->{selectwarehouse}</select></td>
-		<input type=hidden name=selectwarehouse value="|
-              . $form->escape( $form->{selectwarehouse}, 1 ) . qq|">
-	      </tr>
-|;
-
-        }
-    }
-
-    $selectemployee = "";
-    if ( @{ $form->{all_employee} } ) {
-        $selectemployee = "<option>\n";
-        for ( @{ $form->{all_employee} } ) {
-            $selectemployee .=
-              qq|<option value="$_->{name}--$_->{id}">$_->{name}\n|;
-        }
-
-        $selectemployee = qq|
-      <tr>
-	<th align=right>$employee</th>
-	<td colspan=3><select name=employee>$selectemployee</select></td>
-      </tr>
-|;
-    }
-    else {
-        $l_employee = $l_manager = "";
-    }
-
-    $vclabel = ucfirst $form->{vc};
-    $vclabel = $locale->text($vclabel);
-
-    # $locale->text('Vendor')
-    # $locale->text('Customer')
-
-    $vc =
-      ($vc)
-      ? qq|<select name=$form->{vc}><option>\n$vc</select>|
-      : qq|<input name=$form->{vc} size=35>|;
-
-    # departments
-    $form->all_departments();
-    if ( @{ $form->{all_department} } ) {
-        $form->{selectdepartment} = "<option>\n";
-
-        for ( @{ $form->{all_department} } ) {
-            $form->{selectdepartment} .=
-qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
-        }
-    }
-
-    $department = qq|  
-        <tr>  
-	  <th align=right nowrap>| . $locale->text('Department') . qq|</th>
-	  <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
-	</tr>
-| if $form->{selectdepartment};
-
-    if ( $form->{type} =~ /(consolidate.*|generate.*|ship|receive)_order/ ) {
-
-        $openclosed = qq|
-	        <input type=hidden name="open" value=1>
-|;
-
-    }
-    else {
-
-        $openclosed = qq|
-	      <tr>
-	        <td nowrap><input name="open" class=checkbox type=checkbox value=1 checked> |
-          . $locale->text('Open')
-          . qq|</td>
-	        <td nowrap><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
-          . $locale->text('Closed')
-          . qq|</td>
-	      </tr>
-|;
-    }
-
-    if ( @{ $form->{all_years} } ) {
-
-        # accounting years
-        $form->{selectaccountingyear} = "<option>\n";
-        for ( @{ $form->{all_years} } ) {
-            $form->{selectaccountingyear} .= qq|<option>$_\n|;
-        }
-        $form->{selectaccountingmonth} = "<option>\n";
-        for ( sort keys %{ $form->{all_month} } ) {
-            $form->{selectaccountingmonth} .=
-              qq|<option value=$_>|
-              . $locale->text( $form->{all_month}{$_} ) . qq|\n|;
-        }
-
-        $selectfrom = qq|
-        <tr>
-	<th align=right>| . $locale->text('Period') . qq|</th>
-	<td colspan=3>
-	<select name=month>$form->{selectaccountingmonth}</select>
-	<select name=year>$form->{selectaccountingyear}</select>
-	<input name=interval class=radio type=radio value=0 checked>&nbsp;|
-          . $locale->text('Current') . qq|
-	<input name=interval class=radio type=radio value=1>&nbsp;|
-          . $locale->text('Month') . qq|
-	<input name=interval class=radio type=radio value=3>&nbsp;|
-          . $locale->text('Quarter') . qq|
-	<input name=interval class=radio type=radio value=12>&nbsp;|
-          . $locale->text('Year') . qq|
-	</td>
-      </tr>
-|;
-    }
-
-    if ( $form->{type} =~ /_order/ ) {
-        $ponumber = qq|
-        <tr>
-          <th align=right>| . $locale->text('PO Number') . qq|</th>
-          <td colspan=3><input name="ponumber" size=20></td>
-        </tr>
-|;
-
-        $l_ponumber =
-          qq|<input name="l_ponumber" class=checkbox type=checkbox value=Y> |
-          . $locale->text('PO Number');
-    }
-
-    @a = ();
-    push @a,
-      qq|<input name="l_runningnumber" class=checkbox type=checkbox value=Y> |
-      . $locale->text('No.');
-    push @a, qq|<input name="l_id" class=checkbox type=checkbox value=Y> |
-      . $locale->text('ID');
-    push @a,
-qq|<input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel|;
-    push @a,
-qq|<input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
-      . $locale->text('Date');
-    push @a, $l_ponumber if $l_ponumber;
-    push @a,
-qq|<input name="l_reqdate" class=checkbox type=checkbox value=Y checked> $requiredby|;
-    push @a,
-qq|<input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel|;
-    push @a,
-    qq|<input name="l_meta_number" class=checkbox type=checkbox value=Y checked>| . $locale->text('Number');
-    push @a, $l_employee if $l_employee;
-    push @a, $l_manager  if $l_manager;
-    push @a, qq|<input name="l_shipvia" class=checkbox type=checkbox value=Y> |
-      . $locale->text('Ship via');
-    push @a,
-      qq|<input name="l_netamount" class=checkbox type=checkbox value=Y> |
-      . $locale->text('Amount');
-    push @a, qq|<input name="l_tax" class=checkbox type=checkbox value=Y> |
-      . $locale->text('Tax');
-    push @a,
-      qq|<input name="l_amount" class=checkbox type=checkbox value=Y checked> |
-      . $locale->text('Total');
-    push @a,
-      qq|<input name="l_curr" class=checkbox type=checkbox value=Y checked> |
-      . $locale->text('Currency');
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>
-      <table>
-        <tr>
-          <th align=right>$vclabel</th>
-          <td colspan=3>$vc</td>
-        </tr>
-	$warehouse
-	$department
-	$selectemployee
-        <tr>
-          <th align=right>$ordlabel</th>
-          <td colspan=3><input name="$ordnumber" size=20></td>
-        </tr>
-	$ponumber
-        <tr>
-          <th align=right>| . $locale->text('Ship via') . qq|</th>
-          <td colspan=3><input name="shipvia" size=40></td>
-        </tr>
-        <tr>
-          <th align=right>| . $locale->text('Description') . qq|</th>
-          <td colspan=3><input name="description" size=40></td>
-        </tr>
-        <tr>
-          <th align=right>| . $locale->text('From') . qq|</th>
-          <td><input class="date" name=transdatefrom size=11 title="$myconfig{dateformat}"></td>
-          <th align=right>| . $locale->text('To') . qq|</th>
-          <td><input class="date" name=transdateto size=11 title="$myconfig{dateformat}"></td>
-        </tr>
-        <input type=hidden name=sort value=transdate>
-	$selectfrom
-        <tr>
-          <th align=right>| . $locale->text('Include in Report') . qq|</th>
-          <td colspan=3>
-	    <table>
-	      $openclosed
-|;
-
-    while (@a) {
-        for ( 1 .. 5 ) {
-            print qq|<td nowrap>| . shift @a;
-            print qq|</td>\n|;
-        }
-        print qq|</tr>\n|;
-    }
-
-    print qq|
-	      <tr>
-	        <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
-      . $locale->text('Subtotal')
-      . qq|</td>
-	      </tr>
-	    </table>
-          </td>
-        </tr>
-      </table>
-    </td>
-  </tr>
-  <tr><td colspan=4><hr size=3 noshade></td></tr>
-</table>
-
-<br>
-<input type=hidden name=nextsub value=transactions>
-|;
-
-    $form->hide_form(qw(path login sessionid vc type oe_class_id));
-
-    print qq|
-<button class="submit" type="submit" name="action" value="continue">|
-      . $locale->text('Continue')
-      . qq|</button>
-</form>
-|;
-
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
-
-    print qq|
-
-</body>
-</html>
-|;
-
-}
-
-sub transactions {
-
-    # split vendor / customer
-    ( $form->{ $form->{vc} }, $form->{"$form->{vc}_id"} ) =
-      split( /--/, $form->{ $form->{vc} } );
-
-    OE->transactions( \%myconfig, \%$form );
-
-    $ordnumber = ( $form->{type} =~ /_order/ ) ? 'ordnumber' : 'quonumber';
-    $name = $form->escape( $form->{ $form->{vc} } );
-    $name .= qq|--$form->{"$form->{vc}_id"}| if $form->{"$form->{vc}_id"};
-
-    if ($form->{vc} eq 'customer') {
-	$account_class = 2;
-    } elsif ($form->{vc} eq 'vendor') {
-	$account_class = 1;
-    } else {
-	### fixme: invalid VC type
-    }
-
-    # construct href
-    $href = qq|$form->{script}?action=transactions|;
-    for (
-        "oldsort",     "direction", "path",      "type",
-        "vc",          "login",     "sessionid", "transdatefrom",
-        "transdateto", "open",      "closed"
-      )
-    {
-        $href .= qq|&$_=$form->{$_}|;
-    }
-    for (
-        "$ordnumber", "department",  "warehouse", "shipvia",
-        "ponumber",   "description", "employee"
-      )
-    {
-        $href .= qq|&$_=| . $form->escape( $form->{$_} );
-    }
-    $href .= "&$form->{vc}=$name";
-
-    # construct callback
-    $name = $form->escape( $form->{ $form->{vc} }, 1 );
-    $name .= qq|--$form->{"$form->{vc}_id"}| if $form->{"$form->{vc}_id"};
-
-    # flip direction
-    $form->sort_order();
-
-    $callback = qq|$form->{script}?action=transactions|;
-    for (
-        "oldsort",     "direction", "path",      "type",
-        "vc",          "login",     "sessionid", "transdatefrom",
-        "transdateto", "open",      "closed", "oe_class_id"
-      )
-    {
-        $callback .= qq|&$_=$form->{$_}|;
-    }
-    for (
-        "$ordnumber", "department",  "warehouse", "shipvia",
-        "ponumber",   "description", "employee"
-      )
-    {
-        $callback .= qq|&$_=| . $form->escape( $form->{$_}, 1 );
-    }
-    $callback .= "&$form->{vc}=$name";
-
-    @columns = $form->sort_columns(
-        "transdate", "reqdate", "id",        "$ordnumber",
-        "ponumber",  "name",    "meta_number", "netamount", "tax",
-        "amount",    "curr",    "employee",  "manager",
-        "shipvia",   "open",    "closed"
-    );
-    unshift @columns, "runningnumber";
-
-    $form->{l_open} = $form->{l_closed} = "Y"
-      if ( $form->{open} && $form->{closed} );
-
-    for (@columns) {
-        if ( $form->{"l_$_"} eq "Y" ) {
-            push @column_index, $_;
-
-            if ( $form->{l_curr} && $_ =~ /(amount|tax)/ ) {
-                push @column_index, "fx_$_";
-            }
-
-            # add column to href and callback
-            $callback .= "&l_$_=Y";
-            $href     .= "&l_$_=Y";
-        }
-    }
-
-    if ( $form->{l_subtotal} eq 'Y' ) {
-        $callback .= "&l_subtotal=Y";
-        $href     .= "&l_subtotal=Y";
-    }
-
-    $requiredby = $locale->text('Required by');
-
-    $i = 1;
-    if ( $form->{vc} eq 'vendor' ) {
-        if ( $form->{type} eq 'receive_order' ) {
-            $form->{title} = $locale->text('Receive Merchandise');
-        }
-        if ( $form->{type} eq 'purchase_order' ) {
-            $form->{title} = $locale->text('Purchase Orders');
-            if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
-                $button{'Order Entry--Purchase Order'}{code} =
-qq|<button class="submit" type="submit" name="action" value="purchase_order">|
-                  . $locale->text('Purchase Order')
-                  . qq|</button> |;
-                $button{'Order Entry--Purchase Order'}{order} = $i++;
-            }
-        }
-        if ( $form->{type} eq 'generate_sales_order' ) {
-            $form->{title} = $locale->text('Purchase Orders');
-            $form->{type}  = "purchase_order";
-            unshift @column_index, "ndx";
-            if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
-                $button{'Order Entry--Sales Order'}{code} =
-qq|<button class="submit" type="submit" name="action" value="generate_sales_order">|
-                  . $locale->text('Generate Sales Order')
-                  . qq|</button> |;
-                $button{'Order Entry--Sales Order'}{order} = $i++;
-            }
-        }
-        if ( $form->{type} eq 'consolidate_purchase_order' ) {
-            $form->{title} = $locale->text('Purchase Orders');
-            $form->{type}  = "purchase_order";
-            unshift @column_index, "ndx";
-            if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
-                $button{'Order Entry--Purchase Order'}{code} =
-qq|<button class="submit" type="submit" name="action" value="consolidate_orders">|
-                  . $locale->text('Consolidate Orders')
-                  . qq|</button> |;
-                $button{'Order Entry--Purchase Order'}{order} = $i++;
-            }
-        }
-
-        if ( $form->{type} eq 'request_quotation' ) {
-            $form->{title} = $locale->text('Request for Quotations');
-            $quotation = $locale->text('RFQ');
-
-            if ( $myconfig{acs} !~ /Quotations--Quotations/ ) {
-                $button{'Quotations--RFQ'}{code} =
-qq|<button class="submit" type="submit" name="action" value="add">|
-                  . $locale->text('RFQ')
-                  . qq|</button> |;
-                $button{'Quotations--RFQ'}{order} = $i++;
-            }
-
-        }
-        $name     = $locale->text('Vendor');
-        $employee = $locale->text('Employee');
-    }
-    if ( $form->{vc} eq 'customer' ) {
-        if ( $form->{type} eq 'sales_order' ) {
-            $form->{title} = $locale->text('Sales Orders');
-            $employee = $locale->text('Salesperson');
-
-            if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
-                $button{'Order Entry--Sales Order'}{code} =
-qq|<button class="submit" type="submit" name="action" value="sales_order">|
-                  . $locale->text('Sales Order')
-                  . qq|</button> |;
-                $button{'Order Entry--Sales Order'}{order} = $i++;
-            }
-
-        }
-        if ( $form->{type} eq 'generate_purchase_order' ) {
-            $form->{title} = $locale->text('Sales Orders');
-            $form->{type}  = "sales_order";
-            $employee      = $locale->text('Salesperson');
-            unshift @column_index, "ndx";
-            if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
-                $button{'Order Entry--Purchase Order'}{code} =
-qq|<button class="submit" type="submit" name="action" value="generate_purchase_orders">|
-                  . $locale->text('Generate Purchase Orders')
-                  . qq|</button> |;
-                $button{'Order Entry--Purchase Order'}{order} = $i++;
-            }
-        }
-        if ( $form->{type} eq 'consolidate_sales_order' ) {
-            $form->{title} = $locale->text('Sales Orders');
-            $form->{type}  = "sales_order";
-            unshift @column_index, "ndx";
-            if ( $myconfig{acs} !~ /Order Entry--Order Entry/ ) {
-                $button{'Order Entry--Sales Order'}{code} =
-qq|<button class="submit" type="submit" name="action" value="consolidate_orders">|
-                  . $locale->text('Consolidate Orders')
-                  . qq|</button> |;
-                $button{'Order Entry--Sales Order'}{order} = $i++;
-            }
-        }
-
-        if ( $form->{type} eq 'ship_order' ) {
-            $form->{title} = $locale->text('Ship Merchandise');
-            $employee = $locale->text('Salesperson');
-        }
-        if ( $form->{type} eq 'sales_quotation' ) {
-            $form->{title} = $locale->text('Quotations');
-            $employee      = $locale->text('Employee');
-            $requiredby    = $locale->text('Valid until');
-            $quotation     = $locale->text('Quotation');
-
-            if ( $myconfig{acs} !~ /Quotations--Quotations/ ) {
-                $button{'Quotations--Quotation'}{code} =
-qq|<button class="submit" type="submit" name="action" value="add">|
-                  . $locale->text('Quotation')
-                  . qq|</button> |;
-                $button{'Quotations--Quotation'}{order} = $i++;
-            }
-
-        }
-        $name = $locale->text('Customer');
-    }
-
-    for ( split /;/, $myconfig{acs} ) { delete $button{$_} }
-
-    $column_header{ndx}           = qq|<th class=listheading>&nbsp;</th>|;
-    $column_header{runningnumber} = qq|<th class=listheading>&nbsp;</th>|;
-    $column_header{id} =
-        qq|<th><a class=listheading href=$href&sort=id>|
-      . $locale->text('ID')
-      . qq|</a></th>|;
-    $column_header{transdate} =
-        qq|<th><a class=listheading href=$href&sort=transdate>|
-      . $locale->text('Date')
-      . qq|</a></th>|;
-    $column_header{reqdate} =
-      qq|<th><a class=listheading href=$href&sort=reqdate>$requiredby</a></th>|;
-    $column_header{ordnumber} =
-        qq|<th><a class=listheading href=$href&sort=ordnumber>|
-      . $locale->text('Order')
-      . qq|</a></th>|;
-    $column_header{ponumber} =
-        qq|<th><a class=listheading href=$href&sort=ponumber>|
-      . $locale->text('PO Number')
-      . qq|</a></th>|;
-    $column_header{quonumber} =
-qq|<th><a class=listheading href=$href&sort=quonumber>$quotation</a></th>|;
-    $column_header{name} =
-      qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
-    $column_header{meta_number} =
-      qq|<th><a class=listheading href=$href&sort=meta_number>|
-      . $locale->text('Number') . qq|</a></th>|;
-    $column_header{netamount} =
-      qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
-    $column_header{tax} =
-      qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
-    $column_header{amount} =
-      qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
-    $column_header{curr} =
-        qq|<th><a class=listheading href=$href&sort=curr>|
-      . $locale->text('Curr')
-      . qq|</a></th>|;
-    $column_header{shipvia} =
-        qq|<th><a class=listheading href=$href&sort=shipvia>|
-      . $locale->text('Ship via')
-      . qq|</a></th>|;
-    $column_header{open} =
-      qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
-    $column_header{closed} =
-      qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
-
-    $column_header{employee} =
-      qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
-    $column_header{manager} =
-        qq|<th><a class=listheading href=$href&sort=manager>|
-      . $locale->text('Manager')
-      . qq|</a></th>|;
-
-    for (qw(amount tax netamount)) {
-        $column_header{"fx_$_"} = "<th>&nbsp;</th>";
-    }
-
-    if ( $form->{ $form->{vc} } ) {
-        $option = $locale->text( ucfirst $form->{vc} );
-        $option .= " : $form->{$form->{vc}}";
-    }
-    if ( $form->{warehouse} ) {
-        ($warehouse) = split /--/, $form->{warehouse};
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Warehouse');
-        $option .= " : $warehouse";
-    }
-    if ( $form->{department} ) {
-        $option .= "\n<br>" if ($option);
-        ($department) = split /--/, $form->{department};
-        $option .= $locale->text('Department') . " : $department";
-    }
-    if ( $form->{employee} ) {
-        ($employee) = split /--/, $form->{employee};
-        $option .= "\n<br>" if ($option);
-        if ( $form->{vc} eq 'customer' ) {
-            $option .= $locale->text('Salesperson');
-        }
-        else {
-            $option .= $locale->text('Employee');
-        }
-        $option .= " : $employee";
-    }
-    if ( $form->{ordnumber} ) {
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
-    }
-    if ( $form->{quonumber} ) {
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
-    }
-    if ( $form->{ponumber} ) {
-        $option = $locale->text('PO Number');
-        $option .= " : $form->{ponumber}";
-    }
-    if ( $form->{shipvia} ) {
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Ship via') . " : $form->{shipvia}";
-    }
-    if ( $form->{description} ) {
-        $option .= "\n<br>" if $option;
-        $option .= $locale->text('Description') . " : $form->{description}";
-    }
-    if ( $form->{transdatefrom} ) {
-        $option .= "\n<br>"
-          . $locale->text('From') . " "
-          . $locale->date( \%myconfig, $form->{transdatefrom}, 1 );
-    }
-    if ( $form->{transdateto} ) {
-        $option .= "\n<br>"
-          . $locale->text('To') . " "
-          . $locale->date( \%myconfig, $form->{transdateto}, 1 );
-    }
-    if ( $form->{open} ) {
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Open');
-    }
-    if ( $form->{closed} ) {
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Closed');
-    }
-
-    $form->header;
-
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>$option</td>
-  </tr>
-  <tr>
-    <td>
-      <table width=100%>
-	<tr class=listheading>|;
-
-    for (@column_index) { print "\n$column_header{$_}" }
-
-    print qq|
-	</tr>
-|;
-
-    # add sort and escape callback
-    $callback .= "&sort=$form->{sort}";
-    $form->{callback} = $callback;
-    $callback = $form->escape($callback);
-
-    # flip direction
-    $direction = ( $form->{direction} eq 'ASC' ) ? "ASC" : "DESC";
-    $href =~ s/&direction=(\w+)&/&direction=$direction&/;
-
-    if ( @{ $form->{OE} } ) {
-        $sameitem = $form->{OE}->[0]->{ $form->{sort} };
-    }
-
-    $action = "edit";
-    $action = "ship_receive" if ( $form->{type} =~ /(ship|receive)_order/ );
-
-    $warehouse = $form->escape( $form->{warehouse} );
-
-    $i = 0;
-    foreach $oe ( @{ $form->{OE} } ) {
-
-        $i++;
-
-        if ( $form->{l_subtotal} eq 'Y' ) {
-            if ( $sameitem ne $oe->{ $form->{sort} } ) {
-                &subtotal;
-                $sameitem = $oe->{ $form->{sort} };
-            }
-        }
-
-        if ( $form->{l_curr} ) {
-            for (qw(netamount amount)) { $oe->{"fx_$_"} = $oe->{$_} }
-            $oe->{fx_tax} = $oe->{fx_amount} - $oe->{fx_netamount};
-            for (qw(netamount amount)) { $oe->{$_} *= $oe->{exchangerate} }
-
-            for (qw(netamount amount)) {
-                $column_data{"fx_$_"} = "<td align=right>"
-                  . $form->format_amount( \%myconfig, $oe->{"fx_$_"}, 2,
-                    "&nbsp;" )
-                  . "</td>";
-            }
-            $column_data{fx_tax} = "<td align=right>"
-              . $form->format_amount( \%myconfig,
-                $oe->{fx_amount} - $oe->{fx_netamount},
-                2, "&nbsp;" )
-              . "</td>";
-
-            $totalfxnetamount += $oe->{fx_netamount};
-            $totalfxamount    += $oe->{fx_amount};
-
-            $subtotalfxnetamount += $oe->{fx_netamount};
-            $subtotalfxamount    += $oe->{fx_amount};
-        }
-
-        for (qw(netamount amount)) {
-            $column_data{$_} =
-                "<td align=right>"
-              . $form->format_amount( \%myconfig, $oe->{$_}, 2, "&nbsp;" )
-              . "</td>";
-        }
-        $column_data{tax} = "<td align=right>"
-          . $form->format_amount( \%myconfig, $oe->{amount} - $oe->{netamount},
-            2, "&nbsp;" )
-          . "</td>";
-
-        $totalnetamount += $oe->{netamount};
-        $totalamount    += $oe->{amount};
-
-        $subtotalnetamount += $oe->{netamount};
-        $subtotalamount    += $oe->{amount};
-
-        $column_data{id}        = "<td>$oe->{id}</td>";
-        $column_data{transdate} = "<td>$oe->{transdate}&nbsp;</td>";
-        $column_data{reqdate}   = "<td>$oe->{reqdate}&nbsp;</td>";
-
-        $column_data{runningnumber} = qq|<td align=right>$i</td>|;
-        $column_data{ndx} =
-qq|<td><input name="ndx_$i" class=checkbox type=checkbox value=$oe->{id} checked></td>|;
-        $column_data{$ordnumber} =
-"<td><a href=$form->{script}?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$oe->{$ordnumber}</a></td>";
-        # $form->escape is the wrong method to choose here for the actual 
-        # display.  It does $hexhex 
-        # encoding. Long-run we need to move ths all to form-dynatable.  Until
-        # then, however, just going to do basic sanitation if <>&.... 
-        #
-        # Of course this has to be after the hexhex encoding for the URL. --CT
-        #
-        $name = $form->escape( $oe->{name} );
-	$meta_number = $form->escape( $oe->{meta_number} );
-        $dispname = $oe->{name};
-        $dispmeta = $oe->{meta_number};
-        $dispname =~ s/&/&amp;/;
-        $dispname =~ s/>/&gt;/;
-        $dispname =~ s/</&lt;/;
-        $dispmeta=~ s/&/&amp;/;
-        $dispmeta=~ s/>/&gt;/;
-        $dispmeta=~ s/</&lt;/;
-        $column_data{name} =
-qq|<td><a href=$form->{vc}.pl?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&action=get&entity_id=$oe->{entity_id}&meta_number=$meta_number&account_class=$account_class&callback=$callback>$dispname</a></td>|;
-        $column_data{meta_number} =
-qq|<td><a href=$form->{vc}.pl?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&action=get&entity_id=$oe->{entity_id}&meta_number=$meta_number&account_class=$account_class&callback=$callback>$dispmeta</a></td>|;
-
-
-        for (qw(employee manager shipvia curr ponumber)) {
-            $column_data{$_} = "<td>$oe->{$_}&nbsp;</td>";
-        }
-
-        if ( $oe->{closed} ) {
-            $column_data{closed} = "<td align=center>*</td>";
-            $column_data{open}   = "<td>&nbsp;</td>";
-        }
-        else {
-            $column_data{closed} = "<td>&nbsp;</td>";
-            $column_data{open}   = "<td align=center>*</td>";
-        }
-
-        $j++;
-        $j %= 2;
-        print "
-        <tr class=listrow$j>";
-
-        for (@column_index) { print "\n$column_data{$_}" }
-
-        print qq|
-	</tr>
-|;
-
-    }
-
-    if ( $form->{l_subtotal} eq 'Y' ) {
-        &subtotal;
-    }
-
-    # print totals
-    print qq|
-        <tr class=listtotal>|;
-
-    for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
-
-    $column_data{netamount} =
-        "<th class=listtotal align=right>"
-      . $form->format_amount( \%myconfig, $totalnetamount, 2, "&nbsp;" )
-      . "</th>";
-    $column_data{tax} = "<th class=listtotal align=right>"
-      . $form->format_amount( \%myconfig, $totalamount - $totalnetamount,
-        2, "&nbsp;" )
-      . "</th>";
-    $column_data{amount} =
-      "<th class=listtotal align=right>"
-      . $form->format_amount( \%myconfig, $totalamount, 2, "&nbsp;" ) . "</th>";
-
-    if ( $form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal} ) {
-        $column_data{fx_netamount} =
-            "<th class=listtotal align=right>"
-          . $form->format_amount( \%myconfig, $totalfxnetamount, 2, "&nbsp;" )
-          . "</th>";
-        $column_data{fx_tax} = "<th class=listtotal align=right>"
-          . $form->format_amount( \%myconfig,
-            $totalfxamount - $totalfxnetamount,
-            2, "&nbsp;" )
-          . "</th>";
-        $column_data{fx_amount} =
-            "<th class=listtotal align=right>"
-          . $form->format_amount( \%myconfig, $totalfxamount, 2, "&nbsp;" )
-          . "</th>";
-    }
-
-    for (@column_index) { print "\n$column_data{$_}" }
-
-    print qq|
-        </tr>
-      </td>
-    </table>
-  </tr>
-  <tr>
-    <td><hr size=3 noshade></td>
-  </tr>
-</table>
-
-<br>
-|;
-
-    $form->hide_form(
-        qw(callback type vc path login sessionid department ordnumber ponumber shipvia)
-    );
-
-    print qq|
-
-<input type=hidden name=rowcount value=$i>
-
-<input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
-<input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
-
-|;
-
-    if ( $form->{type} !~ /(ship|receive)_order/ ) {
-        for ( sort { $a->{order} <=> $b->{order} } %button ) {
-            print $_->{code};
-        }
-    }
-
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
-
-    print qq|
-</form>
-
-</body>
-</html>
-|;
-
-}
-
-sub subtotal {
-
-    for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
-
-    $column_data{netamount} =
-        "<th class=listsubtotal align=right>"
-      . $form->format_amount( \%myconfig, $subtotalnetamount, 2, "&nbsp;" )
-      . "</th>";
-    $column_data{tax} = "<td class=listsubtotal align=right>"
-      . $form->format_amount( \%myconfig, $subtotalamount - $subtotalnetamount,
-        2, "&nbsp;" )
-      . "</th>";
-    $column_data{amount} =
-        "<th class=listsubtotal align=right>"
-      . $form->format_amount( \%myconfig, $subtotalamount, 2, "&nbsp;" )
-      . "</th>";
-
-    if ( $form->{l_curr} && $form->{sort} eq 'curr' && $form->{l_subtotal} ) {
-        $column_data{fx_netamount} =
-          "<th class=listsubtotal align=right>"
-          . $form->format_amount( \%myconfig, $subtotalfxnetamount, 2,
-            "&nbsp;" )
-          . "</th>";
-        $column_data{fx_tax} = "<td class=listsubtotal align=right>"
-          . $form->format_amount( \%myconfig,
-            $subtotalfxamount - $subtotalfxnetamount,
-            2, "&nbsp;" )
-          . "</th>";
-        $column_data{fx_amount} =
-            "<th class=listsubtotal align=right>"
-          . $form->format_amount( \%myconfig, $subtotalfxamount, 2, "&nbsp;" )
-          . "</th>";
-    }
-
-    $subtotalnetamount = 0;
-    $subtotalamount    = 0;
-
-    $subtotalfxnetamount = 0;
-    $subtotalfxamount    = 0;
-
-    print "
-        <tr class=listsubtotal>
-";
-
-    for (@column_index) { print "\n$column_data{$_}" }
-
-    print qq|
-        </tr>
-|;
-
-}
-
 sub save {
     if (!$form->close_form()){
        $form->{notice} = $locale->text(

Copied: trunk/order.pl (from rev 5367, trunk/invoice.pl)
===================================================================
--- trunk/order.pl	                        (rev 0)
+++ trunk/order.pl	2012-12-19 07:33:27 UTC (rev 5382)
@@ -0,0 +1,8 @@
+#!/usr/bin/perl
+
+use FindBin;
+BEGIN {
+  lib->import($FindBin::Bin) unless $ENV{mod_perl}
+}
+
+require 'lsmb-request.pl';

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-12-18 09:15:29 UTC (rev 5381)
+++ trunk/sql/Pg-database.sql	2012-12-19 07:33:27 UTC (rev 5382)
@@ -2704,7 +2704,6 @@
 106	Time Cards	103	3
 107	Translations	98	5
 108	Description	107	1
-111	Trial Balance	109	2
 113	Balance Sheet	109	4
 114	Inventory Activity	109	5
 117	Sales Invoices	116	1
@@ -2777,9 +2776,10 @@
 41	Reports	35	8
 45	Reconciliation	35	7
 132	Year End	73	3
-112	Income Statement	6	1
 203	Receipts	200	3
 204	Reverse Receipts	200	4
+111	Trial Balance	109	1
+112	Income Statement	109	2
 201	Payments	200	1
 202	Reverse Payment	200	2
 210	Drafts	205	2
@@ -2848,9 +2848,6 @@
 190	Stylesheet	0	22
 128	System	0	21
 116	Batch Printing	0	20
-6	Profit and Loss	109	1
-8	Customer Margin	6	10
-11	Invoice Margin	6	11
 9	Outstanding	4	1
 10	Outstanding	24	1
 \.
@@ -2963,12 +2960,6 @@
 52	action	add	124
 52	type	purchase_order	125
 53	menu	1	126
-54	module	oe.pl	127
-54	type	sales_order	129
-54	action	search	128
-55	module	oe.pl	130
-55	type	purchase_order	132
-55	action	search	131
 56	menu	1	133
 57	module	oe.pl	134
 57	action	search	136
@@ -2998,10 +2989,6 @@
 68	type	sales_quotation	158
 69	type	request_quotation	161
 70	menu	1	162
-71	module	oe.pl	163
-71	type	sales_quotation	165
-71	action	search	164
-72	module	oe.pl	166
 7	module	reports.pl	15
 64	type	ship_order	149
 7	action	start_report	16
@@ -3019,8 +3006,6 @@
 34	module	reports.pl	80
 5	action	start_report	9
 25	action	start_report	58
-72	action	search	168
-72	type	request_quotation	167
 73	menu	1	169
 74	module	gl.pl	170
 74	action	add	171
@@ -3032,7 +3017,6 @@
 206	module	reports.pl	575
 206	action	start_report	576
 38	account_class	1	39
-49	action	start_report	117
 49	module	reports.pl	118
 79	action	add	187
 79	item	service	188
@@ -3057,6 +3041,19 @@
 43	action	get_search_criteria	104
 43	module	payment.pl	103
 43	account_class	1	105
+49	action	start_report	117
+54	module	order.pl	127
+55	module	order.pl	130
+71	module	order.pl	163
+72	module	order.pl	166
+54	action	get_criteria	128
+55	action	get_criteria	131
+71	action	get_criteria	164
+72	action	get_criteria	168
+54	search_type	search	129
+55	search_type	search	132
+71	search_type	search	165
+72	search_type	search	167
 84	action	stock_assembly	203
 85	menu	1	204
 86	module	ic.pl	205
@@ -3500,15 +3497,6 @@
 111	module	reports.pl	276
 111	module_name	gl	40
 210	search_type	drafts	46
-6	menu	1	38
-6	module	menu.pl	41
-8	module	reports.pl	42
-8	action	start_report	47
-8	report_name	customer_margin	48
-8	module_name	gl	49
-11	module	reports.pl	60
-11	action	start_report	61
-11	report_name	invoice_margin	78
 112	module_name	gl	79
 9	module	invoice.pl	21
 9	action	start_report	22
@@ -3518,6 +3506,10 @@
 10	entity_class	1	67
 9	report_name	invoice_outstanding	23
 10	report_name	invoice_outstanding	66
+54	oe_class_id	1	62
+55	oe_class_id	2	68
+71	oe_class_id	3	69
+72	oe_class_id	4	70
 \.
 
 

Added: trunk/sql/modules/OrderEntry.sql
===================================================================
--- trunk/sql/modules/OrderEntry.sql	                        (rev 0)
+++ trunk/sql/modules/OrderEntry.sql	2012-12-19 07:33:27 UTC (rev 5382)
@@ -0,0 +1,99 @@
+-- COPYRIGHT (C) 2012 The LedgerSMB Core Team.  This file may be used under the
+-- terms of the GNU General Public License version 2 or at your option any later
+-- version.  Please see the included license.txt for more information.
+
+
+BEGIN;
+
+DROP TYPE IF EXISTS order_search_line CASCADE;
+
+CREATE TYPE order_search_line AS (
+    id int,
+    ordnumber text,
+    transdate date,
+    reqdate date,
+    amount numeric,
+    legal_name text,
+    netamount numeric,
+    entity_credit_account int,
+    closed bool,
+    quonumber text,
+    shippingpoint text,
+    exchangerate numeric,
+    shipvia text,
+    employee text, 
+    manager text,
+    curr char(3),
+    ponumber text,
+    meta_number text,
+    entity_id int
+);
+
+CREATE OR REPLACE FUNCTION order__search 
+(in_oe_class_id int, in_meta_number text, in_legal_name text, in_ponumber text,
+ in_ordnumber text, in_open bool, in_closed bool, in_shipvia text, 
+ in_description text, in_date_from date, in_date_to date, in_shippable bool,
+ in_buisness_units int[])
+RETURNS SETOF order_search_line
+LANGUAGE PLPGSQL AS $$
+
+DECLARE retval order_search_line;
+
+BEGIN
+
+FOR retval IN
+       SELECT o.id, 
+              CASE WHEN oe_class_id IN (1, 2) THEN o.ordnumber
+                   WHEN oe_class_id IN (3, 4) THEN o.quonumber
+                   ELSE NULL
+               END as ordnumber, o.transdate, o.reqdate,
+              o.amount, c.legal_name AS name, o.netamount, 
+              o.entity_credit_account, o.closed, o.quonumber, o.shippingpoint,
+              CASE WHEN ct.entity_class = 2 THEN ex.buy ELSE ex.sell END
+              AS exchangerate, o.shipvia, pe.first_name || ' ' || pe.last_name 
+              AS employee, pm.first_name || ' ' || pm.last_name AS manager, 
+              o.curr, o.ponumber, ct.meta_number, c.entity_id
+         FROM oe o
+         JOIN entity_credit_account ct ON (o.entity_credit_account = ct.id)
+         JOIN company c ON (c.entity_id = ct.entity_id)
+    LEFT JOIN person pe ON (o.person_id = pe.id)
+    LEFT JOIN entity_employee e ON (pe.entity_id = e.entity_id)
+    LEFT JOIN person pm ON (e.manager_id = pm.id)
+    LEFT JOIN entity_employee m ON (pm.entity_id = m.entity_id)
+    LEFT JOIN exchangerate ex 
+              ON (ex.curr = o.curr AND ex.transdate = o.transdate)
+        WHERE o.oe_class_id = in_oe_class_id
+             AND (in_meta_number IS NULL 
+                   or ct.meta_number ILIKE in_meta_number || '%')
+             AND (in_legal_name IS NULL OR
+                     c.legal_name @@ plainto_tsquery(in_legal_name))
+             AND (in_ponumber IS NULL OR o.ponumber ILIKE in_ponumber || '%')
+            AND (in_ordnumber IS NULL 
+                     OR o.ordnumber ILIKE in_ordnumber || '%')
+             AND (in_open is true or o.closed is not true)
+             AND (in_closed is true or o.closed is not false)
+             AND (in_shipvia IS NULL 
+                      OR o.shipvia @@ plainto_tsquery(in_shipvia))
+             AND (in_description IS NULL AND in_shippable IS NULL OR
+                     EXISTS (SELECT 1 
+                               FROM orderitems oi 
+                               JOIN parts p ON p.id = oi.parts_id
+                              WHERE trans_id = o.id
+                                    AND (in_description IS NULL OR 
+                                        oi.description 
+                                        @@ plainto_tsquery(in_description))
+                                    AND (in_shippable IS NULL OR
+                                         p.assembly OR 
+                                         p.inventory_accno_id IS NOT NULL))
+                 )
+             AND (in_date_from IS NULL OR o.transdate >= in_date_from)
+             AND (in_date_to IS NULL OR o.transdate <= in_date_to)
+                                    
+LOOP
+   RETURN NEXT retval;
+END LOOP;
+END;
+$$;
+
+
+COMMIT;

Modified: trunk/sql/modules/menu_rebuild.sql
===================================================================
--- trunk/sql/modules/menu_rebuild.sql	2012-12-18 09:15:29 UTC (rev 5381)
+++ trunk/sql/modules/menu_rebuild.sql	2012-12-19 07:33:27 UTC (rev 5382)
@@ -203,12 +203,6 @@
 52	action	add	124
 52	type	purchase_order	125
 53	menu	1	126
-54	module	oe.pl	127
-54	type	sales_order	129
-54	action	search	128
-55	module	oe.pl	130
-55	type	purchase_order	132
-55	action	search	131
 56	menu	1	133
 57	module	oe.pl	134
 57	action	search	136
@@ -238,10 +232,6 @@
 68	type	sales_quotation	158
 69	type	request_quotation	161
 70	menu	1	162
-71	module	oe.pl	163
-71	type	sales_quotation	165
-71	action	search	164
-72	module	oe.pl	166
 7	module	reports.pl	15
 64	type	ship_order	149
 7	action	start_report	16
@@ -259,8 +249,6 @@
 34	module	reports.pl	80
 5	action	start_report	9
 25	action	start_report	58
-72	action	search	168
-72	type	request_quotation	167
 73	menu	1	169
 74	module	gl.pl	170
 74	action	add	171
@@ -272,7 +260,6 @@
 206	module	reports.pl	575
 206	action	start_report	576
 38	account_class	1	39
-49	action	start_report	117
 49	module	reports.pl	118
 79	action	add	187
 79	item	service	188
@@ -297,6 +284,19 @@
 43	action	get_search_criteria	104
 43	module	payment.pl	103
 43	account_class	1	105
+49	action	start_report	117
+54	module	order.pl	127
+55	module	order.pl	130
+71	module	order.pl	163
+72	module	order.pl	166
+54	action	get_criteria	128
+55	action	get_criteria	131
+71	action	get_criteria	164
+72	action	get_criteria	168
+54	search_type	search	129
+55	search_type	search	132
+71	search_type	search	165
+72	search_type	search	167
 84	action	stock_assembly	203
 85	menu	1	204
 86	module	ic.pl	205
@@ -740,15 +740,6 @@
 111	module	reports.pl	276
 111	module_name	gl	40
 210	search_type	drafts	46
-6	menu	1	38
-6	module	menu.pl	41
-8	module	reports.pl	42
-8	action	start_report	47
-8	report_name	customer_margin	48
-8	module_name	gl	49
-11	module	reports.pl	60
-11	action	start_report	61
-11	report_name	invoice_margin	78
 112	module_name	gl	79
 9	module	invoice.pl	21
 9	action	start_report	22
@@ -758,6 +749,10 @@
 10	entity_class	1	67
 9	report_name	invoice_outstanding	23
 10	report_name	invoice_outstanding	66
+54	oe_class_id	1	62
+55	oe_class_id	2	68
+71	oe_class_id	3	69
+72	oe_class_id	4	70
 \.
 
 
@@ -841,7 +836,6 @@
 106	Time Cards	103	3
 107	Translations	98	5
 108	Description	107	1
-111	Trial Balance	109	2
 113	Balance Sheet	109	4
 114	Inventory Activity	109	5
 117	Sales Invoices	116	1
@@ -914,9 +908,10 @@
 41	Reports	35	8
 45	Reconciliation	35	7
 132	Year End	73	3
-112	Income Statement	6	1
 203	Receipts	200	3
 204	Reverse Receipts	200	4
+111	Trial Balance	109	1
+112	Income Statement	109	2
 201	Payments	200	1
 202	Reverse Payment	200	2
 210	Drafts	205	2
@@ -985,9 +980,6 @@
 190	Stylesheet	0	22
 128	System	0	21
 116	Batch Printing	0	20
-6	Profit and Loss	109	1
-8	Customer Margin	6	10
-11	Invoice Margin	6	11
 9	Outstanding	4	1
 10	Outstanding	24	1
 \.

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