From 3bc8dfe2724a177e12fd56c7dfeeb7c8a6f8548f Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Fri, 11 Mar 2016 16:53:05 -0600 Subject: [PATCH] RT#40806: Enter invoice details from order package page [v3, only detail-table refactor, no new functionality] --- httemplate/edit/cust_pkg_detail.html | 66 +++-------------------- httemplate/edit/elements/detail-table.html | 85 ++++++++++++++++++++++++++++++ httemplate/edit/quotation_pkg_detail.html | 70 +++--------------------- 3 files changed, 97 insertions(+), 124 deletions(-) create mode 100644 httemplate/edit/elements/detail-table.html diff --git a/httemplate/edit/cust_pkg_detail.html b/httemplate/edit/cust_pkg_detail.html index b1e60dad5..a1a6db6d3 100644 --- a/httemplate/edit/cust_pkg_detail.html +++ b/httemplate/edit/cust_pkg_detail.html @@ -1,9 +1,4 @@ -<% include("/elements/header-popup.html", $title, '', - ( $cgi->param('error') ? '' : 'onload="addRow()"' ), - ) -%> - -%# <% include('/elements/error.html') %> +<& /elements/header-popup.html, $title &>
@@ -40,17 +35,10 @@ <% ucfirst($name{$detailtype}) %>: -% my $row = 0; -% for ( @details ) { - - - - - - - - -% } +<& elements/detail-table.html, + id => 'DetailTable', + details => \@details, + &> @@ -59,48 +47,6 @@
- - <%init> @@ -136,7 +82,7 @@ my $cust_pkg = qsearchs({ my $part_pkg = $cust_pkg->part_pkg; -my @details = $cust_pkg->cust_pkg_detail($detailtype); +my @details = map { $_->detail } $cust_pkg->cust_pkg_detail($detailtype); my $title = ( scalar(@details) ? 'Edit ' : 'Add ' ). $name{$detailtype}; diff --git a/httemplate/edit/elements/detail-table.html b/httemplate/edit/elements/detail-table.html new file mode 100644 index 000000000..496ba31b3 --- /dev/null +++ b/httemplate/edit/elements/detail-table.html @@ -0,0 +1,85 @@ +<%doc> +Common code for editing invoice/quotation details/comments. + +Expects to be the last element in a two-column table with specified id + + <& /edit/elements/detail-table.html, + id => 'element_id', # required + details => \@details, # plain text strings, existing details + label => 'Comments', # optional, shows on first row only + field => 'comment', # input field name/id, appended with rownum, default 'detail' + &> + + + + + +<%shared> +my $detail_table_init = 0; + +<%init> +my %opt = @_; + +my @details = $opt{'details'} ? @{ $opt{'details'} } : (); +push(@details,'') if $details[$#details] || !@details; +my $id = $opt{'id'} or die "No id specified"; +my $label = $opt{'label'} || ''; +my $field = $opt{'field'} || 'detail'; + + diff --git a/httemplate/edit/quotation_pkg_detail.html b/httemplate/edit/quotation_pkg_detail.html index ae09b9c6a..036bffdde 100644 --- a/httemplate/edit/quotation_pkg_detail.html +++ b/httemplate/edit/quotation_pkg_detail.html @@ -1,9 +1,4 @@ -<% include("/elements/header-popup.html", $title, '', - ( $cgi->param('error') ? '' : 'onload="addRow()"' ), - ) -%> - -%# <% include('/elements/error.html') %> +<& /elements/header-popup.html, $title &>
@@ -35,17 +30,11 @@ -% my $row = 0; -% for ( @details ) { - - - <% $row ? '' : 'Detail' %> - - - - - -% } +<& elements/detail-table.html, + id => 'DetailTable', + details => \@details, + label => 'Details', + &> @@ -54,53 +43,6 @@
- - <%init> -- 2.11.0