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

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



Revision: 2994
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2994&view=rev
Author:   einhverfr
Date:     2010-04-30 21:47:12 +0000 (Fri, 30 Apr 2010)

Log Message:
-----------
Adding sort options from Alexey's patch

Modified Paths:
--------------
    trunk/LedgerSMB/Batch.pm
    trunk/LedgerSMB/ScriptLib/Company.pm
    trunk/LedgerSMB/Template.pm
    trunk/UI/create_batch.html
    trunk/bin/am.pl
    trunk/bin/arapprn.pl
    trunk/bin/ca.pl
    trunk/bin/gl.pl
    trunk/bin/rp.pl
    trunk/scripts/admin.pl
    trunk/scripts/drafts.pl
    trunk/scripts/payment.pl
    trunk/scripts/recon.pl
    trunk/scripts/vouchers.pl
    trunk/sql/modules/Voucher.sql

Modified: trunk/LedgerSMB/Batch.pm
===================================================================
--- trunk/LedgerSMB/Batch.pm	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/LedgerSMB/Batch.pm	2010-04-30 21:47:12 UTC (rev 2994)
@@ -45,17 +45,20 @@
     unshift @{$self->{batch_users}}, {username => $self->{_locale}->text('Any'), id => '0', entity_id => '0'};
 }
 
