summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorivan <ivan>2006-07-12 00:20:23 +0000
committerivan <ivan>2006-07-12 00:20:23 +0000
commit1053db7f76169cbbc87840539959a4c362aff242 (patch)
tree1d1895ce43bb5910a8de5e3ead26b2e179ed268e /httemplate/edit
parenta8665e44dbd99bd864e48231928405a31cedce5f (diff)
svc_phone service and CDR billing from imported CDRs
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/elements/edit.html68
-rw-r--r--httemplate/edit/elements/svc_Common.html98
-rwxr-xr-xhttemplate/edit/part_svc.cgi25
-rw-r--r--httemplate/edit/process/elements/process.html15
-rw-r--r--httemplate/edit/process/elements/svc_Common.html14
-rw-r--r--httemplate/edit/process/svc_phone.html4
-rw-r--r--httemplate/edit/svc_phone.cgi11
7 files changed, 212 insertions, 23 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 6fa2b3b6e..f79cc0b24 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -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 ) = @_; },
+ #
+ # #XXX describe
+ # 'field_callback' => sub { },
#
- # #uninmplemented
- # #'html_table_bottom' => '', #string or listref of additinal HTML to
- # # #add before </TABLE>
+ # #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'} )
diff --git a/httemplate/edit/elements/svc_Common.html b/httemplate/edit/elements/svc_Common.html
new file mode 100644
index 000000000..c113ad645
--- /dev/null
+++ b/httemplate/edit/elements/svc_Common.html
@@ -0,0 +1,98 @@
+<%
+
+ 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
+ )
+%>
diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi
index 0298a5461..489a2339c 100755
--- a/httemplate/edit/part_svc.cgi
+++ b/httemplate/edit/part_svc.cgi
@@ -39,11 +39,12 @@ Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref-
<INPUT TYPE="hidden" NAME="svcpart" VALUE="<%= $hashref->{svcpart} %>">
<BR>
Service definitions are the templates for items you offer to your customers.
-<UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, etc.)
+<UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.)
<LI>svc_domain - Domains
<LI>svc_forward - mail forwarding
<LI>svc_www - Virtual domain website
<LI>svc_broadband - Broadband/High-speed Internet service (always-on)
+ <LI>svc_phone - Customer phone numbers
<LI>svc_external - Externally-tracked service
<!-- <LI>svc_charge - One-time charges (Partially unimplemented)
<LI>svc_wo - Work orders (Partially unimplemented)
@@ -60,6 +61,7 @@ that field.
#pry need to eventually create stuff that's shared amount UIs
my $conf = new FS::Conf;
my %defs = (
+
'svc_acct' => {
'dir' => 'Home directory',
'uid' => 'UID (set to fixed and blank for no UIDs)',
@@ -111,14 +113,17 @@ my %defs = (
disable_inventory => 1,
},
},
+
'svc_domain' => {
'domain' => 'Domain',
},
+
'svc_forward' => {
'srcsvc' => 'service from which mail is to be forwarded',
'dstsvc' => 'service to which mail is to be forwarded',
'dst' => 'someone@another.domain.com to use when dstsvc is 0',
},
+
# 'svc_charge' => {
# 'amount' => 'amount',
# },
@@ -126,20 +131,36 @@ my %defs = (
# 'worker' => 'Worker',
# '_date' => 'Date',
# },
+
'svc_www' => {
#'recnum' => '',
#'usersvc' => '',
},
+
'svc_broadband' => {
'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.',
'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.',
'ip_addr' => 'IP address. Leave blank for automatic assignment.',
'blocknum' => 'Address block.',
},
+
+ 'svc_phone' => {
+ 'countrycode' => { desc => 'Country code',
+ type => 'text',
+ disable_inventory => 1,
+ },
+ 'phonenum' => 'Phone number',
+ 'pin' => { desc => 'Personal Identification Number',
+ type => 'text',
+ disable_inventory => 1,
+ },
+ },
+
'svc_external' => {
#'id' => '',
#'title' => '',
},
+
);
my %vfields;
@@ -195,7 +216,7 @@ my %defs = (
my @dbs = $hashref->{svcdb}
? ( $hashref->{svcdb} )
- : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_external );
+ : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_phone svc_external );
tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs;
my $widget = new HTML::Widgets::SelectLayers(
diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html
index a6e3b50e3..7cae78bfc 100644
--- a/httemplate/edit/process/elements/process.html
+++ b/httemplate/edit/process/elements/process.html
@@ -5,6 +5,7 @@
###
##req
##
+ #
# 'table' =>
#
# #? 'primary_key' => #required when the dbdef doesn't know...???
@@ -13,7 +14,14 @@
###
##opt
###
+ #
# 'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
+ # OR
+ # 'redirect' => 'view/table.cgi?', # value of primary key is appended
+ #
+ # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the
+ # #naming is still inconsistent
+ #
# 'process_m2m' => { 'link_table' => 'link_table_name',
# 'target_table' => 'target_table_name',
# },
@@ -65,9 +73,14 @@
);
}
+ # XXX print?!?!
+
if ( $error ) {
$cgi->param('error', $error);
- print $cgi->redirect(popurl(2). "$table.html?". $cgi->query_string );
+ my $edit_ext = $opt{'edit_ext'} || 'html';
+ print $cgi->redirect(popurl(2). "$table.$edit_ext?". $cgi->query_string );
+ } elsif ( $opt{'redirect'} ) {
+ print $cgi->redirect( $opt{'redirect'}. $pkeyvalue );
} else {
print $cgi->redirect( popurl(3).
( $opt{'viewall_dir'} || 'search' ).
diff --git a/httemplate/edit/process/elements/svc_Common.html b/httemplate/edit/process/elements/svc_Common.html
new file mode 100644
index 000000000..1f8f8315e
--- /dev/null
+++ b/httemplate/edit/process/elements/svc_Common.html
@@ -0,0 +1,14 @@
+<%
+
+ my %opt = @_;
+ my $table = $opt{'table'};
+ $opt{'fields'} ||= [ fields($table) ];
+ push @{ $opt{'fields'} }, qw( pkgnum svcpart );
+
+%><%= include( 'process.html',
+ 'edit_ext' => 'cgi',
+ 'redirect' => popurl(3)."view/$table.cgi?",
+ %opt,
+ )
+%>
+
diff --git a/httemplate/edit/process/svc_phone.html b/httemplate/edit/process/svc_phone.html
new file mode 100644
index 000000000..c1d4b7547
--- /dev/null
+++ b/httemplate/edit/process/svc_phone.html
@@ -0,0 +1,4 @@
+<%= include( 'elements/svc_Common.html',
+ 'table' => 'svc_phone',
+ )
+%>
diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi
new file mode 100644
index 000000000..77b4975a1
--- /dev/null
+++ b/httemplate/edit/svc_phone.cgi
@@ -0,0 +1,11 @@
+<%= include( 'elements/svc_Common.html',
+ 'name' => 'Phone number',
+ 'table' => 'svc_phone',
+ 'fields' => [qw( countrycode phonenum )], #pin
+ 'labels' => {
+ 'countrycode' => 'Country code',
+ 'phonenum' => 'Phone number',
+ 'pin' => 'PIN',
+ },
+ )
+%>