diff options
author | ivan <ivan> | 2003-09-29 05:51:50 +0000 |
---|---|---|
committer | ivan <ivan> | 2003-09-29 05:51:50 +0000 |
commit | b59a412755582d30b4f7be2147b6ad32037e6f59 (patch) | |
tree | 141edb3dba7f8271adb4e87413c428c844ab3bbb | |
parent | e17e58178d528e16d45c333996f763afda55e054 (diff) |
agents can be disabled (auto-sensing based on schema)
-rw-r--r-- | FS/FS/agent.pm | 23 | ||||
-rwxr-xr-x | httemplate/browse/agent.cgi | 26 | ||||
-rwxr-xr-x | httemplate/edit/agent.cgi | 65 | ||||
-rwxr-xr-x | httemplate/edit/cust_main.cgi | 6 |
4 files changed, 85 insertions, 35 deletions
diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm index 6de15ae6f..bcba602cc 100644 --- a/FS/FS/agent.pm +++ b/FS/FS/agent.pm @@ -50,6 +50,12 @@ from FS::Record. The following fields are currently supported: =item freq - For future use. +=item disabled - Disabled flag, empty or 'Y' + +=item username - Username for the Agent interface + +=item _password - Password for the Agent interface + =back =head1 METHODS @@ -110,6 +116,21 @@ sub check { ; return $error if $error; + if ( $self->dbdef_table->column('disabled') ) { + $error = $self->ut_enum('disabled', [ '', 'Y' ] ); + return $error if $error; + } + + if ( $self->dbdef_table->column('username') ) { + $error = $self->ut_alphan('username'); + return $error if $error; + if ( length($self->username) ) { + $error = $self->ut_text('password'); # ut_text... arbitrary choice + } else { + $self->_password(''); + } + } + return "Unknown typenum!" unless $self->agent_type; @@ -144,7 +165,7 @@ sub pkgpart_hashref { =head1 VERSION -$Id: agent.pm,v 1.4 2003-08-05 00:20:40 khoff Exp $ +$Id: agent.pm,v 1.5 2003-09-29 05:51:50 ivan Exp $ =head1 BUGS diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi index 0d808cd0d..ece01724e 100755 --- a/httemplate/browse/agent.cgi +++ b/httemplate/browse/agent.cgi @@ -2,6 +2,14 @@ <% + my %search; + if ( $cgi->param('showdisabled') + || !dbdef->table('agent')->column('disabled') ) { + %search = (); + } else { + %search = ( 'disabled' => '' ); + } + #bad false laziness with search/cust_main.cgi (also needs fixing up for #old mysql) my $ncancelled = " @@ -36,9 +44,18 @@ Agents are resellers of your service. Agents may be limited to a subset of your full offerings (via their type).<BR><BR> <A HREF="<%= $p %>edit/agent.cgi"><I>Add a new agent</I></A><BR><BR> +<% if ( dbdef->table('agent')->column('disabled') ) { %> + <%= $cgi->param('showdisabled') + ? do { $cgi->param('showdisabled', 0); + '( <a href="'. $cgi->self_url. '">hide disabled agents</a> )'; } + : do { $cgi->param('showdisabled', 1); + '( <a href="'. $cgi->self_url. '">show disabled agents</a> )'; } + %> +<% } %> + <%= table() %> <TR> - <TH COLSPAN=2>Agent</TH> + <TH COLSPAN=<%= $cgi->param('showdisabled') ? 2 : 3 %>>Agent</TH> <TH>Type</TH> <TH>Customers</TH> <TH><FONT SIZE=-1>Freq.</FONT></TH> @@ -51,7 +68,7 @@ full offerings (via their type).<BR><BR> foreach my $agent ( sort { #$a->getfield('agentnum') <=> $b->getfield('agentnum') $a->getfield('agent') cmp $b->getfield('agent') -} qsearch('agent',{}) ) { +} qsearch('agent', \%search ) ) { $ncancelled_sth->execute($agent->agentnum) or die $ncancelled_sth->errstr; my $num_ncancelled = $ncancelled_sth->fetchrow_arrayref->[0]; @@ -66,6 +83,11 @@ foreach my $agent ( sort { <TR> <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>"> <%= $agent->agentnum %></A></TD> +<% if ( dbdef->table('agent')->column('disabled') + && !$cgi->param('showdisabled') ) { %> + <TD><%= $agent->disabled ? 'DISABLED' : '' %></TD> +<% } %> + <TD><A HREF="<%=$p%>edit/agent.cgi?<%= $agent->agentnum %>"> <%= $agent->agent %></A></TD> <TD><A HREF="<%=$p%>edit/agent_type.cgi?<%= $agent->typenum %>"><%= $agent->agent_type->atype %></A></TD> diff --git a/httemplate/edit/agent.cgi b/httemplate/edit/agent.cgi index 449456cdd..8a1cb2ae1 100755 --- a/httemplate/edit/agent.cgi +++ b/httemplate/edit/agent.cgi @@ -16,59 +16,64 @@ if ( $cgi->param('error') ) { my $action = $agent->agentnum ? 'Edit' : 'Add'; my $hashref = $agent->hashref; -print header("$action Agent", menubar( +%> + +<%= header("$action Agent", menubar( 'Main Menu' => $p, 'View all agents' => $p. 'browse/agent.cgi', -)); +)) %> -print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'), - "</FONT>" - if $cgi->param('error'); +<% if ( $cgi->param('error') ) { %> +<FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT> +<% } %> -print '<FORM ACTION="', popurl(1), 'process/agent.cgi" METHOD=POST>', - qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$hashref->{agentnum}">!, - "Agent #", $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)"; +<FORM ACTION="<%=popurl(1)%>process/agent.cgi" METHOD=POST> +<INPUT TYPE="hidden" NAME="agentnum" VALUE="<%= $hashref->{agentnum} %>"> +Agent #<%= $hashref->{agentnum} ? $hashref->{agentnum} : "(NEW)" %> -print &ntable("#cccccc", 2, ''), <<END; +<%= &ntable("#cccccc", 2, '') %> <TR> <TH ALIGN="right">Agent</TH> - <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="$hashref->{agent}"></TD> + <TD><INPUT TYPE="text" NAME="agent" SIZE=32 VALUE="<%= $hashref->{agent} %>"></TD> </TR> <TR> <TH ALIGN="right">Agent type</TH> <TD><SELECT NAME="typenum" SIZE=1> -END -foreach my $agent_type (qsearch('agent_type',{})) { - print "<OPTION VALUE=". $agent_type->typenum; - print " SELECTED" - if $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ); - print ">", $agent_type->getfield('typenum'), ": ", - $agent_type->getfield('atype'),"\n"; -} +<% foreach my $agent_type (qsearch('agent_type',{})) { %> + <OPTION VALUE="<%= $agent_type->typenum %>"<%= ( $hashref->{typenum} && ( $hashref->{typenum} == $agent_type->typenum ) ) ? ' SELECTED' : '' %>> + <%= $agent_type->getfield('typenum') %>: <%= $agent_type->getfield('atype') %> +<% } %> -print <<END; </SELECT></TD> </TR> +<% if ( dbdef->table('agent')->column('disabled') ) { %> + <TR> + <TD ALIGN="right">Disable</TD> + <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<%= $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>></TD> + </TR> +<% } %> <TR> <TD ALIGN="right"><!--Frequency--></TD> - <TD><INPUT TYPE="hidden" NAME="freq" VALUE="$hashref->{freq}"></TD> + <TD><INPUT TYPE="hidden" NAME="freq" VALUE="<%= $hashref->{freq} %>"></TD> </TR> <TR> <TD ALIGN="right"><!--Program--></TD> - <TD><INPUT TYPE="hidden" NAME="prog" VALUE="$hashref->{prog}"></TD> + <TD><INPUT TYPE="hidden" NAME="prog" VALUE="<%= $hashref->{prog} %>"></TD> </TR> +<% if ( dbdef->table('agent')->column('username') ) { %> + <TR> + <TD ALIGN="right">Agent interface username</TD> + <TD><INPUT TYPE="text" NAME="username" VALUE="<%= $hashref->{username} %>"></TD> + </TR> + <TR> + <TD ALIGN="right">Agent interface password</TD> + <TD><INPUT TYPE="text" NAME="_password" VALUE="<%= $hashref->{_password} %>"></TD> + </TR> +<% } %> </TABLE> -END -print qq!<BR><INPUT TYPE="submit" VALUE="!, - $hashref->{agentnum} ? "Apply changes" : "Add agent", - qq!">!; - -print <<END; +<BR><INPUT TYPE="submit" VALUE="<%= $hashref->{agentnum} ? "Apply changes" : "Add agent" %>"> </FORM> </BODY> </HTML> -END - -%> diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi index eeceed889..73a0eef49 100755 --- a/httemplate/edit/cust_main.cgi +++ b/httemplate/edit/cust_main.cgi @@ -75,9 +75,11 @@ print qq!<FORM ACTION="${p1}process/cust_main.cgi" METHOD=POST NAME="form1">!, my $r = qq!<font color="#ff0000">*</font> !; -my @agents = qsearch( 'agent', {} ); +my %agent_search = dbdef->table('agent')->column('disabled') + ? ( 'disabled' => '' ) : (); +my @agents = qsearch( 'agent', \%agent_search ); #die "No agents created!" unless @agents; -eidiot "You have not created any agents. You must create at least one agent before adding a customer. Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents; +eidiot "You have not created any agents (or all agents are disabled). You must create at least one agent before adding a customer. Go to ". popurl(2). "browse/agent.cgi and create one or more agents." unless @agents; my $agentnum = $cust_main->agentnum || $agents[0]->agentnum; #default to first if ( scalar(@agents) == 1 ) { print qq!<INPUT TYPE="hidden" NAME="agentnum" VALUE="$agentnum">!; |