-sub get_search_results {
-    my ($self, $args) = @_;
-    if ($self->{empty}){
+sub get_search_method {
+	my ($self, @args) = @_;
+	my $search_proc;
+	
+	if ($self->{empty}){
         $search_proc = "batch_search_empty";
     } elsif ($args->{mini}){
         $search_proc = "batch_search_mini";
     } else {
         $search_proc = "batch_search";
     }
-    if ($self->{created_by_eid} == 0){
-	delete $self->{created_by_eid};
+
+	if ($self->{created_by_eid} == 0){
+		delete $self->{created_by_eid};
     }
     if ($args->{custom_types}->{$self->{class_id}}->{select_method}){
         $search_proc 
@@ -63,6 +66,12 @@
     } elsif ($self->{class_id} =~ /[\D]/){
           $self->error("Invalid Batch Type");
     }
+	return $search_proc;
+}
+
+sub get_search_results {
+    my ($self, $args) = @_;
+	my $search_proc = $self->get_search_method($args);
     @{$self->{search_results}} = $self->exec_method(funcname => $search_proc);
     return @{$self->{search_results}};
 }

Modified: trunk/LedgerSMB/ScriptLib/Company.pm
===================================================================
--- trunk/LedgerSMB/ScriptLib/Company.pm	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/LedgerSMB/ScriptLib/Company.pm	2010-04-30 21:47:12 UTC (rev 2994)
@@ -311,37 +311,18 @@
     }
 
     # Column definitions for dynatable
-    @columns = qw(legal_name entity_control_code meta_number credit_description 
-		business_type curr);
-    my %column_heading;
-    $column_heading{legal_name} = {
-        text => $request->{_locale}->text('Name'),
-	href => "$search_url&order_by=legal_name",
+    @columns = qw(legal_name entity_control_code meta_number credit_description business_type curr);
+		
+	my $column_names = {
+	    legal_name => 'Name',
+	    entity_control_code => 'Control Code',
+	    meta_number => 'Vendor Number',
+	    credit_description => 'Description',
+	    business_type => 'Business Type',
+	    curr => 'Currency'
     };
-    $column_heading{entity_control_code} = {
-        text => $request->{_locale}->text('Control Code'),
-	href => "$search_url&order_by=entity_control_code",
-    };
-    $column_heading{legal_name} = {
-        text => $request->{_locale}->text('Name'),
-	href => "$search_url&order_by=legal_name",
-    };
-    $column_heading{meta_number} = {
-        text => $request->{_locale}->text('Vendor Number'),
-	href => "$search_url&order_by=meta_number",
-    };
-    $column_heading{credit_description} = {
-        text => $request->{_locale}->text('Description'),
-	href => "$search_url&order_by=credit_description",
-    };
-    $column_heading{business_type} = {
-        text => $request->{_locale}->text('Business Type'),
-	href => "$search_url&order_by=business_type",
-    };
-    $column_heading{curr} = {
-        text => $request->{_locale}->text('Currency'),
-	href => "$search_url&order_by=curr",
-    };
+	my @sort_columns = @columns;
+	my $sort_href = "$search_url&order_by";
 
     my @rows;
     for $ref (@{$company->{search_results}}){
@@ -388,12 +369,16 @@
 		format => ($request->{FORMAT}) ? $request->{FORMAT}  : 'HTML',
     );
             
+    my $column_heading = $template->column_heading($column_names,
+        {href => $sort_href, columns => ..hidden..
+    );
+            
     $template->render({
 	form    => $company,
 	columns => ..hidden..,
         hiddens => $company,
 	buttons => ..hidden..,
-	heading => \%column_heading,
+	heading => $column_heading,
 	rows    => ..hidden..,
     });
 }

Modified: trunk/LedgerSMB/Template.pm
===================================================================
--- trunk/LedgerSMB/Template.pm	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/LedgerSMB/Template.pm	2010-04-30 21:47:12 UTC (rev 2994)
@@ -406,4 +406,41 @@
 	close(LPR);
 }
 
+# apply locale settings to column headings and add sort urls if necessary.
+sub column_heading {
+	
+	my $self = shift;
+	my ($names, $sortby) = @_; 
+	my %sorturls;
+	
+	if ($sortby) {
+		%sorturls = map 
+		{ $_ => $sortby->{href}."=$_"} @{$sortby->{columns}};
+	}
+		
+	foreach my $attname (keys %$names) {
+		
+		# process 2 cases - simple name => value, and complex name => hash
+		# pairs. The latter is used to include urls in column headers.
+		
+		if (ref $names->{$attname} eq 'HASH') {
+			my $t = $self->{locale}->text($names->{$attname}{text});
+			$names->{$attname}{text} = $t;
+		} else {
+			my $t = $self->{locale}->text($names->{$attname});
+			if (defined $sorturls{$attname}) {
+				$names->{$attname} = 
+				{
+					text => $t,
+				 	href => $sorturls{$attname} 
+				};
+			} else {
+				$names->{$attname} = $t;
+			}
+		}
+	}
+	
+	return $names;
+}
+
 1;

Modified: trunk/UI/create_batch.html
===================================================================
--- trunk/UI/create_batch.html	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/UI/create_batch.html	2010-04-30 21:47:12 UTC (rev 2994)
@@ -20,7 +20,7 @@
     <?lsmb text("Description") ?>
   </div>
   <div class="input">
-    <input name="description" type="text" value="<?lsmb batchnumber ?>"/>
+    <input name="description" type="text" value="<?lsmb batch_number ?>"/>
   </div>
 </div>
 <div class="labelledinput">
@@ -43,11 +43,12 @@
 <div class="listtop"><?lsmb text('Or Add To Batch') ?></div>
 <table>
 <tr class="listheading">
-  <th><?lsmb text('Batch Type') ?></th>
-  <th><?lsmb text('Control Number') ?></th>
-  <th><?lsmb text('Description') ?></th>
-  <th><?lsmb text('Created By') ?></th>
-  <th><?lsmb text('Created On') ?></th>
+  <th class="listtop"><?lsmb text('Batch Type') ?></th>
+  <th class="listtop"><a class="listtop" href = "<?lsmb "vouchers.pl?action=create_batch&batch_type=$batch_type&order_by=control_code" ?>"><?lsmb text('Control Number') ?></th>
+  <th class="listtop"><a class="listtop" href = "<?lsmb "vouchers.pl?action=create_batch&batch_type=$batch_type&order_by=description" ?>"><?lsmb text('Description') ?></th>
+  <th class="listtop"><a class="listtop" href = "<?lsmb "vouchers.pl?action=create_batch&batch_type=$batch_type&order_by=created_by" ?>"><?lsmb text('Created By') ?></th>
+  <th class="listtop"><a class="listtop" href = "<?lsmb "vouchers.pl?action=create_batch&batch_type=$batch_type&order_by=created_on" ?>"><?lsmb text('Created On') ?></th>
+  <th class="listtop"><a class="listtop" href = "<?lsmb "vouchers.pl?action=create_batch&batch_type=$batch_type&order_by=default_date" ?>"><?lsmb text('Post Date') ?></th>
 </tr>
 <?lsmb FOR row = search_results ?>
 <tr>
@@ -56,6 +57,7 @@
   <td><?lsmb row.description ?></td>
   <td><?lsmb row.created_by ?></td>
   <td><?lsmb row.created_on ?></td>
+  <td><?lsmb row.default_date?></td>
 </tr>
 <?lsmb END ?>
 </table>

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/bin/am.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -154,12 +154,14 @@
     $form->{callback} = $callback;
     @column_index = qw(accno gifi_accno description debit credit link);
 
-    $column_header{accno} = $locale->text('Account');
-    $column_header{gifi_accno} = $locale->text('GIFI');
-    $column_header{description} = $locale->text('Description');
-    $column_header{debit} = $locale->text('Debit');
-    $column_header{credit} = $locale->text('Credit');
-    $column_header{link} = $locale->text('Link');
+    my $column_names = {
+        accno => 'Account',
+        gifi_accno => 'GIFI',
+        description => 'Description',
+        debit => 'Debit',
+        credit => 'Credit',
+        link => 'Link'
+    };
 
     # escape callback
     $callback = $form->escape($callback);
@@ -243,12 +245,15 @@
         path => 'UI',
         template => 'form-dynatable',
         format => ($format ne 'LIS')? $format: 'HTML');
+    
+    my $column_heading = $template->column_heading($column_names);
+    
     $template->render({
         form => $form,
         buttons => ..hidden..,
 	hiddens => \%hiddens,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
 	row_alignment => \%row_alignment,
     });
@@ -301,11 +306,12 @@
     $hiddens{sessionid} = $form->{sessionid};
 
     my @column_index = qw(accno description);
-    my %column_header;
     my @rows;
 
-    $column_header{accno} = $locale->text('GIFI');
-    $column_header{description} = $locale->text('Description');
+    my $column_names = {
+        accno => 'GIFI',
+        description => 'Description'
+    };
 
     my $i = 0;
     foreach $ca ( @{ $form->{ALL} } ) {
@@ -338,12 +344,15 @@
         path => 'UI',
 	template => 'form-dynatable',
         format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML');
+    
+    my $column_heading = $template->column_heading($column_names);
+        
     $template->render({
         form => \%$form,
         hiddens => \%hiddens,
         buttons => ..hidden..,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
     });
 }
@@ -1887,10 +1896,12 @@
     $form->{title} = $locale->text('Warehouses');
 
     my @column_index = qw(description);
-    my %column_header;
-    $column_header{description} = {
+    
+    my $column_names = {
+        description => {
         href => $href,
-        text => $locale->text('Description'),
+            text => 'Description'
+        }
         };
 
     my @rows;
@@ -1928,12 +1939,15 @@
         user => \%myconfig, 
         locale => $locale,
         template => 'form-dynatable');
+    
+    my $column_heading = $template->column_heading($column_names);
+    
     $template->render({
         form => $form,
         buttons => ..hidden..,
 	hiddens => \%hiddens,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
     });
 }

