summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-05 22:02:51 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-05 22:02:51 +0000
commit5494edb33464e87b12e55d582ca6477cbb4e9fd0 (patch)
treede782793fd159d8096b10f9b6693f922c5670d76
parent6bb4dec3405f4b892d068960067f990e42abe310 (diff)
Convert the defaults screen to using a template
Make the defaults screen valid XHTML 1.0 Transitional git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1706 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--UI/am-defaults.html152
-rw-r--r--bin/am.pl202
2 files changed, 186 insertions, 168 deletions
diff --git a/UI/am-defaults.html b/UI/am-defaults.html
new file mode 100644
index 00000000..1800ebe0
--- /dev/null
+++ b/UI/am-defaults.html
@@ -0,0 +1,152 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title><?lsmb form.titlebar ?></title>
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Expires" content="-1" />
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+ <link rel="stylesheet" href="css/<?lsmb form.stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+
+ <meta name="robots" content="noindex,nofollow" />
+
+</head>
+<?lsmb PROCESS elements.html ?>
+
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+ <tr><th class="listtop"><?lsmb text('System Defaults') ?></th></tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align="right"><?lsmb text('Business Number') ?></th>
+ <td><input name="businessnumber" size="25" value="<?lsmb form.businessnumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right"><?lsmb text('Weight Unit') ?></th>
+ <td><input name="weightunit" size="5" value="<?lsmb form.weightunit ?>" /></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <th class="listheading"><?lsmb escape(text('Last Numbers & Default Accounts')) ?></th>
+ </tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Inventory') ?></th>
+ <td>
+<?lsmb PROCESS select element_data=selects.IC ?>
+ </td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Income') ?></th>
+ <td>
+<?lsmb PROCESS select element_data=selects.IC_income ?>
+ </td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Expense') ?></th>
+ <td>
+<?lsmb PROCESS select element_data=selects.IC_expense ?>
+ </td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Foreign Exchange Gain') ?></th>
+ <td>
+<?lsmb PROCESS select element_data=selects.FX_gain ?>
+ </td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Foreign Exchange Loss') ?></th>
+ <td>
+<?lsmb PROCESS select element_data=selects.FX_loss ?>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <th align="left"><?lsmb escape(text('Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies')) ?></th>
+ </tr>
+ <tr>
+ <td>
+ <input name="curr" size="40" value="<?lsmb form.curr ?>" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('GL Reference Number') ?></th>
+ <td><input name="glnumber" size="40" value="<?lsmb form.glnumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Sales Invoice/AR Transaction Number') ?></th>
+ <td><input name="sinumber" size="40" value="<?lsmb form.sinumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Sales Order Number') ?></th>
+ <td><input name="sonumber" size="40" value="<?lsmb form.sonumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Vendor Invoice/AP Transaction Number') ?></th>
+ <td><input name="vinumber" size="40" value="<?lsmb form.vinumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Purchase Order Number') ?></th>
+ <td><input name="ponumber" size="40" value="<?lsmb form.ponumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Sales Quotation Number') ?></th>
+ <td><input name="sqnumber" size="40" value="<?lsmb form.sqnumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('RFQ Number') ?></th>
+ <td><input name="rfqnumber" size="40" value="<?lsmb form.rfqnumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Part Number') ?></th>
+ <td><input name="partnumber" size="40" value="<?lsmb form.partnumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Job/Project Number') ?></th>
+ <td><input name="projectnumber" size="40" value="<?lsmb form.projectnumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Employee Number') ?></th>
+ <td><input name="employeenumber" size="40" value="<?lsmb form.employeenumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Customer Number') ?></th>
+ <td><input name="customernumber" size="40" value="<?lsmb form.customernumber ?>" /></td>
+ </tr>
+ <tr>
+ <th align="right" nowrap="nowrap"><?lsmb text('Vendor Number') ?></th>
+ <td><input name="vendornumber" size="40" value="<?lsmb form.vendornumber ?>" /></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;
+PROCESS button element_data={name => 'action', value => 'save' text => text('Save')} ?>
+ </form>
+
+</body>
+</html>
diff --git a/bin/am.pl b/bin/am.pl
index e79a9998..800b0dce 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -1693,182 +1693,48 @@ sub defaults {
# get defaults for account numbers and last numbers
AM->get_all_defaults( \%$form );
+ my %selects = (
+ 'FX_loss' => {name => 'FX_loss', options => []},
+ 'FX_gain' => {name => 'FX_gain', options => []},
+ 'IC_expense' => {name => 'IC_expense', options => []},
+ 'IC_income' => {name => 'IC_income', options => []},
+ 'IC_inventory' => {name => 'IC_inventory', options => []},
+ 'IC' => {name => 'IC', options => []},
+ );
foreach $key ( keys %{ $form->{accno} } ) {
foreach $accno ( sort keys %{ $form->{accno}{$key} } ) {
- $form->{account}{$key} .=
- "<option>$accno--$form->{accno}{$key}{$accno}{description}\n";
- $form->{accno}{ $form->{accno}{$key}{$accno}{id} } = $accno;
+ push @{$selects{$key}{options}}, {
+ text => "$accno--$form->{accno}{$key}{$accno}{description}",
+ value => "$accno--$form->{accno}{$key}{$accno}{description}",
+ };
+ $selects{$key}{default_values} = "$accno--$form->{accno}{$key}{$accno}{description}" if
+ ($form->{defaults}{$key} == $form->{accno}{$key}{$accno}{id});
}
}
- for (qw(IC IC_inventory IC_income IC_expense FX_gain FX_loss)) {
- $form->{account}{$_} =~
-s/>$form->{accno}{$form->{defaults}{$_}}/ selected>$form->{accno}{$form->{defaults}{$_}}/;
- }
-
for (qw(accno defaults)) { delete $form->{$_} }
- $form->{title} = $locale->text('System Defaults');
-
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=type value=defaults>
-
-<table width=100%>
- <tr><th class=listtop>$form->{title}</th></tr>
- <tr>
- <td>
- <table>
- <tr>
- <th align="right">| . $locale->text('Business Number') . qq|</th>
- <td><input name=businessnumber size=25 value="$form->{businessnumber}"></td>
- </tr>
- <tr>
- <th align="right">| . $locale->text('Weight Unit') . qq|</th>
- <td><input name=weightunit size=5 value="$form->{weightunit}"></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <th class="listheading">|
- . $locale->text('Last Numbers & Default Accounts')
- . qq|</th>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <th align="right" nowrap>| . $locale->text('Inventory') . qq|</th>
- <td><select name=IC>$form->{account}{IC}</select></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Income') . qq|</th>
- <td><select name=IC_income>$form->{account}{IC_income}</select></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Expense') . qq|</th>
- <td><select name=IC_expense>$form->{account}{IC_expense}</select></td>
- </tr>
- <tr>
- <th align="right" nowrap>|
- . $locale->text('Foreign Exchange Gain')
- . qq|</th>
- <td><select name=FX_gain>$form->{account}{FX_gain}</select></td>
- </tr>
- <tr>
- <th align="right" nowrap>|
- . $locale->text('Foreign Exchange Loss')
- . qq|</th>
- <td><select name=FX_loss>$form->{account}{FX_loss}</select></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <th align=left>|
- . $locale->text(
-'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
- )
- . qq|</th>
- </tr>
- <tr>
- <td>
- <input name=curr size=40 value="$form->{curr}">
- </td>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <th align="right" nowrap>| . $locale->text('GL Reference Number') . qq|</th>
- <td><input name=glnumber size=40 value="$form->{glnumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>|
- . $locale->text('Sales Invoice/AR Transaction Number')
- . qq|</th>
- <td><input name=sinumber size=40 value="$form->{sinumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Sales Order Number') . qq|</th>
- <td><input name=sonumber size=40 value="$form->{sonumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>|
- . $locale->text('Vendor Invoice/AP Transaction Number')
- . qq|</th>
- <td><input name=vinumber size=40 value="$form->{vinumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>|
- . $locale->text('Purchase Order Number')
- . qq|</th>
- <td><input name=ponumber size=40 value="$form->{ponumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>|
- . $locale->text('Sales Quotation Number')
- . qq|</th>
- <td><input name=sqnumber size=40 value="$form->{sqnumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('RFQ Number') . qq|</th>
- <td><input name=rfqnumber size=40 value="$form->{rfqnumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Part Number') . qq|</th>
- <td><input name=partnumber size=40 value="$form->{partnumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Job/Project Number') . qq|</th>
- <td><input name=projectnumber size=40 value="$form->{projectnumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Employee Number') . qq|</th>
- <td><input name=employeenumber size=40 value="$form->{employeenumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Customer Number') . qq|</th>
- <td><input name=customernumber size=40 value="$form->{customernumber}"></td>
- </tr>
- <tr>
- <th align="right" nowrap>| . $locale->text('Vendor Number') . qq|</th>
- <td><input name=vendornumber size=40 value="$form->{vendornumber}"></td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-|;
-
- $form->hide_form(qw(path login sessionid));
-
- print qq|
-<button type="submit" class="submit" name="action" value="save">|
- . $locale->text('Save')
- . qq|</button>|;
-
- if ( $form->{lynx} ) {
- require "bin/menu.pl";
- &menubar;
- }
-
- print qq|
- </form>
-
-</body>
-</html>
-|;
+##SC: temporary commenting out
+## if ( $form->{lynx} ) {
+## require "bin/menu.pl";
+## &menubar;
+## }
+ my %hiddens = (
+ path => $form->{path},
+ login => $form->{login},
+ sessionid => $form->{sessionid},
+ type => 'defaults',
+ );
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'am-defaults');
+ $template->render({
+ form => $form,
+ hiddens => \%hiddens,
+ selects => \%selects,
+ });
}
sub taxes {