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

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



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

Log Message:
-----------
Convert all functions that use am.pl's account_header to am-account-form.html

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

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

Added: trunk/UI/am-account-form.html
===================================================================
--- trunk/UI/am-account-form.html	                        (rev 0)
+++ trunk/UI/am-account-form.html	2007-10-24 16:31:43 UTC (rev 1809)
@@ -0,0 +1,239 @@
+<?lsmb INCLUDE 'ui-header.html' ?> 
+<?lsmb PROCESS elements.html ?> 
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table border="0" width="100%">
+  <tr><th class="listtop"><?lsmb form.title ?></th></tr>
+  <tr><td> </td></tr>
+  <tr valign="top">
+    <td>
+      <table>
+        <tr>
+          <th align="right"><?lsmb text('Account Number') ?></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 => '40',
+            value => form.description} ?></td>
+        </tr>
+        <tr>
+          <th align="right"><?lsmb text('Account Type') ?></th>
+          <td>
+            <table>
+              <tr valign="top">
+                <td align="right">
+                  <?lsmb PROCESS input element_data={
+                          name => 'category',
+                          type => 'radio',
+                          label => text('Asset'),
+                          value => 'A',
+                          ${checked.A_} => checked.A_,
+                          } ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'category',
+                          type => 'radio',
+                          label => text('Liability'),
+                          ${checked.L_} => checked.L_,
+                          value => 'L'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'category',
+                          type => 'radio',
+                          label => text('Equity'),
+                          ${checked.Q_} => checked.Q_,
+                          value => 'Q'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'category',
+                          type => 'radio',
+                          label => text('Income'),
+                          ${checked.I_} => checked.I_,
+                          value => 'I'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'category',
+                          type => 'radio',
+                          label => text('Expense'),
+                          ${checked.E_} => checked.E_,
+                          value => 'E'} ?>
+                </td>
+                <td>
+                  <?lsmb PROCESS input element_data={
+                          name => 'contra',
+                          type => 'checkbox',
+                          label => text('Contra'),
+                          ${checked.contra} => checked.contra,
+                          value => '1'} ?>
+                </td>
+                <td align="right">
+                  <?lsmb PROCESS input element_data={
+                          name => 'charttype',
+                          type => 'radio',
+                          label => text('Heading'),
+                          ${checked.H} => checked.H,
+                          value => 'H'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'charttype',
+                          type => 'radio',
+                          label => text('Account'),
+                          ${checked.A} => checked.A,
+                          value => 'A'} ?>
+                </td>
+              </tr>
+            </table>
+          </td>
+        </tr>
+<?lsmb IF form.charttype == 'A' ?>
+        <tr>
+          <td colspan="2">
+            <table>
+              <tr>
+                <th align="left"><?lsmb text('Is this a summary account to record') ?></th>
+                <td>
+                  <?lsmb PROCESS input element_data={
+                          name => 'AR',
+                          type => 'checkbox',
+                          label => text('AR'),
+                          ${form.AR} => form.AR,
+                          value => 'AR'} ?> 
+                  <?lsmb PROCESS input element_data={
+                          name => 'AP',
+                          type => 'checkbox',
+                          label => text('AP'),
+                          ${form.AP} => form.AP,
+                          value => 'AP'} ?> 
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC',
+                          type => 'checkbox',
+                          label => text('Inventory'),
+                          ${form.IC} => form.IC,
+                          value => 'IC'} ?> 
+                </td>
+              </tr>
+            </table>
+          </td>
+        </tr>
+        <tr>
+          <th colspan="2" align="left"><?lsmb text('Include in drop-down menus') ?></th>
+        </tr>
+        <tr valign="top">
+          <td colspan="2">
+            <table width="100%">
+              <tr>
+                <th align="left"><?lsmb text('Receivables') ?></th>
+                <th align="left"><?lsmb text('Payables') ?></th>
+                <th align="left"><?lsmb text('Tracking Items') ?></th>
+                <th align="left"><?lsmb text('Non-tracking Items') ?></th>
+              </tr>
+              <tr>
+                <td align="right">
+                  <?lsmb PROCESS input element_data={
+                          name => 'AR_amount',
+                          type => 'checkbox',
+                          label => text('Income'),
+                          ${form.AR_amount} => form.AR_amount,
+                          value => 'AR_amount'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'AR_paid',
+                          type => 'checkbox',
+                          label => text('Payment'),
+                          ${form.AR_paid} => form.AR_paid,
+                          value => 'AR_paid'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'AR_tax',
+                          type => 'checkbox',
+                          label => text('Tax'),
+                          ${form.AR_tax} => form.AR_tax,
+                          value => 'AR_tax'} ?>
+                </td>
+                <td align="right">
+                  <?lsmb PROCESS input element_data={
+                          name => 'AP_amount',
+                          type => 'checkbox',
+                          label => text('Expense/Asset'),
+                          ${form.AP_amount} => form.AP_amount,
+                          value => 'AP_amount'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'AP_paid',
+                          type => 'checkbox',
+                          label => text('Payment'),
+                          ${form.AP_paid} => form.AP_paid,
+                          value => 'AP_paid'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'AP_tax',
+                          type => 'checkbox',
+                          label => text('Tax'),
+                          ${form.AP_tax} => form.AP_tax,
+                          value => 'AP_tax'} ?>
+                </td>
+                <td align="right">
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC_sale',
+                          type => 'checkbox',
+                          label => text('Income'),
+                          ${form.IC_sale} => form.IC_sale,
+                          value => 'IC_sale'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC_cogs',
+                          type => 'checkbox',
+                          label => text('COGS'),
+                          ${form.IC_cogs} => form.IC_cogs,
+                          value => 'IC_cogs'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC_taxpart',
+                          type => 'checkbox',
+                          label => text('Tax'),
+                          ${form.IC_taxpart} => form.IC_taxpart,
+                          value => 'IC_taxpart'} ?>
+                </td>
+                <td align="right">
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC_income',
+                          type => 'checkbox',
+                          label => text('Income'),
+                          ${form.IC_income} => form.IC_income,
+                          value => 'IC_income'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC_expense',
+                          type => 'checkbox',
+                          label => text('Expense'),
+                          ${form.IC_expense} => form.IC_expense,
+                          value => 'IC_expense'} ?><br />
+                  <?lsmb PROCESS input element_data={
+                          name => 'IC_taxservice',
+                          type => 'checkbox',
+                          label => text('Tax'),
+                          ${form.IC_taxservice} => form.IC_taxservice,
+                          value => 'IC_taxservice'} ?>
+                </td>
+              </tr>
+            </table>
+          </td>
+        </tr>
+<?lsmb END ?>
+        <tr><td> </td></tr>
+        <tr>
+          <th align="right"><?lsmb text('GIFI') ?></th>
+          <td><?lsmb PROCESS input element_data={
+            name => 'gifi_accno',
+            size => '9',
+            value => form.gifi_accno} ?></td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+  <tr><td><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-23 22:34:00 UTC (rev 1808)
+++ trunk/bin/am.pl	2007-10-24 16:31:43 UTC (rev 1809)
@@ -66,9 +66,22 @@
 "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
       unless $form->{callback};
 
-    &account_header;
-    &form_footer;
+    my %hiddens;
+    my @buttons;
+    my $checked = &account_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-account-form');
+    $template->render({
+        form => $form,
+        checked => $checked,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
+
 }
 
 sub edit_account {
@@ -84,15 +97,29 @@
         $form->{$item} = "checked";
     }
 
-    &account_header;
-    &form_footer;
+    my %hiddens;
+    my @buttons;
+    my $checked = &account_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-account-form');
+    $template->render({
+        form => $form,
+        checked => $checked,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
 }
 
 sub account_header {
 
+    my $hiddens = shift;
     $form->{title} = $locale->text("$form->{title} Account");
 
+    my %checked;
     $checked{ $form->{charttype} } = "checked";
     $checked{contra} = "checked" if $form->{contra};
     $checked{"$form->{category}_"} = "checked";
@@ -103,171 +130,54 @@
     # type=submit $locale->text('Add Account')
     # type=submit $locale->text('Edit Account')
 
-    $form->header;
+    $hiddens->{type} = 'account';
+    $hiddens->{$_} eq $form->{$_} foreach qw(id inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id);
 
-    print qq|
-<body>
+    \%checked;
+}
 
-<form method=post action=$form->{script}>
+sub form_footer_buttons {
 
-<input type=hidden name=id value=$form->{id}>
-<input type=hidden name=type value=account>
+    my ($hiddens, $buttons) = @_;
+    $hiddens->{$_} = $form->{$_} foreach qw(callback path login sessionid);
 
-<input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>
-<input type=hidden name=income_accno_id value=$form->{income_accno_id}>
-<input type=hidden name=expense_accno_id value=$form->{expense_accno_id}>
-<input type=hidden name=fxgain_accno_id values=$form->{fxgain_accno_id}>
-<input type=hidden name=fxloss_accno_id values=$form->{fxloss_accno_id}>
+    # type=submit $locale->text('Save')
+    # type=submit $locale->text('Save as new')
+    # type=submit $locale->text('Delete')
 
-<table border=0 width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr valign=top>
-    <td>
-      <table>
-	<tr>
-	  <th align="right">| . $locale->text('Account Number') . 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=40 value="$form->{description}"></td>
-	</tr>
-	<tr>
-	  <th align="right">| . $locale->text('Account Type') . qq|</th>
-	  <td>
-	    <table>
-	      <tr valign=top>
-		<td><input name=category type=radio class=radio value=A $checked{A_}>&nbsp;|
-      . $locale->text('Asset')
-      . qq|\n<br>
-		<input name=category type=radio class=radio value=L $checked{L_}>&nbsp;|
-      . $locale->text('Liability')
-      . qq|\n<br>
-		<input name=category type=radio class=radio value=Q $checked{Q_}>&nbsp;|
-      . $locale->text('Equity')
-      . qq|\n<br>
-		<input name=category type=radio class=radio value=I $checked{I_}>&nbsp;|
-      . $locale->text('Income')
-      . qq|\n<br>
-		<input name=category type=radio class=radio value=E $checked{E_}>&nbsp;|
-      . $locale->text('Expense')
-      . qq|</td>
-		<td>
-		<input name=contra class=checkbox type=checkbox value=1 $checked{contra}>&nbsp;|
-      . $locale->text('Contra') . qq|
-		</td>
-		<td>
-		<input name=charttype type=radio class=radio value="H" $checked{H}>&nbsp;|
-      . $locale->text('Heading') . qq|<br>
-		<input name=charttype type=radio class=radio value="A" $checked{A}>&nbsp;|
-      . $locale->text('Account')
-      . qq|</td>
-	      </tr>
-	    </table>
-	  </td>
-	</tr>
-|;
+    %button = ();
 
-    if ( $form->{charttype} eq "A" ) {
-        print qq|
-	<tr>
-	  <td colspan=2>
-	    <table>
-	      <tr>
-		<th align=left>|
-          . $locale->text('Is this a summary account to record')
-          . qq|</th>
-		<td>
-		<input name=AR class=checkbox type=checkbox value=AR $form->{AR}>&nbsp;|
-          . $locale->text('AR')
-          . qq|&nbsp;<input name=AP class=checkbox type=checkbox value=AP $form->{AP}>&nbsp;|
-          . $locale->text('AP')
-          . qq|&nbsp;<input name=IC class=checkbox type=checkbox value=IC $form->{IC}>&nbsp;|
-          . $locale->text('Inventory')
-          . qq|</td>
-	      </tr>
-	    </table>
-	  </td>
-	</tr>
-	<tr>
-	  <th colspan=2>| . $locale->text('Include in drop-down menus') . qq|</th>
-	</tr>
-	<tr valign=top>
-	  <td colspan=2>
-	    <table width=100%>
-	      <tr>
-		<th align=left>| . $locale->text('Receivables') . qq|</th>
-		<th align=left>| . $locale->text('Payables') . qq|</th>
-		<th align=left>| . $locale->text('Tracking Items') . qq|</th>
-		<th align=left>| . $locale->text('Non-tracking Items') . qq|</th>
-	      </tr>
-	      <tr>
-		<td>
-		<input name=AR_amount class=checkbox type=checkbox value=AR_amount $form->{AR_amount}>&nbsp;|
-          . $locale->text('Income')
-          . qq|\n<br>
-		<input name=AR_paid class=checkbox type=checkbox value=AR_paid $form->{AR_paid}>&nbsp;|
-          . $locale->text('Payment')
-          . qq|\n<br>
-		<input name=AR_tax class=checkbox type=checkbox value=AR_tax $form->{AR_tax}>&nbsp;|
-          . $locale->text('Tax') . qq|
-		</td>
-		<td>
-		<input name=AP_amount class=checkbox type=checkbox value=AP_amount $form->{AP_amount}>&nbsp;|
-          . $locale->text('Expense/Asset')
-          . qq|\n<br>
-		<input name=AP_paid class=checkbox type=checkbox value=AP_paid $form->{AP_paid}>&nbsp;|
-          . $locale->text('Payment')
-          . qq|\n<br>
-		<input name=AP_tax class=checkbox type=checkbox value=AP_tax $form->{AP_tax}>&nbsp;|
-          . $locale->text('Tax') . qq|
-		</td>
-		<td>
-		<input name=IC_sale class=checkbox type=checkbox value=IC_sale $form->{IC_sale}>&nbsp;|
-          . $locale->text('Income')
-          . qq|\n<br>
-		<input name=IC_cogs class=checkbox type=checkbox value=IC_cogs $form->{IC_cogs}>&nbsp;|
-          . $locale->text('COGS')
-          . qq|\n<br>
-		<input name=IC_taxpart class=checkbox type=checkbox value=IC_taxpart $form->{IC_taxpart}>&nbsp;|
-          . $locale->text('Tax') . qq|
-		</td>
-		<td>
-		<input name=IC_income class=checkbox type=checkbox value=IC_income $form->{IC_income}>&nbsp;|
-          . $locale->text('Income')
-          . qq|\n<br>
-		<input name=IC_expense class=checkbox type=checkbox value=IC_expense $form->{IC_expense}>&nbsp;|
-          . $locale->text('Expense')
-          . qq|\n<br>
-		<input name=IC_taxservice class=checkbox type=checkbox value=IC_taxservice $form->{IC_taxservice}>&nbsp;|
-          . $locale->text('Tax') . qq|
-		</td>
-	      </tr>
-	    </table>
-	  </td>  
-	</tr>  
-	<tr>
-	</tr>
-|;
+    if ( $form->{id} ) {
+        $button{'save'} =
+          { ndx => 3, key => 'S', value => $locale->text('Save') };
+        $button{'save_as_new'} =
+          { ndx => 7, key => 'N', value => $locale->text('Save as new') };
+
+        if ( $form->{orphaned} ) {
+            $button{'delete'} =
+              { ndx => 16, key => 'D', value => $locale->text('Delete') };
+        }
     }
+    else {
+        $button{'save'} =
+          { ndx => 3, key => 'S', value => $locale->text('Save') };
+    }
 
-    print qq|
-        <tr>
-	  <th align="right">| . $locale->text('GIFI') . qq|</th>
-	  <td><input name=gifi_accno size=9 value="$form->{gifi_accno}"></td>
-	</tr>
-      </table>
-    </td>
-  </tr>
-  <tr>
-    <td><hr size=3 noshade></td>
-  </tr>
-</table>
-|;
+    for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) {
+        push @{$buttons}, {
+            name => 'action',
+            value => $_,
+            accesskey => $button{$_}{key},
+            title => "$button{$_}{value} [Alt-$button{$_}{key}]",
+            text => $button{$_}{value},
+            };
+    }
 
+##SC: Temporary removal
+##    if ( $form->{lynx} ) {
+##        require "bin/menu.pl";
+##        &menubar;
+##    }
 }
 
 sub form_footer {
@@ -704,9 +614,22 @@
     $form->{title}     = "Add";
     $form->{charttype} = "A";
 
-    &account_header;
-    &form_footer;
+    my %hiddens;
+    my @buttons;
+    my $checked = &account_header(\%hiddens);
+    &form_footer_buttons(\%hiddens, ..hidden..);
 
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-account-form');
+    $template->render({
+        form => $form,
+        checked => $checked,
+        buttons => ..hidden..,
+        hiddens => \%hiddens,
+    });
+
 }
 
 sub delete_gifi {


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