1 <% include('/elements/header.html', "$action Virtual Field Definition") %>
3 <% include('/elements/error.html') %>
5 <FORM ACTION="<%$p1%>process/generic.cgi" METHOD="POST">
7 <INPUT TYPE="hidden" NAME="table" VALUE="part_virtual_field">
8 <INPUT TYPE="hidden" NAME="redirect_ok"
9 VALUE="<%popurl(2)%>browse/part_virtual_field.cgi">
10 <INPUT TYPE="hidden" NAME="vfieldpart" VALUE="<%
12 Field #<B><%$vfieldpart or "(NEW)"%></B><BR><BR>
14 <%ntable("#cccccc",2)%>
16 <TD ALIGN="right">Name</TD>
17 <TD><INPUT TYPE="text" NAME="name" MAXLENGTH=32 VALUE="<%
18 $part_virtual_field->name%>"></TD>
21 <TD ALIGN="right">Table</TD>
23 % if ($action eq 'Add') {
25 <SELECT SIZE=1 NAME="dbtable">
27 % my $dbdef = dbdef; # ick
28 % #foreach my $dbtable (sort { $a cmp $b } $dbdef->tables) {
29 % foreach my $dbtable (qw( svc_broadband router )) {
30 % if ($dbtable !~ /^h_/
31 % and $dbdef->table($dbtable)->primary_key) {
33 <OPTION VALUE="<%$dbtable%>"><%$dbtable%></OPTION>
42 <%$part_virtual_field->dbtable%>
43 <INPUT TYPE="hidden" NAME="dbtable" VALUE="<%$part_virtual_field->dbtable%>">
48 <TD ALIGN="right">Label</TD>
49 <TD><INPUT TYPE="text" NAME="label" MAXLENGTH="80" VALUE="<%
50 $part_virtual_field->label%>"></TD>
53 <TD ALIGN="right">Length</TD>
54 <TD><INPUT TYPE="text" NAME="length" MAXLENGTH=4 VALUE="<%
55 $part_virtual_field->length%>"></TD>
58 <TD ALIGN="right">Check</TD>
59 <TD><TEXTAREA COLS="20" ROWS="4" NAME="check_block"><%
60 $part_virtual_field->check_block%></TEXTAREA></TD>
63 <TD ALIGN="right">List source</TD>
64 <TD><TEXTAREA COLS="20" ROWS="4" NAME="list_source"><%
65 $part_virtual_field->list_source%></TEXTAREA></TD>
67 </TABLE><BR><INPUT TYPE="submit" VALUE="Submit">
72 <FONT SIZE=-2>If you don't understand what <I>check_block</I> and
73 <I>list_source</I> mean, <B>LEAVE THEM BLANK</B>. We mean it.</FONT>
75 <% include('/elements/footer.html') %>
80 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
82 my ($vfieldpart, $part_virtual_field);
84 if ( $cgi->param('error') ) {
85 $part_virtual_field = new FS::part_virtual_field ( {
86 map { $_, scalar($cgi->param($_)) } fields('part_virtual_field')});
87 $vfieldpart = $part_virtual_field->vfieldpart;
89 my($query) = $cgi->keywords;
90 if ( $query =~ /^(\d+)$/ ) { #editing
92 $part_virtual_field=qsearchs('part_virtual_field',
93 {'vfieldpart' => $vfieldpart})
94 or die "Unknown vfieldpart!";
97 $part_virtual_field = new FS::part_virtual_field({});
100 my $action = $part_virtual_field->vfieldpart ? 'Edit' : 'Add';