From 7b68b7574abeaa9091a0d435c144d44a8399f40c Mon Sep 17 00:00:00 2001 From: tetragon Date: Mon, 5 Nov 2007 15:54:35 +0000 Subject: Convert list_history to dynatable. Looks like ct.pl is done templating git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1852 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/ct.pl | 276 +++++++++++++++++++++++++------------------------------------- 1 file changed, 111 insertions(+), 165 deletions(-) (limited to 'bin/ct.pl') diff --git a/bin/ct.pl b/bin/ct.pl index 91f13eb4..3b664096 100644 --- a/bin/ct.pl +++ b/bin/ct.pl @@ -925,17 +925,19 @@ sub list_subtotal { sub list_history { CT->get_history( \%myconfig, \%$form ); + my %hiddens; + my @buttons; - $href = + my $href = "$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}"; $form->sort_order(); - $callback = + my $callback = "$form->{script}?action=list_history&direction=$form->{direction}&oldsort=$form->{oldsort}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&type=$form->{type}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&history=$form->{history}"; $form->{l_fxsellprice} = $form->{l_curr}; - @columns = $form->sort_columns( partnumber, description, qty, unit, + my @columns = $form->sort_columns( partnumber, description, qty, unit, sellprice, fxsellprice, curr, discount, deliverydate, projectnumber, serialnumber ); @@ -946,6 +948,7 @@ sub list_history { curr ); } + my @column_index; foreach $item (@columns) { if ( $form->{"l_$item"} eq "Y" ) { push @column_index, $item; @@ -956,21 +959,21 @@ sub list_history { } } + my @options; if ( $form->{history} eq 'detail' ) { - $option = $locale->text('Detail'); - } - if ( $form->{history} eq 'summary' ) { - $option .= $locale->text('Summary'); + push @options, $locale->text('Detail'); + } elsif ( $form->{history} eq 'summary' ) { + push @options, $locale->text('Summary'); } if ( $form->{name} ) { $callback .= "&name=" . $form->escape( $form->{name}, 1 ); $href .= "&name=" . $form->escape( $form->{name} ); - $option .= "\n
" . $locale->text('Name') . " : $form->{name}"; + push @options, $locale->text('Name: [_1]', $form->{name}); } if ( $form->{contact} ) { $callback .= "&contact=" . $form->escape( $form->{contact}, 1 ); $href .= "&contact=" . $form->escape( $form->{contact} ); - $option .= "\n
" . $locale->text('Contact') . " : $form->{contact}"; + push @options, $locale->text('Contact: [_1]', $form->{contact}); } if ( $form->{"$form->{db}number"} ) { $callback .= @@ -978,91 +981,80 @@ sub list_history { . $form->escape( $form->{"$form->{db}number"}, 1 ); $href .= "&$form->{db}number=" . $form->escape( $form->{"$form->{db}number"} ); - $option .= "\n
" - . $locale->text('Number') - . qq| : $form->{"$form->{db}number"}|; + push @options, $locale->text('Number: [_1]', + $form->{"$form->{db}number"}); } if ( $form->{email} ) { $callback .= "&email=" . $form->escape( $form->{email}, 1 ); $href .= "&email=" . $form->escape( $form->{email} ); - $option .= "\n
" . $locale->text('E-mail') . " : $form->{email}"; + push @options, $locale->text('E-mail: [_1]', $form->{email}); } if ( $form->{transdatefrom} ) { $callback .= "&transdatefrom=$form->{transdatefrom}"; $href .= "&transdatefrom=$form->{transdatefrom}"; - $option .= "\n
" 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}"; if ( $form->{transdatefrom} ) { - $option .= " "; - } - else { - $option .= "\n
" if ($option); + pop @options; + push @options, $locale->text('From [_1] To [_2]', + $locale->date( \%myconfig, $form->{transdatefrom}, 1 ), + $locale->date( \%myconfig, $form->{transdateto}, 1 )); + } else { + push @options, $locale->text('To [_1]', + $locale->date( \%myconfig, $form->{transdateto}, 1 )); } - $option .= - $locale->text('To') . " " - . $locale->date( \%myconfig, $form->{transdateto}, 1 ); } if ( $form->{open} ) { $callback .= "&open=$form->{open}"; $href .= "&open=$form->{open}"; - $option .= "\n
" if ($option); - $option .= $locale->text('Open'); + push @options, $locale->text('Open'); } if ( $form->{closed} ) { $callback .= "&closed=$form->{closed}"; $href .= "&closed=$form->{closed}"; - $option .= "\n
" if ($option); - $option .= $locale->text('Closed'); + push @options, $locale->text('Closed'); } $form->{callback} = "$callback&sort=$form->{sort}"; $callback = $form->escape( $form->{callback} ); - $column_header{partnumber} = - qq|| - . $locale->text('Part Number') - . qq||; - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; + my %column_header; + $column_header{partnumber} = { + href => "$href&sort=partnumber", + text => $locale->text('Part Number') + }; + $column_header{description} = { + href => "$href&sort=description", + text => $locale->text('Description') + }; if ( $form->{history} eq 'summary' ) { - $column_header{sellprice} = - qq|| . $locale->text('Total') . qq||; + $column_header{sellprice} = $locale->text('Total'); + } else { + $column_header{sellprice} = $locale->text('Sell Price'); } - else { - $column_header{sellprice} = - qq|| . $locale->text('Sell Price') . qq||; - } - $column_header{fxsellprice} = qq| |; - - $column_header{curr} = - qq|| . $locale->text('Curr') . qq||; - $column_header{discount} = - qq|| . $locale->text('Discount') . qq||; - $column_header{qty} = - qq|| . $locale->text('Qty') . qq||; - $column_header{unit} = - qq|| . $locale->text('Unit') . qq||; - $column_header{deliverydate} = - qq|| - . $locale->text('Delivery Date') - . qq||; - $column_header{projectnumber} = - qq|| - . $locale->text('Project Number') - . qq||; - $column_header{serialnumber} = - qq|| - . $locale->text('Serial Number') - . qq||; + $column_header{fxsellprice} = ' '; + + $column_header{curr} = $locale->text('Curr'); + $column_header{discount} = $locale->text('Discount'); + $column_header{qty} = $locale->text('Qty'); + $column_header{unit} = $locale->text('Unit'); + $column_header{deliverydate} = { + href => "$href&sort=deliverydate", + text => $locale->text('Delivery Date') + }; + $column_header{projectnumber} = { + href => "$href&sort=projectnumber", + text => $locale->text('Project Number') + }; + $column_header{serialnumber} = { + href => "$href&sort=serialnumber", + text => $locale->text('Serial Number') + }; # $locale->text('Customer History') # $locale->text('Vendor History') @@ -1070,33 +1062,6 @@ sub list_history { $label = ucfirst $form->{db}; $form->{title} = $locale->text( $label . " History" ); - $colspan = $#column_index + 1; - - $form->header; - - print qq| - - - - - - - - - - - - - - - - -
$form->{title}
$option
- - -|; - - for (@column_index) { print "$column_header{$_}\n" } - - print qq| - -|; - $module = 'oe'; if ( $form->{db} eq 'customer' ) { $invlabel = $locale->text('Sales Invoice'); @@ -1108,8 +1073,7 @@ sub list_history { if ( $form->{type} eq 'invoice' ) { $module = 'is'; } - } - else { + } else { $invlabel = $locale->text('Vendor Invoice'); $ordlabel = $locale->text('Purchase Order'); $quolabel = $locale->text('RFQ'); @@ -1123,16 +1087,16 @@ sub list_history { $ml = ( $form->{db} eq 'vendor' ) ? -1 : 1; - foreach $ref ( @{ $form->{CT} } ) { + my @rows; + foreach my $ref ( @{ $form->{CT} } ) { if ( $ref->{id} ne $sameid ) { - # print the header - print qq| - - - -|; + push @rows, { + class => 'divider', + text => "$ref->{name} $ref->{address}" + href => "$form->{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback", + }; } if ( $form->{type} ne 'invoice' ) { @@ -1146,92 +1110,74 @@ sub list_history { $i++; $i %= 2; - print qq| - -|; - if ( $form->{type} eq 'invoice' ) { - print -qq||; - } - - if ( $form->{type} eq 'order' ) { - print -qq||; + push @rows, { + class => 'divider', + href => "${module}.pl?action=edit&id=$ref->{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback", + text => "$invlabel $ref->{invnumber} / $ref->{employee}"; + }; + } elsif ( $form->{type} eq 'order' ) { + push @rows, { + class => 'divider', + href => "${module}.pl?action=edit&id=$ref->{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback", + text => "$ordlabel $ref->{ordnumber} / $ref->{employee}" + }; + } elsif ( $form->{type} eq 'quotation' ) { + push @rows, { + class => 'divider', + href => "${module}.pl?action=edit&id=$ref->{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback", + text => "$quolabel $ref->{quonumber} / $ref->{employee}" + }; } - - if ( $form->{type} eq 'quotation' ) { - print -qq||; - } - - print qq| - -|; } - for (@column_index) { $column_data{$_} = "" } + my %column_data; + for (@column_index) { $column_data{$_} = $ref->{$_} } if ( $form->{l_curr} ) { $column_data{fxsellprice} = - qq|"; + $form->format_amount( \%myconfig, $ref->{fxsellprice}, 2 ); } $column_data{sellprice} = - qq|"; - + $form->format_amount( \%myconfig, $ref->{sellprice}, 2 ); $column_data{qty} = - qq|"; - $column_data{discount} = qq|"; - $column_data{partnumber} = -qq||; + $form->format_amount( \%myconfig, $ref->{qty} * $ml ); + $column_data{discount} = + $form->format_amount( \%myconfig, $ref->{discount} * 100, "", ' ' ); + $column_data{partnumber} = { + href => "ic.pl?action=edit&id=$ref->{pid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback" + text => $ref->{partnumber} + }; $i++; $i %= 2; - print qq| - -|; - - for (@column_index) { print "$column_data{$_}\n" } + $column_data{i} = $i; - print qq| - -|; + push @rows, \%column_data; $sameid = $ref->{id}; $sameinvid = $ref->{invid}; } - print qq| -
{script}?action=edit&id=$ref->{ctid}&db=$form->{db}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{name} $ref->{address}
{invid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$invlabel $ref->{invnumber} / $ref->{employee}{invid}&type=$ordertype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ordlabel $ref->{ordnumber} / $ref->{employee}{invid}&type=$quotationtype&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$quolabel $ref->{quonumber} / $ref->{employee}
$ref->{$_} | - . $form->format_amount( \%myconfig, $ref->{fxsellprice}, 2 ) - . "| - . $form->format_amount( \%myconfig, $ref->{sellprice}, 2 ) . "| - . $form->format_amount( \%myconfig, $ref->{qty} * $ml ) . "| - . $form->format_amount( \%myconfig, $ref->{discount} * 100, - "", " " ) - . "{pid}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{partnumber}
-

- -|; - - if ( $form->{lynx} ) { - require "bin/menu.pl"; - &menubar; - } - - print qq| - - - - -|; +##SC: Temporary removal +## if ( $form->{lynx} ) { +## require "bin/menu.pl"; +## &menubar; +## } + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'form-dynatable', + ); + $template->render({ + form => $form, + options => \@options, + rows => \@rows, + columns => \@column_index, + heading => \%column_header, + }); } sub edit { -- cgit v1.2.3