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

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



Revision: 1649
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1649&view=rev
Author:   tetragon
Date:     2007-09-22 16:15:54 -0700 (Sat, 22 Sep 2007)

Log Message:
-----------
Templating the department list

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

Added Paths:
-----------
    trunk/UI/am-list-departments.html

Added: trunk/UI/am-list-departments.html
===================================================================
--- trunk/UI/am-list-departments.html	                        (rev 0)
+++ trunk/UI/am-list-departments.html	2007-09-22 23:15:54 UTC (rev 1649)
@@ -0,0 +1,54 @@
+<!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>
+
+<table width="100%">
+  <tr>
+    <th class="listtop" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
+  </tr>
+  <tr><td colspan="<?lsmb columns.size ?>"></td></tr>
+  <tr class="listheading">
+<?lsmb FOREACH column IN columns ?>
+    <th class="listheading"<?lsmb IF column == 'description' ?> width="90%"<?lsmb END ?>><?lsmb IF heading.$column.href ?><a class="listheading" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a><?lsmb ELSE; heading.$column; END ?></th>
+<?lsmb END ?>
+  </tr>
+<?lsmb FOREACH row IN rows ?>
+  <?lsmb c = "listrow${row.i}" ?>
+<tr class="<?lsmb c ?>">
+  <?lsmb FOREACH column IN columns ?>
+  <td class="<?lsmb c ?>" <?lsmb IF (column == 'cost' || column == 'profit') ?>align="center"<?lsmb END ?>>
+    <?lsmb IF row.$column.href ?>
+    <a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
+    <?lsmb ELSE; row.$column; END ?>
+  </td>
+  <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+  <tr><td colspan="<?lsmb columns.size ?>"><hr size="3" /></td></tr>
+</table>
+
+<br />
+
+<form method="post" action="<?lsmb form.script ?>">
+<?lsmb FOREACH hidden IN hiddens ?>
+<?lsmb PROCESS input element_data={type => 'hidden', name => hidden, value => form.$hidden} ?>
+<?lsmb END ?>
+
+<?lsmb FOREACH button IN buttons ?><?lsmb PROCESS button element_data=button ?><?lsmb END ?>
+</form>
+</body>
+</html>

Modified: trunk/bin/am.pl
===================================================================
--- trunk/bin/am.pl	2007-09-22 19:12:55 UTC (rev 1648)
+++ trunk/bin/am.pl	2007-09-22 23:15:54 UTC (rev 1649)
@@ -723,7 +723,7 @@
 
     AM->departments( \%myconfig, \%$form );
 
-    $href =
+    my $href =
 "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
 
     $form->sort_order();
@@ -731,105 +731,68 @@
     $form->{callback} =
 "$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
 
-    $callback = $form->escape( $form->{callback} );
+    my $callback = $form->escape( $form->{callback} );
 
     $form->{title} = $locale->text('Departments');
 
-    @column_index = qw(description cost profit);
+    my @column_index = qw(description cost profit);
+    my %column_header;
 
-    $column_header{description} =
-        qq|<th width=90%><a class="listheading" href=$href>|
-      . $locale->text('Description')
-      . qq|</a></th>|;
-    $column_header{cost} =
-        qq|<th class="listheading" nowrap>|
-      . $locale->text('Cost Center')
-      . qq|</th>|;
-    $column_header{profit} =
-        qq|<th class="listheading" nowrap>|
-      . $locale->text('Profit Center')
-      . qq|</th>|;
+    $column_header{description} = { text => $locale->text('Description'),
+        href => $href};
+    $column_header{cost} = $locale->text('Cost Center');
+    $column_header{profit} = $locale->text('Profit Center');
 
-    $form->header;
 
-    print qq|
-<body>
+    my @rows;
+    my $i = 0;
+    foreach my $ref ( @{ $form->{ALL} } ) {
 
-<table width=100%>
-  <tr>
-    <th class=listtop>$form->{title}</th>
-  </tr>
-  <tr height="5"></tr>
-  <tr>
-    <td>
-      <table width=100%>
-        <tr class="listheading">
-|;
-
-    for (@column_index) { print "$column_header{$_}\n" }
-
-    print qq|
-        </tr>
-|;
-
-    foreach $ref ( @{ $form->{ALL} } ) {
-
+        my %column_data;
         $i++;
         $i %= 2;
+        $column_data{i} = $i;
 
-        print qq|
-        <tr valign=top class=listrow$i>
-|;
+        $column_data{cost}   = ( $ref->{role} eq "C" ) ? "*" : " ";
+        $column_data{profit} = ( $ref->{role} eq "P" ) ? "*" : " ";
 
-        $costcenter   = ( $ref->{role} eq "C" ) ? "*" : "&nbsp;";
-        $profitcenter = ( $ref->{role} eq "P" ) ? "*" : "&nbsp;";
+        $column_data{description} = { text => $ref->{description}, 
+            href => qq|$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback|,};
 
-        $column_data{description} =
-qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</td>|;
-        $column_data{cost}   = qq|<td align=center>$costcenter</td>|;
-        $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
-
-        for (@column_index) { print "$column_data{$_}\n" }
-
-        print qq|
-	</tr>
-|;
+        push @rows, \%column_data;
     }
 
-    print qq|
-      </table>
-    </td>
-  </tr>
-  <tr>
-  <td><hr size=3 noshade></td>
-  </tr>
-</table>
-
-<br>
-<form method=post action=$form->{script}>
-|;
-
     $form->{type} = "department";
 
-    $form->hide_form(qw(type callback path login sessionid));
+    my @hiddens = qw(type callback path login sessionid);
 
-    print qq|
-<button class="submit" type="submit" name="action" value="add_department">|
-      . $locale->text('Add Department')
-      . qq|"</button>|;
+    ## SC: removing this for now
+    #if ( $form->{lynx} ) {
+    #    require "bin/menu.pl";
+    #    &menubar;
+    #}
 
-    if ( $form->{lynx} ) {
-        require "bin/menu.pl";
-        &menubar;
-    }
+    my @buttons;
+    push @buttons, {
+        name => 'action',
+        value => 'add_department',
+        text => $locale->text('Add Department'),
+        type => 'submit',
+        class => 'submit',
+    };
 
-    print qq|
-  </form>
-  
-  </body>
-  </html> 
-|;
-
+    my $template = LedgerSMB::Template->new_UI(
+        user => \%myconfig, 
+        locale => $locale,
+        template => 'am-list-departments');
+    $template->render({
+        form => $form,
+        buttons => ..hidden..,
+        columns => ..hidden..,
+        heading => \%column_header,
+        rows => ..hidden..,
+        hiddens => ..hidden..,
+    });
 }
 
 sub department_header {


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