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

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



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

Log Message:
-----------
Convert functions that use business_header to templates

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

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

Added: trunk/UI/am-business-form.html
===================================================================
--- trunk/UI/am-business-form.html	                        (rev 0)
+++ trunk/UI/am-business-form.html	2007-10-24 18:18:50 UTC (rev 1811)
@@ -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('Type of Business') ?></th>
+	  <td><?lsmb PROCESS input element_data={name => 'description', size => 30, value => form.description} ?></td>
+        </tr>
+        <tr>
+          <th align="right"><?lsmb text('Discount') ?></th>
+          <td><?lsmb PROCESS input element_data={name => 'discount', size => 5, value => form.discount} ?></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 17:50:22 UTC (rev 1810)
+++ trunk/bin/am.pl	2007-10-24 18:18:50 UTC (rev 1811)
@@ -812,9 +812,21 @@
 "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
       unless $form->{callback};
 
-    &business_header;
-    &form_footer;
+    my %hiddens;
+    my @buttons;
+    my $checked = &business_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-business-form');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
+
 }
 
 sub edit_business {
@@ -823,11 +835,22 @@
 
     AM->get_business( \%myconfig, \%$form );
 
-    &business_header;
-
     $form->{orphaned} = 1;
-    &form_footer;
 
+    my %hiddens;
+    my @buttons;
+    my $checked = &business_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
+
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-business-form');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
 }
 
 sub list_business {
@@ -904,6 +927,7 @@
 }
 
 sub business_header {
+    my $hiddens = shift;
 
     $form->{title} = $locale->text("$form->{title} Business");
 
@@ -914,41 +938,9 @@
     $form->{discount} =
       $form->format_amount( \%myconfig, $form->{discount} * 100 );
 
-    $form->header;
+    $hiddens->{id} = $form->{id};
+    $hiddens->{type} = 'business';
 
-    print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=id value=$form->{id}>
-<input type=hidden name=type value=business>
-
-<table width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>
-      <table>
-	<tr>
-	  <th align="right">| . $locale->text('Type of Business') . qq|</th>
-	  <td><input name=description size=30 value="$form->{description}"></td>
-	<tr>
-	<tr>
-	  <th align="right">| . $locale->text('Discount') . qq| %</th>
-	  <td><input name=discount size=5 value=$form->{discount}></td>
-	</tr>
-      </table>
-    </td>
-  </tr>
-  <tr>
-    <td><hr size=3 noshade></td>
-  </tr>
-</table>
-|;
-
 }
 
 sub save_business {


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