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

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



Revision: 1810
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1810&view=rev
Author:   tetragon
Date:     2007-10-24 10:50:22 -0700 (Wed, 24 Oct 2007)

Log Message:
-----------
Switching forms that use gifi_header to templating

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

Added Paths:
-----------
    trunk/UI/am-gifi-form.html

Added: trunk/UI/am-gifi-form.html
===================================================================
--- trunk/UI/am-gifi-form.html	                        (rev 0)
+++ trunk/UI/am-gifi-form.html	2007-10-24 17:50:22 UTC (rev 1810)
@@ -0,0 +1,33 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?> 
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+  <tr><th class="listtop"><?lsmb form.title ?></th></tr>
+  <tr><td> </td></tr>
+  <tr>
+    <td>
+      <table>
+        <tr>
+          <th align="right"><?lsmb text('GIFI') ?></th>
+          <td><?lsmb PROCESS input element_data={name => 'accno', size => 20, value => form.accno} ?></td>
+        </tr>
+        <tr>
+          <th align="right"><?lsmb text('Description') ?></th>
+          <td><?lsmb PROCESS input element_data={name => 'description', size => 60, value => form.description} ?></td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr><td colspan="2"><hr size="3" noshade="noshade" /></td></tr>
+</table>
+<?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/am.pl
===================================================================
--- trunk/bin/am.pl	2007-10-24 16:31:43 UTC (rev 1809)
+++ trunk/bin/am.pl	2007-10-24 17:50:22 UTC (rev 1810)
@@ -487,9 +487,21 @@
 
     $form->{coa} = 1;
 
-    &gifi_header;
-    &gifi_footer;
+    my %hiddens;
+    my @buttons;
+    &gifi_header(\%hiddens);
+    &gifi_footer(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-gifi-form');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
+
 }
 
 sub edit_gifi {
@@ -501,12 +513,25 @@
     $form->error( $locale->text('Account does not exist!') )
       unless $form->{accno};
 
-    &gifi_header;
-    &gifi_footer;
+    my %hiddens;
+    my @buttons;
+    &gifi_header(\%hiddens);
+    &gifi_footer(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-gifi-form');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
+
 }
 
 sub gifi_header {
+    my $hiddens = shift;
 
     $form->{title} = $locale->text("$form->{title} GIFI");
 
@@ -515,52 +540,21 @@
 
     for (qw(accno description)) { $form->{$_} = $form->quote( $form->{$_} ) }
 
-    $form->header;
+    $hiddens->{id} = $form->{accno};
+    $hiddens->{type} = 'gifi';
 
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=id value="$form->{accno}">
-<input type=hidden name=type value=gifi>
-
-<table width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>
-      <table>
-	<tr>
-	  <th align="right">| . $locale->text('GIFI') . qq|</th>
-	  <td><input name=accno size=20 value="$form->{accno}"></td>
-	</tr>
-	<tr>
-	  <th align="right">| . $locale->text('Description') . qq|</th>
-	  <td><input name=description size=60 value="$form->{description}"></td>
-	</tr>
-      </table>
-    </td>
-  </tr>
-  <tr>
-    <td colspan=2><hr size=3 noshade></td>
-  </tr>
-</table>
-|;
-
 }
 
 sub gifi_footer {
+    my ($hiddens, $buttons) = @_;
 
-    $form->hide_form(qw(callback path login sessionid));
+    $hiddens->{$_} = $form->{$_} foreach qw(callback path login sessionid);
 
     # type=submit $locale->text('Save')
     # type=submit $locale->text('Copy to COA')
     # type=submit $locale->text('Delete')
 
-    %button = ();
+    my %button = ();
 
     $button{'save'} = { ndx => 3, key => 'S', value => $locale->text('Save') };
 
@@ -577,21 +571,21 @@
     }
 
     for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
-        $form->print_button( \%button, $_ );
+        push @{$buttons}, {
+            name => 'action',
+            value => $_,
+            accesskey => $button{$_}{key},
+            title => "$button{$_}{value} [Alt-$button{$_}{key}]",
+            text => $button{$_}{value},
+            };
     }
 
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
+##SC: Temporary commenting
+##    if ( $form->{lynx} ) {
+##        require "bin/menu.pl";
+##        &menubar;
+##    }
 
-    print qq|
-  </form>
-
-</body>
-</html>
-|;
-
 }
 
 sub save_gifi {


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