[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1822] trunk
- Subject: SF.net SVN: ledger-smb: [1822] trunk
- From: ..hidden..
- Date: Sun, 28 Oct 2007 11:32:29 -0700
Revision: 1822
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1822&view=rev
Author: tetragon
Date: 2007-10-28 11:32:29 -0700 (Sun, 28 Oct 2007)
Log Message:
-----------
Finish templating bin/bp.pl
Adjust LSMB::BP's get_spoolfiles to not blow up during tests
Modified Paths:
--------------
trunk/LedgerSMB/BP.pm
trunk/bin/bp.pl
Added Paths:
-----------
trunk/UI/bp-list-spool.html
Modified: trunk/LedgerSMB/BP.pm
===================================================================
--- trunk/LedgerSMB/BP.pm 2007-10-28 17:35:39 UTC (rev 1821)
+++ trunk/LedgerSMB/BP.pm 2007-10-28 18:32:29 UTC (rev 1822)
@@ -200,13 +200,14 @@
$query .= qq|
$union
- SELECT a.id, vc.name, a.$invnumber AS invnumber, a.transdate,
+ SELECT a.id, c.legal_name AS name, a.$invnumber AS invnumber, a.transdate,
a.ordnumber, a.quonumber, $invoice AS invoice,
'$item' AS module, s.spoolfile
- FROM $item a, $form->{vc} vc, status s
+ FROM $item a, $form->{vc} vc, status s, company c
WHERE s.trans_id = a.id
AND s.spoolfile IS NOT NULL
AND s.formname = ?
+ AND c.entity_id = vc.entity_id
AND a.entity_id = vc.entity_id|;
push( @queryargs, $form->{type} );
@@ -217,7 +218,7 @@
if ( $form->{ $form->{vc} } ne "" ) {
$item = $form->like( lc $form->{ $form->{vc} } );
- $query .= " AND lower(vc.name) LIKE ?";
+ $query .= " AND lower(c.legal_name) LIKE ?";
push @queryargs, $item;
}
}
@@ -331,6 +332,7 @@
sub print_spool {
my ( $self, $myconfig, $form ) = @_;
+ ##SC: XXX May need to be changed after hooking up printing to templates
# connect to database
my $dbh = $form->{dbh};
Added: trunk/UI/bp-list-spool.html
===================================================================
--- trunk/UI/bp-list-spool.html (rev 0)
+++ trunk/UI/bp-list-spool.html 2007-10-28 18:32:29 UTC (rev 1822)
@@ -0,0 +1,76 @@
+<!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" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
+ </tr>
+ <tr>
+ <?lsmb IF options.defined ?>
+ <td><?lsmb FOREACH option IN options; option ?><br /><?lsmb END ?></td>
+ <?lsmb ELSE ?>
+ <td colspan="<?lsmb columns.size ?>"></td></tr>
+ <?lsmb END ?>
+ </tr>
+ <tr class="listheading">
+<?lsmb FOREACH column IN columns ?>
+ <th class="listtop">
+ <?lsmb IF heading.$column.href ?><a class="listtop" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a>
+ <?lsmb ELSE; heading.$column; END ?>
+ </th>
+<?lsmb END ?>
+ </tr>
+ <?lsmb USE dumper(indent=2, pad="<br>") ?>
+<?lsmb FOREACH row IN rows ?>
+<?lsmb IF row.class == 'heading'; s = 'th'; c = 'listheading';
+ ELSIF row.class == 'subtotal'; s = 'th'; c = 'listsubtotal';
+ ELSE; s = 'td'; c = "listrow${row.i}"; END ?>
+<tr class="<?lsmb c ?>">
+ <?lsmb FOREACH column IN columns ?>
+ <<?lsmb s ?> class="<?lsmb c ?>" <?lsmb IF (!row.class.defined || row.class != 'heading') && row_alignment.$column ?>align="<?lsmb row_alignment.$column ?>"<?lsmb END ?>>
+ <?lsmb IF row.$column.href.defined ?>
+ <a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
+ <?lsmb ELSIF row.$column.delimiter;
+ FOREACH l IN row.$column.text.split(row.$column.delimiter); l ?><br /><?lsmb END ?>
+ <?lsmb ELSIF row.$column.input.defined;
+ PROCESS input element_data=row.$column.input ?>
+ <?lsmb ELSE; row.$column; END ?>
+ </<?lsmb s ?>>
+ <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+ <tr><td colspan="<?lsmb columns.size ?>"><hr size="3" /></td></tr>
+</table>
+
+<br />
+
+<?lsmb FOREACH hidden IN hiddens.keys;
+ PROCESS input element_data={
+ type => 'hidden',
+ name => hidden,
+ value => hiddens.item(hidden)
+ };
+END;
+IF printers.defined; FOREACH p IN printers;
+ PROCESS input element_data=p;
+END ?><br /><?lsmb END ?>
+<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
+</form>
+</body>
+</html>
Modified: trunk/bin/bp.pl
===================================================================
--- trunk/bin/bp.pl 2007-10-28 17:35:39 UTC (rev 1821)
+++ trunk/bin/bp.pl 2007-10-28 18:32:29 UTC (rev 1822)
@@ -246,6 +246,7 @@
for $i ( 1 .. $form->{rowcount} ) {
if ( $form->{"checked_$i"} ) {
+ ##SC: XXX adjust later once printing hooked up to templates
$form->{OUT} = "${LedgerSMB::Sysconfig::printer}{$form->{media}}";
$form->{printmode} = '|-';
$form->info( $locale->text('Printing') . " ..." );
@@ -269,77 +270,72 @@
sub list_spool {
+ my %hiddens;
+ my @buttons;
+
$form->{ $form->{vc} } = $form->unescape( $form->{ $form->{vc} } );
( $form->{ $form->{vc} }, $form->{"$form->{vc}_id"} ) =
split( /--/, $form->{ $form->{vc} } );
BP->get_spoolfiles( \%myconfig, \%$form );
- $title = $form->escape( $form->{title} );
- $href =
+ my $title = $form->escape( $form->{title} );
+ my $href =
"$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
$form->sort_order();
$title = $form->escape( $form->{title}, 1 );
- $callback =
+ my $callback =
"$form->{script}?action=list_spool&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&vc=$form->{vc}&type=$form->{type}&title=$title";
+ my @options;
if ( $form->{ $form->{vc} } ) {
$callback .=
"&$form->{vc}=" . $form->escape( $form->{ $form->{vc} }, 1 );
$href .= "&$form->{vc}=" . $form->escape( $form->{ $form->{vc} } );
- $option =
+ push @options,
( $form->{vc} eq 'customer' )
- ? $locale->text('Customer')
- : $locale->text('Vendor');
- $option .= " : $form->{$form->{vc}}";
+ ? $locale->text('Customer: [_1]', $form->{$form->{vc}})
+ : $locale->text('Vendor: [_1]', $form->{$form->{vc}});
}
if ( $form->{account} ) {
$callback .= "&account=" . $form->escape( $form->{account}, 1 );
$href .= "&account=" . $form->escape( $form->{account} );
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Account') . " : $form->{account}";
+ push @options, $locale->text('Account: [_1]', $form->{account});
}
if ( $form->{invnumber} ) {
$callback .= "&invnumber=" . $form->escape( $form->{invnumber}, 1 );
$href .= "&invnumber=" . $form->escape( $form->{invnumber} );
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Invoice Number') . " : $form->{invnumber}";
+ push @options, $locale->text('Invoice Number: [_1]', $form->{invnumber});
}
if ( $form->{ordnumber} ) {
$callback .= "&ordnumber=" . $form->escape( $form->{ordnumber}, 1 );
$href .= "&ordnumber=" . $form->escape( $form->{ordnumber} );
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Order Number') . " : $form->{ordnumber}";
+ push @options, $locale->text('Order Number: [_1]', $form->{ordnumber});
}
if ( $form->{quonumber} ) {
$callback .= "&quonumber=" . $form->escape( $form->{quonumber}, 1 );
$href .= "&quonumber=" . $form->escape( $form->{quonumber} );
- $option .= "\n<br>" if ($option);
- $option .= $locale->text('Quotation Number') . " : $form->{quonumber}";
+ push @options, $locale->text('Quotation Number: [_1]', $form->{quonumber});
}
if ( $form->{transdatefrom} ) {
$callback .= "&transdatefrom=$form->{transdatefrom}";
$href .= "&transdatefrom=$form->{transdatefrom}";
- $option .= "\n<br>" if ($option);
- $option .=
- $locale->text('From') . " "
- . $locale->date( \%myconfig, $form->{transdatefrom}, 1 );
+ push @options, $locale->text('From [_1]',
+ $locale->date( \%myconfig, $form->{transdatefrom}, 1 ));
}
if ( $form->{transdateto} ) {
$callback .= "&transdateto=$form->{transdateto}";
$href .= "&transdateto=$form->{transdateto}";
- $option .= "\n<br>" if ($option);
- $option .=
- $locale->text('To') . " "
- . $locale->date( \%myconfig, $form->{transdateto}, 1 );
+ push @options, $locale->text('To [_1]',
+ $locale->date( \%myconfig, $form->{transdateto}, 1 ));
}
- $name = ucfirst $form->{vc};
+ my $name = ucfirst $form->{vc};
- @columns = qw(transdate);
+ my @columns = qw(transdate);
if ( $form->{type} =~ /(invoice)/ ) {
push @columns, "invnumber";
}
@@ -357,74 +353,49 @@
}
push @columns, ( name, spoolfile );
- @column_index = $form->sort_columns(@columns);
+ my @column_index = $form->sort_columns(@columns);
unshift @column_index, "checked";
- $column_header{checked} = "<th class=listheading> </th>";
- $column_header{transdate} =
- "<th><a class=listheading href=$href&sort=transdate>"
- . $locale->text('Date')
- . "</a></th>";
- $column_header{invnumber} =
- "<th><a class=listheading href=$href&sort=invnumber>"
- . $locale->text('Invoice')
- . "</a></th>";
- $column_header{ordnumber} =
- "<th><a class=listheading href=$href&sort=ordnumber>"
- . $locale->text('Order')
- . "</a></th>";
- $column_header{quonumber} =
- "<th><a class=listheading href=$href&sort=quonumber>"
- . $locale->text('Quotation')
- . "</a></th>";
- $column_header{name} =
- "<th><a class=listheading href=$href&sort=name>"
- . $locale->text($name)
- . "</a></th>";
- $column_header{id} =
- "<th><a class=listheading href=$href&sort=id>"
- . $locale->text('ID')
- . "</a></th>";
- $column_header{spoolfile} =
- "<th class=listheading>" . $locale->text('Spoolfile') . "</th>";
+ my %column_header;
+ $column_header{checked} = ' ';
+ $column_header{transdate} = {
+ href => "$href&sort=transdate",
+ text => $locale->text('Date'),
+ };
+ $column_header{invnumber} = {
+ href => "$href&sort=invnumber",
+ text => $locale->text('Invoice'),
+ };
+ $column_header{ordnumber} = {
+ href => "$href&sort=ordnumber",
+ text => $locale->text('Order'),
+ };
+ $column_header{quonumber} = {
+ href => "$href&sort=quonumber",
+ text => $locale->text('Quotation'),
+ };
+ $column_header{name} = {
+ href => "$href&sort=name",
+ text => $locale->text($name),
+ };
+ $column_header{id} = {
+ href => "$href&sort=id",
+ text => $locale->text('ID'),
+ };
+ $column_header{spoolfile} = $locale->text('Spoolfile');
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>$option</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>
-|;
-
- for (@column_index) { print "\n$column_header{$_}" }
-
- print qq|
- </tr>
-|;
-
# add sort and escape callback, this one we use for the add sub
$form->{callback} = $callback .= "&sort=$form->{sort}";
# escape callback for href
$callback = $form->escape($callback);
- $i = 0;
+ my $i = 0;
+ my @rows;
- foreach $ref ( @{ $form->{SPOOL} } ) {
+ foreach my $ref ( @{ $form->{SPOOL} } ) {
+ my %column_data;
$i++;
$form->{"checked_$i"} = "checked" if $form->{"checked_$i"};
@@ -437,94 +408,88 @@
}
$module = "$ref->{module}.pl";
- $column_data{transdate} = "<td>$ref->{transdate} </td>";
+ $column_data{transdate} = $ref->{transdate};
if ( ${LedgerSMB::Sysconfig::spool} eq $ref->{spoolfile} ) {
- $column_data{checked} = qq|<td></td>|;
+ $column_data{checked} = '';
}
else {
- $column_data{checked} =
-qq|<td><input name=checked_$i type=checkbox class=checkbox $form->{"checked_$i"} $form->{"checked_$i"}></td>|;
+ $column_data{checked} = {input => {
+ name => "checked_$i",
+ type => 'checkbox',
+ $form->{"checked_$i"} => $form->{"checked_$i"},
+ }};
}
for (qw(id invnumber ordnumber quonumber)) {
- $column_data{$_} = qq|<td>$ref->{$_}</td>|;
+ $column_data{$_} = $ref->{$_};
}
if ( $ref->{module} eq 'oe' ) {
- $column_data{invnumber} = qq|<td> </td>|;
- $column_data{ordnumber} =
-qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{ordnumber}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{ordnumber}">|;
+ $hiddens{"reference_$i"} = $ref->{ordnumber};
+ $column_data{invnumber} = ' ';
+ $column_data{ordnumber} = {
+ href => "$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback",
+ text => $ref->{ordnumber},
+ };
- $column_data{quonumber} =
-qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{quonumber}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{quonumber}">|;
+ $hiddens{"reference_$i"} = $ref->{quonumber} unless $ref->{ordnumber};
+ $column_data{quonumber} = {
+ href => "$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback",
+ text => $ref->{quonumber},
+ };
}
elsif ( $ref->{module} eq 'jc' ) {
- $column_data{id} =
-qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{id}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{id}">|;
+ $hiddens{"reference_$i"} = $ref->{id};
+ $column_data{id} = {
+ href => "$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback",
+ text => $ref->{id},
+ };
}
else {
- $column_data{invnumber} =
-qq|<td><a href=$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback>$ref->{invnumber}</a></td>
- <input type=hidden name="reference_$i" value="$ref->{invnumber}">|;
+ $hiddens{"reference_$i"} = $ref->{invnumber};
+ $column_data{invnumber} = {
+ href => "$module?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&callback=$callback",
+ text => $ref->{invnumber},
+ };
}
- $column_data{name} = "<td>$ref->{name}</td>";
- $column_data{spoolfile} =
-qq|<td><a href=${LedgerSMB::Sysconfig::spool}/$ref->{spoolfile}>$ref->{spoolfile}</a></td>
+ $column_data{name} = $ref->{name};
+ $column_data{spoolfile} = {
+ href => "${LedgerSMB::Sysconfig::spool}/$ref->{spoolfile}",
+ text => $ref->{spoolfile},
+ };
-|;
-
${LedgerSMB::Sysconfig::spool} = $ref->{spoolfile};
$j++;
$j %= 2;
- print "
- <tr class=listrow$j>
-";
+ $column_data{i} = $j;
- for (@column_index) { print "\n$column_data{$_}" }
+ $hiddens{"id_$i"} = $ref->{id};
+ $hiddens{"spoolfile_$i"} = $ref->{spoolfile};
+ push @rows, \%column_data;
- print qq|
-<input type=hidden name="id_$i" value=$ref->{id}>
-<input type=hidden name="spoolfile_$i" value=$ref->{spoolfile}>
-
- </tr>
-|;
-
}
- print qq|
-<input type=hidden name=rowcount value=$i>
+ $hiddens{rowcount} = $i;
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
+ $hiddens{$_} = $form->{$_} foreach
+ qw(callback title vc type sort module account path login sessionid);
-<br>
-|;
-
- $form->hide_form(
- qw(callback title vc type sort module account path login sessionid));
-
+ my @printers;
if ( %{LedgerSMB::Sysconfig::printer} && ${LedgerSMB::Sysconfig::latex} ) {
- foreach $key ( sort keys %{LedgerSMB::Sysconfig::printer} ) {
- print qq|
-<input name=media type=radio class=radio value="$key" |;
- print qq|checked| if $key eq $myconfig{printer};
- print qq|>$key|;
+ foreach my $key ( sort keys %{LedgerSMB::Sysconfig::printer} ) {
+ push @printers, {
+ type => 'radio',
+ name => 'media',
+ value => $key,
+ label => $key,
+ };
+ $printers[$#printers]{checked} = 'checked' if $key eq $myconfig{printer};
}
- print qq|<p>\n|;
-
# type=submit $locale->text('Select all')
# type=submit $locale->text('Print')
# type=submit $locale->text('Remove')
@@ -540,23 +505,39 @@
for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button )
{
- $form->print_button( \%button, $_ );
+ push @buttons, {
+ name => 'action',
+ value => $_,
+ accesskey => $button{$_}{key},
+ title => "$button{$_}{value} [Alt-$button{$_}{key}]",
+ text => $button{$_}{value},
+ };
}
}
- if ( $form->{lynx} ) {
- require "bin/menu.pl";
- &menubar;
- }
+##SC: Temporary removal
+## if ( $form->{lynx} ) {
+## require "bin/menu.pl";
+## &menubar;
+## }
- print qq|
-</form>
-
-</body>
-</html>
-|;
-
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'bp-list-spool',
+ );
+ $template->render({
+ form => $form,
+ user => \%myconfig,
+ hiddens => \%hiddens,
+ buttons => ..hidden..,
+ options => ..hidden..,
+ rows => ..hidden..,
+ columns => ..hidden..,
+ heading => \%column_header,
+ printers => ..hidden..,
+ });
}
sub select_all {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.