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

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



Revision: 5430
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5430&view=rev
Author:   einhverfr
Date:     2012-12-27 13:14:27 +0000 (Thu, 27 Dec 2012)
Log Message:
-----------
Order generation working now

Modified Paths:
--------------
    trunk/LedgerSMB/OE.pm
    trunk/LedgerSMB/Report/Orders.pm
    trunk/LedgerSMB/Scripts/order.pm
    trunk/LedgerSMB/Scripts/vouchers.pm
    trunk/bin/oe.pl

Modified: trunk/LedgerSMB/OE.pm
===================================================================
--- trunk/LedgerSMB/OE.pm	2012-12-27 09:07:36 UTC (rev 5429)
+++ trunk/LedgerSMB/OE.pm	2012-12-27 13:14:27 UTC (rev 5430)
@@ -2040,11 +2040,11 @@
 		WHERE oi.trans_id = ?|;
     my $sth = $dbh->prepare($query) || $form->dberror($query);
 
-    for ( my $i = 1 ; $i <= $form->{rowcount} ; $i++ ) {
+    for ( 1 .. $form->{rowcount_} ) {
 
-        if ( $form->{"ndx_$i"} ) {
+        if ( $form->{"select_$i"} ) {
 
-            $sth->execute( $form->{"ndx_$i"} );
+            $sth->execute( $form->{"select_$i"} );
 
             while ( $ref = $sth->fetchrow_hashref(NAME_lc) ) {
                 $form->db_parse_numeric(sth=>$sth, hashref=>$ref);

Modified: trunk/LedgerSMB/Report/Orders.pm
===================================================================
--- trunk/LedgerSMB/Report/Orders.pm	2012-12-27 09:07:36 UTC (rev 5429)
+++ trunk/LedgerSMB/Report/Orders.pm	2012-12-27 13:14:27 UTC (rev 5430)
@@ -200,6 +200,10 @@
     my $HREF_ACTION = 'edit';
     $HREF_ACTION = $self->href_action if $self->href_action;
     my $cols = [
+        {col_id => 'select',
+           name => '',
+           type => 'checkbox' },
+
        {col_id => 'id',
           name => LedgerSMB::Report::text('ID'),
           type => 'text', },
@@ -261,14 +265,6 @@
           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;
 }
 

Modified: trunk/LedgerSMB/Scripts/order.pm
===================================================================
--- trunk/LedgerSMB/Scripts/order.pm	2012-12-27 09:07:36 UTC (rev 5429)
+++ trunk/LedgerSMB/Scripts/order.pm	2012-12-27 13:14:27 UTC (rev 5430)
@@ -17,6 +17,7 @@
 use LedgerSMB::App_State;
 use LedgerSMB::Scripts::reports;
 use LedgerSMB::Report::Orders;
+use LedgerSMB::Form; # for dispatching to old code
 
 =head1 ROUTINES
 
@@ -52,7 +53,7 @@
             $request->{title} = $locale->text('Search Sales Orders');
         } elsif ($request->{search_type} eq 'generate'){
             $request->{title} = 
-                   $locale->text('Generate Sales Orders from Purchase Orders');
+                   $locale->text('Generate Purchase Orders from Sales Orders');
         } elsif ($request->{search_type} eq 'combine'){
             $request->{title} = $locale->text('Combine Sales Orders');
         } elsif ($request->{search_type} eq 'ship'){
@@ -65,7 +66,7 @@
             $request->{title} = $locale->text('Combine Purchase Orders');
         } elsif ($request->{search_type} eq 'generate'){
             $request->{title} = 
-                   $locale->text('Generate Purchase Orders from Sales Orders');
+                   $locale->text('Generate Sales Orders from Purchase Orders');
         } elsif ($request->{search_type} eq 'ship'){
             $request->{title} = $locale->text('Receive');
         }
@@ -90,6 +91,7 @@
     if ($request->{search_type} ne 'search'){
        $request->{selectable} = 1;
        $request->{open} =1;
+       $request->{col_select} = 1;
        delete $request->{closed};
     }
     my $report = LedgerSMB::Report::Orders->new(%$request);
@@ -133,6 +135,22 @@
 
 =item generate
 
+This is just a dispatch handle currently to bin/oe's generate_purchase_orders
+callback.
+
+=cut
+
+sub generate {
+    my ($request) = @_;
+    my $form = new Form;
+    for my $k (keys %$request){
+        $form->{$k} = $request->{$k};
+    }
+    { no strict; no warnings 'redefine'; do 'bin/oe.pl'; }
+    $locale = $LedgerSMB::App_State::Locale;
+    lsmb_legacy::generate_purchase_orders($form, $locale);
+}
+
 =back
 
 =head1 COPYRIGHT

Modified: trunk/LedgerSMB/Scripts/vouchers.pm
===================================================================
--- trunk/LedgerSMB/Scripts/vouchers.pm	2012-12-27 09:07:36 UTC (rev 5429)
+++ trunk/LedgerSMB/Scripts/vouchers.pm	2012-12-27 13:14:27 UTC (rev 5430)
@@ -111,11 +111,11 @@
     my $batch = LedgerSMB::Batch->new({base => $request});
     our $vouchers_dispatch = 
     {
-        ap         => {script => 'bin/ap.pl', function => sub {add()}},
-        ar         => {script => 'bin/ar.pl', function => sub {add()}},
-        gl         => {script => 'bin/gl.pl', function => sub {add()}},
-     sales_invoice => {script => 'bin/is.pl', function => sub {add()}},
-    vendor_invoice => {script => 'bin/ir.pl', function => sub {add()}},
+        ap         => {script => 'bin/ap.pl', function => sub {lsmb_legacy::add()}},
+        ar         => {script => 'bin/ar.pl', function => sub {lsmb_legacy::add()}},
+        gl         => {script => 'bin/gl.pl', function => sub {lsmb_legacy::add()}},
+     sales_invoice => {script => 'bin/is.pl', function => sub {lsmb_legacy::add()}},
+    vendor_invoice => {script => 'bin/ir.pl', function => sub {lsmb_legacy::add()}},
         receipt    => {script => undef, 
 	             function => sub {
 				my ($request) = @_;

Modified: trunk/bin/oe.pl
===================================================================
--- trunk/bin/oe.pl	2012-12-27 09:07:36 UTC (rev 5429)
+++ trunk/bin/oe.pl	2012-12-27 13:14:27 UTC (rev 5430)
@@ -1953,15 +1953,15 @@
 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
         $column_data{qty} =
             qq|<td align=right>|
-          . $form->format_amount( \%myconfig, $form->{"qty_$i"} )
-          . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
-        $column_data{ship} =
-            qq|<td align=right><input name="ship_$i" size=5 value="|
-          . $form->format_amount( \%myconfig, $form->{"ship_$i"} )
-          . qq|"></td>|;
-        $column_data{unit} =
-qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
-        $column_data{bin} =
+          . $form->format_amount( \%myconfig, $form->{"qty_$i"} )
+          . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
+        $column_data{ship} =
+            qq|<td align=right><input name="ship_$i" size=5 value="|
+          . $form->format_amount( \%myconfig, $form->{"ship_$i"} )
+          . qq|"></td>|;
+        $column_data{unit} =
+qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
+        $column_data{bin} =
 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
 
         $column_data{serialnumber} =
@@ -2289,16 +2289,16 @@
 
         $column_data{partnumber} =
 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
-        $column_data{description} = "<td>$ref->{description}&nbsp;</td>";
-        $column_data{partsgroup}  = "<td>$ref->{partsgroup}&nbsp;</td>";
-        $column_data{fromwarehouse} =
-qq|<td><input type=hidden name="warehouse_id_$i" value="$ref->{warehouse_id}">$ref->{warehouse}&nbsp;</td>|;
-        $column_data{towarehouse} = qq|<td>$warehouse&nbsp;</td>|;
-        $column_data{qty} =
-            qq|<td><input type=hidden name="qty_$i" value="$ref->{qty}">|
-          . $form->format_amount( \%myconfig, $ref->{qty} )
-          . qq|</td>|;
-        $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
+        $column_data{description} = "<td>$ref->{description}&nbsp;</td>";
+        $column_data{partsgroup}  = "<td>$ref->{partsgroup}&nbsp;</td>";
+        $column_data{fromwarehouse} =
+qq|<td><input type=hidden name="warehouse_id_$i" value="$ref->{warehouse_id}">$ref->{warehouse}&nbsp;</td>|;
+        $column_data{towarehouse} = qq|<td>$warehouse&nbsp;</td>|;
+        $column_data{qty} =
+            qq|<td><input type=hidden name="qty_$i" value="$ref->{qty}">|
+          . $form->format_amount( \%myconfig, $ref->{qty} )
+          . qq|</td>|;
+        $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
 
         $j++;
         $j %= 2;
@@ -2364,9 +2364,10 @@
 }
 
 sub generate_purchase_orders {
+    ($form, $locale) = @_;
 
-    for ( 1 .. $form->{rowcount} ) {
-        if ( $form->{"ndx_$_"} ) {
+    for ( 1 .. $form->{rowcount_} ) {
+        if ( $form->{"select_$_"} ) {
             $ok = 1;
             last;
         }
@@ -2534,13 +2535,13 @@
 
         for (qw(required leadtime lastcost fx)) {
             $column_data{$_} = qq|<td align=right>$form->{"${_}_$i"}</td>|;
-        }
-
-        $column_data{qty} =
-qq|<td align=right><input name="qty_$i" size="6" value="$form->{"qty_$i"}"></td>|;
-
-        if ( $form->{"$form->{vc}_id_$i"} ) {
-            $name = $form->{"$form->{vc}_$i"};
+        }
+
+        $column_data{qty} =
+qq|<td align=right><input name="qty_$i" size="6" value="$form->{"qty_$i"}"></td>|;
+
+        if ( $form->{"$form->{vc}_id_$i"} ) {
+            $name = $form->{"$form->{vc}_$i"};
             $name =~ s/--.*//;
             $column_data{name} = qq|<td>$name</td>|;
             $form->hide_form( "$form->{vc}_id_$i", "$form->{vc}_$i" );

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