From 7b8a5257bcfa2d263f87e9b26053837ed1a3490a Mon Sep 17 00:00:00 2001 From: tetragon Date: Wed, 24 Oct 2007 16:31:43 +0000 Subject: 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 --- bin/am.pl | 247 +++++++++++++++++++++----------------------------------------- 1 file changed, 85 insertions(+), 162 deletions(-) (limited to 'bin') diff --git a/bin/am.pl b/bin/am.pl index c0b5322c..98538299 100644 --- a/bin/am.pl +++ b/bin/am.pl @@ -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| - + \%checked; +} -
{script}> +sub form_footer_buttons { -{id}> - + my ($hiddens, $buttons) = @_; + $hiddens->{$_} = $form->{$_} foreach qw(callback path login sessionid); -{inventory_accno_id}> -{income_accno_id}> -{expense_accno_id}> -{fxgain_accno_id}> -{fxloss_accno_id}> + # type=submit $locale->text('Save') + # type=submit $locale->text('Save as new') + # type=submit $locale->text('Delete') - - - - - - - - - - - -
$form->{title}
- - - - - - - - - - - - - -|; + %button = (); - if ( $form->{charttype} eq "A" ) { - print qq| - - - - - - - - - - - -|; + 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| - - - - -
| . $locale->text('Account Number') . qq|
| . $locale->text('Description') . qq|
| . $locale->text('Account Type') . qq| - - - - - - -
 | - . $locale->text('Asset') - . qq|\n
-  | - . $locale->text('Liability') - . qq|\n
-  | - . $locale->text('Equity') - . qq|\n
-  | - . $locale->text('Income') - . qq|\n
-  | - . $locale->text('Expense') - . qq|
-  | - . $locale->text('Contra') . qq| - -  | - . $locale->text('Heading') . qq|
-  | - . $locale->text('Account') - . qq|
-
- - - - - -
| - . $locale->text('Is this a summary account to record') - . qq| - {AR}> | - . $locale->text('AR') - . qq| {AP}> | - . $locale->text('AP') - . qq| {IC}> | - . $locale->text('Inventory') - . qq|
-
| . $locale->text('Include in drop-down menus') . qq|
- - - - - - - - - - - - - -
| . $locale->text('Receivables') . qq|| . $locale->text('Payables') . qq|| . $locale->text('Tracking Items') . qq|| . $locale->text('Non-tracking Items') . qq|
- {AR_amount}> | - . $locale->text('Income') - . qq|\n
- {AR_paid}> | - . $locale->text('Payment') - . qq|\n
- {AR_tax}> | - . $locale->text('Tax') . qq| -
- {AP_amount}> | - . $locale->text('Expense/Asset') - . qq|\n
- {AP_paid}> | - . $locale->text('Payment') - . qq|\n
- {AP_tax}> | - . $locale->text('Tax') . qq| -
- {IC_sale}> | - . $locale->text('Income') - . qq|\n
- {IC_cogs}> | - . $locale->text('COGS') - . qq|\n
- {IC_taxpart}> | - . $locale->text('Tax') . qq| -
- {IC_income}> | - . $locale->text('Income') - . qq|\n
- {IC_expense}> | - . $locale->text('Expense') - . qq|\n
- {IC_taxservice}> | - . $locale->text('Tax') . qq| -
-
| . $locale->text('GIFI') . qq|
-

-|; + 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, + }); } -- cgit v1.2.3