Modified: trunk/bin/arapprn.pl
===================================================================
--- trunk/bin/arapprn.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/bin/arapprn.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -618,13 +618,14 @@
     # list payments with radio button on a form
     $form->{title} = $locale->text('Select payment');
 
-    my %column_heading;
-    $column_heading{ndx}      = ' ';
-    $column_heading{datepaid} = $locale->text('Date');
-    $column_heading{source}   = $locale->text('Source');
-    $column_heading{memo}     = $locale->text('Memo');
-    $column_heading{paid}     = $locale->text('Amount');
-    $column_heading{"$form->{ARAP}_paid"} = $locale->text('Account');
+    my $column_names = {
+        ndx => ' ',
+        datepaid => 'Date',
+        source => 'Source',
+        memo => 'Memo',
+        paid => 'Amount',
+        "$form->{ARAP}_paid" => 'Account'
+    };
 
     my $checked = "checked";
     my @rows;
@@ -672,12 +673,15 @@
         locale => $locale,
         template => 'form-dynatable',
         );
+        
+    my $column_heading = $template->column_heading($column_names);
+    
     $template->render({
         form => $form,
         buttons => ..hidden..,
         hiddens => \%hiddens,
         columns => ..hidden..,
-        heading => \%column_heading,
+        heading => $column_heading,
         rows => ..hidden..,
         row_alignment => {'paid' => 'right'},
     });

Modified: trunk/bin/ca.pl
===================================================================
--- trunk/bin/ca.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/bin/ca.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -88,11 +88,13 @@
 
     @column_index = qw(accno gifi_accno description debit credit);
 
-    $column_header{accno} = $locale->text('Account');
-    $column_header{gifi_accno} = $locale->text('GIFI');
-    $column_header{description} = $locale->text('Description');
-    $column_header{debit} = $locale->text('Debit');
-    $column_header{credit} = $locale->text('Credit');
+    my $column_names = {
+        accno => 'Account',
+        gifi_accno => 'GIFI',
+        description => 'Description',
+        debit => 'Debit',
+        credit => 'Credit'
+    };
 
     $form->{title} = $locale->text('Chart of Accounts');
     $form->{callback} = 
@@ -168,12 +170,15 @@
         path => 'UI',
         template => 'form-dynatable',
         format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML');
+        
+    my $column_heading = $template->column_heading($column_names);
+    
     $template->render({
         form => \%$form,
         buttons => ..hidden..,
         hiddens => \%hiddens,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         totals => \%column_data,
         rows => ..hidden..,
         row_alignment => {'credit' => 'right', 'debit' => 'right'},

Modified: trunk/bin/gl.pl
===================================================================
--- trunk/bin/gl.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/bin/gl.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -653,29 +653,24 @@
     $href     .= "&category=$form->{category}";
     $hiddens{category} = $form->{category};
 
-    $column_header{id} =
-        {text => $locale->text('ID'), href=> "$href&sort=id"};
-    $column_header{transdate} =
-        {text => $locale->text('Date'), href=> "$href&sort=transdate"};
-    $column_header{reference} =
-        {text => $locale->text('Reference'), href=> "$href&sort=reference"};
-    $column_header{source} =
-        {text => $locale->text('Source'), href=> "$href&sort=source"};
-    $column_header{memo} =
-        {text => $locale->text('Memo'), href=> "$href&sort=memo"};
-    $column_header{description} =
-        {text => $locale->text('Description'), href=> "$href&sort=description"};
-    $column_header{department} =
-        {text => $locale->text('Department'), href=> "$href&sort=department"};
-    $column_header{notes} = $locale->text('Notes');
-    $column_header{debit} = $locale->text('Debit');
-    $column_header{credit} = $locale->text('Credit');
-    $column_header{accno} =
-        {text => $locale->text('Account'), href=> "$href&sort=accno"};
-    $column_header{gifi_accno} =
-        {text => $locale->text('GIFI'), href=> "$href&sort=gifi_accno"};
-    $column_header{balance} = $locale->text('Balance');
-    $column_header{cleared} = $locale->text('R');
+    my $column_names = {
+        id => 'ID',
+        transdate => 'Date',
+        reference => 'Reference',
+        source => 'Source',
+        memo => 'Memo',
+        description => 'Description',
+        department => 'Department',
+        notes => 'Notes',
+        debit => 'Debit',
+        credit => 'Credit',
+        accno => 'Account',
+        gifi_accno => 'GIFI',
+        balance => 'Balance',
+        cleared => 'R'
+    };
+    my $sort_href = "$href&sort";
+    my @sort_columns = qw(id transdate reference source memo description department accno gifi_accno);
 
     # add sort to callback
     $form->{callback} = "$callback&sort=$form->{sort}";
@@ -705,6 +700,7 @@
     }
 
     # reverse href
+    # XXX: should we use the reversed href as the sort_href url above ?
     $direction = ( $form->{direction} eq 'ASC' ) ? "ASC" : "DESC";
     $form->sort_order();
     $href =~ s/direction=$form->{direction}/direction=$direction/;
@@ -865,15 +861,17 @@
         );
     $template->{method} = 'email' if $output_options;
  
+    my $column_heading = $template->column_heading($column_names,
+        {href => $sort_href, columns => ..hidden..
+    );
 
-
    $template->render({
         form => \%$form,
         buttons => ..hidden..,
         hiddens => \%hiddens,
         options => ..hidden..,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
         row_alignment => \%row_alignment,
         totals => \%column_data,

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/bin/rp.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -385,31 +385,16 @@
     my $href =
 qq|rp.pl?path=$form->{path}&action=continue&accounttype=$form->{accounttype}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&l_heading=$form->{l_heading}&l_subtotal=$form->{l_subtotal}&department=$department&projectnumber=$projectnumber&project_id=$form->{project_id}&title=$title&nextsub=$form->{nextsub}|;
 
-    my %column_header;
-    $column_header{partnumber} = {
-        text => $locale->text('Part Number'),
-        href => "$href&sort_col=partnumber",
+    my $column_names = {
+        partnumber => 'Part Number',
+        description => 'Description',
+        sold => 'Sold',
+        revenue => 'Revenue',
+        received => 'Received',
+        expense => 'Expense'
         };
-    $column_header{description} = {
-        text => $locale->text('Description'),
-        href => "$href&sort_col=description",
-        };
-    $column_header{sold} = {
-        text => $locale->text('Sold'),
-        href => "$href&sort_col=sold",
-        };
-    $column_header{revenue} = {
-        text => $locale->text('Revenue'),
-        href => "$href&sort_col=revenue",
-        };
-    $column_header{received} = {
-        text => $locale->text('Received'),
-        href => "$href&sort_col=received",
-        };
-    $column_header{expense} = {
-        text => $locale->text('Expense'),
-        href => "$href&sort_col=expense",
-        };
+    my @sort_columns = @column_index;
+    my $sort_href = "$href&sort_col";
 
     if ( $form->{sort_col} eq 'qty' || $form->{sort_col} eq 'revenue' ) {
         $form->{sort_type} = 'numeric';
@@ -474,12 +459,17 @@
         locale => $locale, 
         template => 'form-dynatable',
         );
+    
+    my $column_heading = $template->column_heading($column_names,
+        {href => $sort_href, columns => ..hidden..
+    );
+    
     $template->render({
         form => $form,
         hiddens => \%hiddens,
         options => ..hidden..,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
         row_alignment => {
             sold => 'right',
@@ -702,16 +692,17 @@
 
     my @column_index = qw(accno description begbalance debit credit endbalance);
 
-    my %column_header;
-    $column_header{accno} = $locale->text('Account');
-    $column_header{description} = $locale->text('Description');
-    $column_header{debit} = $locale->text('Debit');
-    $column_header{credit} = $locale->text('Credit');
-    $column_header{begbalance} = $locale->text('Balance');
-    $column_header{endbalance} = $locale->text('Balance');
+    my $column_names = {
+        accno => 'Account',
+        description => 'Description',
+        debit => 'Debit',
+        credit => 'Credit',
+        begbalance => 'Balance',
+        endbalance => 'Balance'
+    };
 
     if ( $form->{accounttype} eq 'gifi' ) {
-        $column_header{accno} = $locale->text('GIFI');
+        $column_names->{accno} = 'GIFI';
     }
 
     # sort the whole thing by account numbers and display
@@ -904,13 +895,16 @@
         path => 'UI',
         format => $format,
         );
+    
+    my $column_heading = $template->column_heading($column_names);    
+    
     $template->render({
         form => $form,
         hiddens => \%hiddens,
         buttons => ..hidden..,
         options => ..hidden..,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
         totals => \%column_data,
         row_alignment => {
@@ -1757,32 +1751,19 @@
 
     push @options, $form->{period};
 
-    my %column_header;
-    $column_header{id} = {
-        href => "$href&sort=id",
-        text => $locale->text('ID'),
+    my $column_names = {
+        id => 'ID',
+        invnumber => 'Invoice',
+        transdate => 'Date',
+        netamount => 'Amount',
+        tax => 'Tax',
+        total => 'Total',
+        name => $name,
+        description => 'Description'
         };
-    $column_header{invnumber} = {
-        href => "$href&sort=invnumber",
-        text => $locale->text('Invoice')
-        };
-    $column_header{transdate} = {
-        href => "$href&sort=transdate",
-        text => $locale->text('Date'),
-        };
-    $column_header{netamount} = $locale->text('Amount');
-    $column_header{tax} = $locale->text('Tax');
-    $column_header{total} = $locale->text('Total');
+    my @sort_columns = qw(id invnumber transdate name description);
+    my $sort_href = "$href&sort";
 
-    $column_header{name} = {
-        href => "$href&sort=name",
-        text => $name,
-        };
-    $column_header{description} = {
-        href => "$href&sort=description",
-        text => $locale->text('Description'),
-        };
-
     # add sort and escape callback
     $callback = $form->escape( $callback . "&sort=$form->{sort}" );
 
@@ -1862,12 +1843,17 @@
         locale => $locale, 
         template => 'form-dynatable',
         );
+    
+    my $column_heading = $template->column_heading($column_names,
+        {href => $sort_href, columns => ..hidden..
+    );
+    
     $template->render({
         form => $form,
         hiddens => \%hiddens,
         options => ..hidden..,
         columns => ..hidden..,
-        heading => \%column_header,
+        heading => $column_heading,
         rows => ..hidden..,
         totals => \%column_data,
         row_alignment => {

Modified: trunk/scripts/admin.pl
===================================================================
--- trunk/scripts/admin.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/scripts/admin.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -422,14 +422,17 @@
     );
     my $columns;
     @$columns = qw(id username first_name last_name ssn dob edit);
-    my $column_headers = {
-        id         => $request->{_locale}->text('ID'),
-        username   => $request->{_locale}->text('Username'),
-        first_name => $request->{_locale}->text('First Name'),
-        last_name  => $request->{_locale}->text('Last Name'),
-        ssn        => $request->{_locale}->text('Tax ID'),
-        dob         => $request->{_locale}->text('Date of Birth'),
+    
+    my $column_names = {
+        id => 'ID',
+        username => 'Username',
+        first_name => 'First Name',
+        last_name => 'Last Name',
+        ssn => 'Tax ID',
+        dob => 'Date of Birth'
     };
+    my $column_heading = $template->column_heading($column_names);
+    
     my $rows = [];
     my $rowcount = "0";
     my $base_url = "admin.pl?action=edit_user";
@@ -446,7 +449,7 @@
     $template->render({
 	form    => $admin,
 	columns => $columns,
-	heading => $column_headers,
+	heading => $column_heading,
         rows    => $rows,
 	buttons => [],
 	hiddens => [],
@@ -466,13 +469,13 @@
     );
     my $columns;
     @$columns = qw(id username last_used locks_active drop);
-    my $column_headers = {
-        id         => $request->{_locale}->text('ID'),
-        username   => $request->{_locale}->text('Username'),
-        last_used => $request->{_locale}->text('Last Used'),
-        locks_active  => $request->{_locale}->text('Transactions Locked'),
-
+    my $column_names = {
+        id => 'ID',
+        username => 'Username',
+        last_used => 'Last Used',
+        locks_active => 'Transactions Locked'
     };
+    my $column_heading = $template->column_heading($column_names);
     my $rows = [];
     my $rowcount = "0";
     my $base_url = "admin.pl?action=delete_session";
@@ -489,7 +492,7 @@
     $template->render({
 	form    => $admin,
 	columns => $columns,
-	heading => $column_headers,
+    heading => $column_heading,
         rows    => $rows,
 	buttons => [],
 	hiddens => [],

Modified: trunk/scripts/drafts.pl
===================================================================
--- trunk/scripts/drafts.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/scripts/drafts.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -89,29 +89,17 @@
        $search_href .= "&$key=$draft->{$key}";
     }
 
-    my %column_heading = (
-        'select'          => $draft->{_locale}->text('Select'),
-        amount => {
-             text => $draft->{_locale}->text('AR/AP/GL Total'),
-             href => "$search_href&order_by=amount"
-        },
-        description       => {
-             text => $draft->{_locale}->text('Description'),
-             href => "$search_href&order_by=description"
-        },
-        id                => {
-             text => $draft->{_locale}->text('ID'),
-             href => "$search_href&order_by=id"
-        },
-        reference         => {
-             text => $draft->{_locale}->text('Reference'),
-             href => "$search_href&order_by=reference"
-        },
-        transdate          => {
-             text => $draft->{_locale}->text('Date'),
-             href => "$search_href&order_by=transdate"
-        },
-    );
+    my $column_names = {
+        'select' => 'Select',
+         amount =>  'AR/AP/GL Total',
+         description => 'Description',
+         id => 'ID',
+         reference => 'Reference',
+         transdate => 'Date'
+    };
+    my $sort_href = "$search_href&order_by";
+    my @sort_columns = qw(id transdate reference description amount);
+    
     my $count = 0;
     my @rows;
     for my $result (@search_results){
@@ -151,10 +139,14 @@
     $draft->{rowcount} = "$count";
     delete $draft->{search_results};
 
+    my $column_heading = $template->column_heading($column_names,
+        {href => $sort_href, columns => ..hidden..
+    );
+
     $template->render({ 
 	form    => $draft,
 	columns => ..hidden..,
-	heading => \%column_heading,
+	heading => $column_heading,
         rows    => ..hidden..,
         hiddens => $hiddens,
         buttons => [{

Modified: trunk/scripts/payment.pl
===================================================================
--- trunk/scripts/payment.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/scripts/payment.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -137,40 +137,23 @@
     #  $request->{_locale}->text("Vendor Number");
     #  $request->{_locale}->text("Customer Number");
 
-    my $heading = {
-         selected     => $request->{_locale}->text('Selected'),
-         company_paid => {
-                          text => $request->{_locale}->text('Company Name'),
-                          href => "$search_url&orderby=company_paid",
-                         },
-         meta_number  => {
-                          text => $request->{_locale}->text(
-                                        "$contact_type Number"
-                                  ),
-                          href => "$search_url&orderby=meta_number",
-                         },
-         date_paid    => {
-                          text => $request->{_locale}->text('Date Paid'),
-                          href => "$search_url&orderby=date_paid",
-                         },
-         amount       => {
-                          text => $request->{_locale}->text('Total Paid'),
-                          href => "$search_url&orderby=amount",
-                         },
-         source       => {
-                          text => $request->{_locale}->text('Source'),
-                          href => "$search_url&orderby=source",
-                         },
-	 batch_control => {
-                          text => $request->{_locale}->text('Batch'),
-                          href => "$search_url&orderby=batch_control",
-			},
-	 batch_description => {
-                          text => $request->{_locale}->text('Batch Description'),
-                          href => "$search_url&orderby=batch_description",
-			},
+    my $column_names = {
+        selected => 'Selected',
+        company_paid => 'Company Name',
+        meta_number => "$contact_type Number",
+        date_paid => 'Date Paid',
+        amount => 'Total Paid',
+        source => 'Source',
+        batch_control => 'Batch',
+        batch_description => 'Batch Description'
     };
+    my $sort_href = "$search_url&orderby";
+    my @sort_columns = qw(meta_number date_paid amount source 
+		company_paid batch_description batch_control);
 
+	my $column_heading = $template->column_heading($column_names, 
+	    {href => $sort_href, columns => ..hidden..
+	);	
 
     my $classcount;
     $classcount = 0;
@@ -209,7 +192,7 @@
     $template->render({
         form    => $payment,
         columns => ..hidden..,
-        heading => $heading,
+        heading => $column_heading,
         hiddens => $payment->take_top_level,
         rows    => $rows,
         buttons => [{

Modified: trunk/scripts/recon.pl
===================================================================
--- trunk/scripts/recon.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/scripts/recon.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -143,41 +143,22 @@
              "&amount_from=$search->{amount_from}&".
              "amount_to=$search->{amount_to}&chart_id=$search->{chart_id}".
              "&approved=$search->{approved}&submitted=$search->{submitted}";
-        $columns = {
-            "select"         => $request->{_locale}->text('Select'),	
-            account          => {
-		text => $request->{_locale}->text('Account'),	
-		href => $search_url,
-	    },
-            their_total      => {
-                text => $request->{_locale}->text('Balance'),
-                href => "$search_url&order_by=their_total",
-            },
-            end_date         => {
-                text => $request->{_locale}->text('Statement Date'),
-                href => "$search_url&order_by=end_date",
-            },
-            submitted        => {
-		text => $request->{_locale}->text('Submitted'),
-                href => "$search_url&order_by=submitted",
-            },
-            approved         => {
-		text => $request->{_locale}->text('Approved'), 
-		href => "$search_url&order_by=approved",
-            },
-            updated          => {
-		text => $request->{_locale}->text('Last Updated'), 
-		href => "$search_url&order_by=updated",
-            },
-            entered_username => {
-		text => $request->{_locale}->text('Entered By'), 
-		href => "$search_url&order_by=entered_username",
-            },
-            approved_username => {
-		text => $request->{_locale}->text('Approved By'), 
-		href => "$search_url&order_by=approved_username",
-            },
+        
+        my $column_names = {
+            "select" => 'Select',
+            account => 'Account',
+            their_total => 'Balance',
+            end_date => 'Statement Date',
+            submitted => 'Submitted',
+            approved => 'Approved',
+            updated => 'Last Updated',
+            entered_username => 'Entered By',
+            approved_username => 'Approved By'
         };
+        my $sort_href = "$search_url&order_by";
+        my @sort_columns = qw(account their_total end_date submitted 
+            approved updated entered_username approved_username);
+        
 	my $cols = [];
 	my @acts = $search->get_accounts;
 	@$cols = qw(select account end_date their_total approved submitted 
@@ -207,9 +188,14 @@
     	    language => $user->{language}, 
             format => 'HTML',
             path=>"UI");
+        
+        my $column_heading = $template->column_heading($column_names,
+            {href => $sort_href, columns => ..hidden..
+        );
+        
         return $template->render({
 		form     => $recon,
-		heading  => $columns,
+		heading  => $column_heading,
         	hiddens  => $recon,
 		columns  => $cols,
 		rows     => ..hidden..

Modified: trunk/scripts/vouchers.pl
===================================================================
--- trunk/scripts/vouchers.pl	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/scripts/vouchers.pl	2010-04-30 21:47:12 UTC (rev 2994)
@@ -43,6 +43,14 @@
     my $batch = LedgerSMB::Batch->new({base => $request});
     $batch->{class_id} = $batch->get_class_id($batch->{batch_type});
     $batch->get_new_info;
+    
+    if ($batch->{order_by}) {
+        $batch->set_ordering({
+                method => $batch->get_search_method({mini => 1}),
+                column => $batch->{order_by}   
+        });
+    }
+    
     $batch->get_search_results({mini => 1});
 
     my $template = LedgerSMB::Template->new(
@@ -175,49 +183,39 @@
     $batch->open_form;
     if ($batch->{order_by}){
         $batch->set_ordering(
-		{method => 'batch_search', 
-		 column => $batch->{order_by}}
-        );
+		{method => $batch->get_search_method({custom_types => $custom_batch_types}), 
+		 column => $batch->{order_by}
+		});
     }
     my @search_results = $batch->get_search_results({custom_types => $custom_batch_types});
     $batch->{script} = "vouchers.pl";
 
     my @columns = 
-        qw(select id control_code description transaction_total payment_total);
+        qw(select id control_code description transaction_total payment_total default_date);
 
     my $base_href = "vouchers.pl";
     my $search_href = "$base_href?action=list_batches";
     my $batch_href = "$base_href?action=get_batch";
 
     for my $key (
-       qw(class_id approved created_by description amount_gt amount_lt)
+       qw(class_id approved created_by description empty amount_gt amount_lt)
     ){
        $search_href .= "&$key=$batch->{$key}";
     }
 
-    my %column_heading = (
-        'select'          => $batch->{_locale}->text('Select'),
-        transaction_total => {
-             text => $batch->{_locale}->text('AR/AP/GL Total'),
-             href => "$search_href&order_by=transaction_total"
-        },
-        payment_total     => { 
-             text => $batch->{_locale}->text('Paid/Received Total'),
-             href => "$search_href&order_by=payment_total"
-        },
-        description       => {
-             text => $batch->{_locale}->text('Description'),
-             href => "$search_href&order_by=description"
-        },
-        control_code      => {
-             text => $batch->{_locale}->text('Batch Number'),
-             href => "$search_href&order_by=control_code"
-        },
-        id                => {
-             text => $batch->{_locale}->text('ID'),
-             href => "$search_href&order_by=id"
-        },
-    );
+	my $sort_href = "$search_href&order_by";
+	
+    my $column_names = {
+        'select'          => 'Select',
+        transaction_total => 'AR/AP/GL Total',
+        payment_total => 'Paid/Received Total',
+        description => 'Description',
+        control_code => 'Batch Number',
+        id => 'ID',
+        default_date => 'Post Date'
+    };
+    my @sort_columns = qw(id control_code description transaction_total payment_total default_date);
+	
     my $count = 0;
     my @rows;
     for my $result (@search_results){
@@ -244,6 +242,7 @@
 
             },
             id => $result->{id},
+			default_date => $result->{default_date}
         };
     }
     $batch->{rowcount} = $count;
@@ -255,6 +254,10 @@
         format   => ($batch->{format}) ? $batch->{format} : 'HTML', 
     );
 
+	my $column_heading = $template->column_heading($column_names, 
+		{href => $sort_href, columns => ..hidden..
+	);
+
     my $hiddens = $batch->take_top_level();
     $batch->{rowcount} = "$count";
     delete $batch->{search_results};
@@ -291,7 +294,7 @@
     $template->render({ 
 	form    => $batch,
 	columns => ..hidden..,
-	heading => \%column_heading,
+    heading => $column_heading,
         rows    => ..hidden..,
         hiddens => $hiddens,
         buttons => @buttons
@@ -315,33 +318,17 @@
     my $base_href = "vouchers.pl?action=get_batch&batch_id=$batch->{batch_id}";
 
     my @columns = qw(selected id description batch_class reference amount date);
-    my $heading = {
-        selected    => $request->{_locale}->text('Selected'),
-        id          => {
-                        text => $request->{_locale}->text('ID'),
-                        href => "$base_href&order_by=id"
-        },
-        description => { 
-                        href => "$base_href&order_by=description",
-                        text => $request->{_locale}->text('Description'),
-        },
-        batch_class => {
-                        text => $request->{_locale}->text('Class'),
-                        href => "$base_href&order_by=class"
-        },
-        amount      => {
-                        text => $request->{_locale}->text('Amount'),
-                        href => "$base_href&order_by=amount"
-        }, 
-        reference   => {
-                        text => $request->{_locale}->text('Source/Reference'),
-                        href => "$base_href&order_by=reference"
-        },
-        date        => {
-                        text => $request->{_locale}->text('Date'),
-                        href => "$base_href&order_by=date"
-        }
+    my $column_names = {
+        selected => 'Selected',
+        id => 'ID',
+        description => 'Description',
+        batch_class => 'Class',
+        amount => 'Amount',
+        reference => 'Source/Reference',
+        date => 'Date'
     };
+    my $sort_href = "$base_href&order_by";
+    my @sort_columns = qw(id description batch_class reference amount date);
 
     my $classcount;
     my $count = 1;
@@ -379,10 +366,15 @@
         format   => ($batch->{format}) ? $batch->{format} : 'HTML', 
     );
     my $hiddens = $batch->take_top_level();
+    
+    my $column_heading = $template->column_heading($column_names,
+        {href => $sort_href, columns => ..hidden..
+    );
+    
     $template->render({ 
 	form    => $batch,
 	columns => ..hidden..,
-	heading => $heading,
+	heading => $column_heading,
         rows    => $rows,
         hiddens => $hiddens,
         buttons => [{

Modified: trunk/sql/modules/Voucher.sql
===================================================================
--- trunk/sql/modules/Voucher.sql	2010-04-30 19:04:51 UTC (rev 2993)
+++ trunk/sql/modules/Voucher.sql	2010-04-30 21:47:12 UTC (rev 2994)
@@ -147,6 +147,7 @@
     description text,
     created_by text,
     created_on date,
+    default_date date,
     transaction_total numeric,
     payment_total numeric
 );
@@ -162,7 +163,7 @@
 BEGIN
 	FOR out_value IN
 		SELECT b.id, c.class, b.control_code, b.description, u.username,
-			b.created_on,
+			b.created_on, b.default_date,
 			sum(
 				CASE WHEN vc.id = 5 AND al.amount < 0 -- GL
 				     THEN al.amount 
@@ -207,7 +208,7 @@
 			and (in_date_to IS NULL
 				or b.default_date <= in_date_to)
 		GROUP BY b.id, c.class, b.description, u.username, b.created_on,
-			b.control_code
+			b.control_code, b.default_date
 		HAVING  
 			(in_amount_gt IS NULL OR
 			sum(coalesce(ar.amount - ar.paid, ap.amount - ap.paid, 
@@ -240,7 +241,7 @@
 BEGIN
 	FOR out_value IN
 		SELECT b.id, c.class, b.control_code, b.description, u.username,
-			b.created_on, NULL
+			b.created_on, b.default_date, NULL
 		FROM batch b
 		JOIN batch_class c ON (b.batch_class_id = c.id)
 		LEFT JOIN users u ON (u.entity_id = b.created_by)
@@ -255,7 +256,7 @@
 				(in_approved = true AND approved_on IS NOT NULL)
 			)
 		GROUP BY b.id, c.class, b.description, u.username, b.created_on,
-			b.control_code
+			b.control_code, b.default_date
 	LOOP
 		RETURN NEXT out_value;
 	END LOOP;
@@ -273,7 +274,7 @@
 BEGIN
 	FOR out_value IN
 		SELECT b.id, c.class, b.control_code, b.description, u.username,
-			b.created_on,
+			b.created_on, b.default_date,
 			sum(
 				CASE WHEN vc.id = 5 AND al.amount < 0 -- GL
 				     THEN al.amount 
@@ -314,7 +315,7 @@
 				(in_approved = true AND approved_on IS NOT NULL)
 			)
 		GROUP BY b.id, c.class, b.description, u.username, b.created_on,
-			b.control_code
+			b.control_code, b.default_date
 		HAVING  
 			(in_amount_gt IS NULL OR
 			sum(coalesce(ar.amount - ar.paid, ap.amount - ap.paid, 


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