[freeside-users] Upgraded from 1.5.7 to 1.5.8,
now cannot edit services
Peter Kolbe
peter at venturenet.co.za
Tue May 23 01:07:30 PDT 2006
When I click to go add or edit a service, I get the following Error:
Please Advise
Freeside1.5.8 (upgraded from 1.5.7)
Fedora Core 4
Thanks
Peter
Errors Output
1.. Can't call method "table" on an undefined value at /var/www/freeside/edit/part_svc.cgi line 198. , /usr/lib/perl5/site_perl/5.8.6/Apache/ASP.pm line 1526
Debug Output
1.. Can't call method "table" on an undefined value at /var/www/freeside/edit/part_svc.cgi line 198. , /usr/lib/perl5/site_perl/5.8.6/Apache/ASP.pm line 1526
ASP to Perl Script
-: no strict;;use vars qw($Application $Session $Response $Server $Request);;
-: #line 1 /var/www/freeside/edit/part_svc.cgi
1: ;;
2: my $part_svc;
3: my $clone = '';
4: if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {#clone
5: #$cgi->param('clone') =~ /^(\d+)$/ or die "malformed query: $query";
6: $part_svc = qsearchs('part_svc', { 'svcpart'=>$1 } )
7: or die "unknown svcpart: $1";
8: $clone = $part_svc->svcpart;
9: $part_svc->svcpart('');
10: } elsif ( $cgi->keywords ) { #edit
11: my($query) = $cgi->keywords;
12: $query =~ /^(\d+)$/ or die "malformed query: $query";
13: $part_svc=qsearchs('part_svc', { 'svcpart'=>$1 } )
14: or die "unknown svcpart: $1";
15: } else { #adding
16: $part_svc = new FS::part_svc {};
17: }
18:
19: my $action = $part_svc->svcpart ? 'Edit' : 'Add';
20: my $hashref = $part_svc->hashref;
21: # my $p_svcdb = $part_svc->svcdb || 'svc_acct';
22:
23:
24: #" onLoad=\"visualize()\""
25: ; &Apache::ASP::WriteRef($main::Response, \('
26: <!-- mason kludge -->
27: '.( header("$action Service Definition",
28: menubar( 'Main Menu' => $p,
29: 'View all service definitions' => "${p}browse/part_svc.cgi"
30: ),
31: )
32: ).'
33:
34: <FORM NAME="dummy">
35:
36: Service Part #'.( $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" ).'
37: <BR><BR>
38: Service <INPUT TYPE="text" NAME="svc" VALUE="'.( $hashref->{svc} ).'"><BR>
39: Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"'.( $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' ).'><BR>
40: <INPUT TYPE="hidden" NAME="svcpart" VALUE="'.( $hashref->{svcpart} ).'">
41: <BR>
42: Services are items you offer to your customers.
43: <UL><LI>svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
44: <LI>svc_domain - Domains
45: <LI>svc_forward - mail forwarding
46: <LI>svc_www - Virtual domain website
47: <LI>svc_broadband - Broadband/High-speed Internet service
48: <LI>svc_external - Externally-tracked service
49: <!-- <LI>svc_charge - One-time charges (Partially unimplemented)
50: <LI>svc_wo - Work orders (Partially unimplemented)
51: -->
52: </UL>
53: For the selected table, you can give fields default or fixed (unchangable)
54: values. For example, a SLIP/PPP account may have a default (or perhaps fixed)
55: <B>slipip</B> of <B>0.0.0.0</B>, while a POP mailbox will probably have a fixed
56: blank <B>slipip</B> as well as a fixed shell something like <B>/bin/true</B> or
57: <B>/usr/bin/passwd</B>.
58: <BR><BR>
59:
60: '));
61:
62: my %vfields;
63:
64: #these might belong somewhere else for other user interfaces
65: #pry need to eventually create stuff that's shared amount UIs
66: my $conf = new FS::Conf;
67: my %defs = (
68: 'svc_acct' => {
69: 'dir' => 'Home directory',
70: 'uid' => 'UID (set to fixed and blank for no UIDs)',
71: 'slipip' => 'IP address',
72: # 'popnum' => qq!<A HREF="$p/browse/svc_acct_pop.cgi/">POP number</A>!,
73: 'popnum' => {
74: desc => 'Access number',
75: type => 'select',
76: select_table => 'svc_acct_pop',
77: select_key => 'popnum',
78: select_label => 'city',
79: },
80: 'username' => {
81: desc => 'Username',
82: type => 'disabled',
83: },
84: 'quota' => '',
85: '_password' => 'Password',
86: 'gid' => 'GID (when blank, defaults to UID)',
87: 'shell' => {
88: desc =>'Shell (all service definitions should have a default or fixed shell that is present in the <b>shells</b> configuration file, set to blank for no shell tracking)',
89: type =>'select',
90: select_list => [ $conf->config('shells') ],
91: },
92: 'finger' => 'GECOS',
93: 'domsvc' => {
94: desc =>'svcnum from svc_domain',
95: type =>'select',
96: select_table => 'svc_domain',
97: select_key => 'svcnum',
98: select_label => 'domain',
99: },
100: 'usergroup' => {
101: desc =>'ICRADIUS/FreeRADIUS groups',
102: type =>'radius_usergroup_selector',
103: },
104: },
105: 'svc_domain' => {
106: 'domain' => 'Domain',
107: },
108: 'svc_forward' => {
109: 'srcsvc' => 'service from which mail is to be forwarded',
110: 'dstsvc' => 'service to which mail is to be forwarded',
111: 'dst' => 'someone at another.domain.com to use when dstsvc is 0',
112: },
113: # 'svc_charge' => {
114: # 'amount' => 'amount',
115: # },
116: # 'svc_wo' => {
117: # 'worker' => 'Worker',
118: # '_date' => 'Date',
119: # },
120: 'svc_www' => {
121: #'recnum' => '',
122: #'usersvc' => '',
123: },
124: 'svc_broadband' => {
125: 'speed_down' => 'Maximum download speed for this service in Kbps. 0 denotes unlimited.',
126: 'speed_up' => 'Maximum upload speed for this service in Kbps. 0 denotes unlimited.',
127: 'ip_addr' => 'IP address. Leave blank for automatic assignment.',
128: 'blocknum' => 'Address block.',
129: },
130: 'svc_external' => {
131: #'id' => '',
132: #'title' => '',
133: },
134: );
135:
136: foreach my $svcdb (grep dbdef->table($_), keys %defs ) {
137: my $self = "FS::$svcdb"->new;
138: $vfields{$svcdb} = {};
139: foreach my $field ($self->virtual_fields) { # svc_Common::virtual_fields with a null svcpart returns all of them
140: my $pvf = $self->pvf($field);
141: my @list = $pvf->list;
142: if (scalar @list) {
143: $defs{$svcdb}->{$field} = { desc => $pvf->label,
144: type => 'select',
145: select_list => \@list };
146: } else {
147: $defs{$svcdb}->{$field} = $pvf->label;
148: } #endif
149: $vfields{$svcdb}->{$field} = $pvf;
150: warn "\$vfields{$svcdb}->{$field} = $pvf";
151: } #next $field
152: } #next $svcdb
153:
154: my @dbs = $hashref->{svcdb}
155: ? ( $hashref->{svcdb} )
156: : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_external );
157:
158: tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs;
159: my $widget = new HTML::Widgets::SelectLayers(
160: #'selected_layer' => $p_svcdb,
161: 'selected_layer' => $hashref->{svcdb} || 'svc_acct',
162: 'options' => \%svcdb,
163: 'form_name' => 'dummy',
164: #'form_action' => 'process/part_svc.cgi',
165: 'form_action' => 'part_svc.cgi', #self
166: 'form_text' => [ qw( svc svcpart ) ],
167: 'form_checkbox' => [ 'disabled' ],
168: 'layer_callback' => sub {
169: my $layer = shift;
170:
171: my $html = qq!<INPUT TYPE="hidden" NAME="svcdb" VALUE="$layer">!;
172:
173: my $columns = 3;
174: my $count = 0;
175: my @part_export =
176: map { qsearch( 'part_export', {exporttype => $_ } ) }
177: keys %{FS::part_export::export_info($layer)};
178: $html .= '<BR><BR>'. table().
179: table(). "<TR><TH COLSPAN=$columns>Exports</TH></TR><TR>";
180: foreach my $part_export ( @part_export ) {
181: $html .= '<TD><INPUT TYPE="checkbox"'.
182: ' NAME="exportnum'. $part_export->exportnum. '" VALUE="1" ';
183: $html .= 'CHECKED'
184: if ( $clone || $part_svc->svcpart ) #null svcpart search causing error
185: && qsearchs( 'export_svc', {
186: exportnum => $part_export->exportnum,
187: svcpart => $clone || $part_svc->svcpart });
188: $html .= '>'. $part_export->exportnum. ': '. $part_export->exporttype.
189: ' to '. $part_export->machine. '</TD>';
190: $count++;
191: $html .= '</TR><TR>' unless $count % $columns;
192: }
193: $html .= '</TR></TABLE><BR><BR>';
194:
195: $html .= table(). "<TH>Field</TH><TH COLSPAN=2>Modifier</TH>";
196: #yucky kludge
197: my @fields = defined( $FS::Record::dbdef->table($layer) )
198: ? grep { $_ ne 'svcnum' } fields($layer)
199: : ();
200: push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge
201: $part_svc->svcpart($clone) if $clone; #haha, undone below
202: foreach my $field (@fields) {
203: my $part_svc_column = $part_svc->part_svc_column($field);
204: my $value = $part_svc_column->columnvalue;
205: my $flag = $part_svc_column->columnflag;
206: my $def = $defs{$layer}{$field};
207: my $desc = ref($def) ? $def->{desc} : $def;
208:
209: $html .= "<TR><TD>$field";
210: $html .= "- <FONT SIZE=-1>$desc</FONT>" if $desc;
211: $html .= "</TD>";
212: $flag = '' if ref($def) && $def->{type} eq 'disabled';
213: $html .=
214: qq!<TD><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE=""!.
215: ' CHECKED'x($flag eq ''). ">Off</TD>".
216: '<TD>';
217: unless ( ref($def) && $def->{type} eq 'disabled' ) {
218: $html .=
219: qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="D"!.
220: ' CHECKED'x($flag eq 'D'). ">Default ".
221: qq!<INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="F"!.
222: ' CHECKED'x($flag eq 'F'). ">Fixed ";
223: $html .= '<BR>';
224: }
225: if ( ref($def) ) {
226: if ( $def->{type} eq 'select' ) {
227: $html .= qq!<SELECT NAME="${layer}__${field}">!;
228: $html .= '<OPTION> </OPTION>' unless $value;
229: if ( $def->{select_table} ) {
230: foreach my $record ( qsearch( $def->{select_table}, {} ) ) {
231: my $rvalue = $record->getfield($def->{select_key});
232: $html .= qq!<OPTION VALUE="$rvalue"!.
233: ( $rvalue==$value ? ' SELECTED>' : '>' ).
234: $record->getfield($def->{select_label}). '</OPTION>';
235: } #next $record
236: } else { # select_list
237: foreach my $item ( @{$def->{select_list}} ) {
238: $html .= qq!<OPTION VALUE="$item"!.
239: ( $item eq $value ? ' SELECTED>' : '>' ).
240: $item. '</OPTION>';
241: } #next $item
242: } #endif
243: $html .= '</SELECT>';
244: } elsif ( $def->{type} eq 'radius_usergroup_selector' ) {
245: $html .= FS::svc_acct::radius_usergroup_selector(
246: [ split(',', $value) ], "${layer}__${field}" );
247: } elsif ( $def->{type} eq 'disabled' ) {
248: $html .=
249: qq!<INPUT TYPE="hidden" NAME="${layer}__${field}" VALUE="">!;
250: } else {
251: $html .= '<font color="#ff0000">unknown type'. $def->{type};
252: }
253: } else {
254: $html .=
255: qq!<INPUT TYPE="text" NAME="${layer}__${field}" VALUE="$value">!;
256: }
257:
258: if($vfields{$layer}->{$field}) {
259: $html .= qq!<BR><INPUT TYPE="radio" NAME="${layer}__${field}_flag" VALUE="X"!.
260: ' CHECKED'x($flag eq 'X'). ">Excluded ";
261: }
262: $html .= "</TD></TR>\n";
263: }
264: $part_svc->svcpart('') if $clone; #undone
265: $html .= "</TABLE>";
266:
267: $html .= include('/elements/progress-init.html',
268: $layer, #form name
269: [ qw(svc svcpart disabled exportnum), @fields ],
270: 'process/part_svc.cgi',
271: $p.'browse/part_svc.cgi',
272: $layer,
273: );
274: $html .= '<BR><INPUT NAME="submit" TYPE="button" VALUE="'.
275: ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '" '.
276: ' onClick="document.'. "$layer.submit.disabled=true; ".
277: "fixup(document.$layer); $layer". 'process();">';
278:
279: #$html .= '<BR><INPUT TYPE="submit" VALUE="'.
280: # ($hashref->{svcpart} ? 'Apply changes' : 'Add service'). '">';
281:
282: $html;
283:
284: },
285: );
286:
287: ; &Apache::ASP::WriteRef($main::Response, \('
288: Table '.( $widget->html ).'
289: </BODY>
290: </HTML>'));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://420.am/pipermail/freeside-users/attachments/20060523/615b74a4/attachment-0001.html
More information about the freeside-users
mailing list