1 package FS::svc_acct_pop;
4 use vars qw( @ISA @EXPORT_OK @svc_acct_pop %svc_acct_pop );
5 use FS::Record qw( qsearch qsearchs );
7 @ISA = qw( FS::Record Exporter );
8 @EXPORT_OK = qw( popselector );
12 FS::svc_acct_pop - Object methods for svc_acct_pop records
18 $record = new FS::svc_acct_pop \%hash;
19 $record = new FS::svc_acct_pop { 'column' => 'value' };
21 $error = $record->insert;
23 $error = $new_record->replace($old_record);
25 $error = $record->delete;
27 $error = $record->check;
29 $html = FS::svc_acct_pop::popselector( $popnum, $state );
33 An FS::svc_acct object represents an point of presence. FS::svc_acct_pop
34 inherits from FS::Record. The following fields are currently supported:
38 =item popnum - primary key (assigned automatically for new accounts)
48 =item loc - rest of number
58 Creates a new point of presence (if only it were that easy!). To add the
59 point of presence to the database, see L<"insert">.
63 sub table { 'svc_acct_pop'; }
67 Adds this point of presence to the database. If there is an error, returns the
68 error, otherwise returns false.
72 Removes this point of presence from the database.
74 =item replace OLD_RECORD
76 Replaces OLD_RECORD with this one in the database. If there is an error,
77 returns the error, otherwise returns false.
81 Checks all fields to make sure this is a valid point of presence. If there is
82 an error, returns the error, otherwise returns false. Called by the insert
90 $self->ut_numbern('popnum')
91 or $self->ut_text('city')
92 or $self->ut_text('state')
93 or $self->ut_number('ac')
94 or $self->ut_number('exch')
95 or $self->ut_numbern('loc')
96 or $self->SUPER::check
105 "$city, $state ($ac)/$exch"
111 $self->city. ', '. $self->state.
112 ' ('. $self->ac. ')/'. $self->exch. '-'. $self->loc;
121 =item popselector [ POPNUM [ STATE ] ]
125 #horrible false laziness with signup.cgi (pull special-case for 0 & 1
126 # pop code out from signup.cgi??)
128 my( $popnum, $state ) = @_;
130 unless ( @svc_acct_pop ) { #cache pop list
131 @svc_acct_pop = qsearch('svc_acct_pop', {} );
133 push @{$svc_acct_pop{$_->state}}, $_ foreach @svc_acct_pop;
138 function opt(what,href,text) {
139 var optionName = new Option(text, href, false, false)
140 var length = what.length;
141 what.options[length] = optionName;
144 function popstate_changed(what) {
145 state = what.options[what.selectedIndex].text;
146 what.form.popnum.options.length = 0
147 what.form.popnum.options[0] = new Option("", "", false, true);
150 foreach my $popstate ( sort { $a cmp $b } keys %svc_acct_pop ) {
151 $text .= "\nif ( state == \"$popstate\" ) {\n";
153 foreach my $pop ( @{$svc_acct_pop{$popstate}}) {
154 my $o_popnum = $pop->popnum;
155 my $poptext = $pop->text;
156 $text .= "opt(what.form.popnum, \"$o_popnum\", \"$poptext\");\n"
161 $text .= "}\n</SCRIPT>\n";
164 qq!<SELECT NAME="popstate" SIZE=1 onChange="popstate_changed(this)">!.
166 $text .= "<OPTION>$_" foreach sort { $a cmp $b } keys %svc_acct_pop;
167 $text .= '</SELECT>'; #callback? return 3 html pieces? #'</TD><TD>';
169 $text .= qq!<SELECT NAME="popnum" SIZE=1><OPTION> !;
171 if ( scalar(@svc_acct_pop) > 100 ) {
172 @initial_select = qsearchs( 'svc_acct_pop', { 'popnum' => $popnum } );
174 @initial_select = @svc_acct_pop;
176 foreach my $pop ( @initial_select ) {
177 $text .= qq!<OPTION VALUE="!. $pop->popnum. '"'.
178 ( ( $popnum && $pop->popnum == $popnum ) ? ' SELECTED' : '' ). ">".
181 $text .= '</SELECT>';
191 $Id: svc_acct_pop.pm,v 1.10 2003-08-05 00:20:47 khoff Exp $
195 It should be renamed to part_pop.
197 popselector? putting web ui components in here? they should probably live
200 popselector: pull special-case for 0 & 1 pop code out from signup.cgi
204 L<FS::Record>, L<FS::svc_acct>, L<FS::part_pop_local>, schema.html from the