[freeside-commits] freeside/httemplate/edit/elements
svc_Common.html, NONE, 1.1 edit.html, 1.5, 1.6
Ivan,,,
ivan at wavetail.420.am
Tue Jul 11 17:20:24 PDT 2006
Update of /home/cvs/cvsroot/freeside/httemplate/edit/elements
In directory wavetail:/tmp/cvs-serv17459/httemplate/edit/elements
Modified Files:
edit.html
Added Files:
svc_Common.html
Log Message:
svc_phone service and CDR billing from imported CDRs
Index: edit.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/elements/edit.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- edit.html 18 Jun 2006 12:56:20 -0000 1.5
+++ edit.html 12 Jul 2006 00:20:22 -0000 1.6
@@ -9,25 +9,35 @@
# 'column' => 'Label',
# }
#
- # listref - each item is a literal column name (or method) or (notyet) coderef
+ # listref - each item is a literal column name (or method) or hashref
+ # or (notyet) coderef
# if not specified all columns (except for the primary key) will be editable
# 'fields' => [
+ # 'columname',
+ # { 'field' => 'another_columname',
+ # 'type' => 'text', #text, fixed, hidden
+ # },
# ]
#
# 'menubar' => '', #menubar arrayref
#
# #run when re-displaying with an error
- # 'error_callback' => sub { my $cgi, $object = @_; },
+ # 'error_callback' => sub { my( $cgi, $object ) = @_; },
#
# #run when editing
- # 'edit_callback' => sub { my $cgi, $object = @_; },
+ # 'edit_callback' => sub { my( $cgi, $object ) = @_; },
+ #
+ # # returns a hashref for the new object
+ # 'new_hashref_callback'
#
# #run when adding
- # 'new_callback' => sub { my $cgi, $object = @_; },
+ # 'new_callback' => sub { my( $cgi, $object ) = @_; },
#
- # #uninmplemented
- # #'html_table_bottom' => '', #string or listref of additinal HTML to
- # # #add before </TABLE>
+ # #XXX describe
+ # 'field_callback' => sub { },
+ #
+ # #string or coderef of additional HTML to add before </TABLE>
+ # 'html_table_bottom' => '',
#
# 'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
#
@@ -64,13 +74,19 @@
my( $query ) = $cgi->keywords;
$query =~ /^(\d+)$/;
$object = qsearchs( $table, { $pkey => $1 } );
+ warn "$table $pkey => $1"
+ if $opt{'debug'};
&{$opt{'edit_callback'}}($cgi, $object)
if $opt{'edit_callback'};
} else { #adding
- $object = $class->new( {} );
+ my $hashref = $opt{'new_hashref_callback'}
+ ? &{$opt{'new_hashref_callback'}}
+ : {};
+
+ $object = $class->new( $hashref );
&{$opt{'new_callback'}}($cgi, $object)
if $opt{'new_callback'};
@@ -113,16 +129,15 @@
<%= ntable("#cccccc",2) %>
-<% foreach my $f ( @$fields ) {
+<% foreach my $f ( map { ref($_) ? $_ : {'field'=>$_} }
+ @$fields
+ ) {
- my( $field, $type);
- if ( ref($f) ) {
- $field = $f->{'field'},
- $type = $f->{'type'} || 'text',
- } else {
- $field = $f;
- $type = 'text';
- }
+ &{ $opt{'field_callback'} }( $f )
+ if $opt{'field_callback'};
+
+ my $field = $f->{'field'};
+ my $type = $f->{'type'} ||= 'text';
%>
@@ -137,16 +152,29 @@
<%
#eventually more options for <SELECT>, etc. fields
+ if ( $type eq 'fixed' ) {
%>
- <TD>
- <INPUT TYPE="<%= $type %>" NAME="<%= $field %>" VALUE="<%= $object->$field() %>">
- <TD>
+ <TD BGCOLOR="#dddddd"><%= $f->{'value'} %></TD>
+ <INPUT TYPE="hidden" NAME="<%= $field %>" VALUE="<%= $f->{'value'} %>">
+
+ <% } else { %>
+
+ <TD>
+ <INPUT TYPE="<%= $type %>" NAME="<%= $field %>" VALUE="<%= $object->$field() %>">
+ <TD>
+
+ <% } %>
</TR>
<% } %>
+<%= ref( $opt{'html_table_bottom'} )
+ ? &{ $opt{'html_table_bottom'} }( $object )
+ : $opt{'html_table_bottom'}
+%>
+
</TABLE>
<%= ref( $opt{'html_bottom'} )
--- NEW FILE: svc_Common.html ---
<%
my %opt = @_;
#my( $svcnum, $pkgnum, $svcpart, $part_svc );
my( $pkgnum, $svcpart, $part_svc );
#get & untaint pkgnum & svcpart
my($query) = $cgi->keywords; #they're not proper cgi params
if ( $query =~ /^pkgnum(\d+)-svcpart(\d+)$/ ) {
$pkgnum = $1;
$svcpart = $2;
$cgi->delete_all(); #so the standard edit.html treats this correctly as new
}
%><%= include( 'edit.html',
'menubar' => [],
'error_callback' => sub {
my( $cgi, $svc_x ) = @_;
#$svcnum = $svc_x->svcnum;
$pkgnum = $cgi->param('pkgnum');
$svcpart = $cgi->param('svcpart');
$part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart });
die "No part_svc entry!" unless $part_svc;
},
'edit_callback' => sub {
my( $cgi, $svc_x ) = @_;
#$svcnum = $svc_x->svcnum;
my $cust_svc = $svc_x->cust_svc
or die "Unknown (cust_svc) svcnum!";
$pkgnum = $cust_svc->pkgnum;
$svcpart = $cust_svc->svcpart;
$part_svc = qsearchs ('part_svc', { svcpart=>$svcpart });
die "No part_svc entry!" unless $part_svc;
},
'new_hash_callback' => sub {
#my( $cgi, $svc_x ) = @_;
{ svcpart => $svcpart };
},
'new_callback' => sub {
my( $cgi, $svc_x ) = @_;;
$part_svc = qsearchs( 'part_svc', { svcpart=>$svcpart });
die "No part_svc entry!" unless $part_svc;
#$svcnum='';
$svc_x->set_default_and_fixed;
},
'field_callback' => sub {
my $f = shift;
my $columndef = $part_svc->part_svc_column($f->{'field'});
my $flag = $columndef->columnflag;
if ( $flag eq 'F' ) {
$f->{'type'} = 'fixed';
$f->{'value'} = $columndef->columnvalue;
}
},
'html_table_bottom' => sub {
my $svc_x = shift;
my $html = '';
foreach my $field ($svc_x->virtual_fields) {
if ($part_svc->part_svc_column($field)->columnflag ne 'F'){
# If the flag is X, it won't even show up
# in $svc_acct->virtual_fields.
$html .=
$svc_x->pvf($field)->widget( 'HTML',
'edit',
$svc_x->getfield($field)
);
}
}
$html;
},
'html_bottom' => sub {
qq!<INPUT TYPE="hidden" NAME="pkgnum" VALUE="$pkgnum">!.
qq!<INPUT TYPE="hidden" NAME="svcpart" VALUE="$svcpart">!;
},
'debug' => 1,
%opt #pass through/override params
)
%>
More information about the freeside-commits
mailing list