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

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



Revision: 1839
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1839&view=rev
Author:   tetragon
Date:     2007-11-02 08:57:33 -0700 (Fri, 02 Nov 2007)

Log Message:
-----------
Template list_payments (Point of Sale->Receipts)

Modified Paths:
--------------
    trunk/bin/rp.pl

Added Paths:
-----------
    trunk/UI/rp-payments.html

Added: trunk/UI/rp-payments.html
===================================================================
--- trunk/UI/rp-payments.html	                        (rev 0)
+++ trunk/UI/rp-payments.html	2007-11-02 15:57:33 UTC (rev 1839)
@@ -0,0 +1,72 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?> 
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+  <tr>
+    <th class="listtop" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
+  </tr>
+  <tr>
+  <?lsmb IF options.defined ?>
+    <td colspan="<?lsmb columns.size ?>"><?lsmb FOREACH option IN options; option ?><br /><?lsmb END ?></td>
+  <?lsmb ELSE ?>
+    <td colspan="<?lsmb columns.size ?>"></td></tr>
+  <?lsmb END ?>
+  </tr>
+  <tr class="listheading">
+<?lsmb FOREACH column IN columns ?>
+<th class="listtop" 
+	<?lsmb IF heading.$column.href ?><a class="listtop" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a>
+	<?lsmb ELSE; heading.$column; END ?>
+    </th>
+<?lsmb END ?>
+  </tr>
+  <?lsmb FOREACH account IN accounts ?>
+  <tr><th colspan="<?lsmb columns.size ?>"><?lsmb account.header ?></th></tr>
+<?lsmb FOREACH row IN account.rows ?>
+<?lsmb IF row.class == 'heading';      s = 'th'; c = 'listheading';
+	ELSIF row.class == 'subtotal'; s = 'th'; c = 'listsubtotal';
+	ELSE;                          s = 'td'; c = "listrow${row.i}"; END ?>
+<tr class="<?lsmb c ?>">
+  <?lsmb FOREACH column IN columns ?>
+  <<?lsmb s ?> class="<?lsmb c ?>" <?lsmb IF (!row.class.defined || row.class != 'heading') && row_alignment.$column ?>align="<?lsmb row_alignment.$column ?>"<?lsmb END ?>>
+    <?lsmb IF row.$column.href ?>
+    <a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
+    <?lsmb ELSIF row.$column.delimiter;
+	FOREACH l IN row.$column.text.split(row.$column.delimiter); l ?><br /><?lsmb END;
+    ELSIF row.$column.options; PROCESS select element_data=row.$column;
+    ELSIF column == 'statement' AND row.$column.type.defined;
+        PROCESS input element_data=row.$column;
+    ELSE; row.$column; END ?>
+  </<?lsmb s ?>>
+  <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+<?lsmb IF account.totals ?>
+<tr class="listtotal">
+  <?lsmb FOREACH column IN columns ?>
+  <th class="listtotal" align="right"><?lsmb account.totals.$column ?></th>
+  <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+<?lsmb END ?>
+<tr class="listtotal">
+  <?lsmb FOREACH column IN columns ?>
+  <th class="listtotal" align="right"><?lsmb account.totals.$column ?></th>
+  <?lsmb END ?>
+</tr>
+  <tr><td colspan="<?lsmb columns.size ?>"><hr size="3" /></td></tr>
+</table>
+
+<br />
+
+<?lsmb FOREACH hidden IN hiddens.keys;
+	PROCESS input element_data={
+		type => 'hidden',
+		name => hidden,
+		value => hiddens.item(hidden)
+		}; END ?>
+<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
+</form>
+</body>
+</html>

Modified: trunk/bin/rp.pl
===================================================================
--- trunk/bin/rp.pl	2007-11-02 15:25:32 UTC (rev 1838)
+++ trunk/bin/rp.pl	2007-11-02 15:57:33 UTC (rev 1839)
@@ -2436,18 +2436,20 @@
 
 sub list_payments {
 
+    my %hiddens;
+    my @options;
     if ( $form->{account} ) {
         ( $form->{paymentaccounts} ) = split /--/, $form->{account};
     }
     if ( $form->{department} ) {
         ( $department, $form->{department_id} ) = split /--/,
           $form->{department};
-        $option = $locale->text('Department') . " : $department";
+        push @options, $locale->text('Department: [_1]', $department);
     }
 
     RP->payments( \%myconfig, \%$form );
 
-    @columns = $form->sort_columns(qw(transdate name paid source memo));
+    my @columns = $form->sort_columns(qw(transdate name paid source memo));
 
     if ( $form->{till} ) {
         @columns =
@@ -2460,10 +2462,10 @@
     }
 
     # construct href
-    $title = $form->escape( $form->{title} );
+    my $title = $form->escape( $form->{title} );
     $form->{paymentaccounts} =~ s/ /%20/g;
 
-    $href =
+    my $href =
 "$form->{script}?path=$form->{path}&direction=$form->{direction}&sort=$form->{sort}&oldsort=$form->{oldsort}&action=list_payments&till=$form->{till}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&fx_transaction=$form->{fx_transaction}&db=$form->{db}&l_subtotal=$form->{l_subtotal}&prepayment=$form->{prepayment}&paymentaccounts=$form->{paymentaccounts}&title="
       . $form->escape( $form->{title} );
 
@@ -2473,147 +2475,110 @@
 "$form->{script}?path=$form->{path}&direction=$form->{direction}&sort=$form->{sort}&oldsort=$form->{oldsort}&action=list_payments&till=$form->{till}&login=$form->{login}&sessionid=$form->{sessionid}&fromdate=$form->{fromdate}&todate=$form->{todate}&fx_transaction=$form->{fx_transaction}&db=$form->{db}&l_subtotal=$form->{l_subtotal}&prepayment=$form->{prepayment}&paymentaccounts=$form->{paymentaccounts}&title="
       . $form->escape( $form->{title}, 1 );
 
+    my $callback;
     if ( $form->{account} ) {
         $callback .= "&account=" . $form->escape( $form->{account}, 1 );
         $href   .= "&account=" . $form->escape( $form->{account} );
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Account') . " : $form->{account}";
+        push @options, $locale->text('Account: [_1]', $form->{account});
     }
     if ( $form->{department} ) {
         $callback .= "&department=" . $form->escape( $form->{department}, 1 );
         $href   .= "&department=" . $form->escape( $form->{department} );
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Department') . " : $form->{department}";
+        push @options, $locale->text('Department: [_1]', $form->{department});
     }
     if ( $form->{description} ) {
         $callback .= "&description=" . $form->escape( $form->{description}, 1 );
         $href   .= "&description=" . $form->escape( $form->{description} );
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Description') . " : $form->{description}";
+        push @options, $locale->text('Description: [_1]', $form->{description});
     }
     if ( $form->{source} ) {
         $callback .= "&source=" . $form->escape( $form->{source}, 1 );
         $href   .= "&source=" . $form->escape( $form->{source} );
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Source') . " : $form->{source}";
+        push @options, $locale->text('Source: [_1]', $form->{source});
     }
     if ( $form->{memo} ) {
         $callback .= "&memo=" . $form->escape( $form->{memo}, 1 );
         $href   .= "&memo=" . $form->escape( $form->{memo} );
-        $option .= "\n<br>" if ($option);
-        $option .= $locale->text('Memo') . " : $form->{memo}";
+        push @options, $locale->text('Memo: [_1]', $form->{memo});
     }
     if ( $form->{fromdate} ) {
-        $option .= "\n<br>" if ($option);
-        $option .=
-            $locale->text('From') . "&nbsp;"
-          . $locale->date( \%myconfig, $form->{fromdate}, 1 );
+        push @options,
+            $locale->text('From [_1]',
+                $locale->date( \%myconfig, $form->{fromdate}, 1 ));
     }
     if ( $form->{todate} ) {
-        $option .= "\n<br>" if ($option);
-        $option .=
-            $locale->text('To') . "&nbsp;"
-          . $locale->date( \%myconfig, $form->{todate}, 1 );
+        push @options, 
+            $locale->text('To [_1]',
+                $locale->date( \%myconfig, $form->{todate}, 1 ));
     }
 
     $callback = $form->escape( $form->{callback} );
 
-    $column_header{name} =
-        "<th><a class=listheading href=$href&sort=name>"
-      . $locale->text('Description')
-      . "</a></th>";
-    $column_header{transdate} =
-        "<th><a class=listheading href=$href&sort=transdate>"
-      . $locale->text('Date')
-      . "</a></th>";
-    $column_header{paid} =
-      "<th class=listheading>" . $locale->text('Amount') . "</a></th>";
-    $column_header{curr} =
-      "<th class=listheading>" . $locale->text('Curr') . "</a></th>";
-    $column_header{source} =
-        "<th><a class=listheading href=$href&sort=source>"
-      . $locale->text('Source')
-      . "</a></th>";
-    $column_header{memo} =
-        "<th><a class=listheading href=$href&sort=memo>"
-      . $locale->text('Memo')
-      . "</a></th>";
+    my %column_header;
+    $column_header{name} = {
+        href => "$href&sort=name",
+        text => $locale->text('Description'),
+        };
+    $column_header{transdate} = {
+        href => "$href&sort=transdate",
+        text => $locale->text('Date'),
+        };
+    $column_header{paid} = $locale->text('Amount');
+    $column_header{curr} = $locale->text('Curr');
+    $column_header{source} = {
+        href => "$href&sort=source",
+        text => $locale->text('Source'),
+        };
+    $column_header{memo} = {
+        href => "$href&sort=memo",
+        text => $locale->text('Memo'),
+        };
+    $column_header{employee} = {
+        href => "$href&sort=employee",
+        text => $locale->text('Salesperson'),
+        };
+    $column_header{till} = {
+        href => "$href&sort=till",
+        text => $locale->text('Till'),
+        };
 
-    $column_header{employee} =
-        "<th><a class=listheading href=$href&sort=employee>"
-      . $locale->text('Salesperson')
-      . "</a></th>";
-    $column_header{till} =
-        "<th><a class=listheading href=$href&sort=till>"
-      . $locale->text('Till')
-      . "</a></th>";
+    my @column_index = @columns;
 
-    @column_index = @columns;
-    $colspan      = $#column_index + 1;
+    my @accounts;
+    my $i;
+    foreach my $ref ( sort { $a->{accno} cmp $b->{accno} } @{ $form->{PR} } ) {
 
-    $form->header;
-
-    print qq|
-<body>
-
-<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>
-|;
-
-    foreach $ref ( sort { $a->{accno} cmp $b->{accno} } @{ $form->{PR} } ) {
-
         next unless @{ $form->{ $ref->{id} } };
 
-        print qq|
-        <tr>
-	  <th colspan=$colspan align=left>$ref->{accno}--$ref->{description}</th>
-	</tr>
-|;
+        push @accounts, {header => "$ref->{accno}--$ref->{description}"};
 
         if ( @{ $form->{ $ref->{id} } } ) {
             $sameitem = $form->{ $ref->{id} }[0]->{ $form->{sort} };
         }
 
-        foreach $payment ( @{ $form->{ $ref->{id} } } ) {
+        my @rows;
+        foreach my $payment ( @{ $form->{ $ref->{id} } } ) {
 
             if ( $form->{l_subtotal} ) {
                 if ( $payment->{ $form->{sort} } ne $sameitem ) {
 
                     # print subtotal
-                    &payment_subtotal;
+                    push @rows, &payment_subtotal(..hidden..);
                 }
             }
 
             next if ( $form->{till} && !$payment->{till} );
 
-            $column_data{name}      = "<td>$payment->{name}&nbsp;</td>";
-            $column_data{transdate} = "<td>$payment->{transdate}&nbsp;</td>";
+            my %column_data;
+            $column_data{name}      = $payment->{name};
+            $column_data{transdate} = $payment->{transdate};
             $column_data{paid} =
-              "<td align=right>"
-              . $form->format_amount( \%myconfig, $payment->{paid}, 2,
-                "&nbsp;" )
-              . "</td>";
-            $column_data{curr}     = "<td>$payment->{curr}</td>";
-            $column_data{source}   = "<td>$payment->{source}&nbsp;</td>";
-            $column_data{memo}     = "<td>$payment->{memo}&nbsp;</td>";
-            $column_data{employee} = "<td>$payment->{employee}&nbsp;</td>";
-            $column_data{till}     = "<td>$payment->{till}&nbsp;</td>";
+                $form->format_amount(\%myconfig, $payment->{paid}, 2, ' ');
+            $column_data{curr}     = $payment->{curr};
+            $column_data{source}   = $payment->{source};
+            $column_data{memo}     = $payment->{memo};
+            $column_data{employee} = $payment->{employee};
+            $column_data{till}     = $payment->{till};
 
             $subtotalpaid     += $payment->{paid};
             $accounttotalpaid += $payment->{paid};
@@ -2621,104 +2586,70 @@
 
             $i++;
             $i %= 2;
-            print qq|
-	<tr class=listrow$i>
-|;
+            $column_data{i} = $i;
+            push @rows, \%column_data;
 
-            for (@column_index) { print "\n$column_data{$_}" }
-
-            print qq|
-        </tr>
-|;
-
             $sameitem = $payment->{ $form->{sort} };
 
         }
+        push @rows, &payment_subtotal(..hidden..) if $form->{l_subtotal};
+        $accounts[$#accounts]{rows} = ..hidden..;
 
-        &payment_subtotal if $form->{l_subtotal};
-
         # print account totals
-        for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
+        my %column_data;
+        for (@column_index) { $column_data{$_} = ' ' }
 
         $column_data{paid} =
-            "<th class=listtotal align=right>"
-          . $form->format_amount( \%myconfig, $accounttotalpaid, 2, "&nbsp;" )
-          . "</th>";
+            $form->format_amount( \%myconfig, $accounttotalpaid, 2, ' ' );
 
-        print qq|
-	<tr class=listtotal>
-|;
-
-        for (@column_index) { print "\n$column_data{$_}" }
-
-        print qq|
-        </tr>
-|;
-
+        $accounts[$#accounts]{totals} = \%column_data;
         $accounttotalpaid = 0;
 
     }
 
-    # print total
-    for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
+    # prepare total
+    my %column_data;
+    for (@column_index) { $column_data{$_} = ' ' }
+    $column_data{paid} = $form->format_amount( \%myconfig, $totalpaid, 2, ' ' );
 
-    $column_data{paid} =
-      "<th class=listtotal align=right>"
-      . $form->format_amount( \%myconfig, $totalpaid, 2, "&nbsp;" ) . "</th>";
+##SC: Temporary removal
+##    if ( $form->{lynx} ) {
+##        require "bin/menu.pl";
+##        &menubar;
+##    }
 
-    print qq|
-        <tr class=listtotal>
-|;
-
-    for (@column_index) { print "\n$column_data{$_}" }
-
-    print qq|
-        </tr>
-
-      </table>
-    </td>
-  </tr>
-  <tr>
-    <td><hr size=3 noshade></td>
-  </tr>
-</table>
-|;
-
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
-
-    print qq|
- 
-</body>
-</html>
-|;
-
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale, 
+        template => 'rp-payments',
+        );
+    $template->render({
+        form => $form,
+        hiddens => \%hiddens,
+        options => ..hidden..,
+        columns => ..hidden..,
+        heading => \%column_header,
+        accounts => ..hidden..,
+        totals => \%column_data,
+        row_alignment => {
+            paid => 'right',
+            },
+    });
 }
 
 sub payment_subtotal {
 
+    my $column_index = shift;
+    my %column_data;
     if ( $subtotalpaid != 0 ) {
-        for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
+        for (@column_index) { $column_data{$_} = ' ' }
 
         $column_data{paid} =
-            "<th class=listsubtotal align=right>"
-          . $form->format_amount( \%myconfig, $subtotalpaid, 2, "&nbsp;" )
-          . "</th>";
-
-        print qq|
-  <tr class=listsubtotal>
-|;
-
-        for (@column_index) { print "\n$column_data{$_}" }
-
-        print qq|
-  </tr>
-|;
+            $form->format_amount( \%myconfig, $subtotalpaid, 2, ' ' );
+        $column_data{class} = 'subtotal';
     }
 
     $subtotalpaid = 0;
-
+    \%column_data;
 }
 


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