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 --- UI/am-account-form.html | 239 ++++++++++++++++++++++++++++++++++++++++++++++ bin/am.pl | 247 +++++++++++++++++------------------------------- 2 files changed, 324 insertions(+), 162 deletions(-) create mode 100644 UI/am-account-form.html diff --git a/UI/am-account-form.html b/UI/am-account-form.html new file mode 100644 index 00000000..34482b51 --- /dev/null +++ b/UI/am-account-form.html @@ -0,0 +1,239 @@ + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'accno', + size => '20', + value => form.accno} ?>
'description', + size => '40', + value => form.description} ?>
+ + + + + + +
+ 'category', + type => 'radio', + label => text('Asset'), + value => 'A', + ${checked.A_} => checked.A_, + } ?>
+ 'category', + type => 'radio', + label => text('Liability'), + ${checked.L_} => checked.L_, + value => 'L'} ?>
+ 'category', + type => 'radio', + label => text('Equity'), + ${checked.Q_} => checked.Q_, + value => 'Q'} ?>
+ 'category', + type => 'radio', + label => text('Income'), + ${checked.I_} => checked.I_, + value => 'I'} ?>
+ 'category', + type => 'radio', + label => text('Expense'), + ${checked.E_} => checked.E_, + value => 'E'} ?> +
+ 'contra', + type => 'checkbox', + label => text('Contra'), + ${checked.contra} => checked.contra, + value => '1'} ?> + + 'charttype', + type => 'radio', + label => text('Heading'), + ${checked.H} => checked.H, + value => 'H'} ?>
+ 'charttype', + type => 'radio', + label => text('Account'), + ${checked.A} => checked.A, + value => 'A'} ?> +
+
+ + + + + +
+ 'AR', + type => 'checkbox', + label => text('AR'), + ${form.AR} => form.AR, + value => 'AR'} ?> + 'AP', + type => 'checkbox', + label => text('AP'), + ${form.AP} => form.AP, + value => 'AP'} ?> + 'IC', + type => 'checkbox', + label => text('Inventory'), + ${form.IC} => form.IC, + value => 'IC'} ?> +
+
+ + + + + + + + + + + + + +
+ 'AR_amount', + type => 'checkbox', + label => text('Income'), + ${form.AR_amount} => form.AR_amount, + value => 'AR_amount'} ?>
+ 'AR_paid', + type => 'checkbox', + label => text('Payment'), + ${form.AR_paid} => form.AR_paid, + value => 'AR_paid'} ?>
+ 'AR_tax', + type => 'checkbox', + label => text('Tax'), + ${form.AR_tax} => form.AR_tax, + value => 'AR_tax'} ?> +
+ 'AP_amount', + type => 'checkbox', + label => text('Expense/Asset'), + ${form.AP_amount} => form.AP_amount, + value => 'AP_amount'} ?>
+ 'AP_paid', + type => 'checkbox', + label => text('Payment'), + ${form.AP_paid} => form.AP_paid, + value => 'AP_paid'} ?>
+ 'AP_tax', + type => 'checkbox', + label => text('Tax'), + ${form.AP_tax} => form.AP_tax, + value => 'AP_tax'} ?> +
+ 'IC_sale', + type => 'checkbox', + label => text('Income'), + ${form.IC_sale} => form.IC_sale, + value => 'IC_sale'} ?>
+ 'IC_cogs', + type => 'checkbox', + label => text('COGS'), + ${form.IC_cogs} => form.IC_cogs, + value => 'IC_cogs'} ?>
+ 'IC_taxpart', + type => 'checkbox', + label => text('Tax'), + ${form.IC_taxpart} => form.IC_taxpart, + value => 'IC_taxpart'} ?> +
+ 'IC_income', + type => 'checkbox', + label => text('Income'), + ${form.IC_income} => form.IC_income, + value => 'IC_income'} ?>
+ 'IC_expense', + type => 'checkbox', + label => text('Expense'), + ${form.IC_expense} => form.IC_expense, + value => 'IC_expense'} ?>
+ 'IC_taxservice', + type => 'checkbox', + label => text('Tax'), + ${form.IC_taxservice} => form.IC_taxservice, + value => 'IC_taxservice'} ?> +
+
'gifi_accno', + size => '9', + value => form.gifi_accno} ?>
+

+ 'hidden', + name => hidden, + value => hiddens.item(hidden) + }; END ?> + +
+ + 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