diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-10-24 16:31:43 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-10-24 16:31:43 +0000 |
commit | 7b8a5257bcfa2d263f87e9b26053837ed1a3490a (patch) | |
tree | c58a9986a02bf7b9a366f5b7d4854c39d15bd40e /bin | |
parent | 550441b25426ffd6743431bf92afb5bc46170763 (diff) |
Convert all functions that use am.pl's account_header to am-account-form.html
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1809 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'bin')
-rw-r--r-- | bin/am.pl | 247 |
1 files changed, 85 insertions, 162 deletions
@@ -66,8 +66,21 @@ sub add_account { "$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, \@buttons); + + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-account-form'); + $template->render({ + form => $form, + checked => $checked, + buttons => \@buttons, + hiddens => \%hiddens, + }); } @@ -84,15 +97,29 @@ sub edit_account { $form->{$item} = "checked"; } - &account_header; - &form_footer; + my %hiddens; + my @buttons; + my $checked = &account_header(\%hiddens); + &form_footer_buttons(\%hiddens, \@buttons); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-account-form'); + $template->render({ + form => $form, + checked => $checked, + buttons => \@buttons, + 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 @@ sub account_header { # 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_}> | - . $locale->text('Asset') - . qq|\n<br> - <input name=category type=radio class=radio value=L $checked{L_}> | - . $locale->text('Liability') - . qq|\n<br> - <input name=category type=radio class=radio value=Q $checked{Q_}> | - . $locale->text('Equity') - . qq|\n<br> - <input name=category type=radio class=radio value=I $checked{I_}> | - . $locale->text('Income') - . qq|\n<br> - <input name=category type=radio class=radio value=E $checked{E_}> | - . $locale->text('Expense') - . qq|</td> - <td> - <input name=contra class=checkbox type=checkbox value=1 $checked{contra}> | - . $locale->text('Contra') . qq| - </td> - <td> - <input name=charttype type=radio class=radio value="H" $checked{H}> | - . $locale->text('Heading') . qq|<br> - <input name=charttype type=radio class=radio value="A" $checked{A}> | - . $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}> | - . $locale->text('AR') - . qq| <input name=AP class=checkbox type=checkbox value=AP $form->{AP}> | - . $locale->text('AP') - . qq| <input name=IC class=checkbox type=checkbox value=IC $form->{IC}> | - . $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}> | - . $locale->text('Income') - . qq|\n<br> - <input name=AR_paid class=checkbox type=checkbox value=AR_paid $form->{AR_paid}> | - . $locale->text('Payment') - . qq|\n<br> - <input name=AR_tax class=checkbox type=checkbox value=AR_tax $form->{AR_tax}> | - . $locale->text('Tax') . qq| - </td> - <td> - <input name=AP_amount class=checkbox type=checkbox value=AP_amount $form->{AP_amount}> | - . $locale->text('Expense/Asset') - . qq|\n<br> - <input name=AP_paid class=checkbox type=checkbox value=AP_paid $form->{AP_paid}> | - . $locale->text('Payment') - . qq|\n<br> - <input name=AP_tax class=checkbox type=checkbox value=AP_tax $form->{AP_tax}> | - . $locale->text('Tax') . qq| - </td> - <td> - <input name=IC_sale class=checkbox type=checkbox value=IC_sale $form->{IC_sale}> | - . $locale->text('Income') - . qq|\n<br> - <input name=IC_cogs class=checkbox type=checkbox value=IC_cogs $form->{IC_cogs}> | - . $locale->text('COGS') - . qq|\n<br> - <input name=IC_taxpart class=checkbox type=checkbox value=IC_taxpart $form->{IC_taxpart}> | - . $locale->text('Tax') . qq| - </td> - <td> - <input name=IC_income class=checkbox type=checkbox value=IC_income $form->{IC_income}> | - . $locale->text('Income') - . qq|\n<br> - <input name=IC_expense class=checkbox type=checkbox value=IC_expense $form->{IC_expense}> | - . $locale->text('Expense') - . qq|\n<br> - <input name=IC_taxservice class=checkbox type=checkbox value=IC_taxservice $form->{IC_taxservice}> | - . $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,8 +614,21 @@ sub copy_to_coa { $form->{title} = "Add"; $form->{charttype} = "A"; - &account_header; - &form_footer; + my %hiddens; + my @buttons; + my $checked = &account_header(\%hiddens); + &form_footer_buttons(\%hiddens, \@buttons); + + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-account-form'); + $template->render({ + form => $form, + checked => $checked, + buttons => \@buttons, + hiddens => \%hiddens, + }); } |