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

SF.net SVN: ledger-smb:[4942] trunk/LedgerSMB/DBObject



Revision: 4942
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4942&view=rev
Author:   einhverfr
Date:     2012-06-22 06:19:02 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
Business Unit columns for reports

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Report/GL.pm
    trunk/LedgerSMB/DBObject/Report.pm

Modified: trunk/LedgerSMB/DBObject/Report/GL.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Report/GL.pm	2012-06-21 13:12:54 UTC (rev 4941)
+++ trunk/LedgerSMB/DBObject/Report/GL.pm	2012-06-22 06:19:02 UTC (rev 4942)
@@ -161,11 +161,16 @@
 );
 
 sub columns {
-    return ..hidden..;
+    my @bclasses = LedgerSMB::DBObject::Business_Unit_Class->list('1', 'gl');
+    my @COLS = @COLUMNS;
+    for my $class (@bclasses){
+        push @COLS, {col_id =>  "bc_" . $class->id,
+                       name => $locale->text($class->label),
+                       type => 'text',
+                     pwidth => '2'};
+    return ..hidden..;
 }
 
-    # TODO:  business_units int[]
-
 =item filter_template
 
 Returns the template name for the filter.
@@ -378,6 +383,7 @@
         } else {
             $ref->{cleared} = '';
         }
+        $self->process_bclasses($ref);
     }
     $self->rows(..hidden..);
 }

Modified: trunk/LedgerSMB/DBObject/Report.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Report.pm	2012-06-21 13:12:54 UTC (rev 4941)
+++ trunk/LedgerSMB/DBObject/Report.pm	2012-06-22 06:19:02 UTC (rev 4942)
@@ -255,6 +255,9 @@
         if ($request->{"col_$ref->{col_id}"}){
             push @retval, $ref;
         }
+        if ($ref->{col_id} =~ /bc_\d+/){
+            push @retval, $ref if $request->{"col_business_units"};
+        }
     }
     if (scalar @retval == 0){
        @retval = @{$self->columns};
@@ -318,6 +321,22 @@
     );
 }
 
+=item process_bclasses($ref)
+
+This function processes a ref for a hashref key of business_units, which holds 
+an array of arrays of (class_id, bu_id) and adds keys in the form of 
+bc_$class_id holding the $bu_id fields.
+
+=cut
+
+sub process_bclasses {
+    my ($self, $ref) = @_;
+    for my $bu (@{$ref->{business_units}}){
+        push @{$ref->{$bu->[0]}}, $bu->[1] 
+                 unless grep /$bu->[1]/ @{$ref->{$bu->[0]}};
+    }
+}
+
 =back
 
 =head1 COPYRIGHT